MWF.xApplication.process = MWF.xApplication.process || {}; MWF.xApplication.process.Work = MWF.xApplication.process.Work || {}; MWF.xDesktop.requireApp("process.Work", "lp."+MWF.language, null, false); //兼容快速流转,所以需要判断 if( MWF.xApplication.process.Xform && MWF.xApplication.process.Xform.Form ){ 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, "isManagerProcess" : false //是否为管理员提交 }, 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(){ if( !this.form && this.options.isManagerProcess ){ this.managerProcessNoticeNode = new Element("div", {"styles": this.css.managerProcessNoticeNode, "html": MWF.xApplication.process.Work.LP.managerProcessNotice}).inject(this.node); this.managerLoginNode = new Element("div", {"styles": this.css.managerLoginNode, "text": MWF.xApplication.process.Work.LP.managerLogin }).inject(this.node); this.managerLoginNode.addEvent("click", function(ev){ this.managerLogin(ev); }.bind(this)); //var text = MWF.xApplication.process.Work.LP.managerLoginReturn.replace( "{user}", layout.session.user.name ); //this.managerLoginReturnNode = new Element("div", {"styles": this.css.managerLoginNode, "text": text }).inject(this.node); //this.managerLoginReturnNode.hide(); //this.managerPerson = layout.session.user.distinguishedName; //this.managerLoginReturnNode.addEvent("click", function(ev){ // this.managerLoginReturn(ev); //}.bind(this)) } 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(); if( this.form ){ if( layout.mobile ){ 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.orgsArea.hide() }else{ 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(); if( this.form ){ if( layout.mobile ){ this.getRouteGroupList(); if( this.hasDecisionOpinion ){ this.routeContainer = new Element("div", { "styles" : this.css.routeContainer }).inject(this.routeOpinionTile, "before"); this.routeGroupTitle = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRouteGroup }).inject(this.routeContainer); this.routeGroupArea = new Element("div", { "styles": this.css.routeSelectorArea }).inject(this.routeContainer); this.routeSelectorTile = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeContainer); this.routeSelectorArea = new Element("div", { "styles": this.css.routeSelectorArea }).inject(this.routeContainer); this.setRouteGroupList(); }else{ this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before"); this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after"); this.setRouteList(); } }else{ this.getRouteGroupList(); if( this.hasDecisionOpinion ){ //if( this.getMaxOrgLength() > 1 ){ this.routeContainer = new Element("div", { "styles" : this.css.routeContainer }).inject(this.routeOpinionTile, "before"); this.routeLeftWarper = new Element("div", { "styles": this.getMaxOrgLength() > 1 ? this.css.routeLeftWarper : this.css.routeLeftWarper_single }).inject(this.routeContainer); this.routeGroupTitle = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRouteGroup }).inject(this.routeLeftWarper); this.routeGroupArea = new Element("div", { "styles": this.css.routeSelectorArea_hasGroup }).inject(this.routeLeftWarper); this.routeRightWarper = new Element("div", { "styles": this.getMaxOrgLength() > 1 ? this.css.routeRightWarper : this.css.routeRightWarper_single }).inject(this.routeContainer); this.routeSelectorTile = new Element("div", { "styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeRightWarper); this.routeSelectorArea = new Element("div", { "styles": this.css.routeSelectorArea_hasGroup }).inject(this.routeRightWarper); this.setRouteGroupList(); //}else{ // this.routeGroupTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute }).inject(this.routeOpinionTile, "before"); // this.routeGroupArea = new Element("div", {"styles": this.css.routeSelectorArea_hasGroup_wide }).inject(this.routeGroupTile, "after"); // this.setRouteGroupList(); //} }else{ this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before"); this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after"); this.setRouteList(); } } }else{ //快速处理 this.routeSelectorTile = new Element("div", {"styles": this.css.routeSelectorTile, "text": MWF.xApplication.process.Work.LP.selectRoute}).inject(this.routeOpinionTile, "before"); this.routeSelectorArea = new Element("div", {"styles": this.css.routeSelectorArea}).inject(this.routeSelectorTile, "after"); this.setRouteList_noform(); this.setSize_noform(); } this.fireEvent("postLoad"); }, getRouteGroupList : function(){ if( this.routeGroupObject )return this.routeGroupObject; this.routeGroupObject = {}; this.routeGroupNameList = []; this.hasDecisionOpinion = false; var routeList = this.getRouteDataList(); routeList.each(function(route, i){ if( route.hiddenScriptText && this.form && this.form.Macro ){ //如果隐藏路由,返回 if( this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true" )return; } if( route.displayNameScriptText && this.form && this.form.Macro ){ //如果有显示名称公式 route.displayName = this.form.Macro.exec(route.displayNameScriptText, this); }else{ route.displayName = route.name; } if( route.decisionOpinion ){ this.hasDecisionOpinion = true; var decisionOpinionList = route.decisionOpinion.split("#"); decisionOpinionList.each( function( decisionOption ){ this.routeGroupNameList.combine( [decisionOption] ); var d = this.splitByStartNumber( decisionOption ); if( !this.routeGroupObject[ d.name ] )this.routeGroupObject[ d.name ] = []; this.routeGroupObject[ d.name ].push( route ); }.bind(this)) }else{ var defaultName = MWF.xApplication.process.Work.LP.defaultDecisionOpinionName; this.routeGroupNameList.combine( [defaultName] ); if( !this.routeGroupObject[ defaultName ] )this.routeGroupObject[ defaultName ] = []; this.routeGroupObject[ defaultName].push( route ); } }.bind(this)); return this.routeGroupObject; }, splitByStartNumber : function( str ){ var obj = { name : "", order : "" }; 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 ){ debugger; 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) } ] }); }, managerLogin : function(e){ debugger; var _self = this; var user = (this.task.identityDn || this.task.identity).split("@")[0]; var text = MWF.xApplication.process.Work.LP.managerLoginConfirmContent.replace("{user}", user ); MWF.xDesktop.confirm("infor", e, MWF.xApplication.process.Work.LP.managerLoginConfirmTitle, text, 450, 120, function () { o2.Actions.load("x_organization_assemble_authentication").AuthenticationAction.switchUser({"credential": ( _self.task.personDn || _self.task.person ) }, function(){ var text = MWF.xApplication.process.Work.LP.managerLoginSuccess.replace("{user}", user ); MWF.xDesktop.notice("success", {x: "right", y:"top"}, text ); window.open("/x_desktop/work.html?workid="+_self.task.work); }.bind(this)); this.close(); }, function () { this.close(); }, null, null); } }); if( MWF.xApplication.process.Xform && MWF.xApplication.process.Xform.Form ){ MWF.xApplication.process.Work.Processor.Org = new Class({ Implements: [Options, Events], options: { moduleEvents : ["queryLoadSelector","postLoadSelector","postLoadContent","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(){ if( layout.mobile ){ setTimeout( function(){ //如果有输入法界面,这个时候页面的计算不对,所以等100毫秒 var options = this.getOptions(); if(options){ this.selector = new MWF.O2Selector(this.container, options); } }.bind(this), 100 ) }else{ 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; } } if( this.ignoreOldData ){ identityOpt.values = this._computeValue() || []; }else{ 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; } } if( this.ignoreOldData ){ unitOpt.values = this._computeValue() || []; }else{ 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; if( layout.mobile ){ defaultOpt = { "style" : "default", "zIndex" : 3000 }; }else{ defaultOpt = { "style" : "process", "width" : "auto", "height" : "240", "embedded" : true, "hasLetter" : false, //字母 "hasTop" : true //可选、已选的标题 }; } 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; } var mobileEvents = { "onComplete": function(items){ this.selectOnComplete(items); }.bind(this), "onCancel": this.selectOnCancel.bind(this), "onClose": this.selectOnClose.bind(this) }; 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) }, layout.mobile ? mobileEvents : {} , 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, layout.mobile ? mobileEvents : {}, identityOpt ); } if( unitOpt ){ options.unitOptions = Object.merge( defaultOpt, layout.mobile ? mobileEvents : {}, 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.container.empty(); this.loadOrgWidget(values, this.container); this.selector = null; this.fireEvent("select", [items, values]); }.bind(this)) }, selectOnCancel: function(){ //移动端才执行 //this.validation(); }, selectOnLoad: function( selector ){ //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none"); this.fireEvent("loadSelector", [selector]) }, selectOnClose: function(){ var v = this._getBusinessData(); //if (!v || !v.length) if (this.descriptionNode) this.descriptionNode.setStyle("display", "block"); }, loadOrgWidget: function(value, node){ var height = node.getStyle("height").toInt(); if (node.getStyle("overflow")==="visible" && !height) node.setStyle("overflow", "hidden"); if (value && value.length){ value.each(function(data){ var flag = data.distinguishedName.substr(data.distinguishedName.length-1, 1); var copyData = Object.clone(data); if( this.json.displayTextScript && this.json.displayTextScript.code ){ this.currentData = copyData; var displayName = this.form.Macro.exec(this.json.displayTextScript.code, this); if( displayName ){ copyData.displayName = displayName; } this.currentData = null; } var widget; switch (flag.toLowerCase()){ case "i": widget = new MWF.widget.O2Identity(copyData, node, {"style": "xform","lazy":true}); break; case "p": widget = new MWF.widget.O2Person(copyData, node, {"style": "xform","lazy":true}); break; case "u": widget = new MWF.widget.O2Unit(copyData, node, {"style": "xform","lazy":true}); break; case "g": widget = new MWF.widget.O2Group(copyData, node, {"style": "xform","lazy":true}); break; default: widget = new MWF.widget.O2Other(copyData, node, {"style": "xform","lazy":true}); } widget.field = this; if( layout.mobile ){ //widget.node.setStyles({ // "float" : "none" //}) } }.bind(this)); } }, 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 ){ this.empowerChecker.setIgnoreEmpowerFlag(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 && !layout.mobile ){ return this.getSelectedData(); }else{ return this.getValue(); } }, getSelectedData : function(){ if( layout.mobile ){ return this.getValue(); }else{ var data = []; if( this.selector && this.selector.selector){ this.selector.selector.selectedItems.each( function( item ){ data.push( MWF.org.parseOrgData(item.data, true) ); }) } 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, true); }.bind(this), error, v, false); } if (vtype==="object") { data = MWF.org.parseOrgData(v, true); if(data.woPerson)delete data.woPerson; } 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, true); }.bind(this), error, value, false); if (vData)values.push(vData); } if (type==="object"){ var vData = MWF.org.parseOrgData(value, true); if(vData.woPerson)delete vData.woPerson; values.push( vData ); } 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, "work" : (this.form.businessData.work || this.form.businessData.workCompleted).id, "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 }); }