Setting.min.js 15 KB

1
  1. MWF.xDesktop.requireApp("Template","MPopupForm",null,false);MWF.xApplication.Report.SettingForm=new Class({Extends:MPopupForm,Implements:[Options,Events],options:{style:"report",width:"1000",height:"600",minWidth:700,minHeight:320,hasTop:true,hasIcon:false,hasTopIcon:false,hasTopContent:false,maxAction:true,hasBottom:true,draggable:true,resizeable:true,closeAction:true},createTab:function(){var t=this;this.tabContainer=new Element("div.formTabContainer",{styles:this.css.formTabContainer}).inject(this.formNode);var e=new Element("div.formTabNode",{styles:this.css.formTabNode,text:this.lp.systemSetting}).inject(this.tabContainer);e.addEvents({mouseover:function(){if(t.currentTabNode!=this.node)this.node.setStyles(t.css.formTabNode_over)}.bind({node:e}),mouseout:function(){if(t.currentTabNode!=this.node)this.node.setStyles(t.css.formTabNode)}.bind({node:e}),click:function(){if(t.currentTabNode)t.currentTabNode.setStyles(t.css.formTabNode);t.currentTabNode=this.node;this.node.setStyles(t.css.formTabNode_current);t.sysContainer.setStyle("display","");t.personContainer.setStyle("display","none")}.bind({node:e})});e.setStyles(this.css.formTabNode_current);t.currentTabNode=e;var e=new Element("div.tabNode",{styles:this.css.formTabNode,text:this.lp.personSetting}).inject(this.tabContainer);e.addEvents({mouseover:function(){if(t.currentTabNode!=this.node)this.node.setStyles(t.css.formTabNode_over)}.bind({node:e}),mouseout:function(){if(t.currentTabNode!=this.node)this.node.setStyles(t.css.formTabNode)}.bind({node:e}),click:function(){if(t.currentTabNode)t.currentTabNode.setStyles(t.css.formTabNode);t.currentTabNode=this.node;this.node.setStyles(t.css.formTabNode_current);t.sysContainer.setStyle("display","none");t.personContainer.setStyle("display","")}.bind({node:e})})},createContent:function(){this.formTopTextNode.set("text","工作汇报配置");this.isAdmin=this.app.common.isAdmin();this.formContentNode=new Element("div.formContentNode",{styles:this.css.formContentNode}).inject(this.formNode);this.formTableContainer=new Element("div.formTableContainer",{styles:this.css.formTableContainer}).inject(this.formContentNode);this.formTableArea=new Element("div.formTableArea",{styles:this.css.formTableArea}).inject(this.formTableContainer);this._createTableContent()},_createTableContent:function(){if(this.isAdmin){this.sysContainer=new Element("div.sysContainer").inject(this.formTableArea);this.loadSysSetting(this.sysContainer)}else{}},loadPersonSetting:function(e){var t=this.isEdited||this.isNew?"border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;":"";var s="<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin-top:40px;'>"+"<tr><td styles='formTableTitle' lable='defaultView' width='20%'></td>"+" <td styles='formTableValue' colspan='3' width='80%'>"+" <div item='defaultView' style='"+t+"'></div>"+" </td>"+"</tr>"+"</table>";e.set("html",s);MWF.UD.getDataJson("reportConfig",function(t){MWF.xDesktop.requireApp("Template","MForm",function(){this.personform=new MForm(e,t,{usesNewVersion:true,isEdited:this.isEdited||this.isNew,style:"meeting",hasColon:true,itemTemplate:{defaultView:{text:"默认视图",type:"radio",selectValue:["toList","toDay"],selectText:["列表","日"]}}},this.app);this.personform.load()}.bind(this),true)}.bind(this))},loadSysSetting:function(s){this.getSysData();var t=this.isEdited||this.isNew?"border:1px solid #ccc; border-radius: 4px;overflow: hidden;padding:8px;":"";var e="<table width='100%' bordr='0' cellpadding='7' cellspacing='0' styles='formTable' style='margin:20px 0px;'>"+"<tr><td>是否启用:</td>"+" <td styles='formTableValue14' colspan='3' item='MONTHREPORT_ENABLE'></td></tr>"+"<tr><td>自动启动时间类型:</td>"+" <td styles='formTableValue14' colspan='3' item='AUTOCREATE_TYPE'>"+"</td></tr>"+"<tr item='CRON_EXPRESSION_TR' style='display: "+(this.data.AUTOCREATE_TYPE=="CUSTOMDATELIST"?"none":"")+"'>"+" <td>自动启动时间表达式:<a styles='helpNode' href='/x_component_Report/$Setting/cron_express_description.html' target='_blank'></a></td>"+" <td styles='formTableValue14' colspan='3' item='CRON_EXPRESSION'>"+"</td></tr>"+"<tr item='CUSTOM_DATELIST_TR' style='display: "+(this.data.AUTOCREATE_TYPE!="CUSTOMDATELIST"?"none":"")+"'><td>自动启动时间列表:</td>"+" <td styles='formTableValue14' colspan='3'>"+" <div item='CUSTOM_DATELIST' style='"+t+"'></div>"+"</td></tr>"+"<tr><td lable='WEEKEND_IGNORE'></td>"+" <td styles='formTableValue14' item='WEEKEND_IGNORE' colspan='3'></td></tr>"+"<tr><td lable='HOLIDAY_IGNORE'></td>"+" <td styles='formTableValue14' item='HOLIDAY_IGNORE' colspan='3' ></td></tr>"+"<tr><td lable='UNITREPORT_DUTY'></td>"+" <td styles='formTableValue14' item='UNITREPORT_DUTY' colspan='3' ></td></tr>"+"<tr><td>参与应用:</td>"+" <td styles='formTableValue14' colspan='3'>"+" <div item='REPORT_MONTH_MODULE' style='"+t+"'></div>"+"</td></tr>"+"<tr><td>关联流程:</td>"+" <td styles='formTableValue14' colspan='3' item='UNITMONTH_REPORT_WORKFLOW'>"+"</td></tr>"+"<tr><td lable='createDate'></td>"+" <td styles='formTableValue14' colspan='3' >"+" <span item='createDate' ></span>"+" <span item='createReport' ></span>"+"</td></tr>"+"</table>";s.set("html",e);this.itemTemplate={MONTHREPORT_ENABLE:{text:"开启月汇报",type:"select",selectValue:["true","false"],selectText:["是","否"],defaultValue:"false",style:{width:"100px"}},WEEKREPORT_ENABLE:{text:"开启周汇报",type:"select",selectValue:["true","false"],selectText:["是","否"],defaultValue:"false",style:{width:"100px"}},DAYREPORT_ENABLE:{text:"开启日汇报",type:"select",selectValue:["true","false"],selectText:["是","否"],defaultValue:"false",style:{width:"100px"}},createDate:{text:"发起汇报",tType:"date",style:{width:"200px"}},createReport:{text:"手工发起汇报",value:"手工发起汇报",type:"button",event:{click:function(t,e){var s=this.sysform.getItem("createDate").getValue();if(s==""){this.app.notice("请先选择时间","error")}else{this.actions.createImmediately({date:s},function(){this.app.notice("发起汇报成功!");this.sysform.getItem("createDate").setValue("")}.bind(this))}}.bind(this)}},REPORT_MONTH_DAYTYPE:{text:"月报发起时间",type:"select",selectValue:["THIS_MONTH","NEXT_MONTH"],selectText:["当月","下月"],style:{width:"100px"}},REPORT_MONTH_DAY:{text:"每月汇报发起日期",type:"select",selectValue:function(){var t=[];for(var e=1;e<=31;e++)t.push(e.toString());return t},selectText:function(){var t=[];for(var e=1;e<=31;e++)t.push(e.toString()+"号");return t},style:{width:"100px"}},REPORT_MONTH_TIME:{text:"每月汇报发起时间",tType:"time",style:{width:"200px"}},REPORT_WEEK_DAYTYPE:{text:"周报",type:"select",selectValue:["THIS_WEEK","NEXT_WEEK"],selectText:["本周","下周"],style:{width:"100px"}},REPORT_WEEK_DAY:{text:"每周汇报发起日期",type:"select",selectValue:["0","1","2","3","4","5","6"],selectValue:["周日","周一","周二","周三","周四","周五","周六"],style:{width:"100px"}},REPORT_WEEK_TIME:{text:"每周汇报发起时间",tType:"time",style:{width:"200px"}},REPORT_DAY_DAYTYPE:{text:"日报",type:"select",selectValue:["NONE","TODAY","TOMORROW"],selectText:["无","当天","下一天"],style:{width:"100px"}},REPORT_DAY_TIME:{text:"每日汇报发起时间",tType:"time",style:{width:"200px"}},WEEKEND_IGNORE:{text:"忽略周末",type:"select",selectValue:["true","false"],selectText:["是","否"],notEmpty:true,style:{width:"100px"}},HOLIDAY_IGNORE:{text:"忽略假日",type:"select",selectValue:["true","false"],selectText:["是","否"],notEmpty:true,style:{width:"100px"}},REPORT_MONTH_MODULE:{text:"参与月报的应用",type:"checkbox",selectValue:["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"],selectText:["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]},REPORT_WEEK_MODULE:{text:"参与周报的应用",type:"checkbox",selectValue:["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"],selectText:["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]},REPORT_DAY_MODULE:{text:"参与周报的应用",type:"checkbox",selectValue:["CMS","BBS","OKR","WORKFLOW","MEETTING","ATTENDANCE","STRATEGY"],selectText:["内容管理","论坛","OKR","流程应用","会议管理","考勤","战略"]},PERSONMONTH_REPORT_WORKFLOW:{text:"个人月报流程",type:"org",orgType:"Process",className:"inputPlus"},UNITMONTH_REPORT_WORKFLOW:{text:"个人月报流程",type:"org",orgType:"Process",className:"inputPlus"},PERSONWEEK_REPORT_WORKFLOW:{text:"个人周报流程",type:"org",orgType:"Process",className:"inputPlus"},UNITWEEK_REPORT_WORKFLOW:{text:"个人周报流程",type:"org",orgType:"Process",className:"inputPlus"},PERSONDAY_REPORT_WORKFLOW:{text:"个人日报流程",type:"org",orgType:"Process",className:"inputPlus"},UNITDAY_REPORT_WORKFLOW:{text:"组织日报流程",type:"org",orgType:"Process",className:"inputPlus"},PERSONREPORT_REMOVE_DUTY:{text:"个人汇报排除职务",type:"org",orgType:"Duty",count:0,className:"inputPlus"},UNITREPORT_DUTY:{text:"组织汇报指定职务",type:"org",orgType:"Duty",count:0,className:"inputPlus"},AUTOCREATE_TYPE:{text:"汇报自动生成时间类型",type:"select",selectValue:["EXPRESSION","CUSTOMDATELIST"],selectText:["时间表达式","时间列表"],notEmpty:true,style:{width:"100px"},event:{change:function(t,e){if(t.getValue()=="EXPRESSION"){s.getElement("[item='CRON_EXPRESSION_TR']").setStyle("display","");s.getElement("[item='CUSTOM_DATELIST_TR']").setStyle("display","none")}else{s.getElement("[item='CRON_EXPRESSION_TR']").setStyle("display","none");s.getElement("[item='CUSTOM_DATELIST_TR']").setStyle("display","")}}.bind(this)}},CRON_EXPRESSION:{text:"时间表达式",validRule:{isNotEmpty:function(t,e){if(e.form.getItem("AUTOCREATE_TYPE").getValue()=="EXPRESSION"&&!t)return false;return true}.bind(this)},validMessage:{isNotEmpty:"时间表达式不能为空"},onPostLoad:function(e){MWF.xDesktop.requireApp("Template","widget.CronPicker",null,false);new MWF.xApplication.Template.widget.CronPicker(this.app.content,e.container,this.app,{},{position:{x:"right",y:"auto"},onSelect:function(t){e.setValue(t)}})}}};MWF.xDesktop.requireApp("Template","MForm",function(){this.sysform=new MForm(s,this.data,{isEdited:this.isEdited||this.isNew,style:"report",hasColon:true,itemTemplate:this.itemTemplate},this.app);this.sysform.load()}.bind(this),true);var i=[];if(this.data){this.data.CUSTOM_DATELIST.split(",").each(function(t){i.push({CUSTOM_DATELIST:t})})}MWF.xDesktop.requireApp("Template","MGrid",function(){this.dateGrid=new MGrid(s.getElement("[item='CUSTOM_DATELIST']"),i||null,{style:"report",isEdited:this.isEdited||this.isNew,hasOperation:true,minTrCount:1,tableAttributes:{width:"550px",border:"0",cellpadding:"5",cellspacing:"0"},itemTemplate:{CUSTOM_DATELIST:{tType:"datetime",defaultValue:"请选择时间",defaultValueAsEmpty:true,event:{focus:function(t,e){if(t.getValue()=="请选择时间")t.setValue("")}.bind(this),blur:function(t,e){if(t.getValue()=="")t.setValue("请选择时间")}.bind(this)}}}},this.app);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>");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>");this.dateGrid.load()}.bind(this),true)},_createBottomContent:function(){if(this.isNew||this.isEdited){this.okActionNode=new Element("button.inputOkButton",{styles:this.css.inputOkButton,text:this.lp.save}).inject(this.formBottomNode);this.okActionNode.addEvent("click",function(t){this.save(t)}.bind(this))}this.cancelActionNode=new Element("button.inputCancelButton",{styles:this.isEdited||this.isNew?this.css.inputCancelButton:this.css.inputCancelButton_long,text:this.lp.close}).inject(this.formBottomNode);this.cancelActionNode.addEvent("click",function(t){this.close(t)}.bind(this))},getSysData:function(){this.actions.listSetting(function(t){this.decodeSysData(t.data)}.bind(this),null,false)},decodeSysData:function(t){this.data={};this.dataJson={};t.each(function(t){var e=t.configValue;if(typeOf(e)=="string"){if(e=="NONE")e=""}else if(typeOf(e)=="array"){for(var s=0;s<e.length-1;s++){if(e[s]=="NONE")e[s]=""}}this.data[t.configCode]=e;this.dataJson[t.configCode]=t}.bind(this))},encodeSysData:function(t){var e=[];for(var s in t){if(this.dataJson[s]){var i=Object.clone(this.dataJson[s]);var o=t[s];if(o==""&&(s=="REPORT_WEEK_MODULE"||s=="REPORT_MONTH_MODULE"||s=="REPORT_DAY_MODULE")){o="NONE"}var n=["PERSONMONTH_REPORT_WORKFLOW","UNITMONTH_REPORT_WORKFLOW","MONTH_REPORT_WORKFLOW","PERSONWEEK_REPORT_WORKFLOW","UNITWEEK_REPORT_WORKFLOW","WEEK_REPORT_WORKFLOW","PERSONDAY_REPORT_WORKFLOW","UNITDAY_REPORT_WORKFLOW","DAY_REPORT_WORKFLOW"];if(n.contains(s)){if(o==""){o="NONE"}else{if(this.sysform.getItem(s)&&this.sysform.getItem(s).orgObject){o=this.sysform.getItem(s).orgObject[0].data.id}}}if(o==""&&(s=="REPORT_WEEK_TIME"||s=="REPORT_MONTH_TIME"||s=="REPORT_DAY_TIME")){o="--无--"}i.configValue=o;e.push(i)}}return e},save:function(t){var e=this.personform.getResult(true,null,true,false,false);if(e){MWF.UD.putData("reportConfig",e,function(){if(this.sysform){this.saveSysData()}else{this.app.notice(this.lp.save_success,"success")}}.bind(this),false)}},saveSysData:function(){var e=this.sysform.getResult(true,"|",true,false,false);if(e){var t=this.dateGrid.getResult(true,",",true,false,false);var s=[];var i=true;t.each(function(t){if((!t.CUSTOM_DATELIST||t.CUSTOM_DATELIST=="请选择时间")&&e.AUTOCREATE_TYPE=="CUSTOMDATELIST"){i=n}s.push(t.CUSTOM_DATELIST)});if(!i||s.length==0){this.app.notice("请选择启动时间","error");return}e.CUSTOM_DATELIST=s.join(",");var o=this.encodeSysData(e);var n=true;o.each(function(t){this.app.restActions.saveSetting(t,function(t){}.bind(this),function(t){var e=JSON.decode(t.responseText);this.app.notice(this.lp.save_fail+":"+e.message,"error");n=false}.bind(this),false)}.bind(this));if(n){this.app.notice(this.lp.save_success,"success")}else{}}},setFormNodeSize:function(t,e,s,i){if(!t)t=this.options.width?this.options.width:"50%";if(!e)e=this.options.height?this.options.height:"50%";if(!s)s=this.options.top?this.options.top:0;if(!i)i=this.options.left?this.options.left:0;var o=this.container.getSize();if(o.x<t)t=o.x;if(o.y<e)e=o.y;var n=this.app.content.getSize();var a=n.x;var l=n.y;"string"==typeof t&&(1<t.length&&"%"==t.substr(t.length-1,1))&&(t=parseInt(a*parseInt(t,10)/100,10));"string"==typeof e&&(1<e.length&&"%"==e.substr(e.length-1,1))&&(e=parseInt(l*parseInt(e,10)/100,10));300>t&&(t=300);220>e&&(e=220);s=s||parseInt((l-e)/2,10);i=i||parseInt((a-t)/2,10);this.formAreaNode.setStyles({width:""+t+"px",height:""+e+"px",top:""+s+"px",left:""+i+"px"});this.formNode.setStyles({width:""+t+"px",height:""+e+"px"});var r=this.formIconNode?this.formIconNode.getSize():{x:0,y:0};var d=this.formTopNode?this.formTopNode.getSize():{x:0,y:0};var T=this.formBottomNode?this.formBottomNode.getSize():{x:0,y:0};var c=this.tabContainer?this.tabContainer.getSize():{x:0,y:0};var p=e-r.y-d.y-T.y-c.y;this.formContentNode.setStyles({height:""+p+"px"});this.formTableContainer.setStyles({height:""+p+"px"})}});