MyDetail.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  4. MWF.xApplication.Attendance.MyDetail = new Class({
  5. Extends: MWF.widget.Common,
  6. Implements: [Options, Events],
  7. options: {
  8. "style": "default"
  9. },
  10. initialize: function(node, app, actions, options){
  11. this.setOptions(options);
  12. this.app = app;
  13. this.path = "../x_component_Attendance/$MyDetail/";
  14. this.cssPath = "../x_component_Attendance/$MyDetail/"+this.options.style+"/css.wcss";
  15. this._loadCss();
  16. this.actions = actions;
  17. this.node = $(node);
  18. },
  19. load: function(){
  20. //options = {
  21. // "name": "直接主管",
  22. // "personName": this.workContext.getWork().creatorPerson
  23. //}
  24. //return this.org.getPersonAttribute(options);
  25. this.loadTab();
  26. },
  27. loadTab : function(){
  28. this.tabNode = new Element("div",{"styles" : this.css.tabNode }).inject(this.node);
  29. this.detailArea = new Element("div",{"styles" : this.app.css.tabPageContainer }).inject(this.tabNode);
  30. //this.selfHolidayArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  31. this.detailStaticArea = new Element("div",{"styles" : this.app.css.tabPageContainer }).inject(this.tabNode);
  32. //this.selfHolidayStaticArea = new Element("div",{"styles" : this.css.tabPageContainer }).inject(this.tabNode)
  33. MWF.require("MWF.widget.Tab", function(){
  34. this.tabs = new MWF.widget.Tab(this.tabNode, {"style": "attendance"});
  35. this.tabs.load();
  36. this.detailPage = this.tabs.addTab(this.detailArea, this.app.lp.myDetail, false);
  37. this.detailPage.contentNodeArea.set("class","detailPage");
  38. this.detailPage.addEvent("show",function(){
  39. this.detailPage.tabNode.addClass( "mainColor_border" );
  40. this.detailPage.textNode.addClass( "mainColor_color" );
  41. if( !this.detailExplorer ){
  42. this.detailExplorer = new MWF.xApplication.Attendance.MyDetail.Explorer( this.detailArea, this );
  43. this.detailExplorer.load();
  44. }
  45. }.bind(this)).addEvent("hide", function(){
  46. this.detailPage.tabNode.removeClass( "mainColor_border" );
  47. this.detailPage.textNode.removeClass( "mainColor_color" );
  48. }.bind(this));
  49. //this.selfHolidayPage = this.tabs.addTab(this.selfHolidayArea, "我的休假明细", false);
  50. //this.selfHolidayPage.contentNodeArea.set("class","selfHolidayPage");
  51. //this.selfHolidayPage.addEvent("show",function(){
  52. // if( !this.selfHoliday ){
  53. // this.selfHoliday = new MWF.xApplication.Attendance.MyDetail.SelfHoliday( this.selfHolidayArea, this );
  54. // this.selfHoliday.load();
  55. // }
  56. //}.bind(this))
  57. this.detailStaticPage = this.tabs.addTab(this.detailStaticArea, this.app.lp.myDetailStatic, false);
  58. this.detailStaticPage.contentNodeArea.set("class","detailStaticPage");
  59. this.detailStaticPage.addEvent("show",function(){
  60. this.detailStaticPage.tabNode.addClass( "mainColor_border" );
  61. this.detailStaticPage.textNode.addClass( "mainColor_color" );
  62. if( !this.detailStaticExplorer ){
  63. this.detailStaticExplorer = new MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer( this.detailStaticArea, this );
  64. this.detailStaticExplorer.load();
  65. }
  66. }.bind(this)).addEvent("hide", function(){
  67. this.detailStaticPage.tabNode.removeClass( "mainColor_border" );
  68. this.detailStaticPage.textNode.removeClass( "mainColor_color" );
  69. }.bind(this));
  70. //this.selfHolidayStaticPage = this.tabs.addTab(this.selfHolidayStaticArea, "我的休假统计", false);
  71. //this.selfHolidayStaticPage.contentNodeArea.set("class","selfHolidayStaticPage");
  72. //this.selfHolidayStaticPage.addEvent("show",function(){
  73. // if( !this.selfHolidayStaticExplorer ){
  74. // this.selfHolidayStaticExplorer = new MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticExplorer( this.selfHolidayStaticArea, this );
  75. // this.selfHolidayStaticExplorer.load();
  76. // }
  77. //}.bind(this))
  78. this.tabs.pages[0].showTab();
  79. }.bind(this));
  80. }
  81. });
  82. MWF.xApplication.Attendance.MyDetail.Explorer = new Class({
  83. Extends: MWF.xApplication.Attendance.Explorer,
  84. Implements: [Options, Events],
  85. initialize: function(node, parent, options){
  86. this.setOptions(options);
  87. this.parent = parent;
  88. this.app = parent.app;
  89. this.css = parent.css;
  90. this.path = parent.path;
  91. this.actions = parent.actions;
  92. this.node = $(node);
  93. this.preMonthDate = new Date();
  94. //this.preMonthDate.decrement("month", 1);
  95. this.initData();
  96. if (!this.peopleActions) this.peopleActions = new MWF.xAction.org.express.RestActions();
  97. },
  98. initData: function(){
  99. this.toolItemNodes = [];
  100. },
  101. reload: function(){
  102. this.node.empty();
  103. this.load();
  104. },
  105. load: function(){
  106. this.loadConfig();
  107. this.loadFilter();
  108. this.loadContentNode();
  109. this.setNodeScroll();
  110. var month = (this.preMonthDate.getMonth()+1).toString();
  111. if( month.length == 1 )month = "0"+month;
  112. var filterData = {
  113. cycleYear : this.preMonthDate.getFullYear().toString(),
  114. cycleMonth : month
  115. };
  116. this.loadView( filterData );
  117. },
  118. loadConfig : function(){
  119. this.config = {};
  120. var v;
  121. //需要判断申述类型listSetting2020年6月16日 by gee
  122. this.configSetting = new Object(null);
  123. this.actions.listSetting(function(json){
  124. var data = json.data;
  125. if(!!data){
  126. json.data.map(function(e){
  127. this.configSetting[e.configCode]=e;
  128. }.bind(this));
  129. v = this.configSetting.APPEALABLE.configValue;
  130. }else{
  131. v = null;
  132. }
  133. }.bind(this),null,false);
  134. /*this.actions.getSettingCode( "APPEALABLE", function(json){
  135. v = json.data ? json.data.configValue : null;
  136. },null, false);*/
  137. if( !v ){
  138. this.config.APPEALABLE = true;
  139. }else{
  140. this.config.APPEALABLE = (v != "false" )
  141. }
  142. },
  143. loadFilter: function(){
  144. var lp = MWF.xApplication.Attendance.LP;
  145. this.fileterNode = new Element("div.fileterNode", {
  146. "styles" : this.app.css.fileterNode
  147. }).inject(this.node);
  148. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='filterTable' style='width: 900px;'>"+
  149. "<tr>" +
  150. " <td styles='filterTableTitle' lable='cycleYear'></td>"+
  151. " <td styles='filterTableValue' item='cycleYear'></td>" +
  152. " <td styles='filterTableTitle' lable='cycleMonth'></td>"+
  153. " <td styles='filterTableValue' item='cycleMonth'></td>" +
  154. " <td styles='filterTableTitle' lable='date'></td>"+
  155. " <td styles='filterTableValue' item='date'></td>" +
  156. " <td styles='filterTableTitle' lable='isAbsent'></td>"+
  157. " <td styles='filterTableValue' item='isAbsent'></td>" +
  158. " <td styles='filterTableTitle' lable='isLate'></td>"+
  159. " <td styles='filterTableValue' item='isLate'></td>" +
  160. " <td styles='filterTableTitle' lable='isLackOfTime'></td>"+
  161. " <td styles='filterTableValue' item='isLackOfTime'></td>" +
  162. " <td styles='filterTableValue' item='action'></td>" +
  163. "</tr>" +
  164. "</table>";
  165. this.fileterNode.set("html",html);
  166. MWF.xDesktop.requireApp("Template", "MForm", function(){
  167. this.form = new MForm( this.fileterNode, {}, {
  168. style: "attendance",
  169. isEdited : true,
  170. itemTemplate : {
  171. cycleYear : {
  172. text : lp.annuaal,
  173. "type" : "select",
  174. "selectValue" : function(){
  175. var years = [];
  176. var year = new Date().getFullYear();
  177. for(var i=0; i<6; i++ ){
  178. years.push( year-- );
  179. }
  180. return years;
  181. },
  182. "event" : {
  183. "change" : function( item, ev ){
  184. var values = this.getDateSelectValue();
  185. item.form.getItem( "date").resetItemOptions( values , values )
  186. }.bind(this)
  187. }
  188. },
  189. cycleMonth : {
  190. text : lp.months,
  191. "type" : "select",
  192. "defaultValue" : function(){
  193. var month = (new Date().getMonth() + 1 ).toString();
  194. return month.length == 1 ? "0"+month : month;
  195. },
  196. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  197. "event" : {
  198. "change" : function( item, ev ){
  199. var values = this.getDateSelectValue();
  200. item.form.getItem( "date").resetItemOptions( values , values )
  201. }.bind(this)
  202. }
  203. },
  204. date : { text : lp.date, "type" : "select", "selectValue" : function(){
  205. var year = this.preMonthDate.getFullYear() ;
  206. var month = this.preMonthDate.getMonth() ;
  207. var date = new Date(year, month, 1);
  208. var days = [];
  209. days.push("");
  210. while (date.getMonth() === month) {
  211. var d = date.getDate().toString();
  212. if( d.length == 1 )d = "0"+d;
  213. days.push( d );
  214. date.setDate(date.getDate() + 1);
  215. }
  216. return days;
  217. }.bind(this)
  218. },
  219. isAbsent : { text: lp.absent, "type" : "select", "selectValue" : ["","true","false"], "selectText" : lp.absendSelectText },
  220. isLate : { text: lp.late, "type" : "select", "selectValue" : ["","true","false"], "selectText" : lp.lateSelectText },
  221. isLackOfTime : { text: lp.lackOfTime, "type" : "select", "selectValue" : ["","true","false"], "selectText" : lp.truefalseSelectText },
  222. action : { "value" : lp.query, type : "button", className : "filterButton", clazz:"mainColor_bg", event : {
  223. click : function(){
  224. var result = this.form.getResult(false,null,false,true,false);
  225. /* var year = this.preMonthDate.getFullYear().toString();
  226. var month = (this.preMonthDate.getMonth()+1).toString();
  227. if( month.length == 1 )month = "0"+month;
  228. result.cycleYear = year;
  229. result.cycleMonth = month;*/
  230. if( typeOf( result.isAbsent ) == "string" )result.isAbsent = this.getBoolean( result.isAbsent );
  231. if( typeOf( result.isLate ) == "string" )result.isLate = this.getBoolean( result.isLate );
  232. if( typeOf( result.isLackOfTime ) == "string" )result.isLackOfTime = this.getBoolean( result.isLackOfTime );
  233. if( result.date && result.date !="" ){
  234. if( !result.cycleMonth ){
  235. this.app.notice( this.lp.mustSelectMonth, "error");
  236. return;
  237. }
  238. result.q_date = result.cycleYear + "-" + result.cycleMonth + "-" + result.date;
  239. }
  240. this.loadView( result );
  241. }.bind(this)
  242. }}
  243. }
  244. }, this.app, this.app.css);
  245. this.form.load();
  246. }.bind(this), true);
  247. },
  248. getDateSelectValue : function(){
  249. if( this.form ){
  250. var year = parseInt(this.form.getItem("cycleYear").getValue());
  251. var month = parseInt(this.form.getItem("cycleMonth").getValue())-1;
  252. }else{
  253. var year = (new Date()).getFullYear() ;
  254. var month = (new Date()).getMonth() ;
  255. }
  256. var date = new Date(year, month, 1);
  257. var days = [];
  258. days.push("");
  259. while (date.getMonth() === month) {
  260. var d = date.getDate().toString();
  261. if( d.length == 1 )d = "0"+d;
  262. days.push( d );
  263. date.setDate(date.getDate() + 1);
  264. }
  265. return days;
  266. },
  267. //loadFilter2 : function(){
  268. // this.fileterNode = new Element("div.fileterNode", {
  269. // "styles" : this.css.fileterNode
  270. // }).inject(this.node)
  271. //
  272. // var table = new Element("table", {
  273. // "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  274. // }).inject( this.fileterNode );
  275. // var tr = new Element("tr").inject(table);
  276. //
  277. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.preMonthDate.format(this.app.lp.dateFormatMonth) }).inject(tr);
  278. //
  279. // //this.createYearSelectTd( tr )
  280. // //this.createMonthSelectTd( tr )
  281. // this.createDateSelectTd( tr )
  282. // this.createIsAbsent(tr)
  283. // this.createIsLate( tr )
  284. // //this.createIsLeaveEarlier( tr )
  285. // this.createLackOfTimeCount(tr)
  286. // this.createActionTd( tr )
  287. //},
  288. //createYearSelectTd : function( tr ){
  289. // var _self = this;
  290. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "年度" }).inject(tr);
  291. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  292. // this.cycleYear = new MDomItem( td, {
  293. // "name" : "cycleYear",
  294. // "type" : "select",
  295. // "selectValue" : function(){
  296. // var years = [];
  297. // var year = new Date().getFullYear();
  298. // for(var i=0; i<6; i++ ){
  299. // years.push( year-- );
  300. // }
  301. // return years;
  302. // },
  303. // "event" : {
  304. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  305. // }
  306. // }, true, this.app );
  307. // this.cycleYear.load();
  308. //},
  309. //createMonthSelectTd : function( tr ){
  310. // var _self = this;
  311. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  312. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  313. // this.cycleMonth = new MDomItem( td, {
  314. // "name" : "cycleMonth",
  315. // "type" : "select",
  316. // "defaultValue" : function(){
  317. // var month = (new Date().getMonth() + 1 ).toString();
  318. // return month.length == 1 ? "0"+month : month;
  319. // },
  320. // "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"],
  321. // "event" : {
  322. // "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  323. // }
  324. // }, true, this.app );
  325. // this.cycleMonth.load();
  326. //},
  327. //createDateSelectTd : function( tr ){
  328. // var _self = this;
  329. // if( tr ){
  330. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "日期" }).inject(tr);
  331. // this.dateSelecterTd = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  332. // }
  333. // if( this.q_date ){
  334. // this.dateSelecterTd.empty();
  335. // }
  336. // this.q_date = new MDomItem( this.dateSelecterTd, {
  337. // "name" : "q_date",
  338. // "type" : "select",
  339. // "selectValue" : function(){
  340. // var year = _self.cycleYear ? parseInt(_self.cycleYear.getValue()) : _self.preMonthDate.getFullYear() ;
  341. // var month = _self.cycleMonth ? (parseInt(_self.cycleMonth.getValue())-1) : _self.preMonthDate.getMonth() ;
  342. // var date = new Date(year, month, 1);
  343. // var days = [];
  344. // days.push("");
  345. // while (date.getMonth() === month) {
  346. // var d = date.getDate().toString();
  347. // if( d.length == 1 )d = "0"+d
  348. // days.push( d );
  349. // date.setDate(date.getDate() + 1);
  350. // }
  351. // return days;
  352. // }
  353. // }, true, this.app );
  354. // this.q_date.load();
  355. //},
  356. //createIsAbsent: function(tr){
  357. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "缺勤" }).inject(tr);
  358. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  359. // this.isAbsent = new MDomItem( td, {
  360. // "name" : "isAbsent",
  361. // "type" : "select",
  362. // "selectValue" : ["","true","false"],
  363. // "selectText" : ["","缺勤","未缺勤"],
  364. // }, true, this.app );
  365. // this.isAbsent.load();
  366. //},
  367. ////createIsLeaveEarlier: function(tr){
  368. //// var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "早退" }).inject(tr);
  369. //// var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  370. //// this.isLeaveEarlier = new MDomItem( td, {
  371. //// "name" : "isLeaveEarlier",
  372. //// "type" : "select",
  373. //// "selectValue" : ["-1","true","false"],
  374. //// "selectText" : ["","早退","未早退"],
  375. //// }, true, this.app );
  376. //// this.isLeaveEarlier.load();
  377. ////},
  378. //createLackOfTimeCount: function(tr){
  379. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "工时不足" }).inject(tr);
  380. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  381. // this.isLackOfTime = new MDomItem( td, {
  382. // "name" : "isLackOfTime",
  383. // "type" : "select",
  384. // "selectValue" : ["","true","false"],
  385. // "selectText" : ["","是","否"],
  386. // }, true, this.app );
  387. // this.isLackOfTime.load();
  388. //},
  389. //createIsLate: function(tr){
  390. // var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "迟到" }).inject(tr);
  391. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  392. // this.isLate = new MDomItem( td, {
  393. // "name" : "isLate",
  394. // "type" : "select",
  395. // "selectValue" : ["","true","false"],
  396. // "selectText" : ["","迟到","未迟到"],
  397. // }, true, this.app );
  398. // this.isLate.load();
  399. //},
  400. //createActionTd : function( tr ){
  401. // var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  402. // var input = new Element("button",{
  403. // "text" : "查询",
  404. // "styles" : this.css.filterButton
  405. // }).inject(td);
  406. // input.addEvent("click", function(){
  407. // //var filterData = {
  408. // // cycleYear : this.cycleYear.getValue(),
  409. // // cycleMonth : this.cycleMonth.getValue()
  410. // //}
  411. // var result = this.form.getResult(false, null,false,true,false);
  412. // var year = this.preMonthDate.getFullYear().toString();
  413. // var month = (this.preMonthDate.getMonth()+1).toString();
  414. // if( month.length == 1 )month = "0"+month;
  415. // var filterData = {
  416. // cycleYear : year,
  417. // cycleMonth : month
  418. // }
  419. // if( this.isAbsent && this.isAbsent.getValue()!=""){
  420. // filterData.isAbsent = this.getBoolean( this.isAbsent.getValue() );
  421. // }
  422. // if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  423. // filterData.isLeaveEarlier = this.getBoolean( this.isLeaveEarlier.getValue());
  424. // }
  425. // if( this.isLate && this.isLate.getValue()!="" ){
  426. // filterData.isLate = this.getBoolean( this.isLate.getValue());
  427. // }
  428. // if( this.isLackOfTime && this.isLackOfTime.getValue()!=""){
  429. // filterData.isLackOfTime = this.getBoolean( this.isLackOfTime.getValue());
  430. // }
  431. // if( this.q_date && this.q_date.getValue()!="" ){
  432. // filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  433. // }
  434. // this.loadView( filterData );
  435. // }.bind(this))
  436. //},
  437. getBoolean : function( value ){
  438. if( value === "true" )return true;
  439. if( value === "false" )return false;
  440. return value;
  441. },
  442. //selecePerson: function(){
  443. // var options = {
  444. // "type": "person",
  445. // "title": "选择人员",
  446. // "count" : "1",
  447. // "onComplete": function(items){
  448. // var names = [];
  449. // items.each(function(item){
  450. // names.push(item.data.name);
  451. // }.bind(this));
  452. // this.q_empName.setValue( names.join(",") )
  453. // }.bind(this)
  454. // };
  455. // var selector = new MWF.O2Selector(this.app.content, options);
  456. //},
  457. loadContentNode: function(){
  458. this.elementContentNode = new Element("div.elementContentNode", {
  459. "styles": this.css.elementContentNode
  460. }).inject(this.node);
  461. this.app.addEvent("resize", function(){this.setContentSize();}.bind(this));
  462. this.elementContentNode.addEvent("scroll", function () {
  463. var scroll = this.elementContentNode.getScroll();
  464. if(this.fileterNode)this.fileterNode.scrollTo(scroll.x);
  465. }.bind(this));
  466. },
  467. loadView : function( filterData ){
  468. this.elementContentNode.empty();
  469. if( this.view )delete this.view;
  470. this.view = new MWF.xApplication.Attendance.MyDetail.View(this.elementContentNode, this.app,this );
  471. this.view.filterData = filterData;
  472. this.view.load();
  473. this.setContentSize();
  474. },
  475. setContentSize: function(){
  476. var tabNodeSize = this.parent.tabs ? this.parent.tabs.tabNodeContainer.getSize() : {"x":0,"y":0};
  477. var fileterNodeSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  478. var nodeSize = this.parent.node.getSize();
  479. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  480. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  481. //var filterSize = this.filterNode.getSize();
  482. var height = nodeSize.y-tabNodeSize.y-pt-pb-fileterNodeSize.y-20;
  483. this.elementContentNode.setStyle("height", ""+height+"px");
  484. this.pageCount = (height/40).toInt()+5;
  485. if (this.view && this.view.items.length<this.pageCount){
  486. this.view.loadElementList(this.pageCount-this.view.items.length);
  487. }
  488. }
  489. });
  490. MWF.xApplication.Attendance.MyDetail.SelfHoliday = new Class({
  491. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  492. loadView : function( filterData ){
  493. this.elementContentNode.empty();
  494. if( this.view )delete this.view;
  495. this.view = new MWF.xApplication.Attendance.MyDetail.SelfHolidayView(this.elementContentNode, this.app,this );
  496. this.view.filterData = filterData;
  497. this.view.load();
  498. this.setContentSize();
  499. }
  500. });
  501. MWF.xApplication.Attendance.MyDetail.DetailStaticExplorer = new Class({
  502. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  503. /* load: function(){
  504. //this.loadFilter();
  505. this.loadContentNode();
  506. this.setNodeScroll();
  507. debugger;
  508. var filterData = {
  509. cycleYear : this.preMonthDate.getFullYear().toString(),
  510. cycleMonth : this.preMonthDate.format(this.app.lp.dateFormatOnlyMonth)
  511. };
  512. this.loadView( filterData );
  513. },*/
  514. loadFilter : function(){
  515. this.fileterNode = new Element("div.fileterNode", {
  516. "styles" : this.app.css.fileterNode
  517. }).inject(this.node);
  518. this.loadFilterStyle(function( css ){
  519. this.filterFormCss = css;
  520. var table = new Element("table", {
  521. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.app.css.filterTable, "class" : "filterTable"
  522. }).inject( this.fileterNode );
  523. table.setStyle("width","360px");
  524. var tr = new Element("tr").inject(table);
  525. this.createYearSelectTd( tr );
  526. this.createMonthSelectTd( tr );
  527. this.createActionTd( tr );
  528. }.bind(this));
  529. },
  530. createYearSelectTd : function( tr ){
  531. var _self = this;
  532. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.annuaal }).inject(tr);
  533. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  534. this.yearString = new MDomItem( td, {
  535. "name" : "yearString",
  536. "type" : "select",
  537. "selectValue" : function(){
  538. var years = [];
  539. var year = new Date().getFullYear();
  540. for(var i=0; i<6; i++ ){
  541. years.push( year-- );
  542. }
  543. return years;
  544. }
  545. }, true, this.app, this.filterFormCss );
  546. this.yearString.load();
  547. },
  548. createMonthSelectTd : function( tr ){
  549. var _self = this;
  550. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : MWF.xApplication.Attendance.LP.months }).inject(tr);
  551. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  552. this.cycleMonth = new MDomItem( td, {
  553. "name" : "cycleMonth",
  554. "type" : "select",
  555. "selectValue" :["01","02","03","04","05","06","07","08","09","10","11","12"],
  556. "defaultValue" : function(){
  557. var month = (new Date().getMonth() + 1 ).toString();
  558. return month.length == 1 ? "0"+month : month;
  559. },
  560. "event" : {
  561. "change" : function(){ if(_self.dateSelecterTd)_self.createDateSelectTd() }
  562. }
  563. }, true, this.app, this.filterFormCss );
  564. this.cycleMonth.load();
  565. },
  566. createActionTd : function( tr ){
  567. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  568. var input = new Element("button",{
  569. "text" : MWF.xApplication.Attendance.LP.query,
  570. "styles" : this.app.css.filterButton
  571. }).inject(td);
  572. input.addClass("mainColor_bg");
  573. debugger;
  574. input.addEvent("click", function(){
  575. var year = this.yearString.getValue("year");
  576. var month = this.cycleMonth.getValue("month");
  577. if(year && year!=""){
  578. }else{
  579. year = this.preMonthDate.getFullYear().toString();
  580. }
  581. if(month && month!=""){
  582. }else{
  583. month = (this.preMonthDate.getMonth()+1).toString();
  584. }
  585. /*var year = this.preMonthDate.getFullYear().toString();
  586. var month = (this.preMonthDate.getMonth()+1).toString();*/
  587. debugger;
  588. if( month.length == 1 )month = "0"+month;
  589. var filterData = {
  590. cycleYear : year,
  591. cycleMonth : month
  592. };
  593. if( this.isAbsent && this.isAbsent.getValue()!="" ){
  594. filterData.isAbsent = this.isAbsent.getValue();
  595. }
  596. if( this.isLeaveEarlier && this.isLeaveEarlier.getValue()!=""){
  597. filterData.isLeaveEarlier = this.isLeaveEarlier.getValue();
  598. }
  599. if( this.isLate && this.isLate.getValue()!="" ){
  600. filterData.isLate = this.isLate.getValue();
  601. }
  602. if( this.q_date && this.q_date.getValue()!="" ){
  603. filterData.q_date = year + "-" + month + "-" + this.q_date.getValue();
  604. }
  605. this.loadView( filterData );
  606. }.bind(this))
  607. },
  608. loadView : function( filterData ){
  609. this.elementContentNode.empty();
  610. if( this.view )delete this.view;
  611. this.view = new MWF.xApplication.Attendance.MyDetail.DetailStaticView(this.elementContentNode, this.app,this );
  612. this.view.filterData = filterData;
  613. this.view.listItemUrl = this.path+"listItem_detailStatic.json";
  614. this.view.load();
  615. this.setContentSize();
  616. }
  617. });
  618. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticExplorer = new Class({
  619. Extends: MWF.xApplication.Attendance.MyDetail.Explorer,
  620. loadView : function( filterData ){
  621. this.elementContentNode.empty();
  622. if( this.view )delete this.view;
  623. this.view = new MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticView(this.elementContentNode, this.app,this );
  624. this.view.filterData = filterData;
  625. this.view.load();
  626. this.setContentSize();
  627. }
  628. });
  629. MWF.xApplication.Attendance.MyDetail.View = new Class({
  630. Extends: MWF.xApplication.Attendance.Explorer.View,
  631. _createItem: function(data){
  632. return new MWF.xApplication.Attendance.MyDetail.Document(this.table, data, this.explorer, this);
  633. },
  634. _getCurrentPageData: function(callback, count){
  635. if(!count)count=100;
  636. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  637. var filter = this.filterData || {};
  638. filter.key = this.sortField || this.sortFieldDefault || "";
  639. filter.order = this.sortType || this.sortTypeDefault || "";
  640. filter.q_empName = layout.desktop.session.user.distinguishedName;
  641. this.actions.listDetailFilterNext( id, count, filter, function(json){
  642. var data = json.data;
  643. data.each(function(d){
  644. d.APPEALABLE = this.explorer.config.APPEALABLE;
  645. }.bind(this));
  646. json.data = data;
  647. if( callback )callback(json);
  648. }.bind(this));
  649. //this.actions.listDetailFilterUser( filter, function(json){
  650. // if( callback )callback(json);
  651. //}.bind(this))
  652. },
  653. _removeDocument: function(documentData, all){
  654. },
  655. _createDocument: function(){
  656. },
  657. _openDocument: function( documentData ){
  658. }
  659. });
  660. MWF.xApplication.Attendance.MyDetail.SelfHolidayView = new Class({
  661. Extends: MWF.xApplication.Attendance.Explorer.View,
  662. _createItem: function(data){
  663. return new MWF.xApplication.Attendance.MyDetail.SelfHolidayDocument(this.table, data, this.explorer, this);
  664. },
  665. _getCurrentPageData: function(callback, count){
  666. var filter = this.filterData || {};
  667. filter.q_empName = layout.desktop.session.user.distinguishedName;
  668. this.actions.listDetailFilterUser( filter, function(json){
  669. if( callback )callback(json);
  670. }.bind(this))
  671. },
  672. _removeDocument: function(documentData, all){
  673. },
  674. _createDocument: function(){
  675. },
  676. _openDocument: function( documentData ){
  677. }
  678. });
  679. MWF.xApplication.Attendance.MyDetail.DetailStaticView = new Class({
  680. Extends: MWF.xApplication.Attendance.Explorer.View,
  681. _createItem: function(data){
  682. return new MWF.xApplication.Attendance.MyDetail.DetailStaticDocument(this.table, data, this.explorer, this);
  683. },
  684. _getCurrentPageData: function(callback, count){
  685. var filter = this.filterData || {};
  686. filter.key = this.sortField || this.sortFieldDefault || "";
  687. filter.order = this.sortType || this.sortTypeDefault || "";
  688. filter.q_empName = layout.desktop.session.user.distinguishedName;
  689. if( filter.cycleMonth == "" )filter.cycleMonth="(0)";
  690. /*var month = (new Date().getMonth()+1).toString();
  691. if( month.length == 1 )month = "0"+month;
  692. filter.cycleMonth = month;*/
  693. debugger;
  694. this.actions.listStaticMonthPerson( filter.q_empName, filter.cycleYear,filter.cycleMonth, function(json){
  695. if( callback )callback(json);
  696. }.bind(this))
  697. },
  698. _removeDocument: function(documentData, all){
  699. },
  700. _createDocument: function(){
  701. },
  702. _openDocument: function( documentData ){
  703. }
  704. });
  705. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticView = new Class({
  706. Extends: MWF.xApplication.Attendance.Explorer.View,
  707. _createItem: function(data){
  708. return new MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticDocument(this.table, data, this.explorer, this);
  709. },
  710. _getCurrentPageData: function(callback, count){
  711. var filter = this.filterData || {};
  712. this.actions.listDetailFilterUser( filter, function(json){
  713. if( callback )callback(json);
  714. }.bind(this))
  715. },
  716. _removeDocument: function(documentData, all){
  717. },
  718. _createDocument: function(){
  719. },
  720. _openDocument: function( documentData ){
  721. }
  722. });
  723. MWF.xApplication.Attendance.MyDetail.Document = new Class({
  724. Extends: MWF.xApplication.Attendance.Explorer.Document,
  725. appeal :function(){
  726. if(this.explorer.configSetting.APPEAL_AUDIFLOWTYPE.configValue=="BUILTIN"){
  727. var form = new MWF.xApplication.Attendance.MyDetail.Appeal( this.explorer, this.data );
  728. form.create();
  729. }else{
  730. this.loadProcess(this.explorer.configSetting.APPEAL_AUDIFLOW_ID.configValue,{record:this.data} ,null);
  731. }
  732. },
  733. loadProcess: function(id, processData, latest){
  734. this.getProcess(id, function(process){
  735. MWF.xDesktop.requireApp("process.TaskCenter", "ProcessStarter", function(){
  736. var starter = new MWF.xApplication.process.TaskCenter.ProcessStarter(process, this.app, {
  737. "latest" : latest || false,
  738. "workData" : processData,
  739. "onStarted": function(data, title, processName){
  740. this.afterStartProcess(data, title, processName);
  741. }.bind(this)
  742. });
  743. starter.load();
  744. }.bind(this));
  745. }.bind(this));
  746. },
  747. afterStartProcess: function(data, title, processName, workData){
  748. if (data.work){
  749. this.startProcessDraft(data, title, processName, workData);
  750. }else{
  751. this.startProcessInstance(data, title, processName, workData);
  752. }
  753. },
  754. startProcessDraft: function(data, title, processName){
  755. var work = data.work;
  756. var options = {"draft": work, "appId": "process.Work"+(new o2.widget.UUID).toString(), "desktopReload": false,
  757. "onPostClose": function(){
  758. }.bind(this)
  759. };
  760. this.desktop.openApplication(null, "process.Work", options);
  761. },
  762. startProcessInstance: function(data, title, processName, workData){
  763. var workInfors = [];
  764. var currentTask = [];
  765. var createUnit = "";
  766. var workId = "";
  767. debugger;
  768. data.each(function(work){
  769. debugger;
  770. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  771. workInfors.push(this.getStartWorkInforObj(work));
  772. createUnit = work.taskList[work.currentTaskIndex].creatorUnit;
  773. workId = work.taskList[work.currentTaskIndex].work;
  774. }.bind(this));
  775. if (currentTask.length===1){
  776. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  777. this.app.desktop.openApplication(null, "process.Work", options);
  778. debugger;
  779. this.createStartWorkResault(workInfors, title, processName, false,createUnit,workId);
  780. }else{
  781. this.createStartWorkResault(workInfors, title, processName, true,createUnit,workId);
  782. }
  783. },
  784. createStartWorkResault: function(workInfors, title, processName, isopen,createUnit,workId){
  785. var data = {};
  786. data["appealDescription"] = this.app.lp.appealAuditFlow+":"+processName;
  787. data["workId"] = workId;
  788. if(createUnit !=""){
  789. data["unitName"] = createUnit;
  790. }
  791. debugger;
  792. this.createAppeal(data);
  793. if(!layout.desktop.message)return;
  794. var content = "";
  795. workInfors.each(function(infor){
  796. var users = [];
  797. infor.users.each(function(uname){
  798. users.push(MWF.name.cn(uname));
  799. });
  800. content += "<div><b>"+this.app.lp.nextActivity+"<font style=\"color: #ea621f\">"+infor.activity+"</font>, "+this.app.lp.nextUser+"<font style=\"color: #ea621f\">"+users.join(", ")+"</font></b>";
  801. if (infor.currentTask && isopen){
  802. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  803. }else{
  804. content += "</div>";
  805. }
  806. }.bind(this));
  807. var t = workInfors[0].title || title;
  808. var msg = {
  809. "subject": this.app.lp.processStarted,
  810. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  811. };
  812. var tooltip = layout.desktop.message.addTooltip(msg);
  813. var item = layout.desktop.message.addMessage(msg);
  814. this.setStartWorkResaultAction(tooltip);
  815. this.setStartWorkResaultAction(item);
  816. },
  817. getStartWorkInforObj: function(work){
  818. var title = "";
  819. var users = [];
  820. var currentTask = "";
  821. work.taskList.each(function(task, idx){
  822. title = task.title;
  823. users.push(task.person+"("+task.creatorUnit + ")");
  824. if (work.currentTaskIndex===idx) currentTask = task.id;
  825. }.bind(this));
  826. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  827. },
  828. setStartWorkResaultAction: function(item){
  829. var node = item.node.getElements("span");
  830. node.setStyles(this.css.dealStartedWorkAction);
  831. var _self = this;
  832. node.addEvent("click", function(e){
  833. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  834. _self.app.desktop.openApplication(e, "process.Work", options);
  835. });
  836. },
  837. getProcess: function(id, callback){
  838. this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  839. this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
  840. this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": id}, "success": function(json){
  841. if (callback) callback(json.data);
  842. }.bind(this)});
  843. },
  844. createAppeal: function(data){
  845. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  846. }.bind(this));
  847. },
  848. seeAppeal : function(){
  849. if(this.data.appealInfos[0].appealAuditInfo){
  850. if(this.data.appealInfos[0].appealAuditInfo.workId){
  851. var workid = this.data.appealInfos[0].appealAuditInfo.workId;
  852. var options = {"workId":workid, "appId": "process.Work"+workid};
  853. this.app.desktop.openApplication(null, "process.Work", options);
  854. return;
  855. }
  856. }
  857. var form = new MWF.xApplication.Attendance.MyDetail.Appeal( this.explorer, this.data );
  858. form.open();
  859. }
  860. });
  861. MWF.xApplication.Attendance.MyDetail.SelfHolidayDocument = new Class({
  862. Extends: MWF.xApplication.Attendance.Explorer.Document
  863. });
  864. MWF.xApplication.Attendance.MyDetail.DetailStaticDocument = new Class({
  865. Extends: MWF.xApplication.Attendance.Explorer.Document
  866. });
  867. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticDocument = new Class({
  868. Extends: MWF.xApplication.Attendance.Explorer.Document
  869. });
  870. MWF.xApplication.Attendance.MyDetail.Appeal = new Class({
  871. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  872. options : {
  873. "width": 700,
  874. "height": 500,
  875. "hasTop" : true,
  876. "hasBottom" : true,
  877. "title" : MWF.xApplication.Attendance.LP.apealApplyForm,
  878. "draggable" : true,
  879. "closeAction" : true,
  880. },
  881. _createTableContent: function(){
  882. var appLp = MWF.xApplication.Attendance.LP;
  883. var _self = this;
  884. if( this.isNew ){
  885. this.detailData = this.data;
  886. // this.data = this.detailData || {};
  887. // this._open();
  888. }else{
  889. this.detailData = this.data;
  890. this.app.restActions.getAppeal(this.detailData.id, function(json){
  891. this.data = json.data;
  892. this.data.onDutyTime = this.detailData.onDutyTime;
  893. this.data.offDutyTime = this.detailData.offDutyTime;
  894. }.bind(this),null,false);
  895. if(!this.data)this.data = this.detailData || {};
  896. }
  897. var d = this.data;
  898. var status = [];
  899. if(d.isGetSelfHolidays && ( d.selfHolidayDayTime == appLp.wholeDay || d.selfHolidayDayTime == "全天")) {
  900. status.push( appLp.levelAsked )
  901. }else if( d.isAbnormalDuty && (d.abnormalDutyDayTime == appLp.wholeDay || d.abnormalDutyDayTime == "全天")){
  902. status.push( appLp.abNormalDuty )
  903. }else if(d.isLackOfTime ) {
  904. status.push( appLp.lackOfTime )
  905. }else{
  906. if( d.isGetSelfHolidays && ( d.selfHolidayDayTime == appLp.am || d.selfHolidayDayTime == "上午" ) ){
  907. status.push( appLp.levelAsked )
  908. }else if(d.isLate){
  909. status.push( appLp.late )
  910. }else if(d.isAbsent && ["上午","全天",appLp.am, appLp.wholeDay].contains(d.absentDayTime) ){
  911. status.push( appLp.absent )
  912. }else if( d.isAbnormalDuty && ["上午","全天",appLp.am, appLp.wholeDay].contains(d.abnormalDutyDayTime)){
  913. status.push( appLp.abNormalDuty )
  914. }
  915. if( d.isGetSelfHolidays && ( d.selfHolidayDayTime == "下午" || d.selfHolidayDayTime == appLp.pm ) ){
  916. status.push( appLp.levelAsked );
  917. //}else if(d.isLeaveEarlier){
  918. // status.push( '早退')
  919. }else if(d.isAbsent && ( d.absentDayTime == "下午" || d.absentDayTime == appLp.pm ) ){
  920. status.push( appLp.abNormalDuty)
  921. }else if(d.isAbnormalDuty && ( d.abnormalDutyDayTime == "下午" || d.abnormalDutyDayTime == appLp.pm ) ){
  922. status.push( appLp.abNormalDuty )
  923. }
  924. }
  925. this.data.statusShow = status.unique().join();
  926. var appealStatus = appLp.draft;
  927. if (d.status == 0 ) {
  928. appealStatus = appLp.todo
  929. } else if (d.status == 1) {
  930. appealStatus = appLp.approve
  931. } else if (d.status == -1) {
  932. appealStatus = appLp.deny
  933. }
  934. //if (d.appealStatus == 1) {
  935. // appealStatus = "申诉中"
  936. //} else if (d.appealStatus == -1) {
  937. // appealStatus = "申诉未通过"
  938. //} else if (d.appealStatus == 9) {
  939. // appealStatus = "申诉通过"
  940. //}
  941. this.data.appealStatusShow = appealStatus;
  942. //var auditors = this.getAuditor();
  943. var identityList = this.getIdentity();
  944. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  945. "<tr><td style='width: 85px;' styles='formTableTitle'>"+appLp.employeeName+"</td>"+
  946. " <td style='width: 165px;' styles='formTableValue'>"+this.data.empName.split("@")[0]+"</td>" +
  947. " <td style='width: 85px;' styles='formTableTitle' lable='recordDateString'></td>"+
  948. " <td style='width: 165px;' styles='formTableValue' item='recordDateString'></td></tr>"
  949. +"<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  950. " <td styles='formTableValue' item='onDutyTime'></td>" +
  951. ((this.data.signProxy=="2"||this.data.signProxy=="3")?
  952. " <td styles='formTableTitle' lable='morningOffDutyTime'></td>"+
  953. " <td styles='formTableValue' item='morningOffDutyTime'></td></tr>" +
  954. "<tr><td styles='formTableTitle' lable='afternoonOnDutyTime'></td>"+
  955. " <td styles='formTableValue' item='afternoonOnDutyTime'></td>" : ""
  956. ) +
  957. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  958. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  959. ( this.isNew ?
  960. "<tr><td styles='formTableTitle' lable='statusShow'></td>"+
  961. " <td styles='formTableValue' item='statusShow'></td>" +
  962. " <td styles='formTableTitle' lable='appealStatusShow'></td>"+
  963. " <td styles='formTableValue' item='appealStatusShow'></td></tr>"
  964. :
  965. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  966. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>"
  967. )
  968. +
  969. ( ( this.isNew && identityList.identities.length > 1 ) ?
  970. "<tr><td styles='formTableTitle' lable='identity'></td>"+
  971. " <td styles='formTableValue' item='identity' colspan='3'></td></tr>" : ""
  972. ) +
  973. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  974. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  975. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  976. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  977. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  978. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  979. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  980. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  981. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  982. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  983. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  984. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  985. "</table>";
  986. this.formTableArea.set("html",html);
  987. var lp = this.app.lp.schedule;
  988. var signProxy = this.data.signProxy||1;
  989. this.document = new MForm( this.formTableArea, this.data, {
  990. style : "attendance",
  991. isEdited : this.isEdited || this.isNew,
  992. itemTemplate : {
  993. recordDateString : { text: appLp.recordDate, type : "innertext"},
  994. onDutyTime : { text:appLp.onDutyTime, type : "innertext"},
  995. morningOffDutyTime : { text:signProxy==1?"":lp.signProxy[signProxy].middayRestStartTime, type : "innertext"},
  996. afternoonOnDutyTime : { text:signProxy==1?"":lp.signProxy[signProxy].middayRestEndTime, type : "innertext"},
  997. offDutyTime : { text: appLp.offDutyTime, type : "innertext"},
  998. statusShow : { text: appLp.attendanceStatus, type : "innertext" },
  999. appealStatusShow : { text: appLp.appealStatus, type : "innertext"},
  1000. //processPerson1 : {
  1001. // text : "审核人", type : "select", selectValue : auditors, selectText : function(){
  1002. // var array = [];
  1003. // auditors.each( function( a ){ array.push(a.split("@")[0] ) } );
  1004. // return array;
  1005. // }
  1006. //},
  1007. appealReason : {
  1008. notEmpty : true,
  1009. text: appLp.appealReason,
  1010. type : "select",
  1011. selectValue : appLp.appealReasonSelectText,
  1012. event : { change : function(mdi){
  1013. _self.switchFieldByAppealReason(mdi.getValue());
  1014. }}
  1015. },
  1016. identity : {
  1017. notEmpty : true,
  1018. text: appLp.selectDepartment,
  1019. type : "radio",
  1020. defaultValue : function(){
  1021. return identityList.identities[0];
  1022. }.bind(this),
  1023. selectText : identityList.units,
  1024. selectValue : identityList.identities
  1025. },
  1026. address : { text: appLp.address },
  1027. selfHolidayType : {
  1028. text: appLp.leaveType,
  1029. type : "select",
  1030. selectValue : appLp.leaveTypeSelectText
  1031. },
  1032. startTime : { text: appLp.startTime, tType : "datetime" },
  1033. endTime : { text: appLp.endTime, tType : "datetime" },
  1034. appealDescription : { text:appLp.appealDescriptoin }
  1035. }
  1036. }, this.app,this.css);
  1037. this.document.load();
  1038. _self.switchFieldByAppealReason(this.data.appealReason);
  1039. //createFormNode.set("html", html);
  1040. //this.setScrollBar(this.createTableContainer)
  1041. // this.cancelActionNode = new Element("div", {
  1042. // "styles": this.css.createCancelActionNode,
  1043. // "text": appLp.cancel
  1044. // }).inject(this.formNode);
  1045. // this.cancelActionNode.addEvent("click", function(e){
  1046. // this.cancelCreate(e);
  1047. // }.bind(this));
  1048. //
  1049. // if( this.isNew || this.isEdited ){
  1050. // this.createOkActionNode = new Element("div", {
  1051. // "styles": this.css.createOkActionNode,
  1052. // "text": appLp.ok
  1053. // }).inject(this.formNode);
  1054. // this.createOkActionNode.addEvent("click", function(e){
  1055. // this.okCreate(e);
  1056. // }.bind(this));
  1057. // }
  1058. },
  1059. switchFieldByAppealReason : function( ar ){
  1060. var lp = MWF.xApplication.Attendance.LP;
  1061. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  1062. var showField = [];
  1063. if( ar == lp.temporaryLeave ){
  1064. showField = ["selfHolidayType","startTime","endTime"];
  1065. }else if( ar == lp.out ){
  1066. showField = ["address","startTime","endTime"];
  1067. }else if( ar == lp.businessTrip ){
  1068. showField = ["address","startTime","endTime","appealDescription"];
  1069. }else if( ar == lp.other ){
  1070. showField = ["appealDescription"];
  1071. }
  1072. tempField.each( function( f ){
  1073. this.formTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  1074. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  1075. }.bind(this))
  1076. },
  1077. getIdentity : function(){
  1078. var identityList = { identities : [], units : [] };
  1079. this.app.personActions.getPerson( function( json ){
  1080. json.data.woIdentityList.each( function( id ){
  1081. var unit = id.woUnit;
  1082. identityList.identities.push( id.distinguishedName );
  1083. identityList.units.push( unit.name );
  1084. }.bind(this))
  1085. }.bind(this), null, false );
  1086. return identityList;
  1087. },
  1088. getAuditor : function(){
  1089. var lp = MWF.xApplication.Attendance.LP;
  1090. //获取设置
  1091. var setting = {};
  1092. var result = [];
  1093. this.app.restActions.listSetting(function(json){
  1094. json.data.each(function( d ){
  1095. setting[d.configCode] = d;
  1096. }.bind(this))
  1097. }.bind(this),null,false);
  1098. if( setting.APPEAL_AUDITOR_TYPE && setting.APPEAL_AUDITOR_TYPE.configValue!="" && setting.APPEAL_AUDITOR_VALUE && setting.APPEAL_AUDITOR_VALUE.configValue!=""){
  1099. if( setting.APPEAL_AUDITOR_TYPE.configValue == lp.reportTo || setting.APPEAL_AUDITOR_TYPE.configValue == "汇报对象" ) {
  1100. var d = {"personList": [layout.desktop.session.user.distinguishedName] };
  1101. this.app.orgActions.listPersonSupDirectValue( d, function( json ){
  1102. var superior = json.data.personList;
  1103. if( !superior || !superior[0] ){
  1104. this.app.notice( lp.noReportToNotice, "error");
  1105. }else{
  1106. var p = superior[0];
  1107. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1108. result.push( this.getPersonByIdentity( p ) )
  1109. }else{
  1110. result.push( p )
  1111. }
  1112. }
  1113. }.bind(this), null, false );
  1114. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "所属部门职位" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.unitDuty ){
  1115. this.app.personActions.getPerson( function( json ){
  1116. json.data.woIdentityList.each( function( id ){
  1117. var unit = id.woUnit;
  1118. var d = {"name": setting.APPEAL_AUDITOR_VALUE.configValue, "unit": unit.distinguishedName};
  1119. this.app.orgActions.getDutyValue( d, function( js ){
  1120. var ids = js.data ? js.data.identityList : [];
  1121. if ( typeOf( ids ) == "array" && ids[0] ) {
  1122. ids.each( function( id ){
  1123. result = result.concat( this.getPersonByIdentity( id ) );
  1124. }.bind(this));
  1125. }else{
  1126. var text = lp.noUnitDutyNotice.replace("{unit}",unit.name).replace("{duty}",setting.APPEAL_AUDITOR_VALUE.configValue);
  1127. this.app.notice( text, "error");
  1128. // this.app.notice("系统中没有配置"+unit.name+"的"+setting.APPEAL_AUDITOR_VALUE.configValue+"职位,请联系管理员", "error");
  1129. }
  1130. }.bind(this),null ,false)
  1131. }.bind(this))
  1132. }.bind(this), null, false );
  1133. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "人员属性" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.personAttribute ){
  1134. this.app.personActions.getPerson( function( json ){
  1135. var attribute = setting.APPEAL_AUDITOR_VALUE.configValue;
  1136. json.data.woPersonAttributeList.each( function( attr ){
  1137. if( attr.name == attribute ){
  1138. var p = attr.attributeList[0];
  1139. if( p ){
  1140. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1141. result.push( this.getPersonByIdentity( p ) )
  1142. }else{
  1143. result.push( p )
  1144. }
  1145. }
  1146. }
  1147. })
  1148. }.bind(this),null ,false);
  1149. if( result.length == 0 ){
  1150. var text = lp.noPersonAttribute.replace("{att}", setting.APPEAL_AUDITOR_VALUE.configValue);
  1151. this.app.notice( text, "error");
  1152. }
  1153. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "指定人" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.assignedPerson){
  1154. var p = setting.APPEAL_AUDITOR_TYPE.configValue;
  1155. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1156. result.push( this.getPersonByIdentity( p ) )
  1157. }else{
  1158. result.push( p )
  1159. }
  1160. }
  1161. }else{
  1162. this.app.personActions.getPerson( function( json ){
  1163. var attribute = lp.directLeader;
  1164. json.data.woPersonAttributeList.each( function( attr ){
  1165. if( attr.name == attribute ){
  1166. var p = attr.attributeList[0];
  1167. if( p ){
  1168. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1169. result.push( this.getPersonByIdentity( p ) )
  1170. }else{
  1171. result.push( p )
  1172. }
  1173. }
  1174. }
  1175. })
  1176. }.bind(this),null ,false);
  1177. this.app.notice(lp.noDirectLeader, "error");
  1178. }
  1179. return result;
  1180. },
  1181. getPersonByIdentity : function( identity ){
  1182. var d = {"identityList":[ identity ]};
  1183. var result = [];
  1184. this.app.orgActions.listPersonWithIdentityValue( d, function (js){
  1185. result = js.data.personList;
  1186. }.bind(this), null, false);
  1187. return result;
  1188. },
  1189. ok: function(e){
  1190. var data = this.document.getResult(true,",",true,false,true);
  1191. if (data ) {
  1192. var start = data.startTime;
  1193. var end = data.endTime;
  1194. if (start != "" && end != "") {
  1195. var starTime = new Date(start.replace(/-/g, "/"));
  1196. var endTime = new Date(end.replace(/-/g, "/"));
  1197. if (starTime >= endTime) {
  1198. this.app.notice( MWF.xApplication.Attendance.LP.holiday.beginGreateThanEndNotice, "error");
  1199. return;
  1200. }
  1201. }
  1202. this._ok( data )
  1203. }
  1204. //}else{
  1205. // this.app.notice( "请填写申诉原因和具体描述", "error");
  1206. //}
  1207. },
  1208. _ok: function( data ){
  1209. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  1210. if (json.type == "ERROR") {
  1211. this.app.notice(json.message, "error");
  1212. } else {
  1213. if( this.formMaskNode )this.formMaskNode.destroy();
  1214. if( this.formAreaNode )this.formAreaNode.destroy();
  1215. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  1216. this.app.notice( MWF.xApplication.Attendance.LP.createAppealNotice, "success");
  1217. }
  1218. }.bind(this));
  1219. },
  1220. selectDateTime : function( el, timeOnly, isTme, baseDate ){
  1221. var opt = {
  1222. "style": "xform",
  1223. "timeOnly": timeOnly,
  1224. "isTime": isTme,
  1225. "target": this.app.content
  1226. };
  1227. if( baseDate )opt.baseDate = baseDate;
  1228. MWF.require("MWF.widget.Calendar", function(){
  1229. var calendar = new MWF.widget.Calendar( el, opt );
  1230. calendar.show();
  1231. }.bind(this));
  1232. },
  1233. //getProcessPerson : function( callback ){
  1234. // this.getUnitByPerson( function( unitData ){
  1235. // this.app.restActions.listPermission( function(json){
  1236. // if( json.data.length == 0 ){
  1237. // this.app.notice( "系统未配置考勤员,请联系管理员!", "error");
  1238. // return;
  1239. // }
  1240. // var unitManager, topUnitManager, processer;
  1241. // json.data.each( function( d ){
  1242. // if( d.unitName == unitData.name ){
  1243. // unitManager = d.adminName;
  1244. // }
  1245. // if(d.unitName == unitData.topUnit ){
  1246. // topUnitManager = d.adminName;
  1247. // }
  1248. // })
  1249. // processer = unitManager || topUnitManager;
  1250. // if( !processer ){
  1251. // this.app.notice( "未设置您所在部门和公司的考勤管理员,请联系系统管理员!", "error");
  1252. // }else{
  1253. // if(callback)callback(processer)
  1254. // }
  1255. // }.bind(this))
  1256. // }.bind(this));
  1257. //},
  1258. getUnitByPerson : function( callback ){
  1259. var data = {"personList": [layout.desktop.session.user.distinguishedName] };
  1260. this.app.orgActions.listUnitWithPerson( function( json ){
  1261. if( json.data.length > 0 ){
  1262. if(callback)callback( json.data );
  1263. }else{
  1264. this.app.notice( MWF.xApplication.Attendance.LP.noDepartment, "error");
  1265. }
  1266. }.bind(this), function(){
  1267. this.app.notice( MWF.xApplication.Attendance.LP.noDepartment, "error");
  1268. }.bind(this), data, false )
  1269. }
  1270. });