MyDetail.js 60 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348
  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){
  748. var workInfors = [];
  749. var currentTask = [];
  750. var createUnit = "";
  751. var workId = "";
  752. debugger;
  753. data.each(function(work){
  754. debugger;
  755. if (work.currentTaskIndex !== -1) currentTask.push(work.taskList[work.currentTaskIndex].work);
  756. workInfors.push(this.getStartWorkInforObj(work));
  757. createUnit = work.taskList[work.currentTaskIndex].creatorUnit;
  758. workId = work.taskList[work.currentTaskIndex].work;
  759. }.bind(this));
  760. if (currentTask.length===1){
  761. var options = {"workId": currentTask[0], "appId": currentTask[0]};
  762. this.app.desktop.openApplication(null, "process.Work", options);
  763. debugger;
  764. this.createStartWorkResault(workInfors, title, processName, false,createUnit,workId);
  765. }else{
  766. this.createStartWorkResault(workInfors, title, processName, true,createUnit,workId);
  767. }
  768. },
  769. createStartWorkResault: function(workInfors, title, processName, isopen,createUnit,workId){
  770. var data = {};
  771. data["appealDescription"] = this.app.lp.appealAuditFlow+":"+processName;
  772. data["workId"] = workId;
  773. if(createUnit !=""){
  774. data["unitName"] = createUnit;
  775. }
  776. debugger;
  777. this.createAppeal(data);
  778. if(!layout.desktop.message)return;
  779. var content = "";
  780. workInfors.each(function(infor){
  781. var users = [];
  782. infor.users.each(function(uname){
  783. users.push(MWF.name.cn(uname));
  784. });
  785. 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>";
  786. if (infor.currentTask && isopen){
  787. content += "&nbsp;&nbsp;&nbsp;&nbsp;<span value=\""+infor.currentTask+"\">"+this.app.lp.deal+"</span></div>";
  788. }else{
  789. content += "</div>";
  790. }
  791. }.bind(this));
  792. var t = workInfors[0].title || title;
  793. var msg = {
  794. "subject": this.app.lp.processStarted,
  795. "content": "<div>"+this.app.lp.processStartedMessage+"“["+processName+"]"+t+"”</div>"+content
  796. };
  797. var tooltip = layout.desktop.message.addTooltip(msg);
  798. var item = layout.desktop.message.addMessage(msg);
  799. this.setStartWorkResaultAction(tooltip);
  800. this.setStartWorkResaultAction(item);
  801. },
  802. getStartWorkInforObj: function(work){
  803. var title = "";
  804. var users = [];
  805. var currentTask = "";
  806. work.taskList.each(function(task, idx){
  807. title = task.title;
  808. users.push(task.person+"("+task.creatorUnit + ")");
  809. if (work.currentTaskIndex===idx) currentTask = task.id;
  810. }.bind(this));
  811. return {"activity": work.fromActivityName, "users": users, "currentTask": currentTask, "title" : title };
  812. },
  813. setStartWorkResaultAction: function(item){
  814. var node = item.node.getElements("span");
  815. node.setStyles(this.css.dealStartedWorkAction);
  816. var _self = this;
  817. node.addEvent("click", function(e){
  818. var options = {"taskId": this.get("value"), "appId": this.get("value")};
  819. _self.app.desktop.openApplication(e, "process.Work", options);
  820. });
  821. },
  822. getProcess: function(id, callback){
  823. this.action = new o2.xDesktop.Actions.RestActions("", "x_processplatform_assemble_surface", "");
  824. this.action.actions = {"getProces": {"uri": "/jaxrs/process/{id}/complex"}};
  825. this.action.invoke({"name": "getProces", "async": false, "parameter": {"id": id}, "success": function(json){
  826. if (callback) callback(json.data);
  827. }.bind(this)});
  828. },
  829. createAppeal: function(data){
  830. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  831. }.bind(this));
  832. },
  833. seeAppeal : function(){
  834. if(this.data.appealInfos[0].appealAuditInfo){
  835. if(this.data.appealInfos[0].appealAuditInfo.workId){
  836. var workid = this.data.appealInfos[0].appealAuditInfo.workId;
  837. var options = {"workId":workid, "appId": "process.Work"+workid};
  838. this.app.desktop.openApplication(null, "process.Work", options);
  839. return;
  840. }
  841. }
  842. var form = new MWF.xApplication.Attendance.MyDetail.Appeal( this.explorer, this.data );
  843. form.open();
  844. }
  845. });
  846. MWF.xApplication.Attendance.MyDetail.SelfHolidayDocument = new Class({
  847. Extends: MWF.xApplication.Attendance.Explorer.Document
  848. });
  849. MWF.xApplication.Attendance.MyDetail.DetailStaticDocument = new Class({
  850. Extends: MWF.xApplication.Attendance.Explorer.Document
  851. });
  852. MWF.xApplication.Attendance.MyDetail.SelfHolidayStaticDocument = new Class({
  853. Extends: MWF.xApplication.Attendance.Explorer.Document
  854. });
  855. MWF.xApplication.Attendance.MyDetail.Appeal = new Class({
  856. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  857. options : {
  858. "width": 700,
  859. "height": 500,
  860. "hasTop" : true,
  861. "hasBottom" : true,
  862. "title" : MWF.xApplication.Attendance.LP.apealApplyForm,
  863. "draggable" : true,
  864. "closeAction" : true,
  865. },
  866. _createTableContent: function(){
  867. var appLp = MWF.xApplication.Attendance.LP;
  868. var _self = this;
  869. if( this.isNew ){
  870. this.detailData = this.data;
  871. // this.data = this.detailData || {};
  872. // this._open();
  873. }else{
  874. this.detailData = this.data;
  875. this.app.restActions.getAppeal(this.detailData.id, function(json){
  876. this.data = json.data;
  877. this.data.onDutyTime = this.detailData.onDutyTime;
  878. this.data.offDutyTime = this.detailData.offDutyTime;
  879. }.bind(this),null,false);
  880. if(!this.data)this.data = this.detailData || {};
  881. }
  882. var d = this.data;
  883. var status = [];
  884. if(d.isGetSelfHolidays && ( d.selfHolidayDayTime == appLp.wholeDay || d.selfHolidayDayTime == "全天")) {
  885. status.push( appLp.levelAsked )
  886. }else if( d.isAbnormalDuty && (d.abnormalDutyDayTime == appLp.wholeDay || d.abnormalDutyDayTime == "全天")){
  887. status.push( appLp.abNormalDuty )
  888. }else if(d.isLackOfTime ) {
  889. status.push( appLp.lackOfTime )
  890. }else{
  891. if( d.isGetSelfHolidays && ( d.selfHolidayDayTime == appLp.am || d.selfHolidayDayTime == "上午" ) ){
  892. status.push( appLp.levelAsked )
  893. }else if(d.isLate){
  894. status.push( appLp.late )
  895. }else if(d.isAbsent && ["上午","全天",appLp.am, appLp.wholeDay].contains(d.absentDayTime) ){
  896. status.push( appLp.absent )
  897. }else if( d.isAbnormalDuty && ["上午","全天",appLp.am, appLp.wholeDay].contains(d.abnormalDutyDayTime)){
  898. status.push( appLp.abNormalDuty )
  899. }
  900. if( d.isGetSelfHolidays && ( d.selfHolidayDayTime == "下午" || d.selfHolidayDayTime == appLp.pm ) ){
  901. status.push( appLp.levelAsked );
  902. //}else if(d.isLeaveEarlier){
  903. // status.push( '早退')
  904. }else if(d.isAbsent && ( d.absentDayTime == "下午" || d.absentDayTime == appLp.pm ) ){
  905. status.push( appLp.abNormalDuty)
  906. }else if(d.isAbnormalDuty && ( d.abnormalDutyDayTime == "下午" || d.abnormalDutyDayTime == appLp.pm ) ){
  907. status.push( appLp.abNormalDuty )
  908. }
  909. }
  910. this.data.statusShow = status.unique().join();
  911. var appealStatus = appLp.draft;
  912. if (d.status == 0 ) {
  913. appealStatus = appLp.todo
  914. } else if (d.status == 1) {
  915. appealStatus = appLp.approve
  916. } else if (d.status == -1) {
  917. appealStatus = appLp.deny
  918. }
  919. //if (d.appealStatus == 1) {
  920. // appealStatus = "申诉中"
  921. //} else if (d.appealStatus == -1) {
  922. // appealStatus = "申诉未通过"
  923. //} else if (d.appealStatus == 9) {
  924. // appealStatus = "申诉通过"
  925. //}
  926. this.data.appealStatusShow = appealStatus;
  927. //var auditors = this.getAuditor();
  928. var identityList = this.getIdentity();
  929. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  930. "<tr><td style='width: 85px;' styles='formTableTitle'>"+appLp.employeeName+"</td>"+
  931. " <td style='width: 165px;' styles='formTableValue'>"+this.data.empName.split("@")[0]+"</td>" +
  932. " <td style='width: 85px;' styles='formTableTitle' lable='recordDateString'></td>"+
  933. " <td style='width: 165px;' styles='formTableValue' item='recordDateString'></td></tr>"
  934. +"<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  935. " <td styles='formTableValue' item='onDutyTime'></td>" +
  936. ((this.data.signProxy=="2"||this.data.signProxy=="3")?
  937. " <td styles='formTableTitle' lable='morningOffDutyTime'></td>"+
  938. " <td styles='formTableValue' item='morningOffDutyTime'></td></tr>" +
  939. "<tr><td styles='formTableTitle' lable='afternoonOnDutyTime'></td>"+
  940. " <td styles='formTableValue' item='afternoonOnDutyTime'></td>" : ""
  941. ) +
  942. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  943. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  944. ( this.isNew ?
  945. "<tr><td styles='formTableTitle' lable='statusShow'></td>"+
  946. " <td styles='formTableValue' item='statusShow'></td>" +
  947. " <td styles='formTableTitle' lable='appealStatusShow'></td>"+
  948. " <td styles='formTableValue' item='appealStatusShow'></td></tr>"
  949. :
  950. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  951. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>"
  952. )
  953. +
  954. ( ( this.isNew && identityList.identities.length > 1 ) ?
  955. "<tr><td styles='formTableTitle' lable='identity'></td>"+
  956. " <td styles='formTableValue' item='identity' colspan='3'></td></tr>" : ""
  957. ) +
  958. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  959. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  960. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  961. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  962. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  963. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  964. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  965. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  966. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  967. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  968. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  969. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  970. "</table>";
  971. this.formTableArea.set("html",html);
  972. var lp = this.app.lp.schedule;
  973. var signProxy = this.data.signProxy||1;
  974. this.document = new MForm( this.formTableArea, this.data, {
  975. style : "attendance",
  976. isEdited : this.isEdited || this.isNew,
  977. itemTemplate : {
  978. recordDateString : { text: appLp.recordDate, type : "innertext"},
  979. onDutyTime : { text:appLp.onDutyTime, type : "innertext"},
  980. morningOffDutyTime : { text:signProxy==1?"":lp.signProxy[signProxy].middayRestStartTime, type : "innertext"},
  981. afternoonOnDutyTime : { text:signProxy==1?"":lp.signProxy[signProxy].middayRestEndTime, type : "innertext"},
  982. offDutyTime : { text: appLp.offDutyTime, type : "innertext"},
  983. statusShow : { text: appLp.attendanceStatus, type : "innertext" },
  984. appealStatusShow : { text: appLp.appealStatus, type : "innertext"},
  985. //processPerson1 : {
  986. // text : "审核人", type : "select", selectValue : auditors, selectText : function(){
  987. // var array = [];
  988. // auditors.each( function( a ){ array.push(a.split("@")[0] ) } );
  989. // return array;
  990. // }
  991. //},
  992. appealReason : {
  993. notEmpty : true,
  994. text: appLp.appealReason,
  995. type : "select",
  996. selectValue : appLp.appealReasonSelectText,
  997. event : { change : function(mdi){
  998. _self.switchFieldByAppealReason(mdi.getValue());
  999. }}
  1000. },
  1001. identity : {
  1002. notEmpty : true,
  1003. text: appLp.selectDepartment,
  1004. type : "radio",
  1005. defaultValue : function(){
  1006. return identityList.identities[0];
  1007. }.bind(this),
  1008. selectText : identityList.units,
  1009. selectValue : identityList.identities
  1010. },
  1011. address : { text: appLp.address },
  1012. selfHolidayType : {
  1013. text: appLp.leaveType,
  1014. type : "select",
  1015. selectValue : appLp.leaveTypeSelectText
  1016. },
  1017. startTime : { text: appLp.startTime, tType : "datetime" },
  1018. endTime : { text: appLp.endTime, tType : "datetime" },
  1019. appealDescription : { text:appLp.appealDescriptoin }
  1020. }
  1021. }, this.app,this.css);
  1022. this.document.load();
  1023. _self.switchFieldByAppealReason(this.data.appealReason);
  1024. //createFormNode.set("html", html);
  1025. //this.setScrollBar(this.createTableContainer)
  1026. // this.cancelActionNode = new Element("div", {
  1027. // "styles": this.css.createCancelActionNode,
  1028. // "text": appLp.cancel
  1029. // }).inject(this.formNode);
  1030. // this.cancelActionNode.addEvent("click", function(e){
  1031. // this.cancelCreate(e);
  1032. // }.bind(this));
  1033. //
  1034. // if( this.isNew || this.isEdited ){
  1035. // this.createOkActionNode = new Element("div", {
  1036. // "styles": this.css.createOkActionNode,
  1037. // "text": appLp.ok
  1038. // }).inject(this.formNode);
  1039. // this.createOkActionNode.addEvent("click", function(e){
  1040. // this.okCreate(e);
  1041. // }.bind(this));
  1042. // }
  1043. },
  1044. switchFieldByAppealReason : function( ar ){
  1045. var lp = MWF.xApplication.Attendance.LP;
  1046. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  1047. var showField = [];
  1048. if( ar == lp.temporaryLeave ){
  1049. showField = ["selfHolidayType","startTime","endTime"];
  1050. }else if( ar == lp.out ){
  1051. showField = ["address","startTime","endTime"];
  1052. }else if( ar == lp.businessTrip ){
  1053. showField = ["address","startTime","endTime","appealDescription"];
  1054. }else if( ar == lp.other ){
  1055. showField = ["appealDescription"];
  1056. }
  1057. tempField.each( function( f ){
  1058. this.formTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  1059. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  1060. }.bind(this))
  1061. },
  1062. getIdentity : function(){
  1063. var identityList = { identities : [], units : [] };
  1064. this.app.personActions.getPerson( function( json ){
  1065. json.data.woIdentityList.each( function( id ){
  1066. var unit = id.woUnit;
  1067. identityList.identities.push( id.distinguishedName );
  1068. identityList.units.push( unit.name );
  1069. }.bind(this))
  1070. }.bind(this), null, false );
  1071. return identityList;
  1072. },
  1073. getAuditor : function(){
  1074. var lp = MWF.xApplication.Attendance.LP;
  1075. //获取设置
  1076. var setting = {};
  1077. var result = [];
  1078. this.app.restActions.listSetting(function(json){
  1079. json.data.each(function( d ){
  1080. setting[d.configCode] = d;
  1081. }.bind(this))
  1082. }.bind(this),null,false);
  1083. if( setting.APPEAL_AUDITOR_TYPE && setting.APPEAL_AUDITOR_TYPE.configValue!="" && setting.APPEAL_AUDITOR_VALUE && setting.APPEAL_AUDITOR_VALUE.configValue!=""){
  1084. if( setting.APPEAL_AUDITOR_TYPE.configValue == lp.reportTo || setting.APPEAL_AUDITOR_TYPE.configValue == "汇报对象" ) {
  1085. var d = {"personList": [layout.desktop.session.user.distinguishedName] };
  1086. this.app.orgActions.listPersonSupDirectValue( d, function( json ){
  1087. var superior = json.data.personList;
  1088. if( !superior || !superior[0] ){
  1089. this.app.notice( lp.noReportToNotice, "error");
  1090. }else{
  1091. var p = superior[0];
  1092. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1093. result.push( this.getPersonByIdentity( p ) )
  1094. }else{
  1095. result.push( p )
  1096. }
  1097. }
  1098. }.bind(this), null, false );
  1099. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "所属部门职位" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.unitDuty ){
  1100. this.app.personActions.getPerson( function( json ){
  1101. json.data.woIdentityList.each( function( id ){
  1102. var unit = id.woUnit;
  1103. var d = {"name": setting.APPEAL_AUDITOR_VALUE.configValue, "unit": unit.distinguishedName};
  1104. this.app.orgActions.getDutyValue( d, function( js ){
  1105. var ids = js.data ? js.data.identityList : [];
  1106. if ( typeOf( ids ) == "array" && ids[0] ) {
  1107. ids.each( function( id ){
  1108. result = result.concat( this.getPersonByIdentity( id ) );
  1109. }.bind(this));
  1110. }else{
  1111. var text = lp.noUnitDutyNotice.replace("{unit}",unit.name).replace("{duty}",setting.APPEAL_AUDITOR_VALUE.configValue);
  1112. this.app.notice( text, "error");
  1113. // this.app.notice("系统中没有配置"+unit.name+"的"+setting.APPEAL_AUDITOR_VALUE.configValue+"职位,请联系管理员", "error");
  1114. }
  1115. }.bind(this),null ,false)
  1116. }.bind(this))
  1117. }.bind(this), null, false );
  1118. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "人员属性" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.personAttribute ){
  1119. this.app.personActions.getPerson( function( json ){
  1120. var attribute = setting.APPEAL_AUDITOR_VALUE.configValue;
  1121. json.data.woPersonAttributeList.each( function( attr ){
  1122. if( attr.name == attribute ){
  1123. var p = attr.attributeList[0];
  1124. if( p ){
  1125. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1126. result.push( this.getPersonByIdentity( p ) )
  1127. }else{
  1128. result.push( p )
  1129. }
  1130. }
  1131. }
  1132. })
  1133. }.bind(this),null ,false);
  1134. if( result.length == 0 ){
  1135. var text = lp.noPersonAttribute.replace("{att}", setting.APPEAL_AUDITOR_VALUE.configValue);
  1136. this.app.notice( text, "error");
  1137. }
  1138. }else if( setting.APPEAL_AUDITOR_TYPE.configValue == "指定人" || setting.APPEAL_AUDITOR_TYPE.configValue == lp.assignedPerson){
  1139. var p = setting.APPEAL_AUDITOR_TYPE.configValue;
  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. }else{
  1147. this.app.personActions.getPerson( function( json ){
  1148. var attribute = lp.directLeader;
  1149. json.data.woPersonAttributeList.each( function( attr ){
  1150. if( attr.name == attribute ){
  1151. var p = attr.attributeList[0];
  1152. if( p ){
  1153. if( p.split("@")[ p.split("@").length - 1].toLowerCase() == "i" ){
  1154. result.push( this.getPersonByIdentity( p ) )
  1155. }else{
  1156. result.push( p )
  1157. }
  1158. }
  1159. }
  1160. })
  1161. }.bind(this),null ,false);
  1162. this.app.notice(lp.noDirectLeader, "error");
  1163. }
  1164. return result;
  1165. },
  1166. getPersonByIdentity : function( identity ){
  1167. var d = {"identityList":[ identity ]};
  1168. var result = [];
  1169. this.app.orgActions.listPersonWithIdentityValue( d, function (js){
  1170. result = js.data.personList;
  1171. }.bind(this), null, false);
  1172. return result;
  1173. },
  1174. ok: function(e){
  1175. var data = this.document.getResult(true,",",true,false,true);
  1176. if (data ) {
  1177. var start = data.startTime;
  1178. var end = data.endTime;
  1179. if (start != "" && end != "") {
  1180. var starTime = new Date(start.replace(/-/g, "/"));
  1181. var endTime = new Date(end.replace(/-/g, "/"));
  1182. if (starTime >= endTime) {
  1183. this.app.notice( MWF.xApplication.Attendance.LP.holiday.beginGreateThanEndNotice, "error");
  1184. return;
  1185. }
  1186. }
  1187. this._ok( data )
  1188. }
  1189. //}else{
  1190. // this.app.notice( "请填写申诉原因和具体描述", "error");
  1191. //}
  1192. },
  1193. _ok: function( data ){
  1194. this.app.restActions.createAppeal(this.data.id, data, function (json) {
  1195. if (json.type == "ERROR") {
  1196. this.app.notice(json.message, "error");
  1197. } else {
  1198. if( this.formMaskNode )this.formMaskNode.destroy();
  1199. if( this.formAreaNode )this.formAreaNode.destroy();
  1200. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  1201. this.app.notice( MWF.xApplication.Attendance.LP.createAppealNotice, "success");
  1202. }
  1203. }.bind(this));
  1204. },
  1205. selectDateTime : function( el, timeOnly, isTme, baseDate ){
  1206. var opt = {
  1207. "style": "xform",
  1208. "timeOnly": timeOnly,
  1209. "isTime": isTme,
  1210. "target": this.app.content
  1211. };
  1212. if( baseDate )opt.baseDate = baseDate;
  1213. MWF.require("MWF.widget.Calendar", function(){
  1214. var calendar = new MWF.widget.Calendar( el, opt );
  1215. calendar.show();
  1216. }.bind(this));
  1217. },
  1218. //getProcessPerson : function( callback ){
  1219. // this.getUnitByPerson( function( unitData ){
  1220. // this.app.restActions.listPermission( function(json){
  1221. // if( json.data.length == 0 ){
  1222. // this.app.notice( "系统未配置考勤员,请联系管理员!", "error");
  1223. // return;
  1224. // }
  1225. // var unitManager, topUnitManager, processer;
  1226. // json.data.each( function( d ){
  1227. // if( d.unitName == unitData.name ){
  1228. // unitManager = d.adminName;
  1229. // }
  1230. // if(d.unitName == unitData.topUnit ){
  1231. // topUnitManager = d.adminName;
  1232. // }
  1233. // })
  1234. // processer = unitManager || topUnitManager;
  1235. // if( !processer ){
  1236. // this.app.notice( "未设置您所在部门和公司的考勤管理员,请联系系统管理员!", "error");
  1237. // }else{
  1238. // if(callback)callback(processer)
  1239. // }
  1240. // }.bind(this))
  1241. // }.bind(this));
  1242. //},
  1243. getUnitByPerson : function( callback ){
  1244. var data = {"personList": [layout.desktop.session.user.distinguishedName] };
  1245. this.app.orgActions.listUnitWithPerson( function( json ){
  1246. if( json.data.length > 0 ){
  1247. if(callback)callback( json.data );
  1248. }else{
  1249. this.app.notice( MWF.xApplication.Attendance.LP.noDepartment, "error");
  1250. }
  1251. }.bind(this), function(){
  1252. this.app.notice( MWF.xApplication.Attendance.LP.noDepartment, "error");
  1253. }.bind(this), data, false )
  1254. }
  1255. });