Setting.js 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628
  1. MWF.xDesktop.requireApp("Template", "MPopupForm", null, false);
  2. MWF.xApplication.Report.SettingForm = new Class({
  3. Extends: MPopupForm,
  4. Implements: [Options, Events],
  5. options: {
  6. "style": "report",
  7. "width": "1000",
  8. "height": "600",
  9. "minWidth" : 700,
  10. "minHeight" : 320,
  11. "hasTop": true,
  12. "hasIcon": false,
  13. "hasTopIcon" : false,
  14. "hasTopContent" : false,
  15. "maxAction" : true,
  16. "hasBottom": true,
  17. "draggable": true,
  18. "resizeable": true,
  19. "closeAction": true
  20. },
  21. createTab: function(){
  22. var _self = this;
  23. this.tabContainer = new Element("div.formTabContainer",{
  24. styles : this.css.formTabContainer
  25. }).inject(this.formNode);
  26. var tabNode = new Element("div.formTabNode", {
  27. "styles": this.css.formTabNode,
  28. "text" : this.lp.systemSetting
  29. }).inject(this.tabContainer);
  30. tabNode.addEvents({
  31. "mouseover" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode_over) }.bind({node : tabNode }),
  32. "mouseout" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode) }.bind({node : tabNode }),
  33. "click":function(){
  34. if( _self.currentTabNode )_self.currentTabNode.setStyles(_self.css.formTabNode);
  35. _self.currentTabNode = this.node;
  36. this.node.setStyles(_self.css.formTabNode_current);
  37. _self.sysContainer.setStyle("display","");
  38. _self.personContainer.setStyle("display","none");
  39. }.bind({ node : tabNode })
  40. });
  41. tabNode.setStyles( this.css.formTabNode_current );
  42. _self.currentTabNode = tabNode;
  43. var tabNode = new Element("div.tabNode", {
  44. "styles": this.css.formTabNode,
  45. "text" : this.lp.personSetting
  46. }).inject(this.tabContainer);
  47. tabNode.addEvents({
  48. "mouseover" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode_over) }.bind({node : tabNode }),
  49. "mouseout" : function(){ if( _self.currentTabNode != this.node)this.node.setStyles(_self.css.formTabNode) }.bind({node : tabNode }),
  50. "click":function(){
  51. if( _self.currentTabNode )_self.currentTabNode.setStyles(_self.css.formTabNode);
  52. _self.currentTabNode = this.node;
  53. this.node.setStyles(_self.css.formTabNode_current);
  54. _self.sysContainer.setStyle("display","none");
  55. _self.personContainer.setStyle("display","");
  56. }.bind({ node : tabNode })
  57. })
  58. },
  59. createContent: function () {
  60. this.formTopTextNode.set( "text", "工作汇报配置" );
  61. this.isAdmin = this.app.common.isAdmin();
  62. //if( this.isAdmin ) {
  63. // this.createTab();
  64. //}
  65. this.formContentNode = new Element("div.formContentNode", {
  66. "styles": this.css.formContentNode
  67. }).inject(this.formNode);
  68. this.formTableContainer = new Element("div.formTableContainer", {
  69. "styles": this.css.formTableContainer
  70. }).inject(this.formContentNode);
  71. this.formTableArea = new Element("div.formTableArea", {
  72. "styles": this.css.formTableArea
  73. }).inject(this.formTableContainer);
  74. this._createTableContent();
  75. },
  76. _createTableContent: function(){
  77. if( this.isAdmin ){
  78. this.sysContainer = new Element("div.sysContainer").inject(this.formTableArea);
  79. this.loadSysSetting( this.sysContainer );
  80. //this.personContainer = new Element("div.personContainer", { styles : {"display":"none"} }).inject( this.formTableArea );
  81. //this.loadPersonSetting( this.personContainer );
  82. }else{
  83. //this.personContainer = new Element("div.personContainer", { styles : {"display":""} }).inject( this.formTableArea );
  84. //this.loadPersonSetting( this.personContainer );
  85. }
  86. },
  87. loadPersonSetting: function( container ){
  88. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  89. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top:40px;'>" +
  90. "<tr><td styles='formTableTitle' lable='defaultView' width='20%'></td>" +
  91. " <td styles='formTableValue' colspan='3' width='80%'>" +
  92. " <div item='defaultView' style='"+ boxStyle +"'></div>" +
  93. " </td>" +
  94. "</tr>" +
  95. "</table>";
  96. container.set("html", html);
  97. MWF.UD.getDataJson("reportConfig", function (json) {
  98. MWF.xDesktop.requireApp("Template", "MForm", function () {
  99. this.personform = new MForm(container, json, {
  100. usesNewVersion : true,
  101. isEdited: this.isEdited || this.isNew,
  102. style : "meeting",
  103. hasColon : true,
  104. itemTemplate: {
  105. defaultView : {
  106. //text : "默认视图", type : "radio", selectValue : ["toList", "toMonth","toDay"], selectText:["列表","月","日"]
  107. text : "默认视图", type : "radio", selectValue : ["toList","toDay"], selectText:["列表","日"]
  108. }
  109. }
  110. }, this.app);
  111. this.personform.load();
  112. }.bind(this), true);
  113. }.bind(this));
  114. },
  115. loadSysSetting: function ( container ) {
  116. this.getSysData();
  117. var boxStyle = (this.isEdited || this.isNew) ? "border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;" : "";
  118. //var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin:20px 0px;'>" +
  119. //"<tr><td styles='formTableTitle' colspan='4'>基本设置</td></tr>" +
  120. //"<tr><td lable='REPORT_ENABLE' width='20%'></td>" +
  121. //" <td styles='formTableValue14' item='REPORT_ENABLE' colspan='3' width='80%'></td></tr>" +
  122. //"<tr><td lable='WEEKEND_IGNORE'></td>" +
  123. //" <td styles='formTableValue14' item='WEEKEND_IGNORE' colspan='3'></td></tr>" +
  124. //"<tr><td lable='HOLIDAY_IGNORE'></td>" +
  125. //" <td styles='formTableValue14' item='HOLIDAY_IGNORE' colspan='3' ></td></tr>" +
  126. //"<tr><td lable='PERSONREPORT_REMOVE_DUTY'></td>" +
  127. //" <td styles='formTableValue14' item='PERSONREPORT_REMOVE_DUTY' colspan='3' ></td></tr>" +
  128. //"<tr><td lable='UNITREPORT_DUTY'></td>" +
  129. //" <td styles='formTableValue14' item='UNITREPORT_DUTY' colspan='3' ></td></tr>" +
  130. //
  131. //"<tr><td lable='createDate'></td>" +
  132. //" <td styles='formTableValue14' colspan='3' >" +
  133. //" <span item='createDate' ></span>"+
  134. //" <span item='createReport' ></span>"+
  135. //"</td></tr>" +
  136. //
  137. //"<tr><td colspan='4'><div style='border-bottom: 1px dashed #ccc; margin: 5px 0px;width: 100%;'></div></td></tr>" +
  138. //
  139. //"<tr><td styles='formTableTitle' colspan='4'>月报设置</td></tr>" +
  140. //
  141. //"<tr><td>是否启用:</td>" +
  142. //" <td styles='formTableValue14' colspan='3' item='MONTHREPORT_ENABLE'></td></tr>" +
  143. //"<tr><td>发起时间:</td>" +
  144. //" <td styles='formTableValue14' colspan='3' >"+
  145. //" <span item='REPORT_MONTH_DAYTYPE'></span>" +
  146. //" <span item='REPORT_MONTH_DAY'></span>" +
  147. //" <span item='REPORT_MONTH_TIME'></span>" +
  148. //" </td></tr>" +
  149. //"<tr><td>自动启动时间类型:</td>" +
  150. //" <td styles='formTableValue14' colspan='3' item='AUTOCREATE_TYPE'>"+
  151. //"</td></tr>" +
  152. //
  153. //"<tr item='CRON_EXPRESSION_TR' style='display: "+( this.data.AUTOCREATE_TYPE == 'CUSTOMDATELIST' ? "none" : "" )+"'>" +
  154. //" <td>自动启动时间表达式:<a styles='helpNode' href='/x_component_Report/$Setting/cron_express_description.html' target='_blank'></a></td>" +
  155. //" <td styles='formTableValue14' colspan='3' item='CRON_EXPRESSION'>"+
  156. //"</td></tr>" +
  157. //
  158. //"<tr item='CUSTOM_DATELIST_TR' style='display: "+( this.data.AUTOCREATE_TYPE != 'CUSTOMDATELIST' ? "none" : "" )+"'><td>自动启动时间列表:</td>" +
  159. //" <td styles='formTableValue14' colspan='3'>"+
  160. //" <div item='CUSTOM_DATELIST' style='" + boxStyle +"'></div>" +
  161. //"</td></tr>" +
  162. //
  163. //"<tr><td>参与应用:</td>" +
  164. //" <td styles='formTableValue14' colspan='3'>"+
  165. //" <div item='REPORT_MONTH_MODULE' style='"+ boxStyle +"'></div>" +
  166. //"</td></tr>" +
  167. //"<tr><td>个人关联流程:</td>" +
  168. //" <td styles='formTableValue14' colspan='3' item='PERSONMONTH_REPORT_WORKFLOW'>"+
  169. //"</td></tr>" +
  170. //"<tr><td>组织关联流程:</td>" +
  171. //" <td styles='formTableValue14' colspan='3' item='UNITMONTH_REPORT_WORKFLOW'>"+
  172. //"</td></tr>" +
  173. //"<tr><td colspan='4'><div style='border-bottom: 1px dashed #ccc; margin: 5px 0px;width: 100%;'></div></td></tr>" +
  174. //
  175. //"<tr><td styles='formTableTitle' colspan='4'>周报设置</td></tr>" +
  176. //
  177. //"<tr><td>是否启用:</td>" +
  178. //" <td styles='formTableValue14' colspan='3' item='WEEKREPORT_ENABLE'></td></tr>" +
  179. //"<tr><td styles=''>发起时间:</td>" +
  180. //" <td styles='formTableValue14' colspan='3' >"+
  181. //" <span item='REPORT_WEEK_DAYTYPE'></span>" +
  182. //" <span item='REPORT_WEEK_DAY'></span>" +
  183. //" <span item='REPORT_WEEK_TIME'></span>" +
  184. //" </td></tr>" +
  185. //"<tr><td>参与应用:</td>" +
  186. //" <td styles='formTableValue14' colspan='3'>"+
  187. //" <div item='REPORT_WEEK_MODULE' style='"+ boxStyle +"'></div>" +
  188. //"</td></tr>" +
  189. //"<tr><td>个人关联流程:</td>" +
  190. //" <td styles='formTableValue14' colspan='3' item='PERSONWEEK_REPORT_WORKFLOW'>"+
  191. //"</td></tr>" +
  192. //"<tr><td>组织关联流程:</td>" +
  193. //" <td styles='formTableValue14' colspan='3' item='UNITWEEK_REPORT_WORKFLOW'>"+
  194. //"</td></tr>" +
  195. //
  196. //"<tr><td colspan='4'><div style='border-bottom: 1px dashed #ccc; margin: 5px 0px;width: 100%;'></div></td></tr>" +
  197. //
  198. //"<tr><td styles='formTableTitle' colspan='4'>日报设置</td></tr>" +
  199. //
  200. //"<tr><td>是否启用:</td>" +
  201. //" <td styles='formTableValue14' colspan='3' item='DAYREPORT_ENABLE'></td></tr>" +
  202. //"<tr><td>发起时间:</td>" +
  203. //" <td styles='formTableValue14' colspan='3' >"+
  204. //" <span item='REPORT_DAY_DAYTYPE'></span>" +
  205. //" <span item='REPORT_DAY_TIME'></span>" +
  206. //" </td></tr>" +
  207. //"<tr><td>参与应用:</td>" +
  208. //" <td styles='formTableValue14' colspan='3'>"+
  209. //" <div item='REPORT_DAY_MODULE' style='"+ boxStyle +"'></div>" +
  210. //"</td></tr>" +
  211. //"<tr><td>个人关联流程:</td>" +
  212. //" <td styles='formTableValue14' colspan='3' item='PERSONDAY_REPORT_WORKFLOW'>"+
  213. //"</td></tr>" +
  214. //"<tr><td>组织关联流程:</td>" +
  215. //" <td styles='formTableValue14' colspan='3' item='UNITDAY_REPORT_WORKFLOW'>"+
  216. //"</td></tr>" +
  217. //"</table>";
  218. var html = "<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin:20px 0px;'>" +
  219. "<tr><td>是否启用:</td>" +
  220. " <td styles='formTableValue14' colspan='3' item='MONTHREPORT_ENABLE'></td></tr>" +
  221. "<tr><td>自动启动时间类型:</td>" +
  222. " <td styles='formTableValue14' colspan='3' item='AUTOCREATE_TYPE'>"+
  223. "</td></tr>" +
  224. "<tr item='CRON_EXPRESSION_TR' style='display: "+( this.data.AUTOCREATE_TYPE == 'CUSTOMDATELIST' ? "none" : "" )+"'>" +
  225. " <td>自动启动时间表达式:<a styles='helpNode' href='/x_component_Report/$Setting/cron_express_description.html' target='_blank'></a></td>" +
  226. " <td styles='formTableValue14' colspan='3' item='CRON_EXPRESSION'>"+
  227. "</td></tr>" +
  228. "<tr item='CUSTOM_DATELIST_TR' style='display: "+( this.data.AUTOCREATE_TYPE != 'CUSTOMDATELIST' ? "none" : "" )+"'><td>自动启动时间列表:</td>" +
  229. " <td styles='formTableValue14' colspan='3'>"+
  230. " <div item='CUSTOM_DATELIST' style='" + boxStyle +"'></div>" +
  231. "</td></tr>" +
  232. "<tr><td lable='WEEKEND_IGNORE'></td>" +
  233. " <td styles='formTableValue14' item='WEEKEND_IGNORE' colspan='3'></td></tr>" +
  234. "<tr><td lable='HOLIDAY_IGNORE'></td>" +
  235. " <td styles='formTableValue14' item='HOLIDAY_IGNORE' colspan='3' ></td></tr>" +
  236. "<tr><td lable='UNITREPORT_DUTY'></td>" +
  237. " <td styles='formTableValue14' item='UNITREPORT_DUTY' colspan='3' ></td></tr>" +
  238. "<tr><td>参与应用:</td>" +
  239. " <td styles='formTableValue14' colspan='3'>"+
  240. " <div item='REPORT_MONTH_MODULE' style='"+ boxStyle +"'></div>" +
  241. "</td></tr>" +
  242. "<tr><td>关联流程:</td>" +
  243. " <td styles='formTableValue14' colspan='3' item='UNITMONTH_REPORT_WORKFLOW'>"+
  244. "</td></tr>" +
  245. "<tr><td lable='createDate'></td>" +
  246. " <td styles='formTableValue14' colspan='3' >" +
  247. " <span item='createDate' ></span>"+
  248. " <span item='createReport' ></span>"+
  249. "</td></tr>" +
  250. "</table>";
  251. container.set("html", html);
  252. this.itemTemplate = {
  253. //REPORT_ENABLE: { text : "开启汇报", type : "select", selectValue:["true", "false"], selectText : ["是","否"], notEmpty : true, style : { width : "100px" } },
  254. MONTHREPORT_ENABLE: { text : "开启月汇报", type : "select", selectValue:["true", "false"], selectText : ["是","否"], defaultValue : "false", style : { width : "100px" } },
  255. WEEKREPORT_ENABLE: { text : "开启周汇报", type : "select", selectValue:["true", "false"], selectText : ["是","否"], defaultValue : "false", style : { width : "100px" } },
  256. DAYREPORT_ENABLE: { text : "开启日汇报", type : "select", selectValue:["true", "false"], selectText : ["是","否"], defaultValue : "false", style : { width : "100px" } },
  257. createDate: { text: "发起汇报", tType: "date", style: {width: "200px"} },
  258. createReport: { "text": "手工发起汇报", "value": "手工发起汇报", type: "button", event: {
  259. click: function (item, ev) {
  260. var date = this.sysform.getItem("createDate").getValue();
  261. if( date == "" ){
  262. this.app.notice("请先选择时间","error");
  263. }else{
  264. this.actions.createImmediately( {"date":date}, function(){
  265. this.app.notice("发起汇报成功!");
  266. this.sysform.getItem("createDate").setValue("");
  267. }.bind(this))
  268. }
  269. }.bind(this)}
  270. },
  271. REPORT_MONTH_DAYTYPE: { text : "月报发起时间", type : "select", selectValue:["THIS_MONTH","NEXT_MONTH"], selectText:["当月","下月"], style : { width : "100px" }},
  272. REPORT_MONTH_DAY : { text : "每月汇报发起日期", type : "select", selectValue : function(){
  273. var arr = [];
  274. for( var i=1; i<=31; i++ )arr.push( i.toString() );
  275. return arr;
  276. }, selectText : function(){
  277. var arr = [];
  278. for( var i=1; i<=31; i++ )arr.push( i.toString() + "号" );
  279. return arr;
  280. }, style : { width : "100px" }},
  281. REPORT_MONTH_TIME : { text : "每月汇报发起时间", tType : "time", style : { width : "200px" }},
  282. REPORT_WEEK_DAYTYPE: { text : "周报", type : "select", selectValue:["THIS_WEEK","NEXT_WEEK"], selectText:["本周","下周"], style : { width : "100px" }},
  283. REPORT_WEEK_DAY: {text : "每周汇报发起日期", type : "select", selectValue : ["0","1","2","3","4","5","6"], selectValue : ["周日","周一","周二","周三","周四","周五","周六"], style : { width : "100px" }},
  284. REPORT_WEEK_TIME : { text : "每周汇报发起时间", tType : "time", style : { width : "200px" } },
  285. REPORT_DAY_DAYTYPE: { text : "日报", type : "select", selectValue:["NONE","TODAY","TOMORROW"], selectText:["无","当天","下一天"], style : { width : "100px" }},
  286. REPORT_DAY_TIME : { text : "每日汇报发起时间", tType : "time", style : { width : "200px" } },
  287. WEEKEND_IGNORE : { text : "忽略周末", type : "select", selectValue:["true", "false"], selectText : ["是","否"], notEmpty : true, style : { width : "100px" } },
  288. HOLIDAY_IGNORE : { text : "忽略假日", type : "select", selectValue:["true", "false"], selectText : ["是","否"], notEmpty : true, style : { width : "100px" } },
  289. REPORT_MONTH_MODULE : { text : "参与月报的应用", type : "checkbox",
  290. selectValue : ["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"],
  291. selectText : ["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]
  292. },
  293. REPORT_WEEK_MODULE : { text : "参与周报的应用", type : "checkbox",
  294. selectValue : ["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"],
  295. selectText : ["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]
  296. },
  297. REPORT_DAY_MODULE : { text : "参与周报的应用", type : "checkbox",
  298. selectValue : ["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"], //"NONE",
  299. selectText : ["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]
  300. },
  301. //MONTH_REPORT_WORKFLOW : { text : "月报流程", type : "org", orgType : "Process", className : "inputPlus" },
  302. PERSONMONTH_REPORT_WORKFLOW : { text : "个人月报流程", type : "org", orgType : "Process", className : "inputPlus" },
  303. UNITMONTH_REPORT_WORKFLOW : { text : "个人月报流程", type : "org", orgType : "Process", className : "inputPlus" },
  304. //WEEK_REPORT_WORKFLOW : { text : "周报流程", type : "org", orgType : "Process", className : "inputPlus" },
  305. PERSONWEEK_REPORT_WORKFLOW : { text : "个人周报流程", type : "org", orgType : "Process", className : "inputPlus" },
  306. UNITWEEK_REPORT_WORKFLOW : { text : "个人周报流程", type : "org", orgType : "Process", className : "inputPlus" },
  307. //DAY_REPORT_WORKFLOW : { text : "日报流程", type : "org", orgType : "Process", className : "inputPlus" },
  308. PERSONDAY_REPORT_WORKFLOW : { text : "个人日报流程", type : "org", orgType : "Process", className : "inputPlus" },
  309. UNITDAY_REPORT_WORKFLOW : { text : "组织日报流程", type : "org", orgType : "Process", className : "inputPlus" },
  310. PERSONREPORT_REMOVE_DUTY : { text : "个人汇报排除职务", type : "org", orgType : "Duty", count:0, className : "inputPlus" },
  311. UNITREPORT_DUTY : { text : "组织汇报指定职务", type : "org", orgType : "Duty", count:0, className : "inputPlus" },
  312. AUTOCREATE_TYPE : { text : "汇报自动生成时间类型", type : "select", selectValue:["EXPRESSION", "CUSTOMDATELIST"], selectText : ["时间表达式","时间列表"],
  313. notEmpty : true, style : { width : "100px" }, event :{
  314. change : function( item, ev ){
  315. if( item.getValue() == "EXPRESSION" ){
  316. container.getElement("[item='CRON_EXPRESSION_TR']").setStyle("display","");
  317. container.getElement("[item='CUSTOM_DATELIST_TR']").setStyle("display","none");
  318. }else{
  319. container.getElement("[item='CRON_EXPRESSION_TR']").setStyle("display","none");
  320. container.getElement("[item='CUSTOM_DATELIST_TR']").setStyle("display","");
  321. }
  322. }.bind(this)
  323. }},
  324. CRON_EXPRESSION : { text : "时间表达式", validRule : {
  325. isNotEmpty : function( value , item ){
  326. if( item.form.getItem("AUTOCREATE_TYPE").getValue() == "EXPRESSION" && !value)return false;
  327. return true;
  328. }.bind(this) }, validMessage : { isNotEmpty : "时间表达式不能为空" }, onPostLoad : function( item ){
  329. MWF.xDesktop.requireApp("Template", "widget.CronPicker", null, false);
  330. new MWF.xApplication.Template.widget.CronPicker( this.app.content, item.container, this.app, {}, {
  331. position : { //node 固定的位置
  332. x : "right",
  333. y : "auto"
  334. },
  335. onSelect : function( value ){
  336. item.setValue(value);
  337. }
  338. } );
  339. }
  340. }
  341. //CUSTOM_DATELIST : { text : "时间列表" }
  342. };
  343. MWF.xDesktop.requireApp("Template", "MForm", function () {
  344. this.sysform = new MForm(container, this.data, {
  345. isEdited: this.isEdited || this.isNew,
  346. style : "report",
  347. hasColon : true,
  348. itemTemplate: this.itemTemplate
  349. }, this.app);
  350. this.sysform.load();
  351. }.bind(this), true);
  352. var dateList = [];
  353. if( this.data ){
  354. this.data.CUSTOM_DATELIST.split(",").each( function(d ){
  355. dateList.push( { CUSTOM_DATELIST : d } )
  356. })
  357. }
  358. MWF.xDesktop.requireApp("Template", "MGrid", function () {
  359. this.dateGrid = new MGrid( container.getElement("[item='CUSTOM_DATELIST']"), dateList || null , {
  360. style: "report",
  361. isEdited: this.isEdited || this.isNew,
  362. hasOperation : true,
  363. minTrCount : 1,
  364. tableAttributes : { width : "550px", border : "0" , cellpadding : "5", cellspacing : "0" },
  365. itemTemplate: {
  366. CUSTOM_DATELIST: {
  367. tType : "datetime",
  368. defaultValue: "请选择时间",
  369. defaultValueAsEmpty: true,
  370. event: {
  371. focus: function (item, ev) {
  372. if (item.getValue() == "请选择时间")item.setValue("")
  373. }.bind(this),
  374. blur: function (item, ev) {
  375. if (item.getValue() == "")item.setValue("请选择时间")
  376. }.bind(this)
  377. }
  378. }
  379. }
  380. }, this.app );
  381. this.dateGrid.setThTemplate("<tr><th style='text-align: center;font-size:14px;font-weight: normal;'>序号</th><th style='width:360px;text-align: center;font-size:14px;font-weight: normal;'>选择时间</th><th button_add></th></tr>");
  382. this.dateGrid.setTrTemplate( "<tr><td sequence style='text-align: center;vertical-align: top;padding-top:10px;'></td><td><div item='CUSTOM_DATELIST' style='padding-top:5px'></div></td><td button_remove style='vertical-align: top;padding-top:10px;'></td></tr>" );
  383. this.dateGrid.load();
  384. }.bind(this), true);
  385. },
  386. _createBottomContent: function () {
  387. if (this.isNew || this.isEdited) {
  388. this.okActionNode = new Element("button.inputOkButton", {
  389. "styles": this.css.inputOkButton,
  390. "text": this.lp.save
  391. }).inject(this.formBottomNode);
  392. this.okActionNode.addEvent("click", function (e) {
  393. this.save(e);
  394. }.bind(this));
  395. }
  396. this.cancelActionNode = new Element("button.inputCancelButton", {
  397. "styles": (this.isEdited || this.isNew ) ? this.css.inputCancelButton : this.css.inputCancelButton_long,
  398. "text": this.lp.close
  399. }).inject(this.formBottomNode);
  400. this.cancelActionNode.addEvent("click", function (e) {
  401. this.close(e);
  402. }.bind(this));
  403. },
  404. getSysData: function(){
  405. this.actions.listSetting( function( json ){
  406. this.decodeSysData( json.data );
  407. }.bind(this), null, false)
  408. },
  409. decodeSysData : function( data ){
  410. this.data = {};
  411. this.dataJson = {};
  412. data.each( function(d){
  413. var value = d.configValue;
  414. if( typeOf(value) == "string"){
  415. if( value == "NONE" )value = ""
  416. }else if( typeOf(value) == "array" ){
  417. for( var i=0; i<value.length-1; i++ ){
  418. if( value[i] == "NONE" )value[i] = ""
  419. }
  420. }
  421. this.data[d.configCode] = value;
  422. this.dataJson[d.configCode] = d;
  423. }.bind(this));
  424. },
  425. encodeSysData : function( data ){
  426. var arr = [];
  427. for( var d in data ){
  428. if( this.dataJson[d] ){
  429. var result = Object.clone( this.dataJson[d] );
  430. var value = data[d];
  431. if( value == "" && (d == "REPORT_WEEK_MODULE" || d == "REPORT_MONTH_MODULE" || d=="REPORT_DAY_MODULE") ){
  432. value = "NONE";
  433. }
  434. var flowArray = [
  435. "PERSONMONTH_REPORT_WORKFLOW","UNITMONTH_REPORT_WORKFLOW","MONTH_REPORT_WORKFLOW",
  436. "PERSONWEEK_REPORT_WORKFLOW","UNITWEEK_REPORT_WORKFLOW","WEEK_REPORT_WORKFLOW",
  437. "PERSONDAY_REPORT_WORKFLOW","UNITDAY_REPORT_WORKFLOW","DAY_REPORT_WORKFLOW"
  438. ];
  439. if( flowArray.contains( d ) ){
  440. if( value == "" ){
  441. value = "NONE";
  442. }else{
  443. if( this.sysform.getItem(d) && this.sysform.getItem(d).orgObject ){
  444. value = this.sysform.getItem(d).orgObject[0].data.id;
  445. }
  446. }
  447. }
  448. if( value == "" && (d == "REPORT_WEEK_TIME" || d == "REPORT_MONTH_TIME" || d=="REPORT_DAY_TIME") ){
  449. value = "--无--";
  450. }
  451. result.configValue = value;
  452. arr.push( result );
  453. }
  454. }
  455. // alert(JSON.stringify(arr))
  456. return arr;
  457. },
  458. save: function(e){
  459. if( this.personform ){
  460. var pdata = this.personform.getResult(true,null,true,false,false);
  461. if( pdata){
  462. MWF.UD.putData("reportConfig", pdata, function(){
  463. if( this.sysform ){
  464. this.saveSysData();
  465. }else{
  466. this.app.notice(this.lp.save_success, "success");
  467. }
  468. }.bind(this), false);
  469. }
  470. }else if( this.sysform ){
  471. this.saveSysData();
  472. }
  473. },
  474. saveSysData: function(){
  475. var sdata = this.sysform.getResult(true,"|",true,false,false);
  476. if( sdata){
  477. var dateList = this.dateGrid.getResult(true,",",true,false,false);
  478. var dates = [];
  479. var f = true;
  480. dateList.each( function( d ){
  481. if( ( !d.CUSTOM_DATELIST || d.CUSTOM_DATELIST == "请选择时间" ) && sdata.AUTOCREATE_TYPE == "CUSTOMDATELIST" ){
  482. f = flag;
  483. }
  484. dates.push( d.CUSTOM_DATELIST )
  485. });
  486. if( !f || dates.length == 0 ){
  487. this.app.notice("请选择启动时间", "error");
  488. return;
  489. }
  490. sdata.CUSTOM_DATELIST = dates.join(",");
  491. var arr = this.encodeSysData( sdata );
  492. var flag = true;
  493. arr.each( function( d ){
  494. this.app.restActions.saveSetting( d, function(json){
  495. }.bind(this), function( response ){
  496. var json = JSON.decode( response.responseText );
  497. this.app.notice( this.lp.save_fail + ":" + json.message, "error");
  498. flag = false;
  499. }.bind(this), false);
  500. }.bind(this));
  501. if( flag ){
  502. this.app.notice(this.lp.save_success, "success");
  503. }else{
  504. //this.app.notice(this.lp.save_fail, "error");
  505. }
  506. }
  507. },
  508. setFormNodeSize: function (width, height, top, left) {
  509. if (!width)width = this.options.width ? this.options.width : "50%";
  510. if (!height)height = this.options.height ? this.options.height : "50%";
  511. if (!top) top = this.options.top ? this.options.top : 0;
  512. if (!left) left = this.options.left ? this.options.left : 0;
  513. var containerSize = this.container.getSize();
  514. if( containerSize.x < width )width = containerSize.x;
  515. if( containerSize.y < height )height = containerSize.y;
  516. var allSize = this.app.content.getSize();
  517. var limitWidth = allSize.x; //window.screen.width
  518. var limitHeight = allSize.y; //window.screen.height
  519. "string" == typeof width && (1 < width.length && "%" == width.substr(width.length - 1, 1)) && (width = parseInt(limitWidth * parseInt(width, 10) / 100, 10));
  520. "string" == typeof height && (1 < height.length && "%" == height.substr(height.length - 1, 1)) && (height = parseInt(limitHeight * parseInt(height, 10) / 100, 10));
  521. 300 > width && (width = 300);
  522. 220 > height && (height = 220);
  523. top = top || parseInt((limitHeight - height) / 2, 10); //+appTitleSize.y);
  524. left = left || parseInt((limitWidth - width) / 2, 10);
  525. this.formAreaNode.setStyles({
  526. "width": "" + width + "px",
  527. "height": "" + height + "px",
  528. "top": "" + top + "px",
  529. "left": "" + left + "px"
  530. });
  531. this.formNode.setStyles({
  532. "width": "" + width + "px",
  533. "height": "" + height + "px"
  534. });
  535. var iconSize = this.formIconNode ? this.formIconNode.getSize() : {x: 0, y: 0};
  536. var topSize = this.formTopNode ? this.formTopNode.getSize() : {x: 0, y: 0};
  537. var bottomSize = this.formBottomNode ? this.formBottomNode.getSize() : {x: 0, y: 0};
  538. var tabSize = this.tabContainer ? this.tabContainer.getSize() : {x: 0, y: 0};
  539. var contentHeight = height - iconSize.y - topSize.y - bottomSize.y - tabSize.y;
  540. //var formMargin = formHeight -iconSize.y;
  541. this.formContentNode.setStyles({
  542. "height": "" + contentHeight + "px"
  543. });
  544. this.formTableContainer.setStyles({
  545. "height": "" + contentHeight + "px"
  546. });
  547. }
  548. });