| 1 |
- MWF.xApplication.Report.StrategyExplorer.Write=new Class({Implements:[Options,Events],options:{style:"default",isEdited:false,status:"write"},initialize:function(t,e,i,s){this.setOptions(s);this.container=t;this.explorer=e;this.app=this.explorer.app;this.lp=this.app.lp;this.css=this.explorer.css;this.actions=this.app.restActions;this.data=i;this.path="/x_component_Report/$StrategyExplorer/"},load:function(){this.month=parseInt(this.data.month);this.thisMonth_inputContent_all=[];this.nextMonth_inputTitle_all=[];this.nextMonth_inputContent_all=[];this.nextMonth_inputTitle=[];this.thisMonthKeyworkList=[];this.thisMonthKeyworkNode=new Element("div",{}).inject(this.explorer.summaryContainer);this.data.thisMonth_workList.each(function(t,e){var i=new MWF.xApplication.Report.StrategyExplorer.Write.ThisKeyWorkItem(this.thisMonthKeyworkNode,this,t,{reportId:this.data.id,isEdited:this.options.isEdited,status:this.options.status,orderNumber:e+1});i.load();this.thisMonthKeyworkList.push(i)}.bind(this));this.nexMonthKeyworkList=[];this.nextMonthKeyWorkNode=new Element("div",{}).inject(this.explorer.planContainer);this.data.nextMonth_workList.each(function(t,e){if(t.workTitle==""){var i=this.data.thisMonth_workList&&this.data.thisMonth_workList.length>e?this.data.thisMonth_workList[e].workTitle:"";if(i){t.workTitle=i;this.app.restActions.saveWorkInfor(t,function(){}.bind(this))}}var s=new MWF.xApplication.Report.StrategyExplorer.Write.NextKeyWorkItem(this.nextMonthKeyWorkNode,this,t,{reportId:this.data.id,isEdited:this.options.isEdited,status:this.options.status,orderNumber:e+1,defaultTitle:this.data.thisMonth_workList&&this.data.thisMonth_workList.length>e?this.data.thisMonth_workList[e].workTitle:""});s.load();this.nexMonthKeyworkList.push(s)}.bind(this));if(this.options.isEdited&&this.options.status=="write"){var s=this;this.nextMonth_inputTitle.each(function(t,e){var i=new Element("button",{value:"沿用标题",text:"沿用标题",title:"标题沿用上月重点工作",styles:this.css.normalButton,events:{click:function(){var t=this.index;var e=this.input;if(s.data.thisMonth_workList&&s.data.thisMonth_workList.length>t){if(e.get("value")){e.set("value",e.get("value")+" "+s.data.thisMonth_workList[t].workTitle)}else{e.set("value",s.data.thisMonth_workList[t].workTitle)}}}.bind({input:t,index:e})}}).inject(t,"before");if(s.data.thisMonth_workList&&s.data.thisMonth_workList.length>e){new Element("div",{styles:{"margin-bottom":"5px"},html:this.app.common.replaceWithBr(s.data.thisMonth_workList[e].workTitle)}).inject(i,"before")}}.bind(this))}this.extWorkNode=new Element("div",{styles:{width:"96%",margin:"0px auto"}}).inject(this.explorer.threeworkContainer);var t=this.extWork=new MWF.xApplication.Report.StrategyExplorer.Write.ExtWork(this.extWorkNode,this,this.data,{reportId:this.data.id,isEdited:this.options.isEdited,status:this.options.status});t.load()},getExtKeywork:function(t,e){var i=this["ext"+t+"KeyworkList"];for(var s=0;s<i.length;s++){if(i[s].data.id==e){return i[s]}}return null},getThisMonthKeywork:function(t){for(var e=0;e<this.thisMonthKeyworkList.length;e++){if(this.thisMonthKeyworkList[e].data.id==t){return this.thisMonthKeyworkList[e]}}return null},getNextMonthKeywork:function(t){for(var e=0;e<this.nexMonthKeyworkList.length;e++){if(this.nexMonthKeyworkList[e].data.id==t){return this.nexMonthKeyworkList[e]}}return null},listPlan:function(e,t,i){if(!t&&this.planDataObject){if(i)i(this.planDataObject[e]||[])}else{this.actions.listPlan(this.data.id||this.options.id,function(t){this.planDataObject={};t.data.each(function(t){if(!this.planDataObject[t.workInfoId]){this.planDataObject[t.workInfoId]=[]}this.planDataObject[t.workInfoId].push(t)}.bind(this));if(i)i(this.planDataObject[e]||[])}.bind(this))}},listWork:function(e,t,i){if(!t&&this.workDataObject){if(i)i(this.workDataObject[e]||[])}else{this.actions.listWork(this.data.id||this.options.id,function(t){this.workDataObject={};t.data.each(function(t){if(!this.workDataObject[t.workInfoId]){this.workDataObject[t.workInfoId]=[]}this.workDataObject[t.workInfoId].push(t)}.bind(this));if(i)i(this.workDataObject[e]||[])}.bind(this))}},listPlanNext:function(e,t,i){if(!t&&this.planNextDataObject){if(i)i(this.planNextDataObject[e]||[])}else{this.actions.listPlanNext(this.data.id||this.options.id,function(t){this.planNextDataObject={};t.data.each(function(t){if(!this.planNextDataObject[t.workInfoId]){this.planNextDataObject[t.workInfoId]=[]}this.planNextDataObject[t.workInfoId].push(t)}.bind(this));if(i)i(this.planNextDataObject[e]||[])}.bind(this))}},submit:function(){var t=false;var e=this.getResult(true);if(e){this.actions.saveWorkPerson(e,function(){t=true}.bind(this),null,false)}if(!t&&this.errorNodeList&&this.errorNodeList.length>0){var i=this.errorNodeList[0];if(this.app.scrollNode){this.app.scrollNode.scrollTo(0,i.getCoordinates().top-this.app.scrollNode.getCoordinates().top+this.app.scrollNode.scrollTop.toFloat()-120)}}return t},save:function(){var t=false;var e=this.getResult(false);if(e){this.actions.saveWorkPerson(e,function(){t=true}.bind(this),null,false)}return t},verifyProcess:function(t){if(this.errorNodeList&&this.errorNodeList.length){while(this.errorNodeList.length>0){this.errorNodeList.pop().destroy()}}if(t=="confirm"||t=="audit"){var e=true;this.thisMonth_inputContent_all.each(function(t){if(t.get("value")==""){e=false;this.createErrorNode(t,"请填写工作总结")}}.bind(this));var i=true;this.nextMonth_inputTitle_all.each(function(t){if(t.get("value")==""){i=false;this.createErrorNode(t,"请填写标题")}}.bind(this));var s=true;this.nextMonth_inputContent_all.each(function(t){if(t.get("value")==""){s=false;this.createErrorNode(t,"请填写工作计划")}}.bind(this));var n=true;var a,r,o;this.extWork.gridContainer.getElements("textarea").each(function(t){var e=t.get("name").split("_")[0];if(t.get("value").trim()!=""){if(e=="fuwu")a=true;if(e=="guanai")r=true;if(e=="yijian")o=true}}.bind(this));var l=[];if(!a)l.push("至少需要填写一项服务客户内容");if(!r)l.push("至少需要填写一项关爱员工内容");if(!o)l.push("至少需要填写一项意见建议内容");if(l.length>0){this.createErrorNode(this.extWork.gridContainer,l.join(",")+"。")}l=[];if(!e)l.push("本月工作总结不能为空");if(!i)l.push("下月部门重点工作不能为空");if(!s)l.push("下月工作计划工作不能为空");if(!n)l.push("下月举措不能为空");if(!a)l.push("至少需要填写一项服务客户内容");if(!r)l.push("至少需要填写一项关爱员工内容");if(!o)l.push("至少需要填写一项意见建议内容");if(l.length>0){this.app.notice(l.join(",<br/>")+"。","error")}return e&&i&&s&&a&&r&&o}return true},getResult:function(s){if(this.errorNodeList){this.errorNodeList.each(function(t){t.destroy()}.bind(this));this.errorNodeList=[]}var n=true;if(this.options.isEdited&&this.options.status=="confirm"){var a=[];this.nexMonthKeyworkList.each(function(t){var e=t.getWorkTitle();if(!e||e.length==0){if(s){this.createErrorNode(t.workTitleInput,"请填写工作标题",{float:"left"});n=false}}var i=t.getMeasuresList();if(!i||i.length==0){if(s){this.createErrorNode(t.measureContentNode,"请选择举措");n=false}}a.push({id:t.data.id,orderNumber:t.getOrderNumber(),workTitle:e,measuresList:i})}.bind(this));if(!n)return false;return{id:this.data.id,workList:a}}},createErrorNode:function(t,e,i){if(!this.errorNodeList)this.errorNodeList=[];var s=new Element("div",{text:e,styles:this.css.warningMessageNode}).inject(t,"after");if(i)s.setStyles(i);this.errorNodeList.push(s)}});MWF.xApplication.Report.StrategyExplorer.Write.ThisKeyWorkItem=new Class({Implements:[Options,Events],options:{style:"default",reportId:"",isEdited:true,orderNumber:1,status:""},initialize:function(t,e,i,s){this.setOptions(s);this.container=t;this.explorer=e;this.app=this.explorer.app;this.lp=this.app.lp;this.css=this.explorer.css;this.actions=this.app.restActions;this.data=i},load:function(){var t=this.options.status;var e=new Element("table",{width:"96%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.formTable}).inject(this.container);var i=new Element("tr").inject(e);new Element("td",{rowspan:3,text:this.data.orderNumber||this.options.orderNumber,width:"30",styles:this.css.formTableTitle}).inject(i);new Element("td",{text:"部门重点工作",width:"140",styles:this.css.formTableTitle}).inject(i);var s=new Element("td",{styles:this.css.formTableValue}).inject(i);new Element("div",{html:this.app.common.replaceWithBr(this.data.workTitle),styles:{width:"870px",float:"left"}}).inject(s);var n=new Element("input",{type:"button",styles:this.css.showMeasureNode,value:"查看举措"}).inject(s);var a=new MWF.xApplication.Report.ShowMeasureTooltip(this.app.content,n,this.app,this.explorer.data,{style:"report",position:{x:"auto",y:"auto"},event:"click"});a.measuresList=this.data.measuresList;i=new Element("tr").inject(e);new Element("td",{text:"工作计划",styles:this.css.formTableTitle}).inject(i);s=new Element("td",{styles:this.css.formTableValue,html:this.app.common.replaceWithBr(this.data.workPlanSummary)}).inject(i);i=new Element("tr").inject(e);new Element("td",{text:"工作总结",styles:this.css.formTableTitle}).inject(i);s=new Element("td",{styles:this.css.formTableValue}).inject(i);if(t=="confirm"||t=="write"){this.loadWorkView(s)}if(t=="confirm"||t=="audit"){if(this.options.isEdited){this.contentInput_all=new Element("textarea",{placeholder:t=="confirm"?"请汇总工作总结":"",styles:this.css.textarea,value:this.data.workProgSummary}).inject(s);this.explorer.thisMonth_inputContent_all.push(this.contentInput_all);this.contentInput_all.addEvent("blur",function(){if(this.data.workProgSummary!=this.contentInput_all.get("value")){this.data.workProgSummary=this.contentInput_all.get("value");if(this.app.onChangeValue)this.app.onChangeValue()}this.app.restActions.saveWorkProgSummary({id:this.data.id,workProgSummary:this.contentInput_all.get("value")},function(){this.app.notice("工作总结保存并上传成功","success",this.contentInput_all.getParent())}.bind(this))}.bind(this))}else{if(t=="confirm"){var r=new Element("div").inject(s);var o="<table width='100%' bordr='0' cellpadding='3' cellspacing='0' style='margin-top: 5px; '>"+"<tr><td width='70' align='center'>汇总:</td>"+" <td>"+this.app.common.replaceWithBr(this.data.workProgSummary)+"</td>"+"</table>";r.set("html",o)}else{var r=new Element("div").inject(s);r.set("html",this.app.common.replaceWithBr(this.data.workProgSummary))}}}},addContentToAll:function(t){var e=this.contentInput_all.get("value");if(!e){this.contentInput_all.set("value",t.progressContent)}else{this.contentInput_all.set("value",e+" "+t.progressContent)}if(this.app.onChangeValue)this.app.onChangeValue();this.data.workProgSummary=this.contentInput_all.get("value");this.app.restActions.saveWorkProgSummary({id:this.data.id,workProgSummary:this.contentInput_all.get("value")},function(){this.app.notice("工作总结保存并上传成功","success",this.contentInput_all.getParent())}.bind(this))},loadPlanView:function(t){this.planViewNode=new Element("div").inject(t);this.planView=new MWF.xApplication.Report.StrategyExplorer.PlanView(this.planViewNode,this.app,this,{style:"default",documentSortable:false,reportId:this.options.reportId,isEdited:this.options.isEdited,templateUrl:this.explorer.path+"listItemPlan.json",onDocumentSortComplete:function(t,e){var s=[];this.planView.node.getElements("[item='id']").each(function(t,e){var i=t.get("text");this.planView.documents[i].data.orderNumber=e+1;s.push({id:i,orderNumber:e+1})}.bind(this));this.actions.updatePlanOrder({orderList:s})}.bind(this)});this.planView.report=this.explorer.explorer;this.planView.data=this.data.planList;this.planView.load()},loadWorkView:function(t){this.workView=new MWF.xApplication.Report.StrategyExplorer.WorkView(t||this.workViewNode,this.app,this,{style:"default",documentSortable:false,reportId:this.options.reportId,isEdited:this.options.isEdited,templateUrl:this.explorer.path+"listItemWork.json",onDocumentSortComplete:function(t,e){var s=[];this.workView.node.getElements("[item='id']").each(function(t,e){var i=t.get("text");this.workView.documents[i].data.orderNumber=e+1;s.push({id:i,orderNumber:e+1})}.bind(this));this.actions.updateWorkOrder({orderList:s})}.bind(this)});this.workView.report=this.explorer.explorer;this.workView.data=this.data.progList;this.workView.load()}});MWF.xApplication.Report.StrategyExplorer.Write.NextKeyWorkItem=new Class({Implements:[Options,Events],options:{style:"default",reportId:"",isEdited:false,orderNumber:1,status:"",defaultTitle:""},initialize:function(t,e,i,s){this.setOptions(s);this.container=t;this.explorer=e;this.app=this.explorer.app;this.lp=this.app.lp;this.css=this.explorer.css;this.actions=this.app.restActions;this.data=i},load:function(){var t=this.options.status;var e=new Element("table",{width:"96%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.formTable}).inject(this.container);var i=new Element("tr").inject(e);new Element("td",{rowspan:t=="write"?3:4,text:this.data.orderNumber||this.options.orderNumber,width:"30",styles:this.css.formTableTitle}).inject(i);new Element("td",{text:t=="write"?"标题":"部门重点工作",width:"140",styles:this.css.formTableTitle}).inject(i);var s=new Element("td",{styles:this.css.formTableValue}).inject(i);if(t=="confirm"||t=="write"){this.loadPlanTitleViewNext(s)}if(t=="confirm"||t=="audit"){if(this.options.isEdited){this.titleInput_all=new Element("textarea",{placeholder:t=="confirm"?"请汇总部门重点工作":"",styles:this.css.textarea,value:this.data.workTitle||this.options.defaultTitle}).inject(s);this.explorer.nextMonth_inputTitle_all.push(this.titleInput_all);this.titleInput_all.addEvent("blur",function(){var t=Object.clone(this.data);delete t.planNextList;delete t.planList;if(this.data.workTitle!=this.titleInput_all.get("value")){this.data.workTitle=this.titleInput_all.get("value");if(this.app.onChangeValue)this.app.onChangeValue()}t.workPlanSummary=this.contentInput_all.get("value");t.workTitle=this.titleInput_all.get("value");this.app.restActions.saveWorkInfor(t,function(){this.app.notice("部门重点工作保存并上传成功","success",this.titleInput_all.getParent())}.bind(this))}.bind(this))}else{if(t=="confirm"){var n=new Element("div").inject(s);var a="<table width='100%' bordr='0' cellpadding='3' cellspacing='0' style='margin-top: 5px; '>"+"<tr><td width='70' align='center'>汇总:</td>"+" <td>"+this.app.common.replaceWithBr(this.data.workTitle)+"</td>"+"</table>";n.set("html",a)}else{var n=new Element("div").inject(s);n.set("html",this.app.common.replaceWithBr(this.data.workTitle))}}}if(t=="confirm"||t=="audit"){var i=new Element("tr").inject(e);new Element("td",{text:"举措",width:"140",styles:this.css.formTableTitle}).inject(i);var s=new Element("td",{styles:this.css.formTableValue}).inject(i);var r=new Element("table",{width:"100%",border:0,cellspacing:0,cellpadding:0,styles:this.css.listViewTable}).inject(s);var o=new Element("tr",{styles:this.css.listViewTableTr}).inject(r);var l=new Element("td",{styles:this.css.listViewTableTd}).inject(o);this.measureContentNode=new Element("div").inject(l);this.loadMeasureList(this.data.measuresList||[]);l=new Element("td",{styles:this.css.listViewTableTd,width:"80"}).inject(o);if(this.options.isEdited){var h=new Element("button",{text:"选择举措",styles:this.css.selectMeasureAction}).inject(l);var p=new MWF.xApplication.Report.SelectMeasureTooltips(this.app.content,h,this.app,this.explorer.data,{style:"report",hasArrow:false,position:{x:"auto",y:"auto"},event:"click",onSelect:function(t,e){this.measureContentNode.empty();var i=[];t.each(function(t){i.push(t.id)});this.loadMeasureList(i);if(this.app.onChangeValue)this.app.onChangeValue();this.measuresList=this.data.measuresList=i;var s=Object.clone(this.data);delete s.planNextList;delete s.planList;s.workPlanSummary=this.contentInput_all.get("value");s.workTitle=this.titleInput_all.get("value");this.app.restActions.saveWorkInfor(s,function(){this.app.notice("举措保存并上传成功","success")}.bind(this))}.bind(this)});p.measuresList=this.data.measuresList}}i=new Element("tr").inject(e);new Element("td",{text:"工作计划",styles:this.css.formTableTitle}).inject(i);s=new Element("td",{styles:this.css.formTableValue}).inject(i);if(t=="confirm"||t=="write"){this.loadPlanViewNext(s)}if(t=="confirm"||t=="audit"){if(this.options.isEdited){this.contentInput_all=new Element("textarea",{placeholder:t=="confirm"?"请汇总计划":"",styles:this.css.textarea,value:this.data.workPlanSummary}).inject(s);this.explorer.nextMonth_inputContent_all.push(this.contentInput_all);this.contentInput_all.addEvent("blur",function(){if(this.data.workPlanSummary!=this.contentInput_all.get("value")){this.data.workPlanSummary=this.contentInput_all.get("value");if(this.app.onChangeValue)this.app.onChangeValue()}this.app.restActions.saveWorkPlanSummary({id:this.data.id,workPlanSummary:this.contentInput_all.get("value")},function(){this.app.notice("工作计划保存并上传成功","success",this.contentInput_all.getParent())}.bind(this))}.bind(this))}else{if(t=="confirm"){var n=new Element("div").inject(s);var a="<table width='100%' bordr='0' cellpadding='3' cellspacing='0' style='margin-top: 5px; '>"+"<tr><td width='70' align='center'>汇总:</td>"+" <td>"+this.app.common.replaceWithBr(this.data.workPlanSummary)+"</td>"+"</table>";n.set("html",a)}else{var n=new Element("div").inject(s);n.set("html",this.app.common.replaceWithBr(this.data.workPlanSummary))}}}},addTitleToAll:function(t){var e=this.titleInput_all.get("value");if(!e){this.titleInput_all.set("value",t.title)}else{this.titleInput_all.set("value",e+" "+t.title)}var t=Object.clone(this.data);delete t.planNextList;delete t.planList;this.data.workTitle=this.titleInput_all.get("value");if(this.app.onChangeValue)this.app.onChangeValue();t.workPlanSummary=this.contentInput_all.get("value");t.workTitle=this.titleInput_all.get("value");this.app.restActions.saveWorkInfor(t,function(){this.app.notice("部门重点工作保存并上传成功","success",this.titleInput_all.getParent())}.bind(this))},addContentToAll:function(t){var e=this.contentInput_all.get("value");if(!e){this.contentInput_all.set("value",t.planContent)}else{this.contentInput_all.set("value",e+" "+t.planContent)}this.data.workPlanSummary=this.contentInput_all.get("value");if(this.app.onChangeValue)this.app.onChangeValue();this.app.restActions.saveWorkPlanSummary({id:this.data.id,workPlanSummary:this.contentInput_all.get("value")},function(){this.app.notice("工作计划保存并上传成功","success",this.contentInput_all.getParent())}.bind(this))},getOrderNumber:function(){return this.data.orderNumber||this.options.orderNumber},getWorkTitle:function(){return this.workTitleInput.get("value")},getMeasuresList:function(){return this.measuresList||this.data.measuresList},loadMeasureList:function(t){this.selectableMeasureObject={};this.explorer.data.selectableMeasures.each(function(t){this.selectableMeasureObject[t.id]=t}.bind(this));var r=new Element("table",{width:"100%",border:0,cellspacing:0,cellpadding:3,styles:this.css.listViewTable}).inject(this.measureContentNode);t.each(function(t,e){if(t){var i=this.selectableMeasureObject[t];var s=new Element("tr",{styles:this.css.listViewTableTr}).inject(r);var n=new Element("td",{styles:this.css.listViewTableTd,width:"40"}).inject(s);var a=new Element("div",{styles:this.css.descriptionNode,text:"详情"}).inject(n);this.loadMeasureTooltip(a,t);var n=new Element("td",{styles:this.css.listViewTableTd,text:i.measuresinfotitle}).inject(s)}}.bind(this))},loadMeasureTooltip:function(t,e){var i=new MWF.xApplication.Report.MeasureTooltip(this.app.content,t,this.app,this.selectableMeasureObject[e],{style:"report",position:{x:"auto",y:"auto"},measureId:e,displayDelay:300})},loadPlanTitleViewNext:function(t){var e=this;this.planViewTitleNextNode=new Element("div",{"data-id":this.data.id}).inject(t);this.planTitleViewNext=new MWF.xApplication.Report.StrategyExplorer.PlanTitleViewNext(this.planViewTitleNextNode,this.app,this,{style:"default",reportId:this.options.reportId,isEdited:this.options.isEdited,templateUrl:this.explorer.path+"listItemPlanTitleNext.json"});this.planTitleViewNext.report=this.explorer.explorer;this.planTitleViewNext.load()},loadPlanViewNext:function(t){var e=this;this.planViewNextNode=new Element("div",{"data-id":this.data.id}).inject(t);this.planViewNext=new MWF.xApplication.Report.StrategyExplorer.PlanViewNext(this.planViewNextNode,this.app,this,{style:"default",reportId:this.options.reportId,isEdited:this.options.isEdited,templateUrl:this.explorer.path+"listItemPlanNext.json"});this.planViewNext.report=this.explorer.explorer;this.planViewNext.load()},savePersonPlan:function(i,s){var t=this.currentPersonData;var e=this.titleInput.get("value").trim();var n=this.contentInput.get("value").trim();if(e||n){if(!t){t={};var a=this.explorer.explorer.data;var r=this.data;t.reportId=a.id;t.workInfoId=r.id;t.keyWorkId=r.keyWorkId;t.workTitle=r.workTitle;t.flag=a.flag;t.year=a.year;t.month=a.month;t.week=a.week;t.date=a.date;t.targetPerson=(layout.desktop.session.user||layout.user).distinguishedName;t.orderNumber=this.options.orderNumber||1}t.title=e;t.workDescribe=n;t.planContent=n;this.app.restActions.savePlanNext(t,function(t){var e=t.data.id;this.app.restActions.getPlanNext(e,function(t){this.currentPersonData=t.data}.bind(this));this.app.notice(s,"success",i.target.getParent())}.bind(this))}else if(!e&&!n&&t){this.app.restActions.deletePlanNext(t.id,function(){this.currentPersonData=null;this.app.notice(s,"success",i.target.getParent())}.bind(this))}}});MWF.xApplication.Report.StrategyExplorer.Write.ExtWork=new Class({Implements:[Options,Events],options:{style:"default",reportId:"",isEdited:true,status:""},initialize:function(t,e,i,s){this.setOptions(s);this.container=t;this.explorer=e;this.app=this.explorer.app;this.lp=this.app.lp;this.css=this.explorer.css;this.actions=this.app.restActions;this.data=i},load:function(){this.userName=(layout.desktop.session.user||layout.user).distinguishedName;this.summaryContainer_last=new Element("div").inject(this.container);this.personContainer=new Element("div").inject(this.container);this.summaryContainer=new Element("div").inject(this.container);this.listSummary_last();if(this.options.status=="confirm"||this.options.status=="write"){this.listPersonData()}if(this.options.status=="confirm"||this.options.status=="audit"){this.listSummaryData()}},listSummary_last:function(){if(this.data.WoReport_I_Ext_Contents_sumamry_lastMonth){var s=this.table=new Element("table",{width:"100%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.formTable}).inject(this.summaryContainer_last);var n=new Element("tr").inject(s);new Element("td",{colspan:4,styles:this.css.formTableTitle,text:"上月汇总"}).inject(n);n=new Element("tr").inject(s);new Element("td",{width:"30",styles:this.css.formTableTitle,text:"序号"}).inject(n);new Element("td",{width:"140",styles:this.css.formTableTitle,text:"服务客户"}).inject(n);new Element("td",{width:"140",styles:this.css.formTableTitle,text:"关爱员工"}).inject(n);new Element("td",{width:"140",styles:this.css.formTableTitle,text:"意见建议"}).inject(n);this.data.WoReport_I_Ext_Contents_sumamry_lastMonth.each(function(t,e){n=new Element("tr").inject(s);var i=new Element("td",{width:"30",align:"center",styles:this.css.formTableValue,text:e+1}).inject(n);i.setStyle("text-align","center");new Element("td",{text:t.fuwu,width:"140",styles:this.css.formTableValue}).inject(n);new Element("td",{text:t.guanai,width:"140",styles:this.css.formTableValue}).inject(n);new Element("td",{text:t.yijian,width:"140",styles:this.css.formTableValue}).inject(n)}.bind(this))}},listSummaryData:function(){var t=this.data.WoReport_I_Ext_Contents_sumamry;if(!t||!t.length){for(var e=1;e<=5;e++){var i={infoLevel:"汇总",orderNumber:e};this.app.restActions.saveExtWork(this.data.id,i,function(t){}.bind(this),null,false)}this.actions.listExtWorkWithReportId(this.data.id,{infoLevel:"汇总"},function(t){this.loadSummaryGrid(t.data)}.bind(this))}else{this.loadSummaryGrid(this.data.WoReport_I_Ext_Contents_sumamry)}},listPersonData:function(){var e=[];var i=[];var t=this.data.WoReport_I_Ext_Contents||[];t.sort(function(t,e){var i=t.targetPerson.localeCompare(e.targetPerson);if(i==0){return t.orderNumber-e.orderNumber}else{return i}});t.each(function(t){if(t.targetPerson==this.userName&&this.options.status=="write"){e.push(t)}else{if(t.fuwu||t.guanai||t.yijian){i.push(t)}}}.bind(this));this.loadPersonTable(i);if(this.options.status=="write"){this.loadPersonGrid(e)}},loadSummaryGrid:function(i){this.gridContainer=new Element("div").inject(this.summaryContainer);MWF.xDesktop.requireApp("Template","MGrid",function(){var t=new MGrid(this.gridContainer,i,{style:"report",isEdited:this.options.isEdited,hasOperation:false,hasSequence:true,tableAttributes:{width:"100%",border:"0",cellpadding:"5",cellspacing:"0"},itemTemplate:{fuwu:{attr:{placeholder:"请汇总服务客户"},text:"服务客户",type:"textarea",event:{blur:function(t,e){this.saveExtWork_summary(t,e,"服务客户")}.bind(this)}},guanai:{attr:{placeholder:"请汇总关爱员工"},text:"关爱员工",type:"textarea",event:{blur:function(t,e){this.saveExtWork_summary(t,e,"关爱员工")}.bind(this)}},yijian:{attr:{placeholder:"请汇总意见建议"},text:"意见建议",type:"textarea",event:{blur:function(t,e){this.saveExtWork_summary(t,e,"意见建议")}.bind(this)}}},onPostCreateTable:function(t){var e=t.table;var i=new Element("tr").inject(e);new Element("td",{colspan:4,styles:this.css.formTableTitle,text:"本月汇总"}).inject(i)},onQueryCreateTr:function(){},onQueryRemoveTr:function(t,e,i){}.bind(this)},this.app);t.load();var e=i.length?5-i.length:5;t.addTrs(e-1)}.bind(this),true)},loadPersonTable:function(t){var i=this.table=new Element("table",{width:"100%",border:"0",cellpadding:"5",cellspacing:"0",styles:this.css.formTable}).inject(this.personContainer);var e=this.options.status=="write"?"本月同事填写":"本月员工填写";var s=new Element("tr").inject(i);new Element("td",{colspan:this.options.isEdited?5:4,styles:this.css.formTableTitle,text:e}).inject(s);var s=new Element("tr").inject(i);new Element("td",{width:"20",styles:this.css.formTableTitle,text:"姓名"}).inject(s);new Element("td",{width:"100",styles:this.css.formTableTitle,text:"服务客户"}).inject(s);new Element("td",{width:"100",styles:this.css.formTableTitle,text:"关爱员工"}).inject(s);new Element("td",{width:"100",styles:this.css.formTableTitle,text:"意见建议"}).inject(s);t.each(function(t){var e=new Element("tr").inject(i);new Element("td",{styles:this.css.formTableValue,text:t.targetPerson.split("@")[0]}).inject(e);new Element("td",{styles:this.css.formTableValue,text:t.fuwu}).inject(e);new Element("td",{styles:this.css.formTableValue,text:t.guanai}).inject(e);new Element("td",{styles:this.css.formTableValue,text:t.yijian}).inject(e)}.bind(this))},loadPersonGrid:function(e){this.gridContainer=new Element("div").inject(this.personContainer);MWF.xDesktop.requireApp("Template","MGrid",function(){var t=new MGrid(this.gridContainer,e,{style:"report",isEdited:this.options.isEdited,hasOperation:true,hasSequence:true,minTrCount:1,maxTrCount:5,tableAttributes:{width:"100%",border:"0",cellpadding:"5",cellspacing:"0"},lp:{add:"添加",remove:"删除"},itemTemplate:{fuwu:{text:"服务客户",type:"textarea",event:{blur:function(t,e){this.saveExtWork_person(t,e,"服务客户")}.bind(this)}},guanai:{text:"关爱员工",type:"textarea",event:{blur:function(t,e){this.saveExtWork_person(t,e,"关爱员工")}.bind(this)}},yijian:{text:"意见建议",type:"textarea",event:{blur:function(t,e){this.saveExtWork_person(t,e,"意见建议")}.bind(this)}}},onNewData:function(t,e){var i=t.trList;if(i.length>0){var s=i[i.length-1];var n=s.sourceData.orderNumber+1}else{var n=1}if(e)e(this.addEmptyExtWork_person(n))}.bind(this),onPostCreateTable:function(t){var e=t.table;var i=new Element("tr").inject(e);new Element("td",{colspan:this.options.isEdited?5:4,styles:this.css.formTableTitle,text:"本月本人填写"}).inject(i)},onQueryRemoveTr:function(t,e,i){if(i.sourceData&&i.sourceData.id){this.app.restActions.deleteExtWork(this.options.reportId,i.sourceData.id,function(){}.bind(this),null,false)}}.bind(this)},this.app);t.load()}.bind(this),true)},saveExtWork_summary:function(e,i,s){var n=e.parent.getResult(true,"<br>",false,false,true);n.infoLevel="汇总";if(!n.orderNumber){n.orderNumber=e.options.index}if(this.app.onChangeValue)this.app.onChangeValue();this.app.restActions.saveExtWork(this.data.id,n,function(t){if(!n.id){this.app.restActions.getExtWork(t.data.id,function(t){e.parent.sourceData=t.data}.bind(this),null,false)}this.app.notice(s+"保存并上传成功","success",i.target.getParent("tr"))}.bind(this),null,false)},saveExtWork_person:function(e,i,s){var n=e.parent.getResult(true,"<br>",false,false,true);n.infoLevel="员工";if(!n.orderNumber)n.orderNumber=1;this.app.restActions.saveExtWork(this.data.id,n,function(t){if(!n.id){this.app.restActions.getExtWork(t.data.id,function(t){e.parent.sourceData=t.data}.bind(this),null,false)}this.app.notice(s+"保存并上传成功","success",i.target.getParent("tr"))}.bind(this),null,false)},addEmptyExtWork_person:function(t){var e={};e.infoLevel="员工";e.orderNumber=t;var i;this.app.restActions.saveExtWork(this.data.id,e,function(t){this.app.restActions.getExtWork(t.data.id,function(t){i=t.data}.bind(this),null,false)}.bind(this),null,false);return i}});MWF.xApplication.Report.StrategyExplorer.WorkView=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,_createDocument:function(t,e){return new MWF.xApplication.Report.StrategyExplorer.WorkDocument(this.viewBodyNode||this.viewNode,t,this.departmentexplorer,this,null,e)},_getCurrentPageData:function(e,t,i){this.userName=(layout.desktop.session.user||layout.user).distinguishedName;if(!this.loaded){this.loaded=true;var s=this.explorer.data.progList||[];if(e)e({data:s})}else{this.explorer.explorer.listWork(this.explorer.data.id,this.loaded,function(t){this.loaded=true;t.sort(function(t,e){return t.orderNumber-e.orderNumber});if(e)e({data:t})}.bind(this))}},_removeDocument:function(t,i){this.app.common.deleteWork(t,e,function(){this.reload()}.bind(this))},_openDocument:function(t){this.app.common.openWork(t,this.report.data,this.explorer.data,this,this.report.isEdited)},_postCreateViewBody:function(t){if(this.getStatus()=="write"&&this.options.isEdited){this.contentInput=new Element("textarea",{placeholder:"请填写您的工作总结",styles:this.css.textarea}).inject(this.container);if(this.currentPersonData){this.contentInput.set("text",this.currentPersonData.progressContent);this.contentInput.set("value",this.currentPersonData.progressContent)}this.contentInput.addEvent("blur",function(t){this.saveWork(t,"工作总结保存并上传成功")}.bind(this))}},saveWork:function(i,s){var t=this.currentPersonData;var e=this.contentInput.get("value").trim();if(e){if(!t){t={};var n=this.report.data;var a=this.explorer.data;t.reportId=n.id;t.workInfoId=a.id;t.keyWorkId=a.keyWorkId;t.title=a.workTitle;t.workTitle=a.workTitle;t.flag=n.flag;t.year=n.year;t.month=n.month;t.week=n.week;t.date=n.date;t.targetPerson=(layout.desktop.session.user||layout.user).distinguishedName;t.orderNumber=this.options.orderNumber||1}t.workDescribe=e;t.progressContent=e;this.app.restActions.saveWork(t,function(t){var e=t.data.id;this.app.restActions.getWork(e,function(t){this.currentPersonData=t.data}.bind(this));this.app.notice(s,"success",i.target.getParent())}.bind(this))}else if(!e&&t){this.app.restActions.deleteWork(t.id,function(){this.currentPersonData=null;this.app.notice(s,"success",i.target.getParent())}.bind(this))}},getStatus:function(){if(!this.status){this.status=this.explorer.options.status}return this.status}});MWF.xApplication.Report.StrategyExplorer.WorkDocument=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,open:function(){},edit:function(t,e){},delete:function(t,e){this.app.common.deleteWork(this.data,e,function(){this.view.reload()}.bind(this));e.stopPropagation()},_postCreateDocumentNode:function(t,e){if(this.view.getStatus()=="write"&&this.view.options.isEdited){if(e.targetPerson==this.view.userName){t.setStyle("display","none");this.view.currentPersonData=e}}}});MWF.xApplication.Report.StrategyExplorer.PlanView=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,_createDocument:function(t,e){return new MWF.xApplication.Report.StrategyExplorer.PlanDocument(this.viewBodyNode||this.viewNode,t,this.explorer,this,null,e)},_getCurrentPageData:function(e,t,i){this.userName=(layout.desktop.session.user||layout.user).distinguishedName;if(!this.loaded){this.loaded=true;if(e)e({data:this.explorer.data.planList})}else{this.explorer.explorer.listPlan(this.explorer.data.id,this.loaded,function(t){this.loaded=true;t.sort(function(t,e){return t.orderNumber-e.orderNumber});if(e)e({data:t})}.bind(this))}},_openDocument:function(t){this.app.common.openPlan(t,this.report.data,this.explorer.data,this,false,this.report.isEdited)}});MWF.xApplication.Report.StrategyExplorer.PlanDocument=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,open:function(){this.view._openDocument(this.data)},edit:function(t,e){this.app.common.editPlan(this.data,this.view.report.data,this.explorer.data,this.view,false);e.stopPropagation()},delete:function(t,e){this.app.common.deletePlan(this.data,e,function(){this.view.reload()}.bind(this));e.stopPropagation()}});MWF.xApplication.Report.StrategyExplorer.PlanViewNext=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,_createDocument:function(t,e){return new MWF.xApplication.Report.StrategyExplorer.PlanDocumentNext(this.viewBodyNode||this.viewNode,t,this.explorer,this,null,e)},_getCurrentPageData:function(e,t,i){this.userName=(layout.desktop.session.user||layout.user).distinguishedName;var s=true;if(!this.loaded){this.loaded=true;var n=this.explorer.data.planNextList||[];if(e)e({data:n})}else{this.explorer.explorer.listPlanNext(this.explorer.data.id,this.loaded,function(t){this.loaded=true;t.sort(function(t,e){return t.orderNumber-e.orderNumber});if(e)e({data:t})}.bind(this))}},_openDocument:function(t){this.app.common.openPlan(t,this.report.data,this.explorer.data,this,true,this.report.isEdited)},_postCreateViewBody:function(t){if(this.getStatus()=="write"&&this.options.isEdited){this.explorer.contentInput=new Element("textarea",{placeholder:"请填写计划",styles:this.css.textarea}).inject(this.container);if(this.explorer.currentPersonData){this.explorer.contentInput.set("text",this.explorer.currentPersonData.planContent);this.explorer.contentInput.set("value",this.explorer.currentPersonData.planContent)}this.explorer.contentInput.addEvent("blur",function(t){this.explorer.savePersonPlan(t,"计划保存并上传成功")}.bind(this))}},getStatus:function(){if(!this.status){this.status=this.explorer.options.status}return this.status}});MWF.xApplication.Report.StrategyExplorer.PlanDocumentNext=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,open:function(){this.view._openDocument(this.data)},edit:function(t,e){this.app.common.editPlan(this.data,this.view.report.data,this.explorer.data,this.view,true);e.stopPropagation()},delete:function(t,e){this.app.common.deletePlanNext(this.data,e,function(){this.view.reload()}.bind(this));e.stopPropagation()},_postCreateDocumentNode:function(t,e){if(this.view.getStatus()=="write"&&this.view.options.isEdited){if(e.targetPerson==this.view.userName){t.setStyle("display","none");this.explorer.currentPersonData=e}}}});MWF.xApplication.Report.StrategyExplorer.PlanTitleViewNext=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexView,_createDocument:function(t,e){return new MWF.xApplication.Report.StrategyExplorer.PlanTitleDocumentNext(this.viewBodyNode||this.viewNode,t,this.explorer,this,null,e)},_getCurrentPageData:function(e,t,i){this.userName=(layout.desktop.session.user||layout.user).distinguishedName;var s=true;if(!this.loaded){this.loaded=true;var n=this.explorer.data.planNextList||[];if(e)e({data:n})}else{this.explorer.explorer.listPlanNext(this.explorer.data.id,this.loaded,function(t){this.loaded=true;t.sort(function(t,e){return t.orderNumber-e.orderNumber});if(e)e({data:t})}.bind(this))}},_postCreateViewBody:function(t){if(this.getStatus()=="write"&&this.options.isEdited){this.explorer.titleInput=new Element("textarea",{placeholder:"请填写标题",styles:this.css.textarea}).inject(this.container);this.explorer.explorer.nextMonth_inputTitle.push(this.explorer.titleInput);if(this.explorer.currentPersonData){this.explorer.titleInput.set("text",this.explorer.currentPersonData.title);this.explorer.titleInput.set("value",this.explorer.currentPersonData.title)}this.explorer.titleInput.addEvent("blur",function(t){this.explorer.savePersonPlan(t,"标题保存并上传成功")}.bind(this))}},getStatus:function(){if(!this.status){this.status=this.explorer.options.status}return this.status}});MWF.xApplication.Report.StrategyExplorer.PlanTitleDocumentNext=new Class({Extends:MWF.xApplication.Template.Explorer.ComplexDocument,open:function(){this.view._openDocument(this.data)},edit:function(t,e){this.app.common.editPlan(this.data,this.view.report.data,this.explorer.data,this.view,true);e.stopPropagation()},delete:function(t,e){this.app.common.deletePlanNext(this.data,e,function(){this.view.reload()}.bind(this));e.stopPropagation()},_postCreateDocumentNode:function(t,e){if(this.view.getStatus()=="write"&&this.view.options.isEdited){if(e.targetPerson==this.view.userName){t.setStyle("display","none");this.explorer.currentPersonData=e}}}});
|