AppealExplorer.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667
  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.xDesktop.requireApp("Template", "MForm", null, false);
  5. MWF.xApplication.Attendance.AppealExplorer = new Class({
  6. Extends: MWF.xApplication.Attendance.Explorer,
  7. Implements: [Options, Events],
  8. initialize: function(node, app, actions, options){
  9. this.setOptions(options);
  10. this.app = app;
  11. this.path = "../x_component_Attendance/$AppealExplorer/";
  12. this.cssPath = "../x_component_Attendance/$AppealExplorer/"+this.options.style+"/css.wcss";
  13. this._loadCss();
  14. this.actions = actions;
  15. this.node = $(node);
  16. this.preMonthDate = new Date();
  17. this.initData();
  18. if (!this.personActions) this.personActions = new MWF.xAction.org.express.RestActions();
  19. },
  20. load: function(){
  21. this.loadConfig();
  22. this.loadToolbar();
  23. this.loadFilter();
  24. this.loadContentNode();
  25. var month = (this.preMonthDate.getMonth()+1).toString();
  26. if( month.length == 1 )month = "0"+month;
  27. var filterData = {
  28. "status" : "0",
  29. "yearString" : this.preMonthDate.getFullYear().toString(),
  30. "monthString" : month
  31. };
  32. this.loadView( filterData );
  33. this.setNodeScroll();
  34. },
  35. loadConfig : function(){
  36. /*this.config = {};
  37. var v;
  38. this.actions.getSettingCode( "APPEALABLE", function(json){
  39. v = json.data ? json.data.configValue : null
  40. },null, false)
  41. if( !v ){
  42. this.config.APPEALABLE = true;
  43. }else{
  44. this.config.APPEALABLE = (v != "false" )
  45. }*/
  46. this.config = {};
  47. var v;
  48. //需要判断申述类型listSetting2020年6月16日 by gee
  49. this.configSetting = new Object(null);
  50. this.actions.listSetting(function(json){
  51. var data = json.data;
  52. if(!!data){
  53. json.data.map(function(e){
  54. this.configSetting[e.configCode]=e;
  55. }.bind(this));
  56. v = this.configSetting.APPEALABLE.configValue;
  57. }else{
  58. v = null;
  59. }
  60. }.bind(this),null,false);
  61. if( !v ){
  62. this.config.APPEALABLE = true;
  63. }else{
  64. this.config.APPEALABLE = (v != "false" )
  65. }
  66. },
  67. loadToolbar: function(){
  68. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode});
  69. this.toolbarNode.inject(this.node);
  70. var toolbarUrl = this.path + "toolbar.json";
  71. MWF.getJSON(toolbarUrl, function (json) {
  72. json.each(function (tool) {
  73. if( !this.config.APPEALABLE && tool.condition=="onlock" ){
  74. this.createToolbarItemNode(tool)
  75. }else if( this.config.APPEALABLE && tool.condition!="onlock" ){
  76. this.createToolbarItemNode(tool)
  77. }
  78. }.bind(this));
  79. }.bind(this));
  80. },
  81. loadFilter : function(){
  82. this.fileterNode = new Element("div.fileterNode", {
  83. "styles" : this.css.fileterNode
  84. }).inject(this.node);
  85. var table = new Element("table", {
  86. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.filterTable, "class" : "filterTable"
  87. }).inject( this.fileterNode );
  88. var tr = new Element("tr").inject(table);
  89. //var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.preMonthDate.format(this.app.lp.dateFormatMonth) }).inject(tr);
  90. this.createYearSelectTd( tr );
  91. this.createMonthSelectTd( tr );
  92. this.createStatusSelectTd(tr);
  93. this.createAppealReasonTd(tr);
  94. this.createUnitTd(tr);
  95. this.createPersonTd( tr );
  96. this.createActionTd( tr );
  97. },
  98. createStatusSelectTd : function( tr ){
  99. var _self = this;
  100. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "审批状态" }).inject(tr);
  101. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  102. this.status = new MDomItem( td, {
  103. "name" : "status",
  104. "type" : "select",
  105. "value" : "0",
  106. "selectText" :["所有状态","待处理","审批通过","审批未通过"],
  107. "selectValue" :["999","0","1","-1"]
  108. }, true, this.app );
  109. this.status.load();
  110. },
  111. createAppealReasonTd : function( tr ){
  112. var _self = this;
  113. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "申诉原因" }).inject(tr);
  114. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  115. this.appealReason = new MDomItem( td, {
  116. "name" : "appealReason",
  117. "type" : "select",
  118. "selectText" :["","临时请假","出差","因公外出","其他"]
  119. }, true, this.app );
  120. this.appealReason.load();
  121. },
  122. createUnitTd : function(tr){
  123. var _self = this;
  124. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "部门" }).inject(tr);
  125. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  126. this.unitName = new MDomItem( td, {
  127. "name" : "unitName",
  128. "style" : {"width":"60px"},
  129. "defaultValue" : this.app.manageUnits.length > 0 ? this.app.manageUnits[0] : "",
  130. "event" : {
  131. "click" : function(mdi){ _self.selecePerson( mdi, "unit" ); }
  132. }
  133. }, true, this.app );
  134. this.unitName.load();
  135. },
  136. createPersonTd : function(tr){
  137. var _self = this;
  138. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "人员" }).inject(tr);
  139. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  140. this.empName = new MDomItem( td, {
  141. "name" : "empName",
  142. "style" : {"width":"60px"},
  143. "event" : {
  144. "click" : function(mdi){ _self.selecePerson( mdi, "person" ); }
  145. }
  146. }, true, this.app );
  147. this.empName.load();
  148. },
  149. createYearSelectTd : function( tr ){
  150. var _self = this;
  151. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "年度" }).inject(tr);
  152. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  153. this.yearString = new MDomItem( td, {
  154. "name" : "yearString",
  155. "type" : "select",
  156. "selectValue" : function(){
  157. var years = [];
  158. var year = new Date().getFullYear();
  159. for(var i=0; i<6; i++ ){
  160. years.push( year-- );
  161. }
  162. return years;
  163. }
  164. }, true, this.app );
  165. this.yearString.load();
  166. },
  167. createMonthSelectTd : function( tr ){
  168. var _self = this;
  169. var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : "月份" }).inject(tr);
  170. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  171. this.monthString = new MDomItem( td, {
  172. "name" : "monthString",
  173. "type" : "select",
  174. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"]
  175. }, true, this.app );
  176. this.monthString.load();
  177. },
  178. createActionTd : function( tr ){
  179. var td = new Element("td", { "styles" : this.css.filterTableValue }).inject(tr);
  180. var input = new Element("button",{
  181. "text" : "查询",
  182. "styles" : this.css.filterButton
  183. }).inject(td);
  184. input.addEvent("click", function(){
  185. /*var year = this.preMonthDate.getFullYear().toString();
  186. var month = (this.preMonthDate.getMonth()+1).toString();
  187. if( month.length == 1 )month = "0"+month;*/
  188. var filterData = {
  189. status : this.status.getValue(),
  190. appealReason : this.appealReason.getValue(),
  191. unitName : this.unitName.getValue(),
  192. empName : this.empName.getValue(),
  193. yearString : this.yearString.getValue(),
  194. monthString : this.monthString.getValue()
  195. }
  196. this.loadView( filterData );
  197. }.bind(this))
  198. },
  199. selecePerson: function( el, type ){
  200. var text = "选择人员"
  201. if( type=="topUnit") {
  202. text = "选择公司"
  203. }else if( type=="unit"){
  204. text = "选择部门"
  205. }
  206. var options = {
  207. "type": type, //topUnit unit person,
  208. "title": text,
  209. "count" : "1",
  210. "values": [ el.get("value") ] || [],
  211. "onComplete": function(items){
  212. var arr = [];
  213. items.each(function(item){
  214. arr.push(item.data.name);
  215. }.bind(this));
  216. el.set("value",arr.join(","));
  217. }.bind(this)
  218. };
  219. var selector = new MWF.O2Selector(this.app.content, options);
  220. },
  221. setContentSize: function(){
  222. var toolbarSize = this.toolbarNode ? this.toolbarNode.getSize() : {"x":0,"y":0};
  223. var titlebarSize = this.app.titleBar ? this.app.titleBar.getSize() : {"x":0,"y":0};
  224. var filterSize = this.fileterNode ? this.fileterNode.getSize() : {"x":0,"y":0};
  225. var nodeSize = this.node.getSize();
  226. var pt = this.elementContentNode.getStyle("padding-top").toFloat();
  227. var pb = this.elementContentNode.getStyle("padding-bottom").toFloat();
  228. //var filterSize = this.filterNode.getSize();
  229. var filterConditionSize = this.filterConditionNode ? this.filterConditionNode.getSize() : {"x":0,"y":0};
  230. var height = nodeSize.y-toolbarSize.y-pt-pb-filterConditionSize.y-titlebarSize.y-filterSize.y;
  231. this.elementContentNode.setStyle("height", ""+height+"px");
  232. this.pageCount = (height/30).toInt()+5;
  233. if (this.view && this.view.items.length<this.pageCount){
  234. this.view.loadElementList(this.pageCount-this.view.items.length);
  235. }
  236. },
  237. loadView : function( filterData ){
  238. this.elementContentNode.empty();
  239. this.view = new MWF.xApplication.Attendance.AppealExplorer.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  240. this.view.filterData = filterData;
  241. this.view.load();
  242. this.setContentSize();
  243. },
  244. createDocument: function(){
  245. if(this.view)this.view._createDocument();
  246. },
  247. agreeAppeals: function( e ){
  248. var _self = this;
  249. var count = 0;
  250. this.view.items.each( function( it ){
  251. if( it.checkboxElement && it.checkboxElement.get("checked" ) )count++;
  252. }.bind(this))
  253. if( count == 0 ){
  254. this.app.notice("请先选择申诉","error");
  255. return;
  256. }
  257. this.app.confirm("warn", e, "同意申诉", "确定处理您选择的"+count+"份申诉?", 350, 120, function(){
  258. _self.batchAppeals = true;
  259. _self.view.items.each( function( it ){
  260. if( it.checkboxElement && it.checkboxElement.get("checked" ) )it.agree( true );
  261. }.bind(this));
  262. if(_self.view)_self.view.reload();
  263. _self.batchAppeals = false;
  264. _self.app.notice( "处理成功" , "success");
  265. this.close();
  266. }, function(){
  267. this.close();
  268. });
  269. },
  270. denyAppeals: function( e ){
  271. var _self = this;
  272. var count = 0;
  273. this.view.items.each( function( it ){
  274. if( it.checkboxElement && it.checkboxElement.get("checked" ) )count++;
  275. }.bind(this));
  276. if( count == 0 ){
  277. this.app.notice("请先选择申诉","error");
  278. return;
  279. }
  280. this.app.confirm("warn", e, "不同意申诉", "确定处理您选择的"+count+"份申诉?", 350, 120, function(){
  281. _self.batchAppeals = true;
  282. _self.view.items.each( function( it ){
  283. if( it.checkboxElement && it.checkboxElement.get("checked" ) )it.deny( true );
  284. }.bind(this));
  285. if(_self.view)_self.view.reload();
  286. _self.batchAppeals = false;
  287. _self.app.notice( "处理成功" , "success");
  288. this.close();
  289. }, function(){
  290. this.close();
  291. });
  292. }
  293. });
  294. MWF.xApplication.Attendance.AppealExplorer.View = new Class({
  295. Extends: MWF.xApplication.Attendance.Explorer.View,
  296. _createItem: function(data){
  297. return new MWF.xApplication.Attendance.AppealExplorer.Document(this.table, data, this.explorer, this);
  298. },
  299. _getCurrentPageData: function(callback, count){
  300. if(!count )count=20;
  301. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  302. var filter = this.filterData || {};
  303. filter.processPerson1 = layout.desktop.session.user.distinguishedName;
  304. this.actions.listAppealFilterNext(id, count, filter, function(json){
  305. var data = json.data;
  306. data.each(function(d){
  307. d.APPEALABLE = this.explorer.config.APPEALABLE;
  308. d.APPEAL_AUDIFLOWTYPE = this.explorer.configSetting.APPEAL_AUDIFLOWTYPE.configValue;
  309. }.bind(this));
  310. data.sort( function( a, b ){
  311. return parseInt( b.appealDateString.replace(/-/g,"") ) - parseInt( a.appealDateString.replace(/-/g,"") );
  312. })
  313. json.data = data;
  314. if (callback) callback(json);
  315. }.bind(this));
  316. },
  317. _removeDocument: function(documentData, all){
  318. },
  319. _createDocument: function(){
  320. },
  321. _openDocument: function( documentData ){
  322. /*if(!!documentData.appealAuditInfo){
  323. var workid = documentData.appealAuditInfo.workId;
  324. var options = {"workId":workid, "appId": "process.Work"+workid};
  325. this.app.desktop.openApplication(null, "process.Work", options);
  326. }else{
  327. var appeal = new MWF.xApplication.Attendance.AppealExplorer.Appeal(this.explorer, documentData );
  328. if( !documentData.status ){
  329. appeal.edit();
  330. }else{
  331. appeal.open();
  332. }
  333. }*/
  334. if(documentData.appealAuditInfo){
  335. if(documentData.appealAuditInfo.workId){
  336. var workid = documentData.appealAuditInfo.workId;
  337. var options = {"workId":workid, "appId": "process.Work"+workid};
  338. this.app.desktop.openApplication(null, "process.Work", options);
  339. return;
  340. }
  341. }
  342. var appeal = new MWF.xApplication.Attendance.AppealExplorer.Appeal(this.explorer, documentData );
  343. appeal.open();
  344. }
  345. })
  346. MWF.xApplication.Attendance.AppealExplorer.Document = new Class({
  347. Extends: MWF.xApplication.Attendance.Explorer.Document,
  348. agree : function( ){
  349. var data = { 'ids' : [this.data.id], 'status':'1' };
  350. this.process( data );
  351. },
  352. deny : function( batch ){
  353. var data = { 'ids' : [this.data.id], 'status':'-1' };
  354. this.process( data );
  355. },
  356. process: function( data ){
  357. this.app.restActions.processAppeal( data, function(json){
  358. if( json.type == "ERROR" ){
  359. this.app.notice( json.message , "error");
  360. }else{
  361. if( !this.explorer.batchAppeals ){
  362. if(this.explorer.view)this.explorer.view.reload();
  363. this.app.notice( "处理成功" , "success");
  364. }
  365. }
  366. }.bind(this), null, false );
  367. }
  368. })
  369. MWF.xApplication.Attendance.AppealExplorer.Appeal = new Class({
  370. Extends: MWF.widget.Common,
  371. initialize: function( explorer, data ){
  372. this.explorer = explorer;
  373. this.app = explorer.app;
  374. this.data = data || {};
  375. this.css = this.explorer.css;
  376. //this.app.restActions.getAppeal(this.data.detailId, function(json){
  377. // this.data = json.data
  378. //}.bind(this),null,false)
  379. //alert(JSON.stringify(this.data))
  380. this.load();
  381. },
  382. load: function(){
  383. this.app.restActions.getDetail(this.data.detailId, function(json){
  384. this.data.onDutyTime = json.data.onDutyTime;
  385. this.data.offDutyTime = json.data.offDutyTime;
  386. }.bind(this),null,false)
  387. },
  388. open: function(e){
  389. this.isNew = false;
  390. this.isEdited = false;
  391. this._open();
  392. },
  393. create: function(){
  394. this.isNew = true;
  395. this._open();
  396. },
  397. edit: function(){
  398. if( this.explorer.config.APPEALABLE )this.isEdited = true;
  399. this._open();
  400. },
  401. _open : function(){
  402. this.createMarkNode = new Element("div", {
  403. "styles": this.css.createMarkNode,
  404. "events": {
  405. "mouseover": function(e){e.stopPropagation();},
  406. "mouseout": function(e){e.stopPropagation();}
  407. }
  408. }).inject(this.app.content, "after");
  409. this.createAreaNode = new Element("div", {
  410. "styles": this.css.createAreaNode
  411. });
  412. this.createNode();
  413. this.createAreaNode.inject(this.createMarkNode, "after");
  414. this.createAreaNode.fade("in");
  415. this.setCreateNodeSize();
  416. this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  417. this.addEvent("resize", this.setCreateNodeSizeFun);
  418. },
  419. createNode: function(){
  420. var _self = this;
  421. this.createNode = new Element("div", {
  422. "styles": this.css.createNode
  423. }).inject(this.createAreaNode);
  424. //
  425. //this.createIconNode = new Element("div", {
  426. // "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  427. //}).inject(this.createNode);
  428. this.createContainerNode = new Element("div", {
  429. "styles": this.css.createContainerNode
  430. }).inject(this.createNode);
  431. this.setScrollBar( this.createContainerNode );
  432. this.createFormNode = new Element("div", {
  433. "styles": this.css.createFormNode
  434. }).inject(this.createContainerNode);
  435. this.createTableContainer = new Element("div", {
  436. "styles": this.css.createTableContainer
  437. }).inject(this.createFormNode);
  438. this.createTableArea = new Element("div", {
  439. "styles": this.css.createTableArea
  440. }).inject(this.createTableContainer);
  441. var table = new Element("table", {
  442. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.editTable, "class" : "editTable"
  443. }).inject( this.createTableArea );
  444. var d = this.data;
  445. var appealStatus = "发起";
  446. if (d.status == 0 ) {
  447. appealStatus = "待处理"
  448. } else if (d.status == 1) {
  449. appealStatus = "审批通过"
  450. } else if (d.status == -1) {
  451. appealStatus = "审批不通过"
  452. }
  453. this.data.appealStatusShow = appealStatus;
  454. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  455. "<tr><td colspan='4' styles='formTableHead'>申诉处理单</td></tr>" +
  456. "<tr><td styles='formTableTitle' lable='empNameShow'></td>"+
  457. " <td styles='formTableValue' item='empNameShow'></td>" +
  458. " <td styles='formTableTitle' lable='recordDateString'></td>"+
  459. " <td styles='formTableValue' item='recordDateString'></td></tr>" +
  460. "<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  461. " <td styles='formTableValue' item='onDutyTime'></td>" +
  462. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  463. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  464. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  465. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>" +
  466. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  467. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  468. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  469. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  470. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  471. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  472. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  473. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  474. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  475. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  476. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  477. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  478. /*"<tr contain='opinion1'><td styles='formTableTitle' lable='opinion1'></td>"+
  479. " <td styles='formTableValue' item='opinion1' colspan='3'></td></tr>" +*/
  480. "</table>"
  481. this.createTableArea.set("html",html);
  482. this.document = new MForm( this.createTableArea, this.data, {
  483. style : "popup",
  484. isEdited : this.isEdited || this.isNew,
  485. itemTemplate : {
  486. empNameShow : { text:"员工姓名", type : "innertext", value : this.data.empName.split("@")[0] },
  487. recordDateString : { text:"考勤日期", type : "innertext"},
  488. onDutyTime : { text:"上班打卡时间", type : "innertext"},
  489. offDutyTime : { text:"下班打卡时间", type : "innertext"},
  490. statusShow : { text:"考勤状态", type : "innertext" },
  491. appealStatusShow : { text:"审批状态",type : "innertext"},
  492. appealReason : {
  493. text:"申述原因", type : "innertext"
  494. },
  495. address : { text:"地点", type : "innertext" },
  496. selfHolidayType : {
  497. text:"请假类型",
  498. type : "innertext"
  499. },
  500. startTime : { text:"开始日期", type : "innertext" },
  501. endTime : { text:"结束日期", type : "innertext" },
  502. appealDescription : { text:"事由", type : "innertext" }
  503. //opinion1 : { text :"审批意见",type : "textarea" }
  504. }
  505. }, this.app,this.css);
  506. this.document.load();
  507. _self.switchFieldByAppealReason(this.data.appealReason);
  508. //createFormNode.set("html", html);
  509. //this.setScrollBar(this.createTableContainer)
  510. this.cancelActionNode = new Element("div", {
  511. "styles": this.css.createCancelActionNode,
  512. "text": "关闭"
  513. }).inject(this.createFormNode);
  514. this.cancelActionNode.addEvent("click", function(e){
  515. this.cancelCreate(e);
  516. }.bind(this));
  517. if( this.isNew || this.isEdited ){
  518. this.denyActionNode = new Element("div", {
  519. "styles": this.css.createDenyActionNode,
  520. "text": "不同意"
  521. }).inject(this.createFormNode);
  522. this.createOkActionNode = new Element("div", {
  523. "styles": this.css.createOkActionNode,
  524. "text": "同意"
  525. }).inject(this.createFormNode);
  526. this.denyActionNode.addEvent("click", function(e){
  527. this.deny(e);
  528. }.bind(this));
  529. this.createOkActionNode.addEvent("click", function(e){
  530. this.okCreate(e);
  531. }.bind(this));
  532. }
  533. },
  534. switchFieldByAppealReason : function( ar ){
  535. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  536. var showField = [];
  537. if( ar == "临时请假" ){
  538. showField = ["selfHolidayType","startTime","endTime"];
  539. }else if( ar == "出差" ){
  540. showField = ["address","startTime","endTime"];
  541. }else if( ar == "因公外出" ){
  542. showField = ["address","startTime","endTime","appealDescription"];
  543. }else if( ar == "其他" ){
  544. showField = ["appealDescription"];
  545. }
  546. tempField.each( function( f ){
  547. this.createTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  548. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  549. }.bind(this))
  550. },
  551. setCreateNodeSize: function(){
  552. var size = this.app.node.getSize();
  553. var allSize = this.app.content.getSize();
  554. var height = "570";
  555. var width = "800";
  556. this.createAreaNode.setStyles({
  557. "width": ""+size.x+"px",
  558. "height": ""+size.y+"px"
  559. });
  560. var hY = height;
  561. var mY = (size.y-height)/2;
  562. this.createNode.setStyles({
  563. "height": ""+hY+"px",
  564. "margin-top": ""+mY+"px",
  565. "width" : ""+width+"px"
  566. });
  567. this.createContainerNode.setStyles({
  568. "height": ""+hY+"px"
  569. });
  570. var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0};
  571. var formMargin = hY-iconSize.y-60;
  572. this.createFormNode.setStyles({
  573. "height": ""+formMargin+"px",
  574. "margin-top": ""+60+"px"
  575. });
  576. },
  577. cancelCreate: function(e){
  578. this.createMarkNode.destroy();
  579. this.createAreaNode.destroy();
  580. delete this;
  581. },
  582. deny : function(e){
  583. var data = { 'ids' : [this.data.id], 'status':'-1', 'opinion1': this.document.items.opinion1.getValue() };
  584. //if (data.opinion1 ){
  585. this.process( data );
  586. //}else{
  587. // this.app.notice( "请填写意见", "error");
  588. //}
  589. },
  590. okCreate: function(e){
  591. var data = { 'ids' : [this.data.id], 'status':'1', 'opinion1': this.document.items.opinion1.getValue() };
  592. this.process( data );
  593. },
  594. process: function( data ){
  595. this.app.restActions.processAppeal( data, function(json){
  596. if( json.type == "ERROR" ){
  597. this.app.notice( json.message , "error");
  598. }else{
  599. this.createMarkNode.destroy();
  600. this.createAreaNode.destroy();
  601. if(this.explorer.view)this.explorer.view.reload();
  602. this.app.notice( "处理成功" , "success");
  603. }
  604. // this.app.processConfig();
  605. }.bind(this));
  606. }
  607. })