AppSetting.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. MWF.xDesktop.requireApp("Template", "MForm", null, false);
  2. MWF.xApplication.Attendance.AppSetting = new Class({
  3. Extends: MWF.widget.Common,
  4. options:{
  5. style : "default"
  6. },
  7. initialize: function(app, actions, options){
  8. this.setOptions(options);
  9. this.app = app;
  10. this.path = "../x_component_Attendance/$AppSetting/";
  11. this.cssPath = "../x_component_Attendance/$AppSetting/"+this.options.style+"/css.wcss";
  12. this._loadCss();
  13. this.actions = actions;
  14. this.load();
  15. },
  16. load: function(){
  17. this.app.restActions.listSetting(function(json){
  18. if( json.data && json.data.length>0){
  19. this.data = json.data;
  20. }
  21. }.bind(this),null,false);
  22. if( !this.data ){
  23. this.data = [];
  24. }
  25. },
  26. decodeData : function( data ){
  27. //{
  28. // 'configCode':'APPEALABLE',
  29. // 'configName':'申诉功能启用状态',
  30. // 'configValue':'false',
  31. // 'ordernumber':1
  32. //}
  33. var json = {};
  34. this.dataJson = {};
  35. data.each( function(d){
  36. json[d.configCode] = d.configValue;
  37. this.dataJson[d.configCode] = d;
  38. }.bind(this));
  39. //alert(JSON.stringify(json))
  40. return json;
  41. },
  42. encodeData : function( orgData, data ){
  43. var arr = [];
  44. for( var d in data ){
  45. if( this.itemTemplate[d] ){
  46. var flag = false;
  47. for( var i=0; i<orgData.length;i++ ){
  48. if( orgData[i].configCode == d ){
  49. flag = true;
  50. orgData[i].configValue = data[d];
  51. arr.push( Object.clone(orgData[i]) );
  52. }
  53. }
  54. if( !flag ){
  55. arr.push( {
  56. configCode : d,
  57. configValue : data[d],
  58. configName : this.itemTemplate[d].text
  59. } )
  60. }
  61. }
  62. };
  63. // alert(JSON.stringify(arr))
  64. return arr;
  65. },
  66. open: function(e){
  67. this.isNew = false;
  68. this.isEdited = false;
  69. this._open();
  70. },
  71. create: function(){
  72. this.isNew = true;
  73. this._open();
  74. },
  75. edit: function(){
  76. this.isEdited = true;
  77. this._open();
  78. },
  79. _open : function(){
  80. this.createMarkNode = new Element("div", {
  81. "styles": this.css.createMarkNode,
  82. "events": {
  83. "mouseover": function(e){e.stopPropagation();},
  84. "mouseout": function(e){e.stopPropagation();}
  85. }
  86. }).inject(this.app.content, "after");
  87. this.createAreaNode = new Element("div", {
  88. "styles": this.css.createAreaNode
  89. });
  90. this.createNode();
  91. this.createAreaNode.inject(this.createMarkNode, "after");
  92. this.createAreaNode.fade("in");
  93. this.setCreateNodeSize();
  94. this.setCreateNodeSizeFun = this.setCreateNodeSize.bind(this);
  95. this.addEvent("resize", this.setCreateNodeSizeFun);
  96. },
  97. createNode: function(){
  98. var _self = this;
  99. this.createNode = new Element("div", {
  100. "styles": this.css.createNode
  101. }).inject(this.createAreaNode);
  102. //
  103. //this.createIconNode = new Element("div", {
  104. // "styles": this.isNew ? this.css.createNewNode : this.css.createIconNode
  105. //}).inject(this.createNode);
  106. this.createContainerNode = new Element("div", {
  107. "styles": this.css.createContainerNode
  108. }).inject(this.createNode);
  109. this.setScrollBar( this.createContainerNode );
  110. this.createFormNode = new Element("div", {
  111. "styles": this.css.createFormNode
  112. }).inject(this.createContainerNode);
  113. this.createTableContainer = new Element("div", {
  114. "styles": this.css.createTableContainer
  115. }).inject(this.createFormNode);
  116. this.createTableArea = new Element("div", {
  117. "styles": this.css.createTableArea
  118. }).inject(this.createTableContainer);
  119. var table = new Element("table", {
  120. "width" : "100%", "border" : "0", "cellpadding" : "5", "cellspacing" : "0", "styles" : this.css.editTable, "class" : "editTable"
  121. }).inject( this.createTableArea );
  122. var d = this.decodeData( this.data );
  123. var html = "<table width='100%' bordr='0' cellpadding='5' cellspacing='0' styles='formTable'>"+
  124. "<tr><td colspan='4' styles='formTableHead'>系统设置</td></tr>" +
  125. "<tr><td styles='formTableTitle' lable='APPEALABLE'></td>"+
  126. " <td styles='formTableValue' item='APPEALABLE'></td>"+
  127. "<tr><td styles='formTableTitle' lable='APPEAL_AUDIFLOWTYPE'></td>"+
  128. " <td styles='formTableValue' item='APPEAL_AUDIFLOWTYPE'></td>"+
  129. "<tr item='AUDITOR_TYPE' style='display:"+ (d.APPEAL_AUDIFLOWTYPE == "WORKFLOW" ? "none" : "") +"'><td styles='formTableTitle' lable='APPEAL_AUDITOR_TYPE'></td>"+
  130. " <td styles='formTableValue' item='APPEAL_AUDITOR_TYPE'></td>"+
  131. "<tr item='valueArea' style='display:"+ (d.APPEAL_AUDITOR_TYPE == "汇报对象" || d.APPEAL_AUDIFLOWTYPE == "WORKFLOW" ? "none" : "") +"' ><td styles='formTableTitle' lable='APPEAL_AUDITOR_VALUE'></td>"+
  132. " <td styles='formTableValue' style='width: 60%' item='APPEAL_AUDITOR_VALUE'></td>" +
  133. "<tr item='AUDIFLOW' style='display:"+ (d.APPEAL_AUDIFLOWTYPE == "BUILTIN" ? "none" : "") +"'><td styles='formTableTitle' lable='APPEAL_AUDIFLOW_ID'></td>" +
  134. " <td styles='formTableValue' style='width: 60%' item='APPEAL_AUDIFLOW_ID'></td>" +
  135. //"<tr><td styles='formTableTitle' lable='APPEAL_CHECKER_TYPE'></td>"+
  136. //" <td styles='formTableValue' item='APPEAL_CHECKER_TYPE'></td>"+
  137. //"<tr><td styles='formTableTitle' lable='APPEAL_CHECKER_VALUE'></td>"+
  138. //" <td styles='formTableValue' item='APPEAL_CHECKER_VALUE'></td>"+
  139. "</table>";
  140. this.createTableArea.set("html",html);
  141. this.itemTemplate = {
  142. APPEALABLE : { text:"申诉及审批功能启用状态",
  143. type : "select",
  144. value : d.APPEALABLE || "true",
  145. selectText : ["开启","关闭"],
  146. selectValue : ["true","false"]
  147. },
  148. APPEAL_AUDIFLOWTYPE : { text : "考勤结果申诉流程类型",
  149. type : "select",
  150. value : d.APPEAL_AUDIFLOWTYPE ,
  151. selectValue : this.dataJson.APPEAL_AUDIFLOWTYPE.selectContent.split("|"), //["人员属性","所属部门职位","指定人","汇报对象"],
  152. selectText : ["自定义流程","内置流程"],
  153. event : {
  154. change : function( item, ev ){
  155. this.createTableArea.getElement("[item='AUDITOR_TYPE']").setStyle( "display" , (item.getValue() == "WORKFLOW") ? "none" : "" );
  156. this.createTableArea.getElement("[item='valueArea']").setStyle( "display" , (item.getValue() == "WORKFLOW") ? "none" : "" );
  157. this.createTableArea.getElement("[item='AUDIFLOW']").setStyle( "display" , (item.getValue() == "BUILTIN") ? "none" : "" );
  158. }.bind(this)
  159. }
  160. },
  161. APPEAL_AUDITOR_TYPE : { text : "申诉审核人确定方式",
  162. type : "select",
  163. value : d.APPEAL_AUDITOR_TYPE ,
  164. selectValue : this.dataJson.APPEAL_AUDITOR_TYPE.selectContent.split("|"), //["人员属性","所属部门职位","指定人","汇报对象"],
  165. event : {
  166. change : function( item, ev ){
  167. this.createTableArea.getElement("[item='valueArea']").setStyle( "display" , (item.getValue() == "汇报对象") ? "none" : "" );
  168. }.bind(this)
  169. }
  170. },
  171. APPEAL_AUDITOR_VALUE : { text : "申诉审核人确定内容",
  172. type : "text",
  173. value : d.APPEAL_AUDITOR_VALUE ,
  174. defaultValue : "直属领导"
  175. },
  176. APPEAL_AUDIFLOW_ID : { text : "自定义申请流程",
  177. type : "org",
  178. orgType: ["process"],
  179. count : 1,
  180. isEdited : this.isEdited || this.isNew,
  181. value : !d.APPEAL_AUDIFLOW_ID||d.APPEAL_AUDIFLOW_ID=="无" ?"":d.APPEAL_AUDIFLOW_ID,
  182. defaultValue : "",
  183. orgWidgetOptions : {
  184. "onLoadedInfor": function(item){
  185. // this.loadAcceptAndReject( item );
  186. console.log(item);
  187. }.bind(this),
  188. "onComplete": function(item){
  189. console.log(item);
  190. }.bind(this)
  191. }
  192. }
  193. //,
  194. //APPEAL_CHECKER_TYPE : { text : "考勤结果申诉复核人确定方式",
  195. // type : "select",
  196. // value : d.APPEAL_CHECKER_TYPE ,
  197. // selectValue : ["无","人员属性","所属部门职位","指定人"] //,"指定角色"]
  198. //},
  199. //APPEAL_CHECKER_VALUE : { text : "考勤结果申诉复核人确定内容",
  200. // type : "text",
  201. // value : d.APPEAL_CHECKER_VALUE
  202. //}
  203. };
  204. this.document = new MForm( this.createTableArea, this.data, {
  205. style : "popup",
  206. isEdited : this.isEdited || this.isNew,
  207. itemTemplate : this.itemTemplate
  208. }, this.app,this.css);
  209. this.document.load();
  210. this.cancelActionNode = new Element("div", {
  211. "styles": this.css.createCancelActionNode,
  212. "text": "取消"
  213. }).inject(this.createFormNode);
  214. this.cancelActionNode.addEvent("click", function(e){
  215. this.cancelCreate(e);
  216. }.bind(this));
  217. if( this.isNew || this.isEdited ){
  218. this.createOkActionNode = new Element("div", {
  219. "styles": this.css.createOkActionNode,
  220. "text": "确定"
  221. }).inject(this.createFormNode);
  222. this.createOkActionNode.addEvent("click", function(e){
  223. this.okCreate(e);
  224. }.bind(this));
  225. }
  226. },
  227. setCreateNodeSize: function(){
  228. var size = this.app.node.getSize();
  229. var allSize = this.app.content.getSize();
  230. var height = "470";
  231. var width = "600";
  232. this.createAreaNode.setStyles({
  233. "width": ""+size.x+"px",
  234. "height": ""+size.y+"px"
  235. });
  236. var hY = height;
  237. var mY = (size.y-height)/2;
  238. this.createNode.setStyles({
  239. "height": ""+hY+"px",
  240. "margin-top": ""+mY+"px",
  241. "width" : ""+width+"px"
  242. });
  243. this.createContainerNode.setStyles({
  244. "height": ""+hY+"px"
  245. });
  246. var iconSize = this.createIconNode ? this.createIconNode.getSize() : {x:0,y:0};
  247. var formMargin = hY-iconSize.y-60;
  248. this.createFormNode.setStyles({
  249. "height": ""+formMargin+"px",
  250. "margin-top": ""+60+"px"
  251. });
  252. },
  253. cancelCreate: function(e){
  254. this.createMarkNode.destroy();
  255. this.createAreaNode.destroy();
  256. delete this;
  257. },
  258. okCreate: function(e){
  259. var data = this.document.getResult(true,",",true,false,false);
  260. if(data){
  261. var APPEAL_AUDIFLOW_ID = data.APPEAL_AUDIFLOW_ID
  262. if(!!APPEAL_AUDIFLOW_ID&&APPEAL_AUDIFLOW_ID!="无"&&APPEAL_AUDIFLOW_ID!=""&&!!this.document.items.APPEAL_AUDIFLOW_ID.orgObject){
  263. data.APPEAL_AUDIFLOW_ID = this.document.items.APPEAL_AUDIFLOW_ID.orgObject[0].data.id;
  264. }
  265. var arr = this.encodeData( this.data, data );
  266. this.save( arr );
  267. }
  268. },
  269. save: function( arr ){
  270. var flag = true;
  271. arr.each( function( d ){
  272. this.app.restActions.saveSetting( d, function(json){
  273. if( json.type == "ERROR" ){
  274. this.app.notice( json.message , "error");
  275. flag = false;
  276. }
  277. }.bind(this), null, false);
  278. }.bind(this));
  279. if( flag ){
  280. this.createMarkNode.destroy();
  281. this.createAreaNode.destroy();
  282. this.app.notice( "保存成功" , "success");
  283. }
  284. }
  285. });