AppealExplorer.js 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657
  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.createStatusSelectTd(tr);
  91. this.createAppealReasonTd(tr);
  92. this.createUnitTd(tr);
  93. this.createPersonTd( tr );
  94. //this.createYearSelectTd( tr );
  95. //this.createMonthSelectTd( 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 : year, //this.yearString.getValue(),
  194. monthString : month //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. }
  335. })
  336. MWF.xApplication.Attendance.AppealExplorer.Document = new Class({
  337. Extends: MWF.xApplication.Attendance.Explorer.Document,
  338. agree : function( ){
  339. var data = { 'ids' : [this.data.id], 'status':'1' };
  340. this.process( data );
  341. },
  342. deny : function( batch ){
  343. var data = { 'ids' : [this.data.id], 'status':'-1' };
  344. this.process( data );
  345. },
  346. process: function( data ){
  347. this.app.restActions.processAppeal( data, function(json){
  348. if( json.type == "ERROR" ){
  349. this.app.notice( json.message , "error");
  350. }else{
  351. if( !this.explorer.batchAppeals ){
  352. if(this.explorer.view)this.explorer.view.reload();
  353. this.app.notice( "处理成功" , "success");
  354. }
  355. }
  356. }.bind(this), null, false );
  357. }
  358. })
  359. MWF.xApplication.Attendance.AppealExplorer.Appeal = new Class({
  360. Extends: MWF.widget.Common,
  361. initialize: function( explorer, data ){
  362. this.explorer = explorer;
  363. this.app = explorer.app;
  364. this.data = data || {};
  365. this.css = this.explorer.css;
  366. //this.app.restActions.getAppeal(this.data.detailId, function(json){
  367. // this.data = json.data
  368. //}.bind(this),null,false)
  369. //alert(JSON.stringify(this.data))
  370. this.load();
  371. },
  372. load: function(){
  373. this.app.restActions.getDetail(this.data.detailId, function(json){
  374. this.data.onDutyTime = json.data.onDutyTime;
  375. this.data.offDutyTime = json.data.offDutyTime;
  376. }.bind(this),null,false)
  377. },
  378. open: function(e){
  379. this.isNew = false;
  380. this.isEdited = false;
  381. this._open();
  382. },
  383. create: function(){
  384. this.isNew = true;
  385. this._open();
  386. },
  387. edit: function(){
  388. if( this.explorer.config.APPEALABLE )this.isEdited = true;
  389. this._open();
  390. },
  391. _open : function(){
  392. this.createMarkNode = new Element("div", {
  393. "styles": this.css.createMarkNode,
  394. "events": {
  395. "mouseover": function(e){e.stopPropagation();},
  396. "mouseout": function(e){e.stopPropagation();}
  397. }
  398. }).inject(this.app.content, "after");
  399. this.createAreaNode = new Element("div", {
  400. "styles": this.css.createAreaNode
  401. });
  402. this.createNode();
  403. this.createAreaNode.inject(this.createMarkNode, "after");
  404. this.createAreaNode.fade("in");
  405. this.setCreateNodeSize();
  406. this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  407. this.addEvent("resize", this.setCreateNodeSizeFun);
  408. },
  409. createNode: function(){
  410. var _self = this;
  411. this.createNode = new Element("div", {
  412. "styles": this.css.createNode
  413. }).inject(this.createAreaNode);
  414. //
  415. //this.createIconNode = new Element("div", {
  416. // "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  417. //}).inject(this.createNode);
  418. this.createContainerNode = new Element("div", {
  419. "styles": this.css.createContainerNode
  420. }).inject(this.createNode);
  421. this.setScrollBar( this.createContainerNode );
  422. this.createFormNode = new Element("div", {
  423. "styles": this.css.createFormNode
  424. }).inject(this.createContainerNode);
  425. this.createTableContainer = new Element("div", {
  426. "styles": this.css.createTableContainer
  427. }).inject(this.createFormNode);
  428. this.createTableArea = new Element("div", {
  429. "styles": this.css.createTableArea
  430. }).inject(this.createTableContainer);
  431. var table = new Element("table", {
  432. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.editTable, "class" : "editTable"
  433. }).inject( this.createTableArea );
  434. var d = this.data;
  435. var appealStatus = "发起";
  436. if (d.status == 0 ) {
  437. appealStatus = "待处理"
  438. } else if (d.status == 1) {
  439. appealStatus = "审批通过"
  440. } else if (d.status == -1) {
  441. appealStatus = "审批不通过"
  442. }
  443. this.data.appealStatusShow = appealStatus;
  444. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  445. "<tr><td colspan='4' styles='formTableHead'>申诉处理单</td></tr>" +
  446. "<tr><td styles='formTableTitle' lable='empNameShow'></td>"+
  447. " <td styles='formTableValue' item='empNameShow'></td>" +
  448. " <td styles='formTableTitle' lable='recordDateString'></td>"+
  449. " <td styles='formTableValue' item='recordDateString'></td></tr>" +
  450. "<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  451. " <td styles='formTableValue' item='onDutyTime'></td>" +
  452. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  453. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  454. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  455. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>" +
  456. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  457. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  458. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  459. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  460. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  461. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  462. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  463. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  464. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  465. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  466. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  467. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  468. "<tr contain='opinion1'><td styles='formTableTitle' lable='opinion1'></td>"+
  469. " <td styles='formTableValue' item='opinion1' colspan='3'></td></tr>" +
  470. "</table>"
  471. this.createTableArea.set("html",html);
  472. this.document = new MForm( this.createTableArea, this.data, {
  473. style : "popup",
  474. isEdited : this.isEdited || this.isNew,
  475. itemTemplate : {
  476. empNameShow : { text:"员工姓名", type : "innertext", value : this.data.empName.split("@")[0] },
  477. recordDateString : { text:"考勤日期", type : "innertext"},
  478. onDutyTime : { text:"上班打卡时间", type : "innertext"},
  479. offDutyTime : { text:"下班打卡时间", type : "innertext"},
  480. statusShow : { text:"考勤状态", type : "innertext" },
  481. appealStatusShow : { text:"审批状态",type : "innertext"},
  482. appealReason : {
  483. text:"申述原因", type : "innertext"
  484. },
  485. address : { text:"地点", type : "innertext" },
  486. selfHolidayType : {
  487. text:"请假类型",
  488. type : "innertext"
  489. },
  490. startTime : { text:"开始日期", type : "innertext" },
  491. endTime : { text:"结束日期", type : "innertext" },
  492. appealDescription : { text:"事由", type : "innertext" },
  493. opinion1 : { text :"审批意见",type : "textarea" }
  494. }
  495. }, this.app,this.css);
  496. this.document.load();
  497. _self.switchFieldByAppealReason(this.data.appealReason);
  498. //createFormNode.set("html", html);
  499. //this.setScrollBar(this.createTableContainer)
  500. this.cancelActionNode = new Element("div", {
  501. "styles": this.css.createCancelActionNode,
  502. "text": "关闭"
  503. }).inject(this.createFormNode);
  504. this.cancelActionNode.addEvent("click", function(e){
  505. this.cancelCreate(e);
  506. }.bind(this));
  507. if( this.isNew || this.isEdited ){
  508. this.denyActionNode = new Element("div", {
  509. "styles": this.css.createDenyActionNode,
  510. "text": "不同意"
  511. }).inject(this.createFormNode);
  512. this.createOkActionNode = new Element("div", {
  513. "styles": this.css.createOkActionNode,
  514. "text": "同意"
  515. }).inject(this.createFormNode);
  516. this.denyActionNode.addEvent("click", function(e){
  517. this.deny(e);
  518. }.bind(this));
  519. this.createOkActionNode.addEvent("click", function(e){
  520. this.okCreate(e);
  521. }.bind(this));
  522. }
  523. },
  524. switchFieldByAppealReason : function( ar ){
  525. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  526. var showField = [];
  527. if( ar == "临时请假" ){
  528. showField = ["selfHolidayType","startTime","endTime"];
  529. }else if( ar == "出差" ){
  530. showField = ["address","startTime","endTime"];
  531. }else if( ar == "因公外出" ){
  532. showField = ["address","startTime","endTime","appealDescription"];
  533. }else if( ar == "其他" ){
  534. showField = ["appealDescription"];
  535. }
  536. tempField.each( function( f ){
  537. this.createTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  538. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  539. }.bind(this))
  540. },
  541. setCreateNodeSize: function(){
  542. var size = this.app.node.getSize();
  543. var allSize = this.app.content.getSize();
  544. var height = "570";
  545. var width = "800";
  546. this.createAreaNode.setStyles({
  547. "width": ""+size.x+"px",
  548. "height": ""+size.y+"px"
  549. });
  550. var hY = height;
  551. var mY = (size.y-height)/2;
  552. this.createNode.setStyles({
  553. "height": ""+hY+"px",
  554. "margin-top": ""+mY+"px",
  555. "width" : ""+width+"px"
  556. });
  557. this.createContainerNode.setStyles({
  558. "height": ""+hY+"px"
  559. });
  560. var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0};
  561. var formMargin = hY-iconSize.y-60;
  562. this.createFormNode.setStyles({
  563. "height": ""+formMargin+"px",
  564. "margin-top": ""+60+"px"
  565. });
  566. },
  567. cancelCreate: function(e){
  568. this.createMarkNode.destroy();
  569. this.createAreaNode.destroy();
  570. delete this;
  571. },
  572. deny : function(e){
  573. var data = { 'ids' : [this.data.id], 'status':'-1', 'opinion1': this.document.items.opinion1.getValue() };
  574. //if (data.opinion1 ){
  575. this.process( data );
  576. //}else{
  577. // this.app.notice( "请填写意见", "error");
  578. //}
  579. },
  580. okCreate: function(e){
  581. var data = { 'ids' : [this.data.id], 'status':'1', 'opinion1': this.document.items.opinion1.getValue() };
  582. this.process( data );
  583. },
  584. process: function( data ){
  585. this.app.restActions.processAppeal( data, function(json){
  586. if( json.type == "ERROR" ){
  587. this.app.notice( json.message , "error");
  588. }else{
  589. this.createMarkNode.destroy();
  590. this.createAreaNode.destroy();
  591. if(this.explorer.view)this.explorer.view.reload();
  592. this.app.notice( "处理成功" , "success");
  593. }
  594. // this.app.processConfig();
  595. }.bind(this));
  596. }
  597. })