AppealExplorer.js 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583
  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.topWrapNode = new Element("div", {"style": "width:100%;overflow:hidden;background:rgb(240, 240, 240);"}).inject(this.node);
  23. this.topNode = new Element("div", {
  24. "styles" : this.css.topNode
  25. }).inject(this.topWrapNode);
  26. this.topNode.setStyle("width", "900px");
  27. this.loadToolbar();
  28. this.loadFilter();
  29. this.loadContentNode();
  30. this.elementContentNode.addEvent("scroll", function () {
  31. var scroll = this.elementContentNode.getScroll();
  32. if(this.topWrapNode)this.topWrapNode.scrollTo(scroll.x);
  33. }.bind(this));
  34. var month = (this.preMonthDate.getMonth()+1).toString();
  35. if( month.length == 1 )month = "0"+month;
  36. var filterData = {
  37. "status" : "0",
  38. "yearString" : this.preMonthDate.getFullYear().toString(),
  39. "monthString" : month
  40. };
  41. this.loadView( filterData );
  42. this.setNodeScroll();
  43. },
  44. loadConfig : function(){
  45. /*this.config = {};
  46. var v;
  47. this.actions.getSettingCode( "APPEALABLE", function(json){
  48. v = json.data ? json.data.configValue : null
  49. },null, false)
  50. if( !v ){
  51. this.config.APPEALABLE = true;
  52. }else{
  53. this.config.APPEALABLE = (v != "false" )
  54. }*/
  55. this.config = {};
  56. var v;
  57. //需要判断申述类型listSetting2020年6月16日 by gee
  58. this.configSetting = new Object(null);
  59. this.actions.listSetting(function(json){
  60. var data = json.data;
  61. if(!!data){
  62. json.data.map(function(e){
  63. this.configSetting[e.configCode]=e;
  64. }.bind(this));
  65. v = this.configSetting.APPEALABLE.configValue;
  66. }else{
  67. v = null;
  68. }
  69. }.bind(this),null,false);
  70. if( !v ){
  71. this.config.APPEALABLE = true;
  72. }else{
  73. this.config.APPEALABLE = (v != "false" )
  74. }
  75. },
  76. loadToolbar: function(){
  77. this.toolbarNode = new Element("div", {"styles": this.css.toolbarNode || this.app.css.toolbarNode});
  78. this.toolbarNode.inject(this.topNode);
  79. var toolbarUrl = this.path + "toolbar.json";
  80. MWF.getJSON(toolbarUrl, function (json) {
  81. json.each(function (tool) {
  82. // if( !this.config.APPEALABLE && tool.condition=="onlock" ){
  83. // this.createToolbarItemNode(tool)
  84. // }else if( this.config.APPEALABLE && tool.condition!="onlock" ){
  85. // this.createToolbarItemNode(tool)
  86. // }
  87. if( tool.condition && tool.condition.substr( 0, "function".length ) == "function"){
  88. eval("var fun = " + tool.condition);
  89. var flag = fun.call(this, this.configSetting);
  90. if(flag)this.createToolbarItemNode(tool)
  91. }else{
  92. this.createToolbarItemNode(tool)
  93. }
  94. }.bind(this));
  95. }.bind(this));
  96. },
  97. loadFilter : function(){
  98. this.fileterNode = new Element("div.fileterNode", {
  99. "styles": this.css.fileterNode
  100. }).inject(this.topNode);
  101. this.loadFilterStyle(function( css ) {
  102. this.filterFormCss = css;
  103. var table = new Element("table", {
  104. "border": "0",
  105. "cellpadding": "5",
  106. "cellspacing": "0",
  107. "styles": this.app.css.filterTable,
  108. "class": "filterTable",
  109. }).inject(this.fileterNode);
  110. var tr = new Element("tr").inject(table);
  111. //var td = new Element("td", { "styles" : this.css.filterTableTitle, "text" : this.preMonthDate.format(this.app.lp.dateFormatMonth) }).inject(tr);
  112. this.createYearSelectTd(tr);
  113. this.createMonthSelectTd(tr);
  114. this.createStatusSelectTd(tr);
  115. this.createAppealReasonTd(tr);
  116. this.createUnitTd(tr);
  117. this.createPersonTd(tr);
  118. this.createActionTd(tr);
  119. }.bind(this))
  120. },
  121. createStatusSelectTd : function( tr ){
  122. var _self = this;
  123. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.auditStatus }).inject(tr);
  124. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  125. this.status = new MDomItem( td, {
  126. "name" : "status",
  127. "type" : "select",
  128. "value" : "0",
  129. "selectText" : this.app.lp.auditStatusSelectText,
  130. "selectValue" :["999","0","1","-1"]
  131. }, true, this.app, this.filterFormCss );
  132. this.status.load();
  133. },
  134. createAppealReasonTd : function( tr ){
  135. var _self = this;
  136. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.appealReason }).inject(tr);
  137. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  138. this.appealReason = new MDomItem( td, {
  139. "name" : "appealReason",
  140. "type" : "select",
  141. "selectText" : this.app.lp.appealReasonSelectText
  142. }, true, this.app, this.filterFormCss );
  143. this.appealReason.load();
  144. },
  145. createUnitTd : function(tr){
  146. var _self = this;
  147. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.department }).inject(tr);
  148. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  149. this.unitName = new MDomItem( td, {
  150. "name" : "unitName",
  151. "style" : {"width":"60px"},
  152. "defaultValue" : this.app.manageUnits.length > 0 ? this.app.manageUnits[0] : "",
  153. "event" : {
  154. "click" : function(mdi){ _self.selecePerson( mdi, "unit" ); }
  155. }
  156. }, true, this.app, this.filterFormCss );
  157. this.unitName.load();
  158. },
  159. createPersonTd : function(tr){
  160. var _self = this;
  161. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.person }).inject(tr);
  162. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  163. this.empName = new MDomItem( td, {
  164. "name" : "empName",
  165. "style" : {"width":"60px"},
  166. "event" : {
  167. "click" : function(mdi){ _self.selecePerson( mdi, "person" ); }
  168. }
  169. }, true, this.app, this.filterFormCss );
  170. this.empName.load();
  171. },
  172. createYearSelectTd : function( tr ){
  173. var _self = this;
  174. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.annuaal }).inject(tr);
  175. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  176. this.yearString = new MDomItem( td, {
  177. "name" : "yearString",
  178. "type" : "select",
  179. "selectValue" : function(){
  180. var years = [];
  181. var year = new Date().getFullYear();
  182. for(var i=0; i<6; i++ ){
  183. years.push( year-- );
  184. }
  185. return years;
  186. }
  187. }, true, this.app, this.filterFormCss );
  188. this.yearString.load();
  189. },
  190. createMonthSelectTd : function( tr ){
  191. var _self = this;
  192. var td = new Element("td", { "styles" : this.app.css.filterTableTitle, "text" : this.app.lp.months }).inject(tr);
  193. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  194. this.monthString = new MDomItem( td, {
  195. "name" : "monthString",
  196. "type" : "select",
  197. "selectValue" :["","01","02","03","04","05","06","07","08","09","10","11","12"]
  198. }, true, this.app , this.filterFormCss);
  199. this.monthString.load();
  200. },
  201. createActionTd : function( tr ){
  202. var td = new Element("td", { "styles" : this.app.css.filterTableValue }).inject(tr);
  203. var input = new Element("button",{
  204. "text" : this.app.lp.search,
  205. "styles" : this.app.css.filterButton
  206. }).inject(td);
  207. input.addClass("mainColor_bg");
  208. input.addEvent("click", function(){
  209. /*var year = this.preMonthDate.getFullYear().toString();
  210. var month = (this.preMonthDate.getMonth()+1).toString();
  211. if( month.length == 1 )month = "0"+month;*/
  212. var filterData = {
  213. status : this.status.getValue(),
  214. appealReason : this.appealReason.getValue(),
  215. unitName : this.unitName.getValue(),
  216. empName : this.empName.getValue(),
  217. yearString : this.yearString.getValue(),
  218. monthString : this.monthString.getValue()
  219. }
  220. this.loadView( filterData );
  221. }.bind(this))
  222. },
  223. selecePerson: function( el, type ){
  224. var text = this.app.lp.selecePerson;
  225. if( type=="topUnit") {
  226. text = this.app.lp.selectCompany;
  227. }else if( type=="unit"){
  228. text = this.app.lp.selectDepartment;
  229. }
  230. var options = {
  231. "type": type, //topUnit unit person,
  232. "title": text,
  233. "count" : "1",
  234. "values": [ el.get("value") ] || [],
  235. "onComplete": function(items){
  236. var arr = [];
  237. items.each(function(item){
  238. arr.push(item.data.distinguishedName);
  239. }.bind(this));
  240. el.set("value",arr.join(","));
  241. }.bind(this)
  242. };
  243. var selector = new MWF.O2Selector(this.app.content, options);
  244. },
  245. setContentSize: function(){
  246. var topNodeSize = this.topNode ? this.topNode.getSize() : {"x":0,"y":0};
  247. var nodeSize = this.node.getSize();
  248. var height = nodeSize.y - topNodeSize.y - this.getOffsetY(this.topNode) - this.getOffsetY(this.elementContentNode) - this.getOffsetY(this.node);
  249. this.elementContentNode.setStyle("height", ""+height+"px");
  250. this.pageCount = (height/30).toInt()+5;
  251. if (this.view && this.view.items.length<this.pageCount){
  252. this.view.loadElementList(this.pageCount-this.view.items.length);
  253. }
  254. },
  255. loadView : function( filterData ){
  256. this.elementContentNode.empty();
  257. this.view = new MWF.xApplication.Attendance.AppealExplorer.View(this.elementContentNode, this.app,this, this.viewData, this.options.searchKey );
  258. this.view.filterData = filterData;
  259. this.view.load();
  260. this.setContentSize();
  261. },
  262. createDocument: function(){
  263. if(this.view)this.view._createDocument();
  264. },
  265. agreeAppeals: function( e ){
  266. var _self = this;
  267. var count = 0;
  268. this.view.items.each( function( it ){
  269. if( it.checkboxElement && it.checkboxElement.get("checked" ) )count++;
  270. }.bind(this))
  271. if( count == 0 ){
  272. this.app.notice(this.app.lp.selectAppealNotice,"error");
  273. return;
  274. }
  275. this.app.confirm("warn", e, this.app.lp.agreeAppealConfirmTitle, this.app.lp.agreeAppealConfirmContent.replace("{count}", count), 350, 120, function(){
  276. _self.batchAppeals = true;
  277. _self.view.items.each( function( it ){
  278. if( it.checkboxElement && it.checkboxElement.get("checked" ) )it.agree( true );
  279. }.bind(this));
  280. if(_self.view)_self.view.reload();
  281. _self.batchAppeals = false;
  282. _self.app.notice( _self.app.lp.actionSuccess, "success");
  283. this.close();
  284. }, function(){
  285. this.close();
  286. });
  287. },
  288. denyAppeals: function( e ){
  289. var _self = this;
  290. var count = 0;
  291. this.view.items.each( function( it ){
  292. if( it.checkboxElement && it.checkboxElement.get("checked" ) )count++;
  293. }.bind(this));
  294. if( count == 0 ){
  295. this.app.notice(this.app.lp.selectAppealNotice,"error");
  296. return;
  297. }
  298. this.app.confirm("warn", e, this.app.lp.disagreeAppealConfirmTitle, this.app.lp.disagreeAppealConfirmContent.replace("{count}", count), 350, 120, function(){
  299. _self.batchAppeals = true;
  300. _self.view.items.each( function( it ){
  301. if( it.checkboxElement && it.checkboxElement.get("checked" ) )it.deny( true );
  302. }.bind(this));
  303. if(_self.view)_self.view.reload();
  304. _self.batchAppeals = false;
  305. _self.app.notice( _self.app.lp.actionSuccess , "success");
  306. this.close();
  307. }, function(){
  308. this.close();
  309. });
  310. }
  311. });
  312. MWF.xApplication.Attendance.AppealExplorer.View = new Class({
  313. Extends: MWF.xApplication.Attendance.Explorer.View,
  314. _createItem: function(data){
  315. return new MWF.xApplication.Attendance.AppealExplorer.Document(this.table, data, this.explorer, this);
  316. },
  317. _getCurrentPageData: function(callback, count){
  318. if(!count )count=20;
  319. var id = (this.items.length) ? this.items[this.items.length-1].data.id : "(0)";
  320. var filter = this.filterData || {};
  321. filter.processPerson1 = layout.desktop.session.user.distinguishedName;
  322. //this.actions.listAppealFilterNext(id, count, filter, function(json){
  323. this.actions.listAppealWithFilterWithManager(id, count, filter, function(json){
  324. var data = json.data;
  325. data.each(function(d){
  326. d.APPEALABLE = this.explorer.config.APPEALABLE;
  327. d.APPEAL_AUDIFLOWTYPE = this.explorer.configSetting.APPEAL_AUDIFLOWTYPE.configValue;
  328. }.bind(this));
  329. data.sort( function( a, b ){
  330. return parseInt( b.appealDateString.replace(/-/g,"") ) - parseInt( a.appealDateString.replace(/-/g,"") );
  331. })
  332. json.data = data;
  333. if (callback) callback(json);
  334. }.bind(this));
  335. },
  336. _removeDocument: function(documentData, all){
  337. },
  338. _createDocument: function(){
  339. },
  340. _openDocument: function( documentData ){
  341. /*if(!!documentData.appealAuditInfo){
  342. var workid = documentData.appealAuditInfo.workId;
  343. var options = {"workId":workid, "appId": "process.Work"+workid};
  344. this.app.desktop.openApplication(null, "process.Work", options);
  345. }else{
  346. var appeal = new MWF.xApplication.Attendance.AppealExplorer.Appeal(this.explorer, documentData );
  347. if( !documentData.status ){
  348. appeal.edit();
  349. }else{
  350. appeal.open();
  351. }
  352. }*/
  353. if(documentData.appealAuditInfo){
  354. if(documentData.appealAuditInfo.workId){
  355. var workid = documentData.appealAuditInfo.workId;
  356. var options = {"workId":workid, "appId": "process.Work"+workid};
  357. this.app.desktop.openApplication(null, "process.Work", options);
  358. return;
  359. }
  360. }
  361. var appeal = new MWF.xApplication.Attendance.AppealExplorer.Appeal(this.explorer, documentData );
  362. appeal.open();
  363. }
  364. })
  365. MWF.xApplication.Attendance.AppealExplorer.Document = new Class({
  366. Extends: MWF.xApplication.Attendance.Explorer.Document,
  367. agree : function( ){
  368. var data = { 'ids' : [this.data.id], 'status':'1' };
  369. this.process( data );
  370. },
  371. deny : function( batch ){
  372. var data = { 'ids' : [this.data.id], 'status':'-1' };
  373. this.process( data );
  374. },
  375. process: function( data ){
  376. this.app.restActions.processAppeal( data, function(json){
  377. if( json.type == "ERROR" ){
  378. this.app.notice( json.message , "error");
  379. }else{
  380. if( !this.explorer.batchAppeals ){
  381. if(this.explorer.view)this.explorer.view.reload();
  382. this.app.notice( this.app.lp.actionSuccess.replace("{count}", count) , "success");
  383. }
  384. }
  385. }.bind(this), null, false );
  386. }
  387. });
  388. MWF.xApplication.Attendance.AppealExplorer.Appeal = new Class({
  389. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  390. options : {
  391. "width": 700,
  392. "height": 500,
  393. "hasTop" : true,
  394. "hasBottom" : true,
  395. "title" : MWF.xApplication.Attendance.LP.apealForm,
  396. "draggable" : true,
  397. "closeAction" : true,
  398. },
  399. edit: function(){
  400. this.fireEvent("queryEdit");
  401. if( this.explorer.config.APPEALABLE )this.isEdited = true;
  402. this._open();
  403. this.fireEvent("postEdit");
  404. },
  405. _createTableContent: function(){
  406. var _self = this;
  407. if(this.data.detailId){
  408. this.app.restActions.getDetail(this.data.detailId, function(json){
  409. this.data.onDutyTime = json.data.onDutyTime;
  410. this.data.offDutyTime = json.data.offDutyTime;
  411. }.bind(this),null,false)
  412. }
  413. var d = this.data;
  414. var appealStatus = this.app.lp.draft;
  415. if (d.status == 0 ) {
  416. appealStatus = this.app.lp.todo;
  417. } else if (d.status == 1) {
  418. appealStatus = this.app.lp.approve;
  419. } else if (d.status == -1) {
  420. appealStatus = this.app.lp.deny;
  421. }
  422. this.data.appealStatusShow = appealStatus;
  423. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  424. "<tr><td style='width: 85px;' styles='formTableTitle' lable='empNameShow'></td>"+
  425. " <td style='width: 165px;' styles='formTableValue' item='empNameShow'></td>" +
  426. " <td style='width: 85px;' styles='formTableTitle' lable='recordDateString'></td>"+
  427. " <td style='width: 165px;' styles='formTableValue' item='recordDateString'></td></tr>" +
  428. "<tr><td styles='formTableTitle' lable='onDutyTime'></td>"+
  429. " <td styles='formTableValue' item='onDutyTime'></td>" +
  430. " <td styles='formTableTitle' lable='offDutyTime'></td>"+
  431. " <td styles='formTableValue' item='offDutyTime'></td></tr>" +
  432. "<tr><td styles='formTableTitle' lable='appealStatusShow'></td>"+
  433. " <td styles='formTableValue' item='appealStatusShow' colspan='3'></td></tr>" +
  434. "<tr><td styles='formTableTitle' lable='appealReason'></td>"+
  435. " <td styles='formTableValue' item='appealReason' colspan='3'></td></tr>" +
  436. "<tr contain='selfHolidayType'><td styles='formTableTitle' lable='selfHolidayType'></td>"+
  437. " <td styles='formTableValue' item='selfHolidayType' colspan='3'></td></tr>" +
  438. "<tr contain='address'><td styles='formTableTitle' lable='address'></td>"+
  439. " <td styles='formTableValue' item='address' colspan='3'></td></tr>" +
  440. "<tr contain='startTime'><td styles='formTableTitle' lable='startTime'></td>"+
  441. " <td styles='formTableValue' item='startTime' colspan='3'></td></tr>" +
  442. "<tr contain='endTime'><td styles='formTableTitle' lable='endTime'></td>"+
  443. " <td styles='formTableValue' item='endTime' colspan='3'></td></tr>" +
  444. "<tr contain='appealDescription'><td styles='formTableTitle' lable='appealDescription'></td>"+
  445. " <td styles='formTableValue' item='appealDescription' colspan='3'></td></tr>" +
  446. /*"<tr contain='opinion1'><td styles='formTableTitle' lable='opinion1'></td>"+
  447. " <td styles='formTableValue' item='opinion1' colspan='3'></td></tr>" +*/
  448. "</table>"
  449. this.formTableArea.set("html",html);
  450. var lp = this.app.lp;
  451. this.document = new MForm( this.formTableArea, this.data, {
  452. style : "attendance",
  453. isEdited : this.isEdited || this.isNew,
  454. itemTemplate : {
  455. empNameShow : { text: lp.employeeName, type : "innertext", value : this.data.empName.split("@")[0] },
  456. recordDateString : { text:lp.recordDate, type : "innertext"},
  457. onDutyTime : { text: lp.onDutyTime , type : "innertext"},
  458. offDutyTime : { text: lp.offDutyTime, type : "innertext"},
  459. statusShow : { text:lp.attendanceStatus , type : "innertext" },
  460. appealStatusShow : { text:lp.appealStatus, type : "innertext"},
  461. appealReason : {
  462. text:lp.appealReason, type : "innertext"
  463. },
  464. address : { text: lp.address, type : "innertext" },
  465. selfHolidayType : {
  466. text: lp.leaveType,
  467. type : "innertext"
  468. },
  469. startTime : { text:lp.startTime, type : "innertext" },
  470. endTime : { text:lp.endTime, type : "innertext" },
  471. appealDescription : { text: lp.appealDescriptoin , type : "innertext" }
  472. //opinion1 : { text :"审批意见",type : "textarea" }
  473. }
  474. }, this.app,this.css);
  475. this.document.load();
  476. _self.switchFieldByAppealReason(this.data.appealReason);
  477. // this.cancelActionNode = new Element("div", {
  478. // "styles": this.css.createCancelActionNode,
  479. // "text": lp.close
  480. // }).inject(this.createFormNode);
  481. //
  482. //
  483. // this.cancelActionNode.addEvent("click", function(e){
  484. // this.cancelCreate(e);
  485. // }.bind(this));
  486. // if( this.isNew || this.isEdited ){
  487. // this.denyActionNode = new Element("div", {
  488. // "styles": this.css.createDenyActionNode,
  489. // "text": lp.disagree
  490. // }).inject(this.createFormNode);
  491. // this.createOkActionNode = new Element("div", {
  492. // "styles": this.css.createOkActionNode,
  493. // "text": lp.agree
  494. // }).inject(this.createFormNode);
  495. //
  496. // this.denyActionNode.addEvent("click", function(e){
  497. // this.deny(e);
  498. // }.bind(this));
  499. // this.createOkActionNode.addEvent("click", function(e){
  500. // this.okCreate(e);
  501. // }.bind(this));
  502. // }
  503. },
  504. switchFieldByAppealReason : function( ar ){
  505. var lp = this.app.lp;
  506. var tempField = ["selfHolidayType","startTime","endTime","address","appealDescription"];
  507. var showField = [];
  508. if( ar == lp.temporaryLeave ){
  509. showField = ["selfHolidayType","startTime","endTime"];
  510. }else if( ar == lp.out ){
  511. showField = ["address","startTime","endTime"];
  512. }else if( ar == lp.businessTrip ){
  513. showField = ["address","startTime","endTime","appealDescription"];
  514. }else if( ar == lp.other ){
  515. showField = ["appealDescription"];
  516. }
  517. tempField.each( function( f ){
  518. this.formTableArea.getElement("[contain='"+f+"']").setStyle("display", showField.contains(f) ? "" : "none" );
  519. if( this.isNew || this.isEdited )this.document.items[f].options.notEmpty = (showField.contains(f) ? true : false )
  520. }.bind(this))
  521. },
  522. deny : function(e){
  523. var data = { 'ids' : [this.data.id], 'status':'-1', 'opinion1': this.document.items.opinion1.getValue() };
  524. //if (data.opinion1 ){
  525. this.process( data );
  526. //}else{
  527. // this.app.notice( "请填写意见", "error");
  528. //}
  529. },
  530. okCreate: function(e){
  531. var data = { 'ids' : [this.data.id], 'status':'1', 'opinion1': this.document.items.opinion1.getValue() };
  532. this.process( data );
  533. },
  534. process: function( data ){
  535. this.app.restActions.processAppeal( data, function(json){
  536. if( json.type == "ERROR" ){
  537. this.app.notice( json.message , "error");
  538. }else{
  539. if( this.formMaskNode )this.formMaskNode.destroy();
  540. if( this.formAreaNode )this.formAreaNode.destroy();
  541. if (this.explorer && this.explorer.view)this.explorer.view.reload();
  542. this.app.notice( this.app.lp.actionSuccess, "success");
  543. }
  544. // this.app.processConfig();
  545. }.bind(this));
  546. }
  547. })