AppSetting.js 9.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  3. MWF.xApplication.Attendance.AppSetting = new Class({
  4. Extends: MWF.xApplication.Attendance.Explorer.PopupForm,
  5. options : {
  6. "width": "520",
  7. "hasTop" : true,
  8. "hasBottom" : true,
  9. "title": MWF.xApplication.Attendance.LP.systemSetting
  10. },
  11. decodeData : function( data ){
  12. //{
  13. // 'configCode':'APPEALABLE',
  14. // 'configName':'申诉功能启用状态',
  15. // 'configValue':'false',
  16. // 'ordernumber':1
  17. //}
  18. var json = {};
  19. this.dataJson = {};
  20. data.each( function(d){
  21. json[d.configCode] = d.configValue;
  22. this.dataJson[d.configCode] = d;
  23. }.bind(this));
  24. //alert(JSON.stringify(json))
  25. return json;
  26. },
  27. encodeData : function( orgData, data ){
  28. var arr = [];
  29. for( var d in data ){
  30. if( this.itemTemplate[d] ){
  31. var flag = false;
  32. for( var i=0; i<orgData.length;i++ ){
  33. if( orgData[i].configCode == d ){
  34. flag = true;
  35. orgData[i].configValue = data[d];
  36. arr.push( Object.clone(orgData[i]) );
  37. }
  38. }
  39. if( !flag ){
  40. arr.push( {
  41. configCode : d,
  42. configValue : data[d],
  43. configName : this.itemTemplate[d].text
  44. } )
  45. }
  46. }
  47. };
  48. return arr;
  49. },
  50. _createTableContent: function(){
  51. var _self = this;
  52. this.app.restActions.listSetting(function(json){
  53. if( json.data && json.data.length>0){
  54. this.data = json.data;
  55. }
  56. }.bind(this),null,false);
  57. if( !this.data ){
  58. this.data = [];
  59. }
  60. var d = this.decodeData( this.data );
  61. var lp = this.app.lp;
  62. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  63. "<tr><td styles='formTableTitle' lable='APPEALABLE'></td>"+
  64. " <td styles='formTableValue' item='APPEALABLE'></td>"+
  65. "<tr><td styles='formTableTitle' lable='APPEAL_AUDIFLOWTYPE'></td>"+
  66. " <td styles='formTableValue' item='APPEAL_AUDIFLOWTYPE'></td>"+
  67. "<tr item='AUDITOR_TYPE' style='display:"+ (d.APPEAL_AUDIFLOWTYPE == "WORKFLOW" ? "none" : "") +"'><td styles='formTableTitle' lable='APPEAL_AUDITOR_TYPE'></td>"+
  68. " <td styles='formTableValue' item='APPEAL_AUDITOR_TYPE'></td>"+
  69. "<tr item='valueArea' style='display:"+ (d.APPEAL_AUDITOR_TYPE == lp.reportTo || d.APPEAL_AUDITOR_TYPE == "汇报对象" || d.APPEAL_AUDIFLOWTYPE == "WORKFLOW" ? "none" : "") +"' ><td styles='formTableTitle' lable='APPEAL_AUDITOR_VALUE'></td>"+
  70. " <td styles='formTableValue' style='width: 60%' item='APPEAL_AUDITOR_VALUE'></td>" +
  71. "<tr item='AUDIFLOW' style='display:"+ (d.APPEAL_AUDIFLOWTYPE == "BUILTIN" ? "none" : "") +"'><td styles='formTableTitle' lable='APPEAL_AUDIFLOW_ID'></td>" +
  72. " <td styles='formTableValue' style='width: 60%' item='APPEAL_AUDIFLOW_ID'></td>" +
  73. //"<tr><td styles='formTableTitle' lable='APPEAL_CHECKER_TYPE'></td>"+
  74. //" <td styles='formTableValue' item='APPEAL_CHECKER_TYPE'></td>"+
  75. //"<tr><td styles='formTableTitle' lable='APPEAL_CHECKER_VALUE'></td>"+
  76. //" <td styles='formTableValue' item='APPEAL_CHECKER_VALUE'></td>"+
  77. "</table>";
  78. this.formTableArea.set("html",html);
  79. this.itemTemplate = {
  80. APPEALABLE : { text: lp.appealEnable,
  81. type : "select",
  82. value : d.APPEALABLE || "true",
  83. selectText : lp.appealSelectText,
  84. selectValue : ["true","false"]
  85. },
  86. APPEAL_AUDIFLOWTYPE : { text : lp.appealAuditFlowType,
  87. type : "select",
  88. value : d.APPEAL_AUDIFLOWTYPE ,
  89. selectValue : this.dataJson.APPEAL_AUDIFLOWTYPE.selectContent.split("|"), //["人员属性","所属部门职位","指定人","汇报对象"],
  90. selectText : lp.appealAuditFlowTypeSelectText,
  91. event : {
  92. change : function( item, ev ){
  93. this.formTableArea.getElement("[item='AUDITOR_TYPE']").setStyle( "display" , (item.getValue() == "WORKFLOW") ? "none" : "" );
  94. this.formTableArea.getElement("[item='valueArea']").setStyle( "display" , (item.getValue() == "WORKFLOW") ? "none" : "" );
  95. this.formTableArea.getElement("[item='AUDIFLOW']").setStyle( "display" , (item.getValue() == "BUILTIN") ? "none" : "" );
  96. }.bind(this)
  97. }
  98. },
  99. APPEAL_AUDITOR_TYPE : { text : lp.appealAuditorType,
  100. type : "select",
  101. value : d.APPEAL_AUDITOR_TYPE ,
  102. selectValue : this.dataJson.APPEAL_AUDITOR_TYPE.selectContent.split("|"), //["人员属性","所属部门职位","指定人","汇报对象"],
  103. event : {
  104. change : function( item, ev ){
  105. this.formTableArea.getElement("[item='valueArea']").setStyle( "display" , (item.getValue() == "汇报对象" || item.getValue() == lp.reportTo) ? "none" : "" );
  106. }.bind(this)
  107. }
  108. },
  109. APPEAL_AUDITOR_VALUE : { text : lp.appealAuditorValue,
  110. type : "text",
  111. value : d.APPEAL_AUDITOR_VALUE ,
  112. defaultValue : lp.directSupervisor
  113. },
  114. APPEAL_AUDIFLOW_ID : { text : lp.appealAuditFlow,
  115. type : "org",
  116. orgType: ["process"],
  117. count : 1,
  118. isEdited : this.isEdited || this.isNew,
  119. value : (!d.APPEAL_AUDIFLOW_ID||d.APPEAL_AUDIFLOW_ID== lp.none || d.APPEAL_AUDIFLOW_ID=="无") ?"":d.APPEAL_AUDIFLOW_ID,
  120. defaultValue : "",
  121. orgWidgetOptions : {
  122. "lazy": false,
  123. "onLoadedInfor": function(item){
  124. // this.loadAcceptAndReject( item );
  125. console.log(item);
  126. }.bind(this),
  127. "onComplete": function(item){
  128. console.log(item);
  129. }.bind(this)
  130. }
  131. }
  132. //,
  133. //APPEAL_CHECKER_TYPE : { text : "考勤结果申诉复核人确定方式",
  134. // type : "select",
  135. // value : d.APPEAL_CHECKER_TYPE ,
  136. // selectValue : ["无","人员属性","所属部门职位","指定人"] //,"指定角色"]
  137. //},
  138. //APPEAL_CHECKER_VALUE : { text : "考勤结果申诉复核人确定内容",
  139. // type : "text",
  140. // value : d.APPEAL_CHECKER_VALUE
  141. //}
  142. };
  143. this.document = new MForm( this.formTableArea, this.data, {
  144. style : "attendance",
  145. isEdited : this.isEdited || this.isNew,
  146. itemTemplate : this.itemTemplate
  147. }, this.app,this.css);
  148. this.document.load();
  149. // this.cancelActionNode = new Element("div", {
  150. // "styles": this.css.createCancelActionNode,
  151. // "text": lp.cancel
  152. // }).inject(this.createFormNode);
  153. //
  154. //
  155. // this.cancelActionNode.addEvent("click", function(e){
  156. // this.cancelCreate(e);
  157. // }.bind(this));
  158. // if( this.isNew || this.isEdited ){
  159. // this.createOkActionNode = new Element("div", {
  160. // "styles": this.css.createOkActionNode,
  161. // "text": lp.ok
  162. // }).inject(this.createFormNode);
  163. //
  164. // this.createOkActionNode.addEvent("click", function(e){
  165. // this.okCreate(e);
  166. // }.bind(this));
  167. // }
  168. },
  169. ok: function(e){
  170. var data = this.document.getResult(true,",",true,false,false);
  171. if(data){
  172. var APPEAL_AUDIFLOW_ID = data.APPEAL_AUDIFLOW_ID;
  173. if(!!APPEAL_AUDIFLOW_ID &&APPEAL_AUDIFLOW_ID!=this.app.lp.none &&APPEAL_AUDIFLOW_ID!="无"&&APPEAL_AUDIFLOW_ID!=""&&!!this.document.items.APPEAL_AUDIFLOW_ID.orgObject){
  174. data.APPEAL_AUDIFLOW_ID = this.document.items.APPEAL_AUDIFLOW_ID.orgObject[0].data.id;
  175. }
  176. var arr = this.encodeData( this.data, data );
  177. this.save( arr );
  178. }
  179. },
  180. save: function( arr ){
  181. var flag = true;
  182. arr.each( function( d ){
  183. this.app.restActions.saveSetting( d, function(json){
  184. if( json.type == "ERROR" ){
  185. this.app.notice( json.message , "error");
  186. flag = false;
  187. }
  188. }.bind(this), null, false);
  189. }.bind(this));
  190. if( flag ){
  191. if( this.formMaskNode )this.formMaskNode.destroy();
  192. if( this.formAreaNode )this.formAreaNode.destroy();
  193. // if (this.explorer && this.explorer.view)this.explorer.view.reload();
  194. this.app.notice( this.app.lp.saveSuccess , "success");
  195. }
  196. }
  197. });