SelfHoliday.js 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553
  1. MWF.xDesktop.requireApp("Attendance", "Explorer", null, false);
  2. MWF.xDesktop.requireApp("Selector", "package", null, false);
  3. MWF.xDesktop.requireApp("Template", "Explorer", null, false);
  4. MWF.xApplication.Attendance.SelfHoliday = new Class({
  5. Extends: MWF.xApplication.Attendance.Explorer,
  6. Implements: [Options, Events],
  7. initialize: function(node, app, actions, options){
  8. this.setOptions(options);
  9. this.app = app;
  10. this.path = "../x_component_Attendance/$SelfHoliday/";
  11. this.cssPath = "../x_component_Attendance/$SelfHoliday/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.actions = actions;
  14. this.node = $(node);
  15. this.initData();
  16. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  17. },
  18. load: function(){
  19. this.loadToolbar();
  20. this.loadFilter();
  21. this.loadContentNode();
  22. this.loadView();
  23. this.setNodeScroll();
  24. },
  25. loadFilter : function(){
  26. this.fileterNode = new Element("div.fileterNode", {
  27. "styles" : this.css.fileterNode
  28. }).inject(this.node);
  29. this._loadFilterContent();
  30. },
  31. exportExcel : function(){
  32. var exportForm = new MWF.xApplication.Attendance.SelfHoliday.ExportExcelForm( this );
  33. exportForm.edit();
  34. },
  35. _loadFilterContent : function(){
  36. var _self = this;
  37. var html = "<table bordr='0' cellpadding='5' cellspacing='0' styles='formTable' width='950'>"+
  38. "<tr>" +
  39. " <td styles='formTableTitle' lable='q_topUnitName'></td>"+
  40. " <td styles='formTableValue' item='q_topUnitName'></td>"+
  41. " <td styles='formTableTitle' lable='q_unitName'></td>"+
  42. " <td styles='formTableValue' item='q_unitName'></td>"+
  43. " <td styles='formTableTitle' lable='q_empName'></td>"+
  44. " <td styles='formTableValue' item='q_empName'></td>"+
  45. " <td styles='formTableValue' item='action'></td>"+
  46. "</tr>" +
  47. "</table>";
  48. this.fileterNode.set("html",html);
  49. MWF.xDesktop.requireApp("Template", "MForm", function(){
  50. this.filter = new MForm( this.fileterNode, {}, {
  51. style : "filter",
  52. isEdited : true,
  53. itemTemplate : {
  54. q_topUnitName : { "text" : "选择公司", "type" : "org", "orgType" : "unit", style : {"min-width" : "200px"} },
  55. q_unitName : { "text" : "选择部门", "type" : "org", "orgType" : "unit", style : {"min-width" : "250px"} },
  56. q_empName : { "text" : "选择人员", "type" : "org", "orgType" : "person", style : {"min-width" : "100px"} },
  57. action : {
  58. "type" : "button",
  59. "value" : "查询",
  60. "event" : { "click" : function(){
  61. var filterData = _self.filter.getResult( true,",",true,true,true);
  62. this.loadView( filterData );
  63. }.bind(this)}
  64. }
  65. }
  66. }, this.app, this.css);
  67. this.filter.load();
  68. }.bind(this), true);
  69. },
  70. loadView : function( filterData ){
  71. this.elementContentNode.empty();
  72. this.view = new MWF.xApplication.Attendance.SelfHoliday.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  73. this.view.filterData = filterData;
  74. this.view.load();
  75. this.setContentSize();
  76. },
  77. createDocument: function(){
  78. if(this.view)this.view._createDocument();
  79. }
  80. });
  81. MWF.xApplication.Attendance.SelfHoliday.View = new Class({
  82. Extends: MWF.xApplication.Attendance.Explorer.View,
  83. _createItem: function(data){
  84. return new MWF.xApplication.Attendance.SelfHoliday.Document(this.table, data, this.explorer, this);
  85. },
  86. _getCurrentPageData: function(callback, count){
  87. //this.actions.listSelfHoliday(function(json){
  88. // if (callback) callback(json);
  89. //});
  90. if(!count )count=20;
  91. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  92. var filter = this.filterData || {};
  93. this.actions.listSelfHolidayFilterNext(id, count, filter, function(json){
  94. if (callback) callback(json);
  95. });
  96. },
  97. _removeDocument: function(documentData, all){
  98. this.actions.deleteSelfHoliday(documentData.id, function(json){
  99. this.explorer.view.reload();
  100. this.app.notice(this.app.lp.deleteDocumentOK, "success");
  101. }.bind(this));
  102. },
  103. _createDocument: function(){
  104. var selfHoliday = new MWF.xApplication.Attendance.SelfHoliday.Form(this.explorer);
  105. selfHoliday.create();
  106. },
  107. _openDocument: function( documentData ){
  108. var selfHoliday = new MWF.xApplication.Attendance.SelfHoliday.Form(this.explorer, documentData );
  109. selfHoliday.open();
  110. }
  111. });
  112. MWF.xApplication.Attendance.SelfHoliday.Document = new Class({
  113. Extends: MWF.xApplication.Attendance.Explorer.Document
  114. });
  115. MWF.xApplication.Attendance.SelfHoliday.ExportExcelForm = new Class({
  116. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  117. _createTableContent: function(){
  118. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  119. "<tr><td colspan='2' styles='formTableHead'>导出员工休假记录</td></tr>" +
  120. "<tr>" +
  121. " <td styles='formTableTitle' lable='startDate'></td>"+
  122. " <td styles='formTableValue' item='startDate'></td>"+
  123. "</tr>" +
  124. "<tr>" +
  125. " <td styles='formTableTitle' lable='endDate'></td>"+
  126. " <td styles='formTableValue' item='endDate'></td>"+
  127. //" <td styles='formTableValue' item='action'></td>"+
  128. "</tr>" +
  129. "</table>";
  130. this.formTableArea.set("html",html);
  131. MWF.xDesktop.requireApp("Template", "MForm", function(){
  132. this.form = new MForm( this.formTableArea, {q_empName : layout.desktop.session.user.distinguishedName }, {
  133. isEdited : true,
  134. itemTemplate : {
  135. startDate : { "text" : "开始日期", "tType" : "date" },
  136. endDate : { "text" : "结束日期", "tType" : "date" }
  137. }
  138. }, this.app );
  139. this.form.load();
  140. }.bind(this), true);
  141. },
  142. _ok: function( data, callback ){
  143. this.app.restActions.exportSelfHoliday( data.startDate, data.endDate, function(json){
  144. if( callback )callback(json);
  145. }.bind(this) );
  146. this.close();
  147. }
  148. });
  149. MWF.xApplication.Attendance.SelfHoliday.Form = new Class({
  150. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  151. options : {
  152. "width": 600,
  153. "height": 450,
  154. "hasTop" : true,
  155. "hasBottom" : true,
  156. "title" : "",
  157. "draggable" : true,
  158. "closeAction" : true
  159. },
  160. _createTableContent: function(){
  161. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  162. "<tr><td colspan='2' styles='formTableHead'>员工休假记录</td></tr>" +
  163. "<tr><td styles='formTabelTitle' lable='unitName'></td>"+
  164. " <td styles='formTableValue' item='unitName'></td></tr>" +
  165. "<tr><td styles='formTabelTitle' lable='employeeName'></td>"+
  166. " <td styles='formTableValue' item='employeeName'></td></tr>" +
  167. "<tr><td styles='formTabelTitle' lable='leaveType'></td>"+
  168. " <td styles='formTableValue' item='leaveType'></td></tr>" +
  169. "<tr><td styles='formTabelTitle' lable='startTime'></td>"+
  170. " <td styles='formTableValue' item='startTime'></td></tr>" +
  171. "<tr><td styles='formTabelTitle' lable='endTime'></td>"+
  172. " <td styles='formTableValue' item='endTime'></td></tr>" +
  173. "<tr><td styles='formTabelTitle' lable='leaveDayNumber'></td>"+
  174. " <td styles='formTableValue' item='leaveDayNumber'></td></tr>" +
  175. "</table>";
  176. this.formTableArea.set("html",html);
  177. MWF.xDesktop.requireApp("Template", "MForm", function(){
  178. this.form = new MForm( this.formTableArea, this.data, {
  179. isEdited : this.isEdited || this.isNew,
  180. itemTemplate : {
  181. unitName : { text : "部门", "type" : "org", orgType : "unit", notEmpty : true},
  182. employeeName : { text: "员工姓名", "type" : "org", orgType : "person" , notEmpty : true },
  183. leaveType : {
  184. text: "休假类型",
  185. "type" : "select", notEmpty : true,
  186. "selectValue" : "带薪年休假,带薪病假,带薪福利假,扣薪事假,其他".split(",")
  187. },
  188. startTime : {
  189. text:"开始时间", tType : "datetime", notEmpty : true
  190. },
  191. endTime : {
  192. text:"结束时间", tType : "datetime", notEmpty : true
  193. },
  194. leaveDayNumber : {
  195. text:"休假天数", tType : "number", notEmpty : true
  196. }
  197. }
  198. }, this.app);
  199. this.form.load();
  200. }.bind(this), true);
  201. },
  202. _ok: function( data, callback ){
  203. this.app.restActions.saveSelfHoliday(data, function(json){
  204. if( callback )callback(json);
  205. }.bind(this));
  206. }
  207. });
  208. //
  209. //MWF.xApplication.Attendance.SelfHoliday.Form = new Class({
  210. // Extends: MWF.widget.Common,
  211. // Implements: [Options, Events],
  212. // options: {
  213. // "width": "500",
  214. // "height": "400"
  215. // },
  216. // initialize: function( explorer, data ){
  217. // this.explorer = explorer;
  218. // this.app = explorer.app;
  219. // this.data = data || {};
  220. // this.css = this.explorer.css;
  221. //
  222. // this.load();
  223. // },
  224. // load: function(){
  225. //
  226. // },
  227. //
  228. // open: function(){
  229. // this.isNew = false;
  230. // this.isEdited = false;
  231. // this._open();
  232. // },
  233. // create: function(){
  234. // this.isNew = true;
  235. // this._open();
  236. // },
  237. // edit: function(){
  238. // this.isEdited = true;
  239. // this._open();
  240. // },
  241. // _open : function(){
  242. // this.createMarkNode = new Element("div", {
  243. // "styles": this.css.createMarkNode,
  244. // "events": {
  245. // "mouseover": function(e){e.stopPropagation();},
  246. // "mouseout": function(e){e.stopPropagation();}
  247. // }
  248. // }).inject(this.app.content, "after");
  249. //
  250. // this.createAreaNode = new Element("div", {
  251. // "styles": this.css.createAreaNode
  252. // });
  253. //
  254. // this.createNode();
  255. //
  256. // this.createAreaNode.inject(this.createMarkNode, "after");
  257. // this.createAreaNode.fade("in");
  258. //
  259. //
  260. // this.setCreateNodeSize();
  261. // this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  262. // this.addEvent("resize", this.setCreateNodeSizeFun);
  263. // },
  264. // createNode: function(){
  265. // var _self = this;
  266. // var d = this.data;
  267. // this.createNode = new Element("div", {
  268. // "styles": this.css.createNode
  269. // }).inject(this.createAreaNode);
  270. //
  271. //
  272. // this.createIconNode = new Element("div", {
  273. // "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  274. // }).inject(this.createNode);
  275. //
  276. //
  277. // this.createFormNode = new Element("div", {
  278. // "styles": this.css.createFormNode
  279. // }).inject(this.createNode);
  280. //
  281. //
  282. // var table = new Element("table", {
  283. // "width" : "100%", "border" : "0", "cellpadding" : "0", "cellspacing" : "0"
  284. // }).inject( this.createFormNode );
  285. //
  286. // var tr = new Element("tr").inject(table);
  287. // var td = new Element("td", { "colspan":'2', "styles" : this.css.editTableHead, "text" : "员工休假记录" }).inject(tr);
  288. //
  289. // var tr = new Element("tr").inject(table);
  290. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "部门:" }).inject(tr);
  291. // var td = new Element("td", { "styles" : this.css.editTableValue }).inject(tr);
  292. // if( !this.isNew && !this.isEdited ){
  293. // td.set("text", d.unitName )
  294. // }else{
  295. // this.unitName = new MDomItem( td, {
  296. // "name" : "unitName",
  297. // "value" : d.unitName,
  298. // "style" : this.css.inputPersonStyle,
  299. // "event" : {
  300. // "click" : function( mdi){ _self.selectPeople(this, "unit", mdi.get("value").split(",") ) }
  301. // }
  302. // }, true, this.app );
  303. // this.unitName.load();
  304. // }
  305. //
  306. // var tr = new Element("tr").inject(table);
  307. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "员工姓名:" }).inject(tr);
  308. // var td = new Element("td", { "styles" : this.css.editTableValue }).inject(tr);
  309. // if( !this.isNew && !this.isEdited ){
  310. // td.set("text", d.employeeName )
  311. // }else{
  312. // this.employeeName = new MDomItem( td, {
  313. // "name" : "employeeName",
  314. // "value" : d.employeeName,
  315. // "style" : this.css.inputPersonStyle,
  316. // "event" : {
  317. // "click" : function( mdi){ _self.selectPeople(this, "person", mdi.get("value").split(",") ) }
  318. // }
  319. // }, true, this.app );
  320. // this.employeeName.load();
  321. // }
  322. //
  323. // var tr = new Element("tr").inject(table);
  324. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "休假类型:" }).inject(tr);
  325. // var td = new Element("td", { "styles" : this.css.editTableValue }).inject(tr);
  326. // if( !this.isNew && !this.isEdited ){
  327. // td.set("text", d.leaveType )
  328. // }else{
  329. // this.leaveType = new MDomItem( td, {
  330. // "name" : "leaveType",
  331. // "type" : "select",
  332. // "value" : d.leaveType,
  333. // "selectValue" : "带薪年休假,带薪病假,带薪福利假,扣薪事假,其他".split(",")
  334. // }, true, this.app );
  335. // this.leaveType.load();
  336. // }
  337. //
  338. // var tr = new Element("tr").inject(table);
  339. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "开始时间:" }).inject(tr);
  340. // var td = new Element("td", { "styles" : this.css.editTableValue }).inject(tr);
  341. // if( !this.isNew && !this.isEdited ){
  342. // td.set("text", d.startTime )
  343. // }else{
  344. // this.startTime = new MDomItem( td, {
  345. // "name" : "startTime",
  346. // "value" : d.startTime,
  347. // "style" : this.css.inputTimeStyle,
  348. // "event" : {
  349. // "click" : function( mdi){ _self.selectDateTime(this, false, true ) }
  350. // }
  351. // }, true, this.app );
  352. // this.startTime.load();
  353. // }
  354. //
  355. // var tr = new Element("tr").inject(table);
  356. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "结束时间:" }).inject(tr);
  357. // var td = new Element("td", { "styles" : this.css.editTableValue} ).inject(tr);
  358. // if( !this.isNew && !this.isEdited ){
  359. // td.set("text", d.endTime )
  360. // }else{
  361. // this.endTime = new MDomItem( td, {
  362. // "name" : "endTime",
  363. // "value" : d.endTime,
  364. // "style" : this.css.inputTimeStyle,
  365. // "event" : {
  366. // "click" : function( mdi){ _self.selectDateTime(this, false, true ) }
  367. // }
  368. // }, true, this.app );
  369. // this.endTime.load();
  370. // }
  371. //
  372. // var tr = new Element("tr").inject(table);
  373. // var td = new Element("td", { "styles" : this.css.editTableTitle, "text" : "休假天数:" }).inject(tr);
  374. // var td = new Element("td", { "styles" : this.css.editTableValue}).inject(tr);
  375. // if( !this.isNew && !this.isEdited ){
  376. // td.set("text", d.leaveDayNumber )
  377. // }else{
  378. // this.leaveDayNumber = new MDomItem( td, {
  379. // "name" : "leaveDayNumber",
  380. // "value" : d.leaveDayNumber,
  381. // "style" : this.css.inputStyle,
  382. // "event" : {
  383. // "keyup" : function(){ this.value=this.value.replace(/[^\d.]/g,'') }
  384. // }
  385. // }, true, this.app );
  386. // this.leaveDayNumber.load();
  387. // }
  388. //
  389. // if( this.isNew || this.isEdited ){
  390. // this.createOkActionNode = new Element("div", {
  391. // "styles": this.css.createOkActionNode,
  392. // "text": this.app.lp.ok
  393. // }).inject(this.createFormNode);
  394. //
  395. // this.createOkActionNode.addEvent("click", function(e){
  396. // this.okCreate(e);
  397. // }.bind(this));
  398. // }
  399. // this.cancelActionNode = new Element("div", {
  400. // "styles": this.css.createCancelActionNode,
  401. // "text": this.app.lp.cancel
  402. // }).inject(this.createFormNode);
  403. //
  404. // this.cancelActionNode.addEvent("click", function(e){
  405. // this.cancelCreate(e);
  406. // }.bind(this));
  407. //
  408. // },
  409. // setCreateNodeSize: function (width, height, top, left) {
  410. // if (!width)width = this.options && this.options.width ? this.options.width : "50%"
  411. // if (!height)height = this.options && this.options.height ? this.options.height : "50%"
  412. // if (!top) top = this.options && this.options.top ? this.options.top : 0;
  413. // if (!left) left = this.options && this.options.left ? this.options.left : 0;
  414. //
  415. // var allSize = this.app.content.getSize();
  416. // var limitWidth = allSize.x; //window.screen.width
  417. // var limitHeight = allSize.y; //window.screen.height
  418. //
  419. // "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  420. // "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  421. // 300 > width && (width = 300);
  422. // 220 > height && (height = 220);
  423. // top = top || parseInt((limitHeight - height) / 2, 10);
  424. // left = left || parseInt((limitWidth - width) / 2, 10);
  425. //
  426. // this.createAreaNode.setStyles({
  427. // "width": "" + width + "px",
  428. // "height": "" + height + "px",
  429. // "top": "" + top + "px",
  430. // "left": "" + left + "px"
  431. // });
  432. //
  433. // this.createNode.setStyles({
  434. // "width": "" + width + "px",
  435. // "height": "" + height + "px"
  436. // });
  437. //
  438. // var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x: 0, y: 0};
  439. // var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  440. // var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  441. //
  442. // var contentHeight = height - iconSize.y - topSize.y - bottomSize.y;
  443. // //var formMargin = formHeight -iconSize.y;
  444. // this.createFormNode.setStyles({
  445. // "height": "" + contentHeight + "px"
  446. // });
  447. // },
  448. // cancelCreate: function(e){
  449. // var _self = this;
  450. // if( this.unitName )var unitName = this.unitName.get("value");
  451. // if ( this.isNew && unitName!="" && unitName!="default" ){
  452. // this.app.confirm("warn", e,
  453. // this.app.lp.create_cancel_title,
  454. // this.app.lp.create_cancel, "320px", "100px",
  455. // function(){
  456. // _self.createMarkNode.destroy();
  457. // _self.createAreaNode.destroy();
  458. // this.close();
  459. // },function(){
  460. // this.close();
  461. // }
  462. // );
  463. // }else{
  464. // this.createMarkNode.destroy();
  465. // this.createAreaNode.destroy();
  466. // delete _self;
  467. // }
  468. // },
  469. // okCreate: function(e){
  470. // var data = {
  471. // "id" : (this.data && this.data.id) ? this.data.id : null,
  472. // "unitName": this.unitName.get("value"),
  473. // "employeeName": this.employeeName.get("value"),
  474. // "leaveType": this.leaveType.get("value"),
  475. // "startTime": this.startTime.get("value"),
  476. // "endTime": this.endTime.get("value"),
  477. // "leaveDayNumber": this.leaveDayNumber.get("value")
  478. // };
  479. //
  480. // //alert(JSON.stringify(data))
  481. //
  482. // if (data.unitName && data.employeeName && data.leaveType && data.startTime && data.endTime && data.leaveDayNumber){
  483. // this.app.restActions.saveSelfHoliday(data, function(json){
  484. // if( json.type == "ERROR" ){
  485. // this.app.notice( json.message , "error");
  486. // }else{
  487. // this.createMarkNode.destroy();
  488. // this.createAreaNode.destroy();
  489. // if(this.explorer.view)this.explorer.view.reload();
  490. // this.app.notice( this.isNew ? this.app.lp.createSuccess : this.app.lp.updateSuccess , "success");
  491. // }
  492. // // this.app.processConfig();
  493. // }.bind(this));
  494. // }else{
  495. // this.app.notice( this.app.lp.selfHoliday.inputVaild, "error");
  496. // }
  497. // },
  498. // selectDateTime : function( el, timeOnly, isTme ){
  499. // MWF.require("MWF.widget.Calendar", function(){
  500. // var calendar = new MWF.widget.Calendar( el, {
  501. // "style": "xform",
  502. // "timeOnly": timeOnly,
  503. // "isTime": isTme,
  504. // "target": this.app.content
  505. // });
  506. // calendar.show();
  507. // }.bind(this));
  508. // },
  509. // selectPeople: function(el, type, value ){
  510. // var title
  511. // if( type == "unit" ){
  512. // title = "选择部门"
  513. // }else if( type == "topUnit" ){
  514. // title = "选择公司"
  515. // }else{
  516. // title = "选择个人"
  517. // }
  518. // var options = {
  519. // "type": type,
  520. // "title": title,
  521. // "count" : "1",
  522. // "values": value || [],
  523. // "onComplete": function(items){
  524. // var vs = [];
  525. // items.each(function(item){
  526. // vs.push(item.data.name);
  527. // }.bind(this));
  528. // el.set("value",vs.join( "," ));
  529. // }.bind(this)
  530. // };
  531. // var selector = new MWF.O2Selector(this.app.content, options);
  532. // }
  533. //});