MWF.xApplication.process = MWF.xApplication.process || {}; MWF.xApplication.process.Work = MWF.xApplication.process.Work || {}; MWF.xDesktop.requireApp("process.Work", "lp."+MWF.language, null, false); MWF.xDesktop.requireApp("process.Xform", "Org", null, false); MWF.xApplication.process.Work.Processor = new Class({ Extends: MWF.widget.Common, Implements: [Options, Events], options: { "style": "default", "mediaNode": null, "opinion": "", "tabletWidth" : 0, "tabletHeight" : 0, "orgHeight" : 276, "maxOrgCountPerline" : 2 }, initialize: function(node, task, options, form){ this.setOptions(options); this.path = "/x_component_process_Work/$Processor/"; this.cssPath = "/x_component_process_Work/$Processor/"+this.options.style+"/css.wcss"; this._loadCss(); this.task = task; this.node = $(node); this.selectedRoute = null; this.form = form; this.load(); }, load: function(){ this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.node); this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.node); this.routeOpinionTile = new Element("div", {"styles": this.css.routeOpinionTile, "text": MWF.xApplication.process.Work.LP.inputOpinion}).inject(this.node); this.routeOpinionArea = new Element("div", {"styles": this.css.routeOpinionArea}).inject(this.node); this.setOpinion(); this.orgsArea = new Element("div", {"styles": this.css.orgsArea}).inject(this.node); this.orgsTile = new Element("div", {"styles": this.css.orgsTitle, "text": MWF.xApplication.process.Work.LP.selectPerson}).inject(this.orgsArea); this.buttonsArea = new Element("div", {"styles": this.css.buttonsArea}).inject(this.node); this.setButtons(); this.setRouteList(); this.fireEvent("postLoad"); }, setRouteList: function(){ var _self = this; //this.task.routeNameList = ["送审核", "送办理", "送公司领导阅"]; var routeList = this.getRouteDataList(); //this.task.routeNameList.each(function(route, i){ routeList.each(function(route, i){ if( route.hiddenScriptText ){ if( this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true" )return; } var routeName = route.name; if( route.displayNameScriptText ){ routeName = this.form.Macro.exec(route.displayNameScriptText, this); } var routeNode = new Element("div", {"styles": this.css.routeNode}).inject(this.routeSelectorArea); var routeIconNode = new Element("div", {"styles": this.css.routeIconNode}).inject(routeNode); var routeTextNode = new Element("div", {"styles": this.css.routeTextNode, "text": routeName}).inject(routeNode); routeNode.store( "route", this.task.routeList[i] ); routeNode.store( "routeName", route.name ); routeNode.addEvents({ "mouseover": function(e){_self.overRoute(this);}, "mouseout": function(e){_self.outRoute(this);}, "click": function(e){_self.selectRoute(this);} }); if (routeList.length==1){ this.selectRoute(routeNode); }else{ this.setSize(0); } }.bind(this)); }, overRoute: function(node){ if (this.selectedRoute){ if (this.selectedRoute.get("text") != node.get("text")){ node.setStyle("background-color", "#f7e1d0"); } }else{ node.setStyle("background-color", "#f7e1d0"); } }, outRoute: function(node){ if (this.selectedRoute){ if (this.selectedRoute.get("text") != node.get("text")){ node.setStyles(this.css.routeNode); } }else{ node.setStyles(this.css.routeNode); } }, selectRoute: function(node){ if (this.selectedRoute){ if (this.selectedRoute.get("text") != node.get("text")){ this.selectedRoute.setStyles(this.css.routeNode); this.selectedRoute.getFirst().setStyles(this.css.routeIconNode); this.selectedRoute.getLast().setStyles(this.css.routeTextNode); this.selectedRoute = node; node.setStyle("background-color", "#da7429"); node.getFirst().setStyle("background-image", "url("+"/x_component_process_Work/$Processor/default/checked.png)"); node.getLast().setStyle("color", "#FFF"); }else{ this.selectedRoute.setStyles(this.css.routeNode); this.selectedRoute.getFirst().setStyles(this.css.routeIconNode); this.selectedRoute.getLast().setStyles(this.css.routeTextNode); this.selectedRoute = null; } }else{ this.selectedRoute = node; node.setStyle("background-color", "#da7429"); node.getFirst().setStyle("background-image", "url("+"/x_component_process_Work/$Processor/default/checked.png)"); node.getLast().setStyle("color", "#FFF"); } this.routeSelectorArea.setStyle("background-color", "#FFF"); this.loadOrgs( this.selectedRoute ? this.selectedRoute.retrieve("route") : "" ); }, setOpinion: function(){ this.selectIdeaNode = new Element("div", {"styles": this.css.selectIdeaNode}).inject(this.routeOpinionArea); this.selectIdeaScrollNode = new Element("div", {"styles": this.css.selectIdeaScrollNode}).inject(this.selectIdeaNode); this.selectIdeaAreaNode = new Element("div", {"styles": { "overflow": "hidden" }}).inject(this.selectIdeaScrollNode); this.inputOpinionNode = new Element("div", {"styles": this.css.inputOpinionNode}).inject(this.routeOpinionArea); this.inputTextarea = new Element("textarea", {"styles": this.css.inputTextarea, "value": this.options.opinion || MWF.xApplication.process.Work.LP.inputText}).inject(this.inputOpinionNode); this.inputTextarea.addEvents({ "focus": function(){if (this.get("value")==MWF.xApplication.process.Work.LP.inputText) this.set("value", "");}, "blur": function(){if (!this.get("value")) this.set("value", MWF.xApplication.process.Work.LP.inputText);}, "keydown": function(){this.inputTextarea.setStyles( this.inputTextareaStyle || this.css.inputTextarea);}.bind(this) }); this.mediaActionArea = new Element("div", {"styles": this.css.inputOpinionMediaActionArea}).inject(this.inputOpinionNode); this.handwritingAction = new Element("div", {"styles": this.css.inputOpinionHandwritingAction, "text": MWF.xApplication.process.Work.LP.handwriting}).inject(this.mediaActionArea); this.handwritingAction.addEvent("click", function(){ this.handwriting(); }.bind(this)); // if (navigator.getUserMedia || navigator.webkitGetUserMedia || navigator.mozGetUserMedia || navigator.msGetUserMedia){ // this.audioRecordAction = new Element("div", {"styles": this.css.inputOpinionAudioRecordAction, "text": MWF.xApplication.process.Work.LP.audioRecord}).inject(this.mediaActionArea); // this.audioRecordAction.addEvent("click", function(){ // this.audioRecord(); // }.bind(this)); // } if (layout.mobile){ this.selectIdeaNode.inject(this.routeOpinionArea, "after"); } MWF.require("MWF.widget.ScrollBar", function(){ new MWF.widget.ScrollBar(this.selectIdeaScrollNode, { "style":"small", "where": "before", "distance": 30, "friction": 4, "indent": false, "axis": {"x": false, "y": true} }); }.bind(this)); MWF.require("MWF.widget.UUID", function(){ MWF.UD.getDataJson("idea", function(json){ if (json){ if (json.ideas){ this.setIdeaList(json.ideas); } }else{ MWF.UD.getPublicData("idea", function(pjson){ if (pjson){ if (pjson.ideas){ this.setIdeaList(pjson.ideas); } } }.bind(this)); } }.bind(this)); }.bind(this)); }, audioRecord: function(){ if (!this.audioRecordNode) this.createAudioRecord(); this.audioRecordNode.show(); this.audioRecordNode.position({ "relativeTo": this.options.mediaNode || this.node, "position": "center", "edge": "center" }); MWF.require("MWF.widget.AudioRecorder", function () { this.audioRecorder = new MWF.widget.AudioRecorder(this.audioRecordNode, { "onSave" : function( blobFile ){ this.soundFile = blobFile; this.audioRecordNode.hide(); // this.page.get("div_image").node.set("src",base64Image); }.bind(this), "onCancel": function(){ this.soundFile = null; this.audioRecordNode.hide(); }.bind(this) }, null ); }.bind(this)); }, createAudioRecord: function(){ this.audioRecordNode = new Element("div", {"styles": this.css.handwritingNode}).inject(this.node, "after"); var size = (this.options.mediaNode || this.node).getSize(); // var y = Math.max(size.y, 320); // var x = Math.max(size.x, 400); // for (k in this.node.style){ // if (this.node.style[k]) this.audioRecordNode.style[k] = this.node.style[k]; // } var zidx = this.node.getStyle("z-index"); this.audioRecordNode.setStyles({ "height": ""+size.y+"px", "width": ""+size.x+"px", "z-index": zidx+1 }); }, handwriting: function(){ if (!this.handwritingNode) this.createHandwriting(); if(this.handwritingNodeMask)this.handwritingNodeMask.show(); this.handwritingNode.show(); this.handwritingNode.position({ "relativeTo": this.options.mediaNode || this.node, "position": "center", "edge": "center" }); }, createHandwriting: function(){ this.handwritingNodeMask = new Element("div", {"styles": this.css.handwritingMask}).inject(this.node); this.handwritingNode = new Element("div", {"styles": this.css.handwritingNode}).inject(this.node, "after"); //var size = (this.options.mediaNode || this.node).getSize(); //var y = size.y; //var x = size.x; //兼容以前的默认高宽 var x = 600; var y = 320; if (!layout.mobile){ x = Math.max( this.options.tabletWidth || x , 500); y = Math.max(this.options.tabletHeight ? (parseInt(this.options.tabletHeight) + 110) : y, 320); //y = Math.max(size.y, 320); //x = Math.max(size.x, 480); } // for (k in this.node.style){ // if (this.node.style[k]) this.handwritingNode.style[k] = this.node.style[k]; // } var zidx = this.node.getStyle("z-index"); this.handwritingNode.setStyles({ "height": ""+y+"px", "width": ""+x+"px", "z-index": zidx+1 }); if( layout.mobile ){ this.handwritingNode.addEvent('touchmove' , function(e){ e.preventDefault(); }) } this.handwritingNode.position({ "relativeTo": this.options.mediaNode || this.node, "position": "center", "edge": "center" }); this.handwritingAreaNode = new Element("div", {"styles": this.css.handwritingAreaNode}).inject(this.handwritingNode); this.handwritingActionNode = new Element("div", {"styles": this.css.handwritingActionNode, "text": MWF.xApplication.process.Work.LP.saveWrite}).inject(this.handwritingNode); var h = this.handwritingActionNode.getSize().y+this.handwritingActionNode.getStyle("margin-top").toInt()+this.handwritingActionNode.getStyle("margin-bottom").toInt(); h = y - h; this.handwritingAreaNode.setStyle("height", ""+h+"px"); MWF.require("MWF.widget.Tablet", function () { this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, { "style": "default", "contentWidth" : this.options.tabletWidth || 0, "contentHeight" : this.options.tabletHeight || 0, "onSave" : function( base64code, base64Image, imageFile ){ this.handwritingFile = imageFile; this.handwritingNode.hide(); this.handwritingNodeMask.hide(); // this.page.get("div_image").node.set("src",base64Image); }.bind(this), "onCancel": function(){ this.handwritingFile = null; this.handwritingNode.hide(); this.handwritingNodeMask.hide(); }.bind(this) }, null ); this.tablet.load(); }.bind(this)); this.handwritingActionNode.addEvent("click", function(){ //this.handwritingNode.hide(); if (this.tablet) this.tablet.save(); }.bind(this)); }, setIdeaList: function(ideas){ var _self = this; ideas.each(function(idea){ new Element("div", { "styles": this.css.selectIdeaItemNode, "text": idea, "events": { "click": function(){ if (_self.inputTextarea.get("value")==MWF.xApplication.process.Work.LP.inputText){ _self.inputTextarea.set("value", this.get("text")); }else{ _self.inputTextarea.set("value", _self.inputTextarea.get("value")+", "+this.get("text")); } }, "dblclick": function(){ if (_self.inputTextarea.get("value")==MWF.xApplication.process.Work.LP.inputText){ _self.inputTextarea.set("value", this.get("text")); }else{ _self.inputTextarea.set("value", _self.inputTextarea.get("value")+", "+this.get("text")); } }, "mouseover": function(){this.setStyles(_self.css.selectIdeaItemNode_over);}, "mouseout": function(){this.setStyles(_self.css.selectIdeaItemNode);} } }).inject(this.selectIdeaAreaNode); }.bind(this)); }, setButtons: function(){ this.cancelButton = new Element("div", {"styles": this.css.cancelButton}).inject(this.buttonsArea); var iconNode = new Element("div", {"styles": this.css.cancelIconNode}).inject(this.cancelButton); var textNode = new Element("div", {"styles": this.css.cancelTextNode, "text": MWF.xApplication.process.Work.LP.cancel}).inject(this.cancelButton); this.okButton = new Element("div", {"styles": this.css.okButton}).inject(this.buttonsArea); var iconNode = new Element("div", {"styles": this.css.okIconNode}).inject(this.okButton); var textNode = new Element("div", {"styles": this.css.okTextNode, "text": MWF.xApplication.process.Work.LP.ok}).inject(this.okButton); this.cancelButton.addEvent("click", function(){ this.destroy(); this.fireEvent("cancel"); }.bind(this)); this.okButton.addEvent("click", function( ev ){ if (!this.selectedRoute) { this.routeSelectorArea.setStyle("background-color", "#ffe9e9"); //new mBox.Notice({ // type: "error", // position: {"x": "center", "y": "top"}, // move: false, // target: this.routeSelectorArea, // delayClose: 6000, // content: MWF.xApplication.process.Work.LP.mustSelectRoute //}); MWF.xDesktop.notice( "error", {"x": "center", "y": "top"}, MWF.xApplication.process.Work.LP.mustSelectRoute, this.routeSelectorArea, null, //{"x": 0, "y": 30} { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return false; } debugger; var routeName = this.selectedRoute.retrieve("routeName") || this.selectedRoute.get("text"); var opinion = this.inputTextarea.get("value"); if (opinion === MWF.xApplication.process.Work.LP.inputText) opinion = ""; var medias = []; if (this.handwritingFile) medias.push(this.handwritingFile); if (this.soundFile) medias.push(this.soundFile); if (this.videoFile) medias.push(this.videoFile); var currentRouteId = this.selectedRoute.retrieve("route"); var routeData = this.getRouteData( currentRouteId ); if( !opinion && medias.length === 0 ){ if( routeData.opinionRequired == true ){ this.inputTextarea.setStyle("background-color", "#ffe9e9"); //new mBox.Notice({ // type: "error", // position: {"x": "center", "y": "top"}, // move: false, // target: this.inputTextarea, // delayClose: 6000, // content: MWF.xApplication.process.Work.LP.opinionRequired //}); MWF.xDesktop.notice( "error", {"x": "center", "y": "top"}, MWF.xApplication.process.Work.LP.opinionRequired, this.inputTextarea, null, //{"x": 0, "y": 30} { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return false; } } var appendTaskOrgItem = ""; if( routeData.type === "appendTask" && routeData.appendTaskIdentityType === "select" ){ if( !this.orgItems || this.orgItems.length === 0 ){ //new mBox.Notice({ // type: "error", // position: {"x": "center", "y": "top"}, // move: false, // target: this.orgsArea, // delayClose: 6000, // content: MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig //"没有配置转交人,请联系管理员" //}); MWF.xDesktop.notice( "error", {"x": "center", "y": "center"}, MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig, this.node, null, //{"x": 0, "y": 30} { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return false; }else{ appendTaskOrgItem = this.orgItems[0] } } this.saveOrgsWithCheckEmpower( function(){ var array = [routeName, opinion, medias]; if( appendTaskOrgItem ){ var appandTaskIdentityList = appendTaskOrgItem.getData(); if( !appandTaskIdentityList || appandTaskIdentityList.length === 0){ //new mBox.Notice({ // type: "error", // position: {"x": "center", "y": "top"}, // move: false, // target: this.orgsArea, // delayClose: 6000, // content: MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice //"请选择转交人" //}); MWF.xDesktop.notice( "error", {"x": "center", "y": "center"}, MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice, this.node, {"x": 0, "y": 30}, { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return; }else{ array.push( appendTaskOrgItem.getData() ); appendTaskOrgItem.setData([]); } } debugger; if( routeData.validationScriptText ){ var validation = this.form.Macro.exec(routeData.validationScriptText, this); if( !validation || validation.toString() !== "true" ){ if( typeOf(validation) === "string" ){ MWF.xDesktop.notice( "error", {"x": "center", "y": "center"}, validation, this.node, {"x": 0, "y": 30}, { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return false; }else{ //"路由校验失败" MWF.xDesktop.notice( "error", {"x": "center", "y": "center"}, MWF.xApplication.process.Work.LP.routeValidFailure, this.node, {"x": 0, "y": 30}, { "closeOnBoxClick" : true, "closeOnBodyClick" : true, "fixed" : true, "delayClose" : 6000 } ); return false; } } } this.node.mask({ "inject": {"where": "bottom", "target": this.node}, "destroyOnHide": true, "style": { "background-color": "#999", "opacity": 0.3, "z-index":600 } }); this.fireEvent("submit", array ); }.bind(this)) }.bind(this)); }, destroy: function(){ this.node.empty(); delete this.task; delete this.node; delete this.routeSelectorTile; delete this.routeSelectorArea; delete this.routeOpinionTile; delete this.routeOpinionArea; delete this.buttonsArea; delete this.inputOpinionNode; delete this.inputTextarea; delete this.cancelButton; delete this.okButton; }, getRouteDataList : function(){ if( !this.routeDataList ){ o2.Actions.get("x_processplatform_assemble_surface").listRoute( {"valueList":this.task.routeList} , function( json ){ json.data.each( function(d){ d.selectConfigList = JSON.parse( d.selectConfig || "[]" ); }.bind(this)); this.routeDataList = json.data; }.bind(this), null, false ); } return this.routeDataList; }, getRouteData : function( routeId ){ var routeList = this.getRouteDataList(); for( var i=0; i 0 ){ if( this.orgsTile )height = height + this.getOffsetY(this.orgsTile) + this.orgsTile.getStyle("height").toInt(); height = height + lines*this.options.orgHeight + this.getOffsetY(this.orgsArea); this.node.setStyle( "height", height ); //flag = (lines*this.options.orgHeight + 431) > Math.floor( this.form.app.content.getSize().y * 0.9); //this.node.store("height", Math.min( Math.floor( this.form.app.content.getSize().y * 0.9) , lines*this.options.orgHeight + 431 )); }else{ this.node.setStyle( "height", height ); //this.node.store("height", 401 ); } if( this.getMaxOrgLength() > 1 ){ this.node.setStyles( this.css.node_wide ); this.inputOpinionNode.setStyles( this.css.inputOpinionNode_wide ); this.inputTextarea.setStyles( this.css.inputTextarea_wide ); this.inputTextareaStyle = this.css.inputTextarea_wide; this.selectIdeaNode.setStyles( this.css.selectIdeaNode_wide ); }else{ this.node.setStyles( this.css.node ); this.inputOpinionNode.setStyles( this.css.inputOpinionNode ); this.inputTextarea.setStyles( this.css.inputTextarea ); this.inputTextareaStyle = this.css.inputTextarea; this.selectIdeaNode.setStyles( this.css.selectIdeaNode ); } //this.node.store("width", this.node.getStyle("width").toInt() + ( flag ? 20 : 0 )); this.fireEvent("resize"); }, validationOrgs : function(){ if( !this.orgItems || !this.orgItems.length )return true; var flag = true; this.orgItems.each( function(item){ if( !item.validation() )flag = false; }.bind(this)); return flag; }, isOrgsHasEmpower: function(){ if( !this.orgItems || !this.orgItems.length )return true; var flag = false; this.needCheckEmpowerOrg = []; this.orgItems.each( function(item){ if( item.hasEmpowerIdentity() ){ this.needCheckEmpowerOrg.push(item); flag = true; } }.bind(this)); return flag; }, saveOrgs : function( keepSilent ){ if( !this.orgItems || !this.orgItems.length )return true; var flag = true; this.orgItems.each( function(item){ if( !item.save( !keepSilent ) )flag = false; }.bind(this)); return flag; }, saveOrgsWithCheckEmpower : function( callback ){ if( !this.orgItems || !this.orgItems.length ){ if( callback )callback(); return true; } if( !this.validationOrgs() )return false; if( !this.isOrgsHasEmpower() ){ if( callback )callback(); return true; } //this.checkEmpowerMode = true; this.showEmpowerDlg( callback ); }, showEmpowerDlg : function( callback ){ //this.empowerMask = new Element("div", {"styles": this.css.handwritingMask}).inject(this.node); //this.needCheckEmpowerOrg.each( function(org){ // org.saveCheckedEmpowerData(); //}.bind(this)); var empowerNode = new Element("div.empowerNode", {"styles": this.css.empowerNode}); var empowerTitleNode = new Element("div",{ text : MWF.xApplication.process.Xform.LP.empowerDlgText, styles : this.css.empowerTitleNode }).inject(empowerNode); var orgs = this.needCheckEmpowerOrg; var len = orgs.length; var lines = ((len+1)/2).toInt(); var empowerTable = new Element("table",{ "cellspacing" : 0, "cellpadding" : 0, "border" : 0, "width" : "100%", "styles" : this.css.empowerTable }).inject( empowerNode ); for (var n=0; n 1 ){ // width = "840" //}else{ // width = "420" //} empowerNode.setStyle( "width", width+"px" ); this.node.getParent().mask( { "style": this.css.mask }); this.empowerDlg = o2.DL.open({ "title": MWF.xApplication.process.Xform.LP.selectEmpower, "style": this.form.json.dialogStyle || "user", "isResize": false, "content": empowerNode, //"container" : this.node, "width": width, //600, "height": "auto", //dlgHeight, "mark" : false, "buttonList": [ { "type" : "ok", "text": MWF.LP.process.button.ok, "action": function(d, e){ //if (this.empowerDlg) this.empowerDlg.okButton.click(); orgs.each( function( org, i ){ org.saveCheckedEmpowerData( function(){ if( i === orgs.length-1 ){ if( callback )callback(); this.node.getParent().unmask(); this.empowerDlg.close(); } }.bind(this)) }.bind(this)) }.bind(this) }, { "type" : "cancel", "text": MWF.LP.process.button.cancel, "action": function(){ this.node.getParent().unmask(); this.empowerDlg.close(); }.bind(this) } ] }); } }); MWF.xApplication.process.Work.Processor.Org = new Class({ Implements: [Options, Events], options: { moduleEvents : ["queryLoadSelector","postLoadSelector","queryLoadCategory","postLoadCategory","selectCategory", "unselectCategory","queryLoadItem","postLoadItem","selectItem", "unselectItem","change"] }, initialize: function (container, form, json, processor, options) { this.form = form; this.json = json; this.processor = processor; this.container = $(container); this.orgAction = MWF.Actions.get("x_organization_assemble_control"); this.setOptions(options); }, load : function(){ var options = this.getOptions(); if(options){ this.selector = new MWF.O2Selector(this.container, options); } }, _getOrgOptions: function(){ this.selectTypeList = typeOf( this.json.selectType ) == "array" ? this.json.selectType : [this.json.selectType]; if( this.selectTypeList.contains( "identity" ) ) { this.identityOptions = new MWF.xApplication.process.Work.Processor.IdentityOptions(this.form, this.json); } if( this.selectTypeList.contains( "unit" ) ) { this.unitOptions = new MWF.xApplication.process.Work.Processor.UnitOptions(this.form, this.json); } //if( this.selectTypeList.contains( "group" ) ){ // this.groupOptions = new MWF.APPOrg.GroupOptions( this.form, this.json ); //} }, getOptions: function(){ var _self = this; this._getOrgOptions(); if( this.selectTypeList.length === 0 )return false; var exclude = []; if( this.json.exclude ){ var v = this.form.Macro.exec(this.json.exclude.code, this); exclude = typeOf(v)==="array" ? v : [v]; } var identityOpt; if( this.identityOptions ){ identityOpt = this.identityOptions.getOptions(); if (this.json.identityRange!=="all"){ if ( !identityOpt.noUnit && (!identityOpt.units || !identityOpt.units.length) ){ this.form.notice(MWF.xApplication.process.Xform.LP.noIdentitySelectRange, "error", this.node); return false; } } if ( !identityOpt.noUnit && this.json.dutyRange && this.json.dutyRange!=="all"){ if (!identityOpt.dutys || !identityOpt.dutys.length){ this.form.notice(MWF.xApplication.process.Xform.LP.noIdentityDutySelectRange, "error", this.node); return false; } } identityOpt.values = this.getValue(); identityOpt.exclude = exclude; } var unitOpt; if( this.unitOptions ){ unitOpt = this.unitOptions.getOptions(); if (this.json.unitRange!=="all"){ if ( !unitOpt.units || !unitOpt.units.length){ this.form.notice(MWF.xApplication.process.Xform.LP.noUnitSelectRange, "error", this.node); return false; } } unitOpt.values = this.getValue(); unitOpt.exclude = exclude; } //var groupOpt; //if( this.groupOptions ){ // groupOpt = this.groupOptions.getOptions(); // groupOpt.values = (this.json.isInput) ? [] : values; // groupOpt.exclude = exclude; //} var defaultOpt = { "style" : "process", "width" : "auto", "height" : "240", "embedded" : true, "hasLetter" : false, //字母 "hasTop" : true, //可选、已选的标题 "hasShuttle" : true //穿梭按钮 }; debugger; if( this.json.events && typeOf(this.json.events) === "object" ){ Object.each(this.json.events, function(e, key){ if (e.code){ if (this.options.moduleEvents.indexOf(key)!==-1){ //this.addEvent(key, function(event){ // return this.form.Macro.fire(e.code, this, event); //}.bind(this)); if( key === "postLoadSelector" ) { this.addEvent("loadSelector", function (selector) { return this.form.Macro.fire(e.code, selector); }.bind(this)) }else if( key === "queryLoadSelector"){ defaultOpt["onQueryLoad"] = function(target){ return this.form.Macro.fire(e.code, target); }.bind(this) }else{ defaultOpt["on"+key.capitalize()] = function(target){ return this.form.Macro.fire(e.code, target); }.bind(this) } } } }.bind(this)); } if( this.form.json.selectorStyle ){ defaultOpt = Object.merge( Object.clone(this.form.json.selectorStyle), defaultOpt ); if( this.form.json.selectorStyle.style )defaultOpt.style = this.form.json.selectorStyle.style; } if( this.selectTypeList.length === 1 ){ return Object.merge( defaultOpt, { "type": this.selectTypeList[0], "onLoad": function(){ //this 为 selector _self.selectOnLoad(this, this.selector ) } //"onComplete": function(items){ // this.selectOnComplete(items); //}.bind(this), //"onCancel": this.selectOnCancel.bind(this), //"onClose": this.selectOnClose.bind(this) }, identityOpt || unitOpt ) }else if( this.selectTypeList.length > 1 ){ var options = { "type" : "", "types" : this.selectTypeList, "onLoad": function(){ //this 为 selector _self.selectOnLoad(this) } //"onComplete": function(items){ // this.selectOnComplete(items); //}.bind(this), //"onCancel": this.selectOnCancel.bind(this), //"onClose": this.selectOnClose.bind(this) }; if( identityOpt ){ options.identityOptions = Object.merge( defaultOpt, identityOpt); } if( unitOpt ){ options.unitOptions = Object.merge( defaultOpt, unitOpt); } //if( groupOpt )options.groupOptions = groupOpt; return options; } }, //selectOnComplete: function(items){ // var array = []; // items.each(function(item){ // array.push(item.data); // }.bind(this)); // this.checkEmpower( array, function( data ){ // var values = []; // data.each(function(d){ // values.push(MWF.org.parseOrgData(d, true)); // }.bind(this)); // // this.setData(values); // //this.validationMode(); // //this.validation(); // this.fireEvent("select"); // }.bind(this)) //}, //selectOnCancel: function(){ // //this.validation(); //}, selectOnLoad: function( selector ){ //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none"); this.fireEvent("loadSelector", [selector]) }, //selectOnClose: function(){ // //v = this._getBusinessData(); // //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block"); //}, hasEmpowerIdentity : function(){ var data = this.getData(); if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor); return this.empowerChecker.hasEmpowerIdentity( data ); }, checkEmpower : function( data, callback, container, selectAllNode ){ if( typeOf(data)==="array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity" ) { if(!this.empowerChecker )this.empowerChecker = new MWF.xApplication.process.Work.Processor.EmpowerChecker(this.form, this.json, this.processor); this.empowerChecker.selectAllNode = selectAllNode; this.empowerChecker.load(data, callback, container); }else{ if( callback )callback( data ); } }, loadCheckEmpower : function( callback, container, selectAllNode ){ this.checkEmpower( this.getData(), callback, container, selectAllNode) }, saveCheckedEmpowerData:function( callback ){ var data = this.getData(); this.empowerChecker.replaceEmpowerIdentity(data, function( newData ){ var values = []; newData.each(function(d){ values.push(MWF.org.parseOrgData(d, true)); }.bind(this)); this.setData( values ); if( callback )callback(values) }.bind(this)) }, //saveWithCheckEmpower: function( isValid, callback ){ // var checkEmpowerData = function(){ // var array = this.getData(); // this.checkEmpower( array, function( data ){ // var values = []; // data.each(function(d){ // values.push(MWF.org.parseOrgData(d, true)); // }.bind(this)); // this.setData( values ); // if( callback )callback(values) // }.bind(this), container, selectAllNode) // }.bind(this) // if( isValid ){ // if( this.validation() ){ // checkEmpowerData( function(){ // if(callback)callback(); // }.bind(this)); // return true; // }else{ // return false; // } // }else{ // //this.setData( this.getData() ); // checkEmpowerData( function(){ // if(callback)callback(); // }.bind(this)); // return true; // } //}, save: function( isValid ){ if( isValid ){ if( this.validation() ){ return true; }else{ return false; } }else{ this.setData( this.getData() ); return true; } }, resetSelectorData : function(){ if( this.selector && this.selector.selector ){ this.selector.selector.emptySelectedItems(); this.selector.selector.options.values = this.getValue(); this.selector.selector.setSelectedItem(); } }, resetData: function(){ var v = this.getValue(); //this.setData((v) ? v.join(", ") : ""); this.setData(v); }, getData: function(){ if( this.selector ){ return this.getSelectedData(); }else{ return this.getValue(); } }, getSelectedData : function(){ var data = []; if( this.selector && this.selector.selector){ this.selector.selector.selectedItems.each( function( item ){ data.push( MWF.org.parseOrgData(item.data) ); }) } return data; }, getValue: function(){ var value = this._getBusinessData(); if (!value) value = this._computeValue(); return value || ""; }, _computeValue: function(){ var values = []; if (this.json.identityValue) { this.json.identityValue.each(function(v){ if (v) values.push(v)}); } if (this.json.unitValue) { this.json.unitValue.each(function(v){ if (v) values.push(v)}); } if (this.json.dutyValue) { var dutys = JSON.decode(this.json.dutyValue); var par; if (dutys.length){ dutys.each(function(duty){ if (duty.code) par = this.form.Macro.exec(duty.code, this); var code = "return this.org.getDuty(\""+duty.name+"\", \""+par+"\")"; var d = this.form.Macro.exec(code, this); if (typeOf(d)!=="array") d = (d) ? [d.toString()] : []; d.each(function(dd){if (dd) values.push(dd);}); }.bind(this)); } } if (this.json.defaultValue && this.json.defaultValue.code){ var fd = this.form.Macro.exec(this.json.defaultValue.code, this); if (typeOf(fd)!=="array") fd = (fd) ? [fd] : []; fd.each(function(fdd){ if (fdd){ if (typeOf(fdd)==="string"){ var data; this.getOrgAction()[this.getValueMethod(fdd)](function(json){ data = json.data }.bind(this), null, fdd, false); values.push(data); }else{ values.push(fdd); } } }.bind(this)); } if (this.json.count>0){ return values.slice(0, this.json.count); } return values; //return (this.json.defaultValue.code) ? this.form.Macro.exec(this.json.defaultValue.code, this): (value || ""); }, getOrgAction: function(){ if (!this.orgAction) this.orgAction = MWF.Actions.get("x_organization_assemble_control"); //if (!this.orgAction) this.orgAction = new MWF.xApplication.Selector.Actions.RestActions(); return this.orgAction; }, setData: function(value){ if (!value) return false; var oldValues = this.getValue(); var values = []; var type = typeOf(value); if (type==="array"){ value.each(function(v){ var vtype = typeOf(v); var data = null; if (vtype==="string"){ this.getOrgAction()[this.getValueMethod(v)](function(json){ data = MWF.org.parseOrgData(json.data); }.bind(this), error, v, false); } if (vtype==="object") data = v; if (data)values.push(data); }.bind(this)); } if (type==="string"){ var vData; this.getOrgAction()[this.getValueMethod(value)](function(json){ vData = MWF.org.parseOrgData(json.data); }.bind(this), error, value, false); if (vData)values.push(vData); } if (type==="object")values.push(value); var change = false; if (oldValues.length && values.length){ if (oldValues.length === values.length){ for (var i=0; i 0) { o2.Actions.get("x_organization_assemble_express").listEmpowerWithIdentity({ "application": (this.form.businessData.work || this.form.businessData.workCompleted).application, "process": (this.form.businessData.work || this.form.businessData.workCompleted).process, "identityList": array }, function (json) { var arr = []; json.data.each(function (d) { if (d.fromIdentity !== d.toIdentity) arr.push(d); }); if (arr.length > 0) { flag = true; } }.bind(this), null, false) } } return flag; }, openSelectEmpowerDlg : function( data, orgData, callback, container ){ var node = new Element("div", {"styles": this.css.empowerAreaNode}); //var html = "
"+MWF.xApplication.process.Xform.LP.empowerDlgText+"
"; var html = "
"; node.set("html", html); var itemNode = node.getLast(); this.getEmpowerItems(itemNode, data); node.inject( container || this.container ); if( this.selectAllNode ){ var selectNode = this.createSelectAllEmpowerNode(); selectNode.inject( this.selectAllNode ); if( this.checkedAllItems ){ selectNode.store("isSelected", true); selectNode.setStyles( this.css.empowerSelectAllItemNode_selected ); } } }, getSelectedData : function( callback ){ var json = {}; this.empowerSelectNodes.each(function(node){ if( node.retrieve("isSelected") ){ var d = node.retrieve("data"); json[ d.fromIdentity ] = d; } }.bind(this)); if( callback )callback( json ); } }); MWF.xApplication.process.Work.Processor.UnitOptions = new Class({ Extends : MWF.APPOrg.UnitOptions }); MWF.xApplication.process.Work.Processor.IdentityOptions = new Class({ Extends : MWF.APPOrg.IdentityOptions });