12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155 |
- 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.ProcessFlow_ORG_HEIGHT = 275;
- MWF.xApplication.process.Work.Flow = MWF.ProcessFlow = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- style: "default",
- processEnable: true,
- addTaskEnable: true,
- resetEnable: true,
- goBackEnable: true,
- processOptions: {},
- mainColorEnable: true,
- zIndex: 20001 //比正文编辑器痕迹窗口多1
- },
- initialize: function (container, task, options, form) {
- this.setOptions(options);
- this.path = "../x_component_process_Work/$Flow/";
- // this.cssPath = "../x_component_process_Work/$Flow/" + this.options.style + "/css.wcss";
- // this._loadCss();
- this.lp = MWF.xApplication.process.Work.LP;
- this.task = task;
- this.container = $(container);
- this.form = form;
- this.businessData = this.form.businessData;
- this.load();
- },
- load: function () {
- this.container.loadCss( this.path + this.options.style + "/style.css", null, function () {
- this.cssLoaded = true;
- this.checkLoadEvent();
- }.bind(this));
- this.processEnable = this.options.processEnable && this.businessData.control["allowProcessing"];
- this.addTaskEnable = this.options.addTaskEnable && this.businessData.control["allowAddTask"];
- this.resetEnable = this.options.resetEnable && this.businessData.control["allowReset"];
- this.goBackEnable = this.options.goBackEnable && this.businessData.control["allowGoBack"];
- this.navi = [];
- if( this.processEnable )this.navi.push({ key: "process", label: this.lp.flowActions.process });
- if( this.addTaskEnable )this.navi.push({ key: "addTask", label: this.lp.flowActions.addTask });
- if( this.resetEnable )this.navi.push({ key: "reset", label: this.lp.flowActions.reset });
- if( this.goBackEnable )this.navi.push({ key: "goBack", label: this.lp.flowActions.goBack });
- var url = this.path+this.options.style+"/main.html";
- this.container.loadHtml(url, {"bind": {"lp": this.lp, "navi": this.navi}, "module": this}, function(){
- this.changeAction( this.navi[0].key );
- if( this.processEnable || this.resetEnable || this.addTaskEnable ){
- this.loadQuickSelect();
- }else{
- this.quickSelectNode.hide();
- }
- }.bind(this));
- },
- getSize: function(){
- return {
- y: this.contentWraper.getSize().y + this.getMarginY(this.contentWraper) + this.getOffsetY(this.node) + 1,
- x: this.node.getSize().x + this.getMarginY(this.node)
- };
- },
- checkLoadEvent: function(){
- if( this.cssLoaded && this.firstActionLoaded){
- if( this.currentAction === "process" ){
- if( this.processor.getMaxOrgLength() > 1 ){
- this.node.addClass("o2flow-node-wide").removeClass("o2flow-node");
- }
- }
- this.fireEvent("load");
- }
- },
- changeAction: function( action, quickData ){
- debugger;
- if( this.currentAction ){
- this[ this.currentAction+"ContentNode" ].hide();
- this[ this.currentAction+"TitleNode" ].removeClass("o2flow-navi-item-active");
- if( this.options.mainColorEnable )this[ this.currentAction+"TitleNode" ].removeClass("mainColor_bg");
- }
- this[ action+"ContentNode" ].show();
- this[ action+"TitleNode" ].addClass("o2flow-navi-item-active");
- if( this.options.mainColorEnable )this[ action+"TitleNode" ].addClass("mainColor_bg");
- this.currentAction = action;
- switch (action) {
- case "process":
- this.loadProcessor( quickData );
- break;
- case "addTask":
- this.loadAddTask( quickData );
- break;
- case "reset":
- this.loadReset( quickData );
- break;
- case "goBack":
- this.loadGoBack();
- break;
- }
- },
- loadProcessor: function ( quickData ) {
- if( this.processor ){
- if( quickData )this.processor.setQuickData( quickData );
- this.resize();
- return;
- }
- this.processor = new MWF.ProcessFlow.Processor(
- this.processContentNode,
- this,
- Object.merge( this.options.processOptions, {
- onLoad: function () {
- if( this.firstActionLoaded ){
- this.resize();
- }else{
- this.firstActionLoaded = true;
- this.checkLoadEvent();
- }
- }.bind(this)
- })
- );
- this.processor.load( quickData );
- },
- loadReset: function( quickData ){
- if( this.reset ){
- if( quickData )this.reset.setQuickData( quickData );
- this.resize();
- return;
- }
- this.reset = new MWF.ProcessFlow.Reset(
- this.resetContentNode,
- this,
- Object.merge( this.options.resetOptions, {
- onLoad: function () {
- if( this.firstActionLoaded ){
- this.resize();
- }else{
- this.firstActionLoaded = true;
- this.checkLoadEvent();
- }
- }.bind(this)
- })
- );
- this.reset.load( quickData );
- },
- loadAddTask: function( quickData ){
- if( this.addTask ){
- if( quickData )this.addTask.setQuickData( quickData );
- this.resize();
- return;
- }
- this.addTask = new MWF.ProcessFlow.AddTask(
- this.addTaskContentNode,
- this,
- Object.merge( this.options.addTaskOptions, {
- onLoad: function () {
- if( this.firstActionLoaded ){
- this.resize();
- }else{
- this.firstActionLoaded = true;
- this.checkLoadEvent();
- }
- }.bind(this)
- })
- );
- this.addTask.load( quickData );
- },
- loadGoBack: function(){
- if( this.goBack ){
- //if( quickData )this.goBack.setQuickData( quickData );
- this.resize();
- return;
- }
- this.goBack = new MWF.ProcessFlow.GoBack(
- this.goBackContentNode,
- this,
- Object.merge( this.options.goBackOptions, {
- onLoad: function () {
- if( this.firstActionLoaded ){
- this.resize();
- }else{
- this.firstActionLoaded = true;
- this.checkLoadEvent();
- }
- }.bind(this)
- })
- );
- this.goBack.load();
- },
- loadQuickSelect: function(){
- if( !this.addTaskEnable && !this.resetEnable && !this.processEnable ){
- if(this.quickSelector)this.quickSelector.hide();
- return;
- }
- this.quickSelector = new MWF.ProcessFlow.widget.QuickSelect(
- this.form.app ? this.form.app.content : $(document.body),
- this.quickSelectNode,
- this.form.app,
- {},
- {
- nodeStyles: {
- "z-index" : this.options.zIndex + 1
- }
- }
- );
- this.quickSelector.flow = this;
- this.contentScrollNode.addEvent("scroll", function () {
- if(this.quickSelector.status === "display")this.quickSelector.hide();
- }.bind(this))
- },
- submit: function(){
- switch ( this.currentAction ) {
- case "process":
- this.processor.submit();
- break;
- case "addTask":
- this.addTask.submit();
- break;
- case "reset":
- this.reset.submit();
- break;
- case "goBack":
- this.goBack.submit();
- break;
- }
- },
- destroy: function () {
- if( this.processor )this.processor.destroy();
- if( this.reset )this.reset.destroy();
- if( this.addTask )this.addTask.destroy();
- if( this.goBack )this.goBack.destroy();
- if(this.quickSelector)this.quickSelector.destroy();
- this.fireEvent("cancel");
- },
- getMarginY : function(node){
- return (node.getStyle("margin-top").toInt() || 0 ) +
- (node.getStyle("margin-bottom").toInt() || 0 );
- },
- getMarginX : function(node){
- return (node.getStyle("margin-left").toInt() || 0 ) +
- (node.getStyle("margin-right").toInt() || 0 );
- },
- getOffsetY : function(node){
- return (node.getStyle("margin-top").toInt() || 0 ) +
- (node.getStyle("margin-bottom").toInt() || 0 ) +
- (node.getStyle("padding-top").toInt() || 0 ) +
- (node.getStyle("padding-bottom").toInt() || 0 )+
- (node.getStyle("border-top-width").toInt() || 0 ) +
- (node.getStyle("border-bottom-width").toInt() || 0 );
- },
- getOffsetX : function(node){
- return (node.getStyle("margin-left").toInt() || 0 ) +
- (node.getStyle("margin-right").toInt() || 0 ) +
- (node.getStyle("padding-left").toInt() || 0 ) +
- (node.getStyle("padding-right").toInt() || 0 )+
- (node.getStyle("border-left-width").toInt() || 0 ) +
- (node.getStyle("border-right-width").toInt() || 0 );
- },
- getEl: function( ev, className ){
- var node = ev.target;
- while (node && !node.hasClass(className)){ node = node.getParent();}
- return node;
- },
- noticeError: function( text, node, offset, position ){
- MWF.xDesktop.notice(
- "error",
- position || {"x": "center", "y": "center"},
- text,
- node || this.node,
- offset === null ? null : ( offset || {"x": 0, "y": 30} ),
- {"closeOnBoxClick": true, "closeOnBodyClick": true, "fixed": true, "delayClose": 6000}
- );
- },
- resize: function () {
- this.fireEvent("resize");
- },
- getRouteGroupConfig: function () {
- if (this.routeGroupObject) return this.routeGroupObject;
- this.routeGroupObject = {};
- this.routeGroupNameList = [];
- this.hasRouteGroup = false;
- var routeList = this.getRouteConfigList();
- 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.hasRouteGroup = true;
- route.decisionOpinion.split("#").each(function (rg) {
- this.routeGroupNameList.combine([rg]);
- var d = this.splitByStartNumber(rg);
- 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;
- },
- getRouteConfigList: function () {
- if(this.routeConfigList)return this.routeConfigList;
- if (this.task.routeNameDisable){
- this.routeConfigList = [{
- "id": o2.uuid(),
- "asyncSupported": false,
- "soleDirect": false,
- "name": "继续流转",
- "alias": "",
- "selectConfigList": []
- }];
- return this.routeConfigList;
- }
- if( this.form && this.form.businessData && this.form.businessData.routeList ){
- this.form.businessData.routeList.sort( function(a, b){
- var aIdx = parseInt(a.orderNumber || "9999999");
- var bIdx = parseInt(b.orderNumber || "9999999");
- return aIdx - bIdx;
- }.bind(this));
- this.form.businessData.routeList.each( function(d){
- d.selectConfigList = JSON.parse(d.selectConfig || "[]");
- }.bind(this));
- this.routeConfigList = this.form.businessData.routeList;
- }
- if (!this.routeConfigList) {
- o2.Actions.get("x_processplatform_assemble_surface").listRoute({"valueList": this.task.routeList}, function (json) {
- json.data.sort(function(a, b){
- var aIdx = parseInt(a.orderNumber || "9999999");
- var bIdx = parseInt(b.orderNumber || "9999999");
- return aIdx - bIdx;
- }.bind(this));
- json.data.each(function (d) {
- d.selectConfigList = JSON.parse(d.selectConfig || "[]");
- }.bind(this));
- this.routeConfigList = json.data;
- }.bind(this), null, false);
- }
- return this.routeConfigList;
- },
- getRouteConfig: function (routeId) {
- var routeList = this.getRouteConfigList();
- for (var i = 0; i < routeList.length; i++) {
- if (routeList[i].id === routeId || routeList[i].name === routeId) {
- return routeList[i];
- }
- }
- },
- getOrgConfig: function (routeId) {
- var routeList = this.getRouteConfigList();
- for (var i = 0; i < routeList.length; i++) {
- if (routeList[i].id === routeId) {
- return routeList[i].selectConfigList;
- }
- }
- },
- getVisableOrgConfig: function (routeId) {
- var selectConfigList = this.getOrgConfig(routeId);
- var list = [];
- (selectConfigList || []).each(function (config) {
- if (!this.isOrgHidden(config)) {
- list.push(config);
- }
- }.bind(this));
- return list;
- },
- getSingleOrgConfig: function( routeId, orgName ){
- var orgList = this.getOrgConfig( routeId );
- for (var i = 0; i < orgList.length; i++) {
- if (orgList[i].name === orgName) {
- return orgList[i];
- }
- }
- },
- isOrgHidden: function (d) {
- if (d.hiddenScript && d.hiddenScript.code) { //如果隐藏路由,返回
- var hidden = this.form.Macro.exec(d.hiddenScript.code, this);
- if (hidden && hidden.toString() === "true") return true;
- }
- return false;
- },
- getMaxOrgLength: function () {
- var routeList = this.getRouteConfigList();
- var length = 0;
- routeList.each(function (route) {
- if (route.hiddenScriptText) { //如果隐藏路由,返回
- if (this.form.Macro.exec(route.hiddenScriptText, this).toString() === "true") return;
- }
- length = Math.max(length, this.getVisableOrgConfig( route.id ).length);
- }.bind(this));
- return length;
- },
- splitByStartNumber: function (str) {
- var obj = {
- name: "",
- order: ""
- };
- for (var i = 0; i < str.length; i++) {
- if (parseInt(str.substr(i, 1)).toString() !== "NaN") {
- obj.order = obj.order + str.substr(i, 1);
- } else {
- obj.name = str.substr(i, str.length);
- break;
- }
- }
- return obj;
- },
- });
- MWF.ProcessFlow.Reset = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options:{
- data: null,
- style: "default"
- },
- initialize: function (container, flow, options) {
- this.setOptions(options);
- this.container = $(container);
- this.flow = flow;
- this.task = flow.task;
- this.form = flow.form;
- this.lp = flow.lp;
- this.businessData = this.form.businessData;
- },
- load: function( quickData ){
- this.quickData = quickData || {};
- this.container.loadHtml(this.getUrl(), {"bind": {"lp": this.lp}, "module": this}, function(){
- this.loadOpinion();
- this.loadOrg();
- this.afterLoad();
- this.fireEvent("load");
- }.bind(this));
- },
- setQuickData: function( data ){
- //if(this.keepOption)this.keepOption.setValue( data.keepTask ? "true" : null );
- if(this.opinion)this.opinion.setValue( data.opinion || "" );
- if(this.selector && this.selector.selector)this.selector.selector.setValues( data.organizations ? (data.organizations.default || []) : [] );
- },
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/reset.html";
- },
- show: function(){
- },
- afterLoad: function () {
- // this.keepOption = new MWF.ProcessFlow.widget.Radio(this.keepOptionArea, this.flow, {
- // optionList: [{
- // text: this.lp.keepTask,
- // value: "true"
- // }],
- // value: (this.quickData.keepTask) ? "true" : null
- // });
- // this.keepOption.load();
- },
- loadOpinion: function(){
- var opt = Object.clone(this.flow.options.opinionOptions);
- opt.isHandwriting = this.options.isHandwriting;
- if( this.quickData.opinion ){
- opt.opinion = this.quickData.opinion;
- delete this.quickData.opinion;
- }
- this.opinion = new MWF.ProcessFlow.widget.Opinion( this.opinionContent, this.flow, opt );
- this.opinion.load();
- },
- loadOrg: function(){
- this.getSelOptions( function (options) {
- options.values = this.quickData.organizations ? (this.quickData.organizations.default || []) : [];
- if(this.quickData.organizations)delete this.quickData.organizations.default;
- this.selector = new MWF.O2Selector(this.orgsArea, options);
- }.bind(this) );
- },
- getSelOptions: function( callback ){
- // o2.Actions.get("x_processplatform_assemble_surface").listTaskByWork(this.businessData.work.id, function(json){
- // var identityList = [];
- // json.data.each(function(task){
- // identityList.push(task.identity);
- // });
- // this._getSelOptions(identityList, callback);
- // }.bind(this))
- this._getSelOptions([], callback);
- },
- _getSelOptions: function (exclude, callback) {
- var options = this.getSelDefaultOptions();
- var range = this.businessData.activity.resetRange || "department";
- switch (range) {
- case "unit":
- options.units = this.businessData.task.unitDn ? [this.businessData.task.unitDn] : [];
- options.exclude = exclude;
- callback( options );
- break;
- case "topUnit":
- MWF.require("MWF.xScript.Actions.UnitActions", function () {
- orgActions = new MWF.xScript.Actions.UnitActions();
- var data = { "unitList": [this.businessData.task.unitDn] };
- orgActions.listUnitSupNested(data, function (json) {
- options.units = json.data[0] ? [json.data[0]]: [];
- options.exclude = exclude;
- callback( options );
- }.bind(this));
- }.bind(this));
- break;
- case "script":
- o2.Actions.load("x_processplatform_assemble_surface").ProcessAction.getActivity(this.businessData.work.activity, "manual", function (activityJson) {
- var scriptText = activityJson.data.activity.resetRangeScriptText;
- if (!scriptText) return;
- var resetRange = this.Macro.exec(activityJson.data.activity.resetRangeScriptText, this);
- options.noUnit = true;
- options.include = typeOf(resetRange) === "array" ? resetRange : [resetRange];
- options.exclude = exclude;
- callback( options );
- }.bind(this));
- break;
- default:
- callback( options );
- }
- },
- getSelDefaultOptions: function(){
- var defaultOpt = {
- "type": "identity",
- "mainColorEnable": this.flow.options.mainColorEnable,
- "style": "flow",
- "width": "auto",
- "height": MWF.ProcessFlow_ORG_HEIGHT,
- "count": this.businessData.activity.resetCount || 0,
- "embedded": true,
- "hasLetter": false, //字母
- "hasTop": true //可选、已选的标题
- };
- 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;
- }
- return defaultOpt;
- },
- getSelOrgData: function () {
- var data;
- if (this.selector && this.selector.selector) {
- data = this.selector.selector.selectedItems.map(function (item) {
- return item.data.distinguishedName;
- // return MWF.org.parseOrgData(item.data, true, simple);
- })
- }
- return data || [];
- },
- submit: function () {
- var names = this.getSelOrgData();
- if (!names.length) {
- this.flow.noticeError(MWF.xApplication.process.Xform.LP.inputResetPeople, this.orgsArea);
- return false;
- }
- var opinion = this.opinion.getValue();
- // var keep = this.keepOption.getValue() === "true";
- var leftText = MWF.xApplication.process.Xform.LP.resetTo;
- var nameText = [];
- names.each(function (n) { nameText.push(MWF.name.cn(n)); });
- if (!opinion) {
- opinion = leftText + ": " + nameText.join(", ");
- }
- var n = nameText.length > 3 ? (nameText[0]+"、"+nameText[1]+"、"+nameText[2]+"...") : nameText.join(", ");
- var routeName = leftText+":"+n;
- this.flow.quickSelector.saveData();
- this.fireEvent("submit", [names, opinion, routeName, this.opinion.getValue()]);
- },
- getQuickData: function(){
- return {
- routeId: "reset",
- opinion: this.opinion.getValue(),
- //keepTask: this.keepOption.getValue() === "true",
- organizations: {
- default: this.getSelOrgData()
- }
- }
- },
- destroy: function () {
- if (this.orgItem && this.orgItem.clearTooltip){
- this.orgItem.clearTooltip();
- }
- if (this.node) this.node.empty();
- },
- });
- MWF.ProcessFlow.AddTask = new Class({
- Extends: MWF.ProcessFlow.Reset,
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/addTask.html";
- },
- afterLoad: function () {
- this.mode = new MWF.ProcessFlow.widget.Radio(this.modeArea, this.flow, {
- optionList: [{
- text: this.lp.single,
- value: "single"
- },{
- text: this.lp.queue,
- value: "queue"
- },{
- text: this.lp.parallel,
- value: "parallel"
- }],
- value: this.quickData.mode || "single" //默认为单人
- });
- this.mode.load();
- var position = "";
- if( this.quickData.routeId ){
- position = (this.quickData.routeId === "before") ? "true" : "false";
- }else{
- position = "false"; //默认为后加签
- }
- this.position = new MWF.ProcessFlow.widget.Radio(this.positionArea, this.flow, {
- optionList: [{
- text: this.lp.addTaskBefore,
- value: "true"
- },
- {
- text: this.lp.addTaskAfter,
- value: "false"
- }],
- value: position
- });
- this.position.load();
- },
- submit: function () {
- var opinion = this.opinion.getValue();
- var before = this.position.getValue() === "true";
- if (!this.position.getValue()) {
- this.flow.noticeError(MWF.xApplication.process.Work.LP.inputAddTaskType, this.positionArea);
- return false;
- }
- var mode = this.mode.getValue();
- if (!mode) {
- this.flow.noticeError(MWF.xApplication.process.Work.LP.inputModeType, this.modeArea);
- return false;
- }
- var names = this.getSelOrgData();
- if (!names.length) {
- this.flow.noticeError(MWF.xApplication.process.Work.LP.inputAddTaskPeople, this.orgsArea);
- return false;
- }
- var leftText = (before ? this.lp.addTaskBefore : this.lp.addTaskAfter) + this.lp[mode];
- var nameText = names.map(function (n) { return MWF.name.cn(n); });
- if (!opinion) {
- opinion = leftText + ": " + nameText.join(", ");
- }
- var n = nameText.length > 3 ? (nameText[0]+"、"+nameText[1]+"、"+nameText[2]+"...") : nameText.join(", ");
- var routeName = leftText+":"+n;
- this.flow.quickSelector.saveData();
- this.fireEvent("submit", [names, opinion, mode, before, routeName, this.opinion.getValue()]);
- },
- setQuickData: function( data ){
- if(this.position)this.position.setValue( data.routeId === "before" ? "true" : null ); //前后加签存在 routeId
- if(this.mode)this.mode.setValue( data.routeGroup || null ); //单人、并行、串行存在 routeGroup
- if(this.opinion)this.opinion.setValue( data.opinion || "" );
- if(this.selector && this.selector.selector)this.selector.selector.setValues( data.organizations ? (data.organizations.default || []) : [] );
- },
- getQuickData: function(){
- var names = this.getSelOrgData();
- // var nameText = names.map(function (n) { return MWF.name.cn(n); });
- // var routeName = o2.xApplication.process.Xform.LP.form.addTask+":"+nameText.join(", ");
- return {
- routeId: this.position.getValue() === "true" ? "before" : "after",
- routeGroup: this.mode.getValue(),
- opinion: this.opinion.getValue(),
- //before: this.position.getValue() === "true",
- routeName: this.position.getValue() === "true" ? "before" : "after",
- organizations: {
- default: names
- }
- }
- },
- });
- MWF.ProcessFlow.GoBack = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options:{
- data: null,
- style: "default"
- },
- initialize: function (container, flow, options) {
- this.setOptions(options);
- this.container = $(container);
- this.flow = flow;
- this.task = flow.task;
- this.form = flow.form;
- this.lp = flow.lp;
- this.businessData = this.form.businessData;
- this.checkedItems = [];
- },
- load: function(){
- this.container.loadHtml(this.getUrl(), {"bind": {"lp": this.lp}, "module": this}, function(){
- this.loadOpinion();
- this.loadActivitys();
- }.bind(this));
- },
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/goBack.html";
- },
- loadActivitys: function(){
- o2.Actions.load('x_processplatform_assemble_surface').WorkAction.V2ListActivityGoBack(this.task.work, function(json) {
- this.activitys = json.data.map(function (d) {
- var ids = o2.name.cns(d.lastIdentityList);
- d.identityNameString = (ids.length>8) ? ids.slice(0,8).join(', ')+' ...' : ids.join(', ');
- d.identityNameTitle = ids.join(',');
- return d;
- })
- // var act2 = Array.clone(this.activitys);
- // act2[0].way = "custom";
- // var act3 = Array.clone(this.activitys);
- // act3[0].way = "custom";
- // var act4 = Array.clone(this.activitys);
- // this.activitys = this.activitys.concat(act2, act3, act4);
- this.activitysArea.loadHtml(this.flow.path+this.flow.options.style+"/widget/gobackActivity.html",
- {"bind": {"lp": this.lp, "activityList":this.activitys}, "module": this},
- function(){
- if( this.activitys.length === 1 ){
- var el = this.activitysArea.getElement(".o2flow-radio2");
- this.check( el );
- }
- this.afterLoad();
- this.fireEvent("load");
- }.bind(this));
- }.bind(this));
- },
- loadWayRadio: function(ev, activityData){
- var wayRadio = new MWF.ProcessFlow.widget.Radio(ev.target, this.flow, {
- optionList: [{
- text: this.lp.goBackActivityWayStep,
- value: "step"
- },{
- text: this.lp.goBackActivityWayJump,
- value: "jump"
- }],
- value: "step", //默认为单人
- onLoad: function () {
- this.container.getElement(".o2flow-radio-area").setStyle("display","flex");
- this.container.getElements(".o2flow-radio").setStyles({
- "padding-top":"0px",
- "padding-bottom":"0px"
- })
- }
- });
- wayRadio.load();
- var parentNode = ev.target.getParent(".o2flow-radio2");
- parentNode.store("wayRadio", wayRadio);
- ev.target.hide();
- },
- toggle: function( ev ){
- var el = this.flow.getEl(ev, "o2flow-radio2");
- if( this.checkedItems.contains( el ) ){
- //if( this.options.cancelEnable )this.uncheck( el, true )
- }else{
- this.check( el );
- }
- },
- showWayRadio: function(el){
- var parentNode = this.flow.getEl({target: el}, "o2flow-radio2");
- var wayRadio = parentNode.retrieve("wayRadio");
- if(wayRadio)wayRadio.container.show();
- },
- hideWayRadio: function(el){
- var parentNode = this.flow.getEl({target: el}, "o2flow-radio2");
- var wayRadio = parentNode.retrieve("wayRadio");
- if(wayRadio)wayRadio.container.hide();
- },
- check: function(el){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- el.addClass("o2flow-radio2-active");
- if( this.flow.options.mainColorEnable )el.addClass("mainColor_color");
- el.getElement("i").removeClass("o2icon-icon_circle").addClass("o2icon-radio-checked").addClass("o2flow-radio2-icon");
- if( this.flow.options.mainColorEnable )el.getElement("i").addClass("mainColor_color");
- el.dataset["o2Checked"] = true;
- this.activitysArea.removeClass("o2flow-invalid-bg");
- this.checkedItems.push(el);
- this.showWayRadio(el);
- this.fireEvent("check", [el, el.dataset["o2Value"]])
- },
- uncheck: function(el, isFire){
- el.removeClass("o2flow-radio2-active");
- if( this.flow.options.mainColorEnable )el.removeClass("mainColor_color");
- el.getElement("i").removeClass("o2icon-radio-checked").addClass("o2icon-icon_circle").removeClass("o2flow-radio2-icon");
- if( this.flow.options.mainColorEnable )el.getElement("i").removeClass("mainColor_color");
- el.dataset["o2Checked"] = false;
- this.checkedItems.erase(el);
- this.hideWayRadio(el);
- if(isFire)this.fireEvent("uncheck", [el, el.dataset["o2Value"]])
- },
- show: function(){
- },
- afterLoad: function () {
- },
- loadOpinion: function(){
- var opt = Object.clone(this.flow.options.opinionOptions);
- opt.isHandwriting = this.options.isHandwriting;
- this.opinion = new MWF.ProcessFlow.widget.Opinion( this.opinionContent, this.flow, opt );
- this.opinion.load();
- },
- submit: function () {
- if (!this.checkedItems.length) {
- this.activitysArea.addClass("o2flow-invalid-bg");
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.selectGoBackActivity,
- this.activitysArea,
- null,
- {"x": "center", "y": "top"}
- );
- return false;
- }
- var itemNode = this.checkedItems[0];
- var activity = itemNode.dataset["o2Value"];
- var activityName = itemNode.dataset["o2Text"];
- var way;
- var wayRadio = itemNode.retrieve("wayRadio");
- if( wayRadio ){
- way = wayRadio.getValue();
- }else{
- way = itemNode.dataset["o2Way"];
- }
- var opinion = this.opinion.getValue();
- if(!opinion)opinion = this.lp.goBackTo+activityName;
- var routeName = this.lp.goBackTo+activityName;
- debugger;
- this.fireEvent("submit", [opinion, routeName, activity, way, this.opinion.getValue()]);
- },
- // getQuickData: function(){
- // return {
- // routeId: "goBack",
- // opinion: this.opinion.getValue(),
- // //keepTask: this.keepOption.getValue() === "true",
- // organizations: {
- // default: this.getSelOrgData()
- // }
- // }
- // },
- destroy: function () {
- if (this.node) this.node.empty();
- },
- });
- MWF.ProcessFlow.Processor = new Class({
- Extends: MWF.widget.Common,
- Implements: [Options, Events],
- options: {
- "style": "default",
- "defaultRouteGroup": "",
- "defaultRoute": ""
- },
- initialize: function (container, flow, options) {
- this.setOptions(options);
- this.container = $(container);
- this.node = this.container;
- this.flow = flow;
- this.task = flow.task;
- this.form = flow.form;
- this.lp = flow.lp;
- this.businessData = this.form.businessData;
- this.routeOrgMap = {};
- },
- load: function( quickData ){
- this.quickData = quickData;
- if( quickData )quickData.rId = quickData.routeId;
- if( quickData && (quickData.routeId || quickData.routeName) ){
- this.options.defaultRoute = quickData.routeId || quickData.routeName;
- delete quickData.routeId;
- delete quickData.routeName;
- this.options.defaultRouteGroup = quickData.routeGroup;
- delete quickData.routeGroup;
- }
- this.container.loadHtml(this.flow.path+this.flow.options.style+"/process.html", {"bind": {"lp": this.lp}, "module": this}, function(){
- this.loadOpinion();
- this.loadRouteOrGroupList();
- //this.loadOrg();
- //this.afterLoad();
- }.bind(this));
- },
- checkLoadEvent: function(){
- if( !this.loadEventFired ){
- this.fireEvent("load");
- this.loadEventFired = true;
- }
- },
- setQuickData: function( quickData ){
- this.quickData = quickData;
- if(quickData)quickData.rId = quickData.routeId;
- if( this.routeGroupRadio && quickData.routeGroup ){
- if( quickData.routeId || quickData.routeName ){
- this.options.defaultRoute = quickData.routeId || quickData.routeName;
- delete quickData.routeId;
- delete quickData.routeName;
- }
- this.routeGroupRadio.setValue( quickData.routeGroup );
- delete quickData.routeGroup;
- }else{
- this.routeRadio.setValue( quickData.routeId );
- delete quickData.routeId;
- }
- if(this.opinion){
- this.opinion.setValue( quickData.opinion || "" );
- delete quickData.opinion;
- }
- //if(this.selector && this.selector.selector)this.selector.selector.setValues( data.organizations ? (data.organizations.default || []) : [] );
- },
- loadOpinion: function(){
- var opt = Object.clone(this.flow.options.opinionOptions);
- opt.isHandwriting = this.options.isHandwriting;
- if( this.quickData && this.quickData.opinion ){
- opt.opinion = this.quickData.opinion;
- delete this.quickData.opinion;
- }
- this.opinion = new MWF.ProcessFlow.widget.Opinion( this.opinionContent, this.flow, opt );
- this.opinion.load();
- },
- loadRouteOrGroupList: function () {
- this.getRouteGroupConfig();
- if (this.hasRouteGroup) {
- this.loadRouteGroupList();
- } else {
- this.routeGroupWraper.destroy();
- this.routeWraper.removeClass("o2flow-route-wraper").addClass("o2flow-route-fullsize-wraper");
- this.routeArea.removeClass("o2flow-route-area").addClass("o2flow-route-fullsize-area");
- this.loadRouteList();
- }
- },
- loadRouteGroupList: function(){
- var keys = this.routeGroupNameList;
- keys.sort(function (a, b) {
- var aIdx = parseInt(this.flow.splitByStartNumber(a).order || "9999999");
- var bIdx = parseInt(this.flow.splitByStartNumber(b).order || "9999999");
- return aIdx - bIdx;
- }.bind(this));
- var routeGroupNames = keys.map(function (k) { return this.flow.splitByStartNumber(k).name; }.bind(this));
- var defaultValue;
- if( keys.length === 1 ) {
- defaultValue = routeGroupNames[0];
- }else if( this.opinion.defaultRouteGroup ){
- defaultValue = this.opinion.defaultRouteGroup;
- this.opinion.defaultRouteGroup = "";
- }else if( this.options.defaultRoute ){
- routeGroupNames.each(function (routeGroupName) {
- if( defaultValue )return;
- var routeList = this.routeGroupObject[routeGroupName];
- var matchRoutes = routeList.filter(function(r){ return r.id === this.options.defaultRoute || r.name === this.options.defaultRoute; }.bind(this));
- if( matchRoutes.length )defaultValue = routeGroupName;
- }.bind(this));
- }
- var optionList = routeGroupNames.map(function (routeGroupName) {
- return {
- text: routeGroupName,
- value: routeGroupName,
- data: this.routeGroupObject[routeGroupName]
- };
- }.bind(this));
- var _self = this;
- this.routeGroupRadio = new MWF.ProcessFlow.widget.Radio2(this.routeGroupArea, this.flow, {
- optionList: optionList,
- cancelEnable: false,
- onCheck: function(el, value){
- var routeConfigList = this.getData().data;
- _self.loadRouteList( routeConfigList );
- },
- onLoad: function(){
- if( defaultValue ){
- this.setValue( defaultValue );
- }else{
- _self.loadOrgs();
- }
- }
- });
- this.routeGroupRadio.load();
- },
- loadRouteList: function (routeConfigList) {
- var _self = this;
- this.routeArea.empty();
- if (!routeConfigList) routeConfigList = this.getRouteConfigList();
- var optionList = [], isSelectedDefault = false, defaultRoute;
- routeConfigList.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 && this.form && this.form.Macro) {
- routeName = this.form.Macro.exec(route.displayNameScriptText, this);
- }
- optionList.push({
- value: route.id,
- text: routeName,
- data: route
- });
- if( route.id === this.options.defaultRoute || route.name === this.options.defaultRoute) {
- defaultRoute = route.id;
- this.options.defaultRoute = "";
- isSelectedDefault = true;
- }else if ( !isSelectedDefault && (routeConfigList.length == 1 || route.sole )) { //sole表示优先路由
- defaultRoute = route.id;
- }
- }.bind(this));
- this.routeRadio = new MWF.ProcessFlow.widget.Radio(this.routeArea, this.flow, {
- optionList: optionList,
- onCheck: function(el, value){
- var routeConfig = this.getData().data;
- var checkOpinion = function(){
- var op = _self.opinion.getValue();
- if( op === (_self.lastDefaultOpinion || "") || op === "" ){
- _self.lastDefaultOpinion = routeConfig.opinion || "";
- _self.opinion.setValue( _self.lastDefaultOpinion );
- }
- };
- if( _self.opinion.loaded ){
- checkOpinion()
- }else{
- _self.opinion.addEvent("load", checkOpinion);
- }
- _self.loadOrgs( routeConfig );
- },
- onUncheck: function(el, value){
- var routeConfig = this.getData( value ).data;
- var op = _self.opinion.getValue();
- if (op === (routeConfig.opinion || "") || op === "" ) {
- _self.lastDefaultOpinion = "";
- _self.opinion.setValue("");
- }
- _self.loadOrgs();
- },
- onLoad: function(){
- if( defaultRoute ){
- this.setValue( defaultRoute );
- }else{
- _self.loadOrgs();
- }
- }
- });
- this.routeRadio.load();
- },
- loadOrgs: function( routeConfig ){
- for( var r in this.routeOrgMap ){
- this.routeOrgMap[r].hide();
- }
- var notFireResize = !this.loadEventFired;
- if( routeConfig ){
- var routeId = routeConfig.id;
- var orgList = this.routeOrgMap[routeId];
- if( orgList ){
- orgList.load( notFireResize );
- }else{
- orgList = new MWF.ProcessFlow.Processor.OrgList(this, {
- routeId: routeId
- });
- this.routeOrgMap[routeId] = orgList;
- orgList.load( notFireResize );
- }
- this.currentOrgList = orgList;
- }else{
- this.orgsWraper.hide();
- //this.setSize(0);
- if( !notFireResize )this.flow.resize();
- this.currentOrgList = null;
- }
- this.checkLoadEvent();
- },
- cancel: function(){
- this.destroy();
- this.fireEvent("cancel");
- },
- submit: function (ev) {
- if (this.hasRouteGroup && !this.routeGroupRadio.getValue() ) {
- this.routeGroupRadio.setRequireStyle();
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.mustSelectRouteGroup,
- this.routeGroupArea,
- null,
- {"x": "center", "y": "top"}
- );
- return false;
- }
- if (!this.routeRadio.getValue()) {
- this.routeRadio.setRequireStyle();
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.mustSelectRoute,
- this.routeArea,
- null, //{"x": 0, "y": 30}
- {"x": "center", "y": "top"}
- );
- return false;
- }
- var routeName = this.routeRadio.getData().data.name;
- var opinion = this.opinion.getValue();
- var medias = [];
- if (this.opinion.handwritingFile) medias.push(this.opinion.handwritingFile);
- var currentRouteId = this.routeRadio.getValue();
- var routeConfig = this.getRouteConfig(currentRouteId);
- if (!opinion && medias.length === 0) {
- if (routeConfig.opinionRequired === true) {
- this.opinion.setRequireStyle();
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.opinionRequired,
- this.opinion.opinionTextarea,
- null,
- {"x": "center", "y": "top"}
- );
- return false;
- }
- }
- var orgItems = this.currentOrgList ? this.currentOrgList.orgVisableItems : [];
- var appendTaskOrgItem = "";
- if (routeConfig.type === "appendTask" && routeConfig.appendTaskIdentityType === "select") {
- if (!orgItems || orgItems.length === 0) {
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.noAppendTaskIdentityConfig,
- this.node,
- null
- );
- return false;
- } else {
- appendTaskOrgItem = orgItems[0];
- }
- }
- this.currentOrgList.saveOrgsWithCheckEmpower(function () {
- var appandTaskIdentityList;
- if (appendTaskOrgItem) {
- appandTaskIdentityList = appendTaskOrgItem.getData();
- if (!appandTaskIdentityList || appandTaskIdentityList.length === 0) {
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.selectAppendTaskIdentityNotice,
- this.node
- );
- return;
- }
- }
- if (routeConfig.validationScriptText) {
- var validation = this.form.Macro.exec(routeConfig.validationScriptText, this);
- if (!validation || validation.toString() !== "true") {
- if (typeOf(validation) === "string") {
- this.flow.noticeError( validation, this.node );
- return false;
- } else {
- //"路由校验失败"
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.routeValidFailure,
- this.node
- );
- return false;
- }
- }
- }
- this.node.mask({
- "inject": {"where": "bottom", "target": this.node},
- "destroyOnHide": true,
- "style": {
- "background-color": "#999",
- "opacity": 0.3,
- "z-index": this.flow.options.zIndex+1
- }
- });
- var array = [routeName, opinion, medias, appandTaskIdentityList, orgItems, function () {
- if (appendTaskOrgItem) appendTaskOrgItem.setData([]);
- }];
- this.flow.quickSelector.saveData();
- this.fireEvent("submit", array);
- }.bind(this));
- },
- getQuickData: function(){
- var organizations = {};
- var orgItems = this.currentOrgList ? this.currentOrgList.orgVisableItems : [];
- orgItems.each(function (org) {
- var vs = org.getValue();
- organizations[org.json.name] = vs.map(function (o) {
- return typeOf(o) === "string" ? o : o.distinguishedName;
- })
- });
- var route = this.routeRadio.getData().data;
- return {
- routeGroup: this.routeGroupRadio ? this.routeGroupRadio.getValue() : "",
- routeId: route.id,
- routeName: route.name,
- opinion: this.opinion.getValue(),
- organizations: organizations
- }
- },
- destroy: function () {
- Object.values( this.routeOrgMap ).each(function (orgList) {
- Object.values( orgList.orgMap ).each(function( org ){
- if(org.clearTooltip)org.clearTooltip();
- });
- });
- },
- getRouteGroupConfig: function () {
- var config = this.flow.getRouteGroupConfig();
- this.routeGroupObject = this.flow.routeGroupObject;
- this.routeGroupNameList = this.flow.routeGroupNameList;
- this.hasRouteGroup = this.flow.hasRouteGroup;
- return config;
- },
- getRouteConfigList: function () {
- return this.flow.getRouteConfigList();
- },
- getRouteConfig: function (routeId) {
- return this.flow.getRouteConfig( routeId );
- },
- getOrgConfig: function (routeId) {
- return this.flow.getOrgConfig( routeId );
- },
- getVisableOrgConfig: function (routeId) {
- return this.flow.getVisableOrgConfig(routeId);
- },
- isOrgHidden: function (d) {
- return this.flow.isOrgHidden(d);
- },
- getMaxOrgLength: function () {
- return this.flow.getMaxOrgLength();
- },
- getOffsetY: function (node) {
- return (node.getStyle("margin-top").toInt() || 0) +
- (node.getStyle("margin-bottom").toInt() || 0) +
- (node.getStyle("padding-top").toInt() || 0) +
- (node.getStyle("padding-bottom").toInt() || 0) +
- (node.getStyle("border-top-width").toInt() || 0) +
- (node.getStyle("border-bottom-width").toInt() || 0);
- },
- // setSize: function (currentOrgLength, flag) {
- // this.flow.resize()
- // return;
- // }
- });
- MWF.xDesktop.requireApp("process.Xform", "Org", null, false);
- MWF.ProcessFlow.Processor.OrgList = new Class({
- Implements: [Options, Events],
- options: {
- routeId: ""
- },
- initialize: function (processor, options) {
- this.processor = processor;
- this.form = processor.form;
- this.flow = processor.flow;
- this.businessData = this.form.businessData;
- this.wraper = processor.orgsWraper;
- this.container = processor.orgsArea;
- this.node = new Element("div").inject( processor.orgsArea );
- this.setOptions(options);
- this.orgs = [];
- this.orgMap = {};
- this.domMap = {};
- },
- load: function ( notFireResize ) {
- this.orgVisableItems = [];
- var configVisable = this.getVisableOrgConfig();
- if (configVisable.length) {
- this.wraper.show();
- this.node.show();
- this.loadOrgs();
- //this.processor.setSize(configVisable.length);
- if(!notFireResize)this.flow.resize();
- } else {
- this.orgMap = {};
- this.domMap = {};
- this.node.hide();
- this.wraper.hide();
- //this.processor.setSize(0);
- if(!notFireResize)this.flow.resize();
- }
- },
- hide: function(){
- this.node.hide();
- },
- getVisableOrgConfig: function(){
- return this.processor.getVisableOrgConfig( this.options.routeId );
- },
- getQuickOrgData: function( orgConfig ){
- if( !this.processor.quickData )return;
- if( this.processor.quickData.rId !== this.options.routeId )return;
- if( !this.processor.quickData.organizations )return;
- var d = this.processor.quickData.organizations[orgConfig.name];
- delete this.processor.quickData.organizations[orgConfig.name];
- return d;
- },
- loadOrgs: function () {
- var lastDom, configVisable = this.getVisableOrgConfig(), len = configVisable.length, lineNode;
- configVisable.each(function (config, i) {
- var dom, cfgId = config.id, quickOrgData = this.getQuickOrgData( config );
- if( i % 2 === 0 )lineNode = new Element("div.o2flow-org-line").inject( this.node );
- if( this.domMap[cfgId] ){
- dom = this.domMap[cfgId].show().inject( lineNode );
- if( quickOrgData && this.orgMap[cfgId]){
- var org = this.orgMap[cfgId];
- org.setData( quickOrgData );
- org.resetSelectorData();
- }
- this.orgVisableItems.push( this.orgMap[cfgId] );
- }else{
- //dom = new Element("div" ).inject( lastDom || this.node, lastDom ? "after" : "bottom" );
- dom = new Element("div" ).inject( lineNode );
- this.domMap[cfgId] = dom;
- this.loadOrg(dom, config, false, quickOrgData );
- }
- if( (i + 1 === len) && (len % 2 === 1) ){ //fullsize
- dom.addClass("o2flow-org-fullsize-node").removeClass("o2flow-org-left-node").removeClass("o2flow-org-right-node");
- }else{
- if( i % 2 === 0 ){ //left
- dom.removeClass("o2flow-org-fullsize-node").addClass("o2flow-org-left-node").removeClass("o2flow-org-right-node");
- }else{
- dom.removeClass("o2flow-org-fullsize-node").removeClass("o2flow-org-left-node").addClass("o2flow-org-right-node");
- }
- }
- //lastDom = dom;
- }.bind(this));
- },
- loadOrg: function (container, json, ignoreOldData, quickOrgData) {
- var titleNode = new Element("div.o2flow-selector-title").inject(container);
- new Element("div.o2flow-selector-titletext", { "text": json.title }).inject(titleNode);
- var errorNode = new Element("div.o2flow-selector-errornode").inject(titleNode);
- var contentNode = new Element("div.o2flow-selector-content").inject(container);
- contentNode.setStyle( "height", MWF.ProcessFlow_ORG_HEIGHT + "px" );
- var org = new MWF.ProcessFlow.Processor.Org(contentNode, this.form, json, this);
- org.ignoreOldData = ignoreOldData;
- org.errContainer = errorNode;
- org.load( quickOrgData );
- this.orgVisableItems.push(org);
- this.orgMap[json.id] = org;
- },
- clearAllOrgs: function () {
- //清空组织所选人
- Object.values(this.orgMap).each(function (org) {
- org.setDataToOriginal();
- })
- this.orgMap = {};
- this.domMap = {};
- this.orgVisableItems = [];
- this.node.empty();
- },
- getSelectedData: function (filedName) {
- var data = [];
- for (var i = 0; i < this.orgVisableItems.length; i++) {
- var org = this.orgVisableItems[i];
- if (org.json.name === filedName) {
- var selector = org.selector.selector;
- selector.selectedItems.each(function (item) {
- data.push(item.data)
- })
- }
- }
- return data;
- },
- isErrorHeightOverflow: function () {
- var hasOverflow = false;
- (this.orgVisableItems || []).each(function (item) {
- if (item.errorHeightOverflow) {
- hasOverflow = true;
- }
- }.bind(this));
- return hasOverflow;
- },
- checkErrorHeightOverflow: function (force) {
- if (force || this.isErrorHeightOverflow()) {
- //this.processor.setSize(this.orgVisableItems.length, true);
- this.flow.resize();
- }
- },
- errorHeightChange: function () {
- this.checkErrorHeightOverflow(true)
- },
- validationOrgs: function () {
- if (!this.orgVisableItems || !this.orgVisableItems.length) return true;
- var flag = true;
- this.orgVisableItems.each(function (item) {
- if (!item.validation()) flag = false;
- }.bind(this));
- this.checkErrorHeightOverflow();
- return flag;
- },
- isOrgsHasEmpower: function () {
- if (!this.orgVisableItems || !this.orgVisableItems.length) return true;
- this.needCheckEmpowerOrg = [];
- var ps = this.orgVisableItems.map(function (item) {
- return Promise.resolve( item.hasEmpowerIdentity() ).then(function ( flag ) {
- if( flag )return item;
- }.bind(this));
- }.bind(this));
- return Promise.all( ps ).then(function ( array ) {
- this.needCheckEmpowerOrg = array.clean();
- return this.needCheckEmpowerOrg.length > 0;
- }.bind(this));
- },
- saveOrgs: function (keepSilent) {
- if (!this.orgVisableItems || !this.orgVisableItems.length) return true;
- var flag = true;
- this.orgVisableItems.each(function (item) {
- if (!item.save(!keepSilent)) flag = false;
- }.bind(this));
- return flag;
- },
- saveOrgsWithCheckEmpower: function (callback) {
- var visableOrg = this.getVisableOrgConfig();
- var needOrgLength = visableOrg.length;
- var loadedOrgLength = 0;
- if ( this.orgVisableItems && this.orgVisableItems.length)loadedOrgLength = this.orgVisableItems.length;
- if( needOrgLength !== loadedOrgLength ){
- this.flow.noticeError(
- MWF.xApplication.process.Work.LP.loadedOrgCountUnexpected,
- this.node
- );
- return false;
- }
- if (!this.orgVisableItems || !this.orgVisableItems.length) {
- if (callback) callback();
- return true;
- }
- if (!this.validationOrgs()) return false;
- Promise.resolve( this.isOrgsHasEmpower() ).then(function (flag) {
- if( flag ){
- this.showEmpowerDlg(callback);
- }else{
- if (callback) callback();
- return true;
- }
- }.bind(this));
- },
- showEmpowerDlg: function (callback) {
- var empowerNode = new Element("div.o2flow-empower-node");
- empowerNode.loadCss( this.flow.path + this.flow.options.style + "/style.css" );
- var empowerTitleNode = new Element("div.o2flow-empower-titleNode", {
- text: MWF.xApplication.process.Xform.LP.empowerDlgText
- }).inject(empowerNode);
- var orgs = this.needCheckEmpowerOrg;
- var len = orgs.length;
- var lines = ((len + 1) / 2).toInt();
- var empowerTable = new Element("table.o2flow-empower-table", {
- "cellspacing": 0, "cellpadding": 0, "border": 0, "width": "100%"
- }).inject(empowerNode);
- for (var n = 0; n < lines; n++) {
- var tr = new Element("tr").inject(empowerTable);
- new Element("td.o2flow-empower-oddTd").inject(tr);
- new Element("td.o2flow-empower-evenTd").inject(tr);
- }
- var trs = empowerTable.getElements("tr");
- orgs.each(function (org, i) {
- var sNode;
- var width;
- if (i + 1 == len && (len % 2 === 1)) {
- sNode = trs[trs.length - 1].getFirst("td");
- sNode.set("colspan", 2);
- trs[trs.length - 1].getLast("td").destroy();
- width = "50%";
- } else {
- var row = ((i + 2) / 2).toInt();
- var tr = trs[row - 1];
- sNode = (i % 2 === 0) ? tr.getFirst("td") : tr.getLast("td");
- }
- org.loadCheckEmpower(sNode);
- }.bind(this));
- var width = 840;
- empowerNode.setStyle("height", lines * MWF.ProcessFlow_ORG_HEIGHT + 20);
- empowerNode.setStyle("width", width + "px");
- empowerNode.setStyle("opacity", 0);
- this.node.getParent().mask({
- "opacity": 0.7,
- "background-color": "#eee",
- "z-index": this.flow.options.zIndex + 2
- });
- 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 + 40, //600,
- "height": "auto", //dlgHeight,
- "mark": true,
- "zindex": this.flow.options.zIndex + 3,
- "onPostShow": function () {
- if (this.nodeWidth)this.node.setStyle("width", this.nodeWidth + "px");
- if (this.nodeHeight)this.node.setStyle("height", this.nodeHeight + "px");
- empowerNode.setStyle("opacity", 1);
- },
- "buttonList": [
- {
- "type": "ok",
- "text": MWF.LP.process.button.ok,
- "action": function (d, e) {
- 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.ProcessFlow.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 ( quickData ) {
- var options = this.getOptions();
- if (options) {
- if( quickData )options.values = quickData;
- this.selector = new MWF.O2Selector(this.container, options);
- }
- },
- clearTooltip: function(){
- if( this.selector && this.selector.selector && this.selector.selector.clearTooltip ){
- this.selector.selector.clearTooltip();
- }
- },
- _getOrgOptions: function () {
- this.selectTypeList = typeOf(this.json.selectType) == "array" ? this.json.selectType : [this.json.selectType];
- if (this.selectTypeList.contains("identity")) {
- this.identityOptions = new MWF.ProcessFlow.Processor.IdentityOptions(this.form, this.json);
- }
- if (this.selectTypeList.contains("unit")) {
- this.unitOptions = new MWF.ProcessFlow.Processor.UnitOptions(this.form, this.json);
- }
- if( this.selectTypeList.contains( "group" ) ){
- this.groupOptions = new MWF.ProcessFlow.Processor.GroupOptions( this.form, this.json );
- }
- },
- getDefaultOptions: function(){
- return {
- "style": "flow",
- "mainColorEnable": this.processor.flow.options.mainColorEnable,
- "width": "auto",
- "height": MWF.ProcessFlow_ORG_HEIGHT,
- "embedded": true,
- "hasLetter": false, //字母
- "hasTop": true //可选、已选的标题
- };
- },
- getOptionEvents: function(){
- return {};
- },
- 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);
- identityOpt.disabled = true;
- // 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);
- identityOpt.disabled = true;
- // 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);
- unitOpt.disabled = true;
- // 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();
- if (this.ignoreOldData) {
- groupOpt.values = this._computeValue() || [];
- } else {
- groupOpt.values = this.getValue() || [];
- }
- groupOpt.exclude = exclude;
- }
- var defaultOpt = this.getDefaultOptions();
- 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) {
- 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.needValid()) {
- defaultOpt["onValid"] = function (selector) {
- this.validOnSelect();
- }.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 events = this.getOptionEvents();
- if (this.selectTypeList.length === 1) {
- var opts = Object.merge(
- defaultOpt,
- {
- "type": this.selectTypeList[0],
- "onLoad": function () {
- //this 为 selector
- _self.selectOnLoad(this, this.selector)
- }
- },
- events,
- identityOpt || unitOpt || groupOpt
- )
- return this.filterOptionValues( opts, this.selectTypeList[0] );
- } else if (this.selectTypeList.length > 1) {
- var options = {
- "type": "",
- "types": this.selectTypeList,
- "onLoad": function () {
- //this 为 selector
- _self.selectOnLoad(this)
- }
- };
- if (identityOpt) {
- options.identityOptions = Object.merge(
- defaultOpt, events, identityOpt
- );
- }
- if (unitOpt) {
- options.unitOptions = Object.merge(
- defaultOpt, events, unitOpt
- );
- }
- if (groupOpt) {
- options.groupOptions = Object.merge(
- defaultOpt, events, groupOpt
- );
- }
- return options;
- }
- },
- filterOptionValues: function( options, type ){
- var suffix;
- switch (type) {
- case "identity": suffix = "I"; break;
- case "unit": suffix = "U"; break;
- case "group": suffix = "G"; break;
- }
- options.values = (options.values || []).filter(function (v) {
- if( typeOf(v) === "string" ){
- if( v.contains("@") ){
- return v.split("@").getLast().toUpperCase() === suffix;
- }else{
- return true;
- }
- }else if( typeOf(v) === "object" ){
- if( v.distinguishedName ){
- return v.distinguishedName.split("@").getLast().toUpperCase() === suffix;
- }else{
- return false;
- }
- }
- return false;
- }.bind(this));
- return options;
- },
- selectOnLoad: function (selector) {
- //if (this.descriptionNode) this.descriptionNode.setStyle("display", "none");
- this.fireEvent("loadSelector", [selector])
- },
- 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) {
- if( typeOf(data) === "string" ){
- data = { distinguishedName : data, name : o2.name.cn(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, this.getOrgWidgetOption());
- break;
- case "p":
- widget = new MWF.widget.O2Person(copyData, node, this.getOrgWidgetOption());
- break;
- case "u":
- widget = new MWF.widget.O2Unit(copyData, node, this.getOrgWidgetOption());
- break;
- case "g":
- widget = new MWF.widget.O2Group(copyData, node, this.getOrgWidgetOption());
- break;
- default:
- widget = new MWF.widget.O2Other(copyData, node, this.getOrgWidgetOption());
- }
- widget.field = this;
- widget.load();
- }.bind(this));
- }
- },
- getOrgWidgetOption: function(){
- return {"style": "xform", "lazy": true, "delay":true}
- },
- hasEmpowerIdentity: function () {
- var data = this.getData();
- if (!this.empowerChecker){
- this.empowerChecker = new MWF.ProcessFlow.Processor.EmpowerChecker(this);
- }
- return this.empowerChecker.hasEmpowerIdentity(data);
- },
- checkEmpower: function (data, callback, container) {
- if (typeOf(data) === "array" && this.identityOptions && this.json.isCheckEmpower && this.json.identityResultType === "identity") {
- if (!this.empowerChecker){
- this.empowerChecker = new MWF.ProcessFlow.Processor.EmpowerChecker(this);
- }
- this.empowerChecker.load(data, callback, container);
- } else {
- if (callback) callback(data);
- }
- },
- loadCheckEmpower: function (container, callback) {
- this.checkEmpower(this.getData(), callback, container);
- },
- saveCheckedEmpowerData: function (callback) {
- var data = this.getData();
- var simple = this.json.storeRange === "simple";
- //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, simple));
- }.bind(this));
- this.setData(values);
- if (callback) callback(values);
- }.bind(this))
- },
- save: function (isValid) {
- if (isValid) {
- if (this.validation()) {
- return true;
- } else {
- this.processor.checkErrorHeightOverflow();
- 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();
- }
- },
- setDataToOriginal: function () {
- var v = this._computeValue();
- this.setData(v || "");
- },
- 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 simple = this.json.storeRange === "simple";
- var data = [];
- if (this.selector && this.selector.selector) {
- this.selector.selector.selectedItems.each(function (item) {
- data.push(MWF.org.parseOrgData(item.data, true, simple));
- })
- }
- 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.groupValue) {
- // this.json.groupValue.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 simple = this.json.storeRange === "simple";
- 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, simple);
- }.bind(this), null, v, false);
- }
- if (vtype === "object") {
- data = MWF.org.parseOrgData(v, true, simple);
- 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, simple);
- }.bind(this), null, value, false);
- if (vData) values.push(vData);
- }
- if (type === "object") {
- var vData = MWF.org.parseOrgData(value, true, simple);
- 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 < oldValues.length; i++) {
- if ((oldValues[i].distinguishedName !== values[i].distinguishedName) || (oldValues[i].name !== values[i].name) || (oldValues[i].unique !== values[i].unique)) {
- change = true;
- break;
- }
- }
- } else {
- change = true;
- }
- } else if (values.length || oldValues.length) {
- change = true;
- }
- this._setBusinessData(values);
- if (change) this.fireEvent("change");
- },
- getValueMethod: function (value) {
- if (value) {
- var flag = value.substr(value.length - 1, 1);
- switch (flag.toLowerCase()) {
- case "i":
- return "getIdentity";
- case "p":
- return "getPerson";
- case "u":
- return "getUnit";
- case "g":
- return "getGroup";
- default:
- return (this.json.selectType === "unit") ? "getUnit" : "getIdentity";
- }
- }
- return (this.json.selectType === "unit") ? "getUnit" : "getIdentity";
- },
- _getBusinessData: function () {
- if (this.json.section == "yes") {
- return this._getBusinessSectionData();
- } else {
- if (this.json.type === "Opinion") {
- return this._getBusinessSectionDataByPerson();
- } else {
- return this.form.businessData.data[this.json.name] || "";
- }
- }
- },
- _getBusinessSectionData: function () {
- switch (this.json.sectionBy) {
- case "person":
- return this._getBusinessSectionDataByPerson();
- case "unit":
- return this._getBusinessSectionDataByUnit();
- case "activity":
- return this._getBusinessSectionDataByActivity();
- case "splitValue":
- return this._getBusinessSectionDataBySplitValue();
- case "script":
- return this._getBusinessSectionDataByScript(this.json.sectionByScript.code);
- default:
- return this.form.businessData.data[this.json.name] || "";
- }
- },
- _getBusinessSectionDataByPerson: function () {
- this.form.sectionListObj[this.json.name] = layout.desktop.session.user.id;
- var dataObj = this.form.businessData.data[this.json.name];
- return (dataObj) ? (dataObj[layout.desktop.session.user.id] || "") : "";
- },
- _getBusinessSectionDataByUnit: function () {
- this.form.sectionListObj[this.json.name] = "";
- var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
- if (key) this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) return "";
- return (key) ? (dataObj[key] || "") : "";
- },
- _getBusinessSectionDataByActivity: function () {
- this.form.sectionListObj[this.json.name] = "";
- var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
- if (key) this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) return "";
- return (key) ? (dataObj[key] || "") : "";
- },
- _getBusinessSectionDataBySplitValue: function () {
- this.form.sectionListObj[this.json.name] = "";
- var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
- if (key) this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) return "";
- return (key) ? (dataObj[key] || "") : "";
- },
- _getBusinessSectionDataByScript: function (code) {
- this.form.sectionListObj[this.json.name] = "";
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) return "";
- var key = this.form.Macro.exec(code, this);
- if (key) this.form.sectionListObj[this.json.name] = key;
- return (key) ? (dataObj[key] || "") : "";
- },
- loadPathData: function (path) {
- var data = null;
- this.form.workAction.getJobDataByPath(this.form.businessData.work.job, path, function (json) {
- data = json.data || null;
- }, null, false);
- return data;
- },
- _setBusinessData: function (v) {
- if (this.json.section == "yes") {
- // var d = this.loadPathData(this.json.name);
- // if (d) this.form.businessData.data[this.json.name] = d;
- this._setBusinessSectionData(v);
- } else {
- if (this.json.type === "Opinion") {
- // var d = this.loadPathData(this.json.name);
- // if (d) this.form.businessData.data[this.json.name] = d;
- this._setBusinessSectionDataByPerson(v);
- } else {
- if (this.form.businessData.data[this.json.name]) {
- this.form.businessData.data[this.json.name] = v;
- } else {
- this.form.businessData.data[this.json.name] = v;
- this.form.Macro.environment.setData(this.form.businessData.data);
- }
- if (this.json.isTitle) this.form.businessData.work.title = v;
- }
- }
- },
- _setBusinessSectionData: function (v) {
- switch (this.json.sectionBy) {
- case "person":
- this._setBusinessSectionDataByPerson(v);
- break;
- case "unit":
- this._setBusinessSectionDataByUnit(v);
- break;
- case "activity":
- this._setBusinessSectionDataByActivity(v);
- break;
- case "splitValue":
- this._setBusinessSectionDataBySplitValue(v);
- break;
- case "script":
- this._setBusinessSectionDataByScript(this.json.sectionByScript.code, v);
- break;
- default:
- if (this.form.businessData.data[this.json.name]) {
- this.form.businessData.data[this.json.name] = v;
- } else {
- this.form.businessData.data[this.json.name] = v;
- this.form.Macro.environment.setData(this.form.businessData.data);
- }
- }
- },
- _setBusinessSectionDataByPerson: function (v) {
- var resetData = false;
- var key = layout.desktop.session.user.id;
- this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) {
- dataObj = {};
- this.form.businessData.data[this.json.name] = dataObj;
- resetData = true;
- }
- if (!dataObj[key]) resetData = true;
- dataObj[key] = v;
- if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
- },
- _setBusinessSectionDataByUnit: function (v) {
- var resetData = false;
- var key = (this.form.businessData.task) ? this.form.businessData.task.unit : "";
- if (key) {
- this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) {
- dataObj = {};
- this.form.businessData.data[this.json.name] = dataObj;
- resetData = true;
- }
- if (!dataObj[key]) resetData = true;
- dataObj[key] = v;
- }
- if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
- },
- _setBusinessSectionDataByActivity: function (v) {
- var resetData = false;
- var key = (this.form.businessData.work) ? this.form.businessData.work.activity : "";
- if (key) {
- this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) {
- dataObj = {};
- this.form.businessData.data[this.json.name] = dataObj;
- resetData = true;
- }
- if (!dataObj[key]) resetData = true;
- dataObj[key] = v;
- }
- if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
- },
- _setBusinessSectionDataBySplitValue: function (v) {
- var resetData = false;
- var key = (this.form.businessData.work) ? this.form.businessData.work.splitValue : "";
- if (key) {
- this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) {
- dataObj = {};
- this.form.businessData.data[this.json.name] = dataObj;
- resetData = true;
- }
- if (!dataObj[key]) resetData = true;
- dataObj[key] = v;
- }
- if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
- },
- _setBusinessSectionDataByScript: function (code, v) {
- var resetData = false;
- var key = this.form.Macro.exec(code, this);
- if (key) {
- this.form.sectionListObj[this.json.name] = key;
- var dataObj = this.form.businessData.data[this.json.name];
- if (!dataObj) {
- dataObj = {};
- this.form.businessData.data[this.json.name] = dataObj;
- resetData = true;
- }
- if (!dataObj[key]) resetData = true;
- dataObj[key] = v;
- }
- if (resetData) this.form.Macro.environment.setData(this.form.businessData.data);
- },
- createErrorNode: function (text) {
- var _self = this;
- var node;
- if (this.processor.css && this.processor.css.errorContentNode) {
- node = new Element("div", {
- "styles": this.processor.css.errorContentNode,
- "text": text
- });
- if (this.processor.css.errorCloseNode) {
- var closeNode = new Element("div", {
- "styles": this.processor.css.errorCloseNode,
- "events": {
- "click": function () {
- this.destroy();
- if (_self.errorHeightOverflow) {
- _self.errorHeightOverflow = false;
- _self.processor.errorHeightChange();
- }
- }.bind(node)
- }
- }).inject(node);
- }
- } else {
- node = new Element("div");
- var iconNode = new Element("div", {
- "styles": {
- "width": "20px",
- "height": "20px",
- "float": "left",
- "background": "url(" + "../x_component_process_Xform/$Form/default/icon/error.png) center center no-repeat"
- }
- }).inject(node);
- var textNode = new Element("div", {
- "styles": {
- "height": "auto",
- "min-height": "20px",
- "line-height": "20px",
- "margin-left": "20px",
- "color": "red",
- "word-break": "break-all"
- },
- "text": text
- }).inject(node);
- }
- return node;
- },
- notValidationMode: function (text) {
- if (!this.isNotValidationMode) {
- //this.isNotValidationMode = true;
- //this.node.store("borderStyle", this.node.getStyles("border-left", "border-right", "border-top", "border-bottom"));
- //this.node.setStyle("border-color", "red");
- this.errNode = this.createErrorNode(text);
- if (this.errContainer) {
- this.errContainer.empty();
- this.errNode.inject(this.errContainer);
- } else {
- this.errNode.inject(this.container, "after");
- }
- if (!this.errNode.isIntoView()) this.errNode.scrollIntoView(false);
- var errorSize = this.errNode.getSize();
- if (!layout.mobile && errorSize.y > 26) {
- this.errorHeightOverflow = true;
- }
- }
- },
- needValid: function () {
- return ((this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") ||
- (this.json.validation && this.json.validation.code));
- },
- validOnSelect: function () {
- if (!this.errNode) return true;
- var flag = true;
- if (this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") {
- if (this.selector.selector.selectedItems.length < this.json.validationCount.toInt()) {
- flag = MWF.xApplication.process.Xform.LP.selectItemCountNotice.replace("{count}", this.json.validationCount);
- }
- }
- if (flag === true) {
- if (this.json.validation && this.json.validation.code) {
- var data = this.getData();
- this.setData(data);
- flag = this.form.Macro.exec(this.json.validation.code, this);
- if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
- }
- }
- if (flag.toString() != "true") {
- this.notValidationMode(flag);
- this.processor.errorHeightChange();
- return false;
- } else if (this.errNode) {
- this.errNode.destroy();
- this.errNode = null;
- if (this.errorHeightOverflow) {
- this.errorHeightOverflow = false;
- this.processor.errorHeightChange();
- }
- }
- return true;
- },
- validation: function () {
- var data = this.getData();
- this.setData(data);
- var flag = true;
- if (this.json.validationCount && typeOf(this.json.validationCount.toInt()) === "number") {
- if (data.length < this.json.validationCount.toInt()) {
- //"请至少选择" + this.json.validationCount + "项"
- flag = MWF.xApplication.process.Xform.LP.selectItemCountNotice.replace("{count}", this.json.validationCount);
- }
- }
- if (flag === true) {
- if (this.json.validation && this.json.validation.code) {
- flag = this.form.Macro.exec(this.json.validation.code, this);
- if (!flag) flag = MWF.xApplication.process.Xform.LP.notValidation;
- }
- }
- if (flag.toString() != "true") {
- this.notValidationMode(flag);
- return false;
- } else if (this.errNode) {
- this.errNode.destroy();
- this.errNode = null;
- }
- return true;
- }
- });
- MWF.ProcessFlow.Processor.EmpowerChecker = new Class({
- initialize: function (org) {
- this.org = org;
- this.form = org.form;
- this.json = org.json;
- this.processor = org.processor;
- this.flow = org.processor.flow;
- },
- load: function (data, callback, container) {
- var p = this.getEmpowerData( data );
- return Promise.resolve(p).then(function ( eArr ) {
- if (eArr.length > 0) {
- this.loadDom(eArr, data, container);
- } else {
- if (callback) callback(data);
- }
- }.bind(this));
- },
- loadDom: function(eArr, data, container){
- var _self = this;
- var titleNode = new Element("div.o2flow-empower-areaTitle").inject(container);
- new Element("div.o2flow-empower-areaTitleText", { text: this.json.title }).inject(titleNode);
- var selectAllNode = new Element("div.o2flow-empower-selectAllNode").inject( titleNode );
- var contentNode = new Element("div.o2flow-empower-areaContent").inject(container);
- this.selectAllRadio = new MWF.ProcessFlow.widget.Radio2(selectAllNode, this.flow, {
- optionList: [{
- value: "true", text: this.flow.lp.selectAll
- }],
- value: "true",
- onCheck: function(el, value){
- _self.empowerCheckbox.checkAll();
- },
- onUncheck: function(el, value){
- _self.empowerCheckbox.uncheckAll();
- },
- });
- this.selectAllRadio.load();
- this.empowerCheckbox = new MWF.ProcessFlow.widget.Checkbox(contentNode, this.flow, {
- optionList: eArr.map(function (e) {
- return {
- value: e.id,
- text: e.fromIdentity.split("@")[0] + " " + this.flow.lp.empowerTo + " " + e.toIdentity.split("@")[0],
- data: e
- };
- }.bind(this)),
- values: eArr.map(function (e) {
- return e.id;
- })
- });
- this.empowerCheckbox.load();
- },
- hasEmpowerIdentity: function (data) {
- var p = this.getEmpowerData( data );
- return Promise.resolve(p).then(function ( arr ) {
- return arr.length > 0;
- });
- },
- isNeedCheck: function(data){
- return typeOf(data) === "array" && this.json.isCheckEmpower && this.json.identityResultType === "identity";
- },
- getIdentityDn: function( data ){
- return data.filter(function (d) {
- return d.distinguishedName && d.distinguishedName.substr(d.distinguishedName.length - 1, 1).toLowerCase() === "i";
- }).map(function (d) {
- return d.distinguishedName;
- });
- },
- getEmpowerData: function(data){
- if( !this.isNeedCheck(data) )return [];
- var array = this.getIdentityDn( data );
- if( array.length < 1)return [];
- return 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) {
- return json.data.filter(function (d) {
- return d.fromIdentity !== d.toIdentity;
- });
- }.bind(this), function () {
- return [];
- })
- },
- 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);
- },
- setIgnoreEmpowerFlag : function(data, callback){
- var ignoreList = this.empowerCheckbox.getUncheckData().map(function (d) {
- return d.data.fromIdentity;
- });
- for( var i=0; i<data.length; i++ ){
- var d = data[i];
- if( ignoreList.indexOf( d.distinguishedName ) > -1 ){
- d.ignoreEmpower = true;
- }else if( d.ignoreEmpower ){
- delete d.ignoreEmpower;
- }
- }
- if( callback )callback( data );
- },
- });
- MWF.ProcessFlow.Processor.UnitOptions = new Class({
- Extends: MWF.APPOrg.UnitOptions
- });
- MWF.ProcessFlow.Processor.IdentityOptions = new Class({
- Extends: MWF.APPOrg.IdentityOptions
- });
- MWF.ProcessFlow.Processor.GroupOptions = new Class({
- Extends: MWF.APPOrg.GroupOptions
- });
- MWF.ProcessFlow.widget = {};
- MWF.xDesktop.requireApp("Template", "MTooltips", null, false);
- MWF.ProcessFlow.widget.QuickSelect = new Class({
- Extends: MTooltips,
- options: {
- event : "click",
- hasArrow : false,
- hideByClickBody : true,
- offset : {
- x : 0,
- y : 5
- },
- nodeStyles: {
- "font-size" : "13px",
- "position" : "absolute",
- "max-width" : "500px",
- "min-width" : "260px",
- "z-index" : 20002,
- "background-color" : "#fff",
- "padding" : "10px 0px 10px 0px",
- "border-radius" : "8px",
- "box-shadow": "0px 0px 8px 0px rgba(0,0,0,0.25)",
- "-webkit-user-select": "text",
- "-moz-user-select": "text"
- }
- },
- _loadCustom : function( callback ){
- this.node.loadCss( this.flow.path + this.flow.options.style + "/style.css" );
- var width = this.target.getSize().x ;
- this.node.setStyles({
- "max-width": width+"px",
- "min-width": width+"px"
- });
- var work = this.flow.form.businessData.work;
- var d = {
- process: work.process,
- activity: work.activity,
- activityAlias: work.activityAlias,
- activityName: work.activityName
- };
- // if( work.activityAlias ){
- // d.activityAlias = work.activityAlias
- // }else{
- // d.activityName = work.activityName;
- // }
- var p = o2.Actions.load("x_processplatform_assemble_surface").TaskProcessModeAction.listMode( d );
- Promise.resolve(p).then(function (json) {
- debugger;
- var list = this.filterData(json.data);
- var data = list.map(function (d) {
- return {
- type: d.action,
- text: this.getText( d ),
- data: d
- }
- }.bind(this));
- if( !data || !data.length ){
- new Element("div.o2flow-quick-select-item", {
- text: this.flow.lp.noQuickSelectDataNote
- }).inject( this.contentNode );
- }else{
- this.loadItems(data)
- }
- //setTimeout( function () {
- if(callback)callback( data );
- //}, 50);
- }.bind(this));
- },
- loadItems: function(data){
- var _self = this;
- data.each( function (d) {
- var item = new Element("div.o2flow-quick-select-item", {
- events: {
- mouseover: function () {
- this.addClass("o2flow-quick-select-item-active");
- this.getFirst().addClass("o2flow-quick-select-item-contnet-active");
- if( _self.flow.options.mainColorEnable ){
- this.addClass("mainColor_bg");
- this.getFirst().addClass("mainColor_bg");
- }
- },
- mouseout: function () {
- this.removeClass("o2flow-quick-select-item-active");
- this.getFirst().removeClass("o2flow-quick-select-item-contnet-active");
- if( _self.flow.options.mainColorEnable ) {
- this.removeClass("mainColor_bg");
- this.getFirst().removeClass("mainColor_bg");
- }
- },
- click: function () {
- var d = Object.clone( item.retrieve("data"));
- _self.flow.changeAction( d.type, d.data );
- _self.hide();
- }
- }
- }).inject( this.contentNode );
- item.store( "data", d );
- var title = new Element("div.o2flow-quick-select-itemtitle", {
- text: this.flow.lp.flowActions[d.type]
- }).inject( item );
- title.addClass( "o2flow-"+d.type+"-color" );
- var content = new Element("div.o2flow-quick-select-itemtext", {
- text: ":"+ d.text
- }).inject( item )
- }.bind(this))
- },
- filterData: function( data ){
- //var onekeyList = listData();
- return data.filter(function (d) {
- var flag = (d.action === "process" && this.flow.processEnable) || (d.action === "reset" && this.flow.resetEnable) || (d.action === "addTask" && this.flow.addTaskEnable);
- if( !flag )return false;
- if( d.action === "process" && !this.flow.getRouteConfig(d.routeName) )return false;
- return true;
- }.bind(this));
- },
- getText: function( d ){
- //选择[送办理],意见:请办理,处理人:张三、李四、张三、李四、张三、李四、张三、李四、张三、李四、张三、李四、张三、李四
- //选择[前加签],意见:请处理,加签人:赵六
- //保留待办,意见:请处理,重置给:王五
- var text, orgtexts = [], lp = this.flow.lp;
- switch (d.action) {
- case "process":
- Object.each( d.organizations, function (value, key) {
- if( value && value.length ){
- orgtexts.push( ( this.flow.getSingleOrgConfig( d.routeId , key ) ).title + ":" + value.clean().map(function(v){ return v.split("@")[0]; }).join("、"));
- }
- }.bind(this));
- text = lp.submitQuickText.replace("{route}", d.routeName ).replace("{opinion}", d.opinion);
- if( !orgtexts.length ){
- return text.replace("{org}", "");
- }else{
- return text.replace("{org}", "," + orgtexts.join(",") );
- }
- case "addTask":
- if( d.organizations && d.organizations.default ){
- orgtexts.push( d.organizations.default.clean().map(function(v){ return v.split("@")[0]; }).join("、") );
- }
- var route = d.routeId === "before" ? lp.addTaskBefore : lp.addTaskAfter;
- var mode = lp[ d.routeGroup ] || "";
- return lp.addTaskQuickText.replace("{route}", route ).replace("{mode}", mode).replace("{opinion}", d.opinion).replace("{org}", orgtexts.join(",") );
- case "reset":
- if( d.organizations && d.organizations.default ){
- orgtexts.push( d.organizations.default.clean().map(function(v){ return v.split("@")[0]; }).join("、") );
- }
- return lp.resetQuickText.replace("{opinion}", d.opinion).replace("{org}", orgtexts.join(",") );
- //return lp.resetQuickText.replace("{flag}", d.keepTask ? "" : lp.not ).replace("{opinion}", d.opinion).replace("{org}", orgtexts.join(",") );
- }
- },
- saveData: function () {
- debugger;
- var work = this.flow.form.businessData.work || this.flow.form.businessData.workCompleted;
- var d = {
- process: work.process,
- processName: work.processName,
- activity: work.activity,
- activityName: work.activityName,
- activityAlias: work.activityAlias,
- action: this.flow.currentAction
- };
- // routeId: "",
- // routeName: "",
- // routeGroup:决策组.
- // keepTask:是否保留待办.
- // opinion:意见.
- // organizations:人员组织列表.
- var quickData = {};
- switch ( this.flow.currentAction ) {
- case "process":
- quickData = this.flow.processor.getQuickData();
- break;
- case "addTask":
- quickData = this.flow.addTask.getQuickData();
- break;
- case "reset":
- quickData = this.flow.reset.getQuickData();
- break;
- }
- d = Object.merge(d, quickData);
- o2.Actions.load("x_processplatform_assemble_surface").TaskProcessModeAction.saveMode( d, null, null, false );
- },
- });
- MWF.ProcessFlow.widget.Opinion = new Class({
- Implements: [Options, Events],
- options: {
- isHandwriting: false,
- opinion: "",
- tabletToolHidden: [],
- tabletWidth: 0,
- tabletHeight: 0
- },
- initialize: function( container, flow, options ){
- this.setOptions( options );
- this.container = container;
- this.flow = flow;
- this.lp = flow.lp;
- },
- load: function(){
- this.loadData( function () {
- this.loadDom();
- }.bind(this));
- },
- loadData: function ( callback ) {
- MWF.require("MWF.widget.UUID", function () {
- MWF.UD.getDataJson("idea", function (json) {
- if (json) {
- if (json.ideas) {
- this.opinionList = json.ideas;
- if(callback)callback();
- }else{
- this.opinionList = [];
- if(callback)callback();
- }
- } else {
- MWF.UD.getPublicData("idea", function (pjson) {
- if (pjson && pjson.ideas) {
- this.opinionList = pjson.ideas;
- if(callback)callback();
- }else{
- this.opinionList = [];
- if(callback)callback();
- }
- }.bind(this));
- }
- }.bind(this));
- }.bind(this));
- },
- loadDom: function(){
- var url = this.flow.path+this.flow.options.style+"/widget/opinion.html";
- this.container.loadHtml(url, {
- "bind": {
- "lp": this.lp, "opinionList": this.opinionList, "opinion": this.options.opinion || ""
- },
- "module": this
- }, function(){
- if( this.options.isHandwriting )this.handwritingButton.show();
- this.opinionTextarea.addEvent("change", function () {
- this.removeRequireStyle();
- }.bind(this));
- this.loaded = true;
- this.fireEvent("load");
- }.bind(this)
- );
- },
- setRequireStyle: function(){
- this.opinionTextarea.addClass("o2flow-invalid-bg");
- },
- removeRequireStyle: function(){
- if(this.opinionTextarea.hasClass("o2flow-invalid-bg")){
- this.opinionTextarea.removeClass("o2flow-invalid-bg");
- }
- },
- getValue: function(){
- return this.opinionTextarea.get("value");
- },
- setValue: function( value ){
- this.opinionTextarea.set("value", value);
- },
- selectOpinion: function( opinion ){
- var op = this.opinionTextarea.get("value");
- if ( !op ) {
- this.opinionTextarea.set("value", opinion );
- } else {
- this.opinionTextarea.set("value", op + ", " + opinion );
- }
- this.removeRequireStyle();
- },
- overItemNode: function (ev) {
- ev.target.addClass("o2flow-bg-opacity");
- if( this.flow.options.mainColorEnable ){
- ev.target.addClass("mainColor_bg_opacity");
- }
- },
- outItemNode: function (ev) {
- ev.target.removeClass("o2flow-bg-opacity");
- if( this.flow.options.mainColorEnable ) {
- ev.target.removeClass("mainColor_bg_opacity");
- }
- },
- handwriting: function () {
- if( !this.tablet )this.createHandwriting();
- this.handwritingMask.show();
- this.handwritingNode.show();
- this.handwritingNode.position({
- "relativeTo": this.flow.node,
- "position": "center",
- "edge": "center"
- });
- },
- createHandwriting: function () {
- this.handwritingMask.inject( this.flow.node );
- this.handwritingNode.show().inject(this.flow.node, "after");
- //兼容以前的默认高宽
- var x = 600;
- var y = 320;
- x = Math.max(this.options.tabletWidth || x, 600);
- this.options.tabletWidth = x;
- y = Math.max(this.options.tabletHeight ? (parseInt(this.options.tabletHeight) + 110) : y, 320);
- var zidx = this.flow.node.getStyle("z-index");
- this.handwritingNode.setStyles({
- "height": "" + y + "px",
- "width": "" + x + "px",
- "z-index": zidx + 1
- });
- this.handwritingNode.position({
- "relativeTo": this.flow.node,
- "position": "center",
- "edge": "center"
- });
- if( this.flow.options.mainColorEnable )this.handwritingSaveNode.addClass("mainColor_bg");
- var h = this.handwritingSaveNode.getSize().y + this.flow.getOffsetY(this.handwritingSaveNode);
- this.handwritingAreaNode.setStyle("height", "" + ( y - h ) + "px");
- MWF.require("MWF.widget.Tablet", function () {
- var handWritingOptions = this.getHandWritingOptions();
- this.tablet = new MWF.widget.Tablet(this.handwritingAreaNode, handWritingOptions, null);
- this.tablet.load();
- }.bind(this));
- },
- getHandWritingOptions: function(){
- return {
- "style": "default",
- "toolHidden": this.options.tabletToolHidden || [],
- "contentWidth": this.options.tabletWidth || 0,
- "contentHeight": this.options.tabletHeight || 0,
- "iconfontEnable": true,
- "mainColorEnable": this.flow.options.mainColorEnable,
- "onSave": function (base64code, base64Image, imageFile) {
- if( !this.tablet.isBlank() ){
- this.handwritingFile = imageFile;
- this.handwritingButton.getElement("i").removeClass("o2icon-edit2").
- addClass("o2icon-checkbox").addClass("o2flow-handwriting-buttonok");
- this.removeRequireStyle();
- }else{
- this.handwritingFile = null;
- this.handwritingButton.getElement("i").addClass("o2icon-edit2").
- removeClass("o2icon-checkbox").removeClass("o2flow-handwriting-buttonok");
- }
- this.handwritingNode.hide();
- this.handwritingMask.hide();
- }.bind(this),
- "onCancel": function () {
- this.handwritingFile = null;
- this.handwritingButton.getElement("i").addClass("o2icon-edit2").
- removeClass("o2icon-checkbox").removeClass("o2flow-handwriting-buttonok");
- this.handwritingNode.hide();
- this.handwritingMask.hide();
- }.bind(this)
- };
- },
- saveTablet: function () {
- if (this.tablet) this.tablet.save();
- }
- });
- MWF.ProcessFlow.widget.Radio = new Class({
- Implements: [Options, Events],
- options: {
- optionList: [],
- value: null,
- cancelEnable: true
- },
- initialize: function( container, flow, options ){
- this.container = container;
- this.flow = flow;
- this.lp = flow.lp;
- this.setOptions( options );
- },
- load: function(){
- this.checkedItems = [];
- this.container.loadHtml(this.getUrl(), {"bind": {"lp": this.lp, "optionList": this.options.optionList}, "module": this}, function(){
- if( this.options.value !== null )this.setValue( this.options.value );
- this.fireEvent("load");
- }.bind(this));
- },
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/widget/radio.html";
- },
- setValue: function( values ){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- if( typeOf( values ) === "null" )return;
- values = typeOf( values ) === "array" ? values : [values];
- this.container.getElements(".o2flow-radio").each(function (el) {
- if(values.contains( el.dataset["o2Value"] )){
- this.check(el)
- }
- }.bind(this))
- },
- getData: function( value ){
- if( !value )value = this.getValue();
- var arr = this.options.optionList.filter(function (o) {
- return o.value === value;
- });
- return arr[0] || null;
- },
- getValue: function(){
- var data = this.checkedItems.map(function (item) {
- return item.dataset["o2Value"];
- });
- return data[0] || null;
- },
- getText: function(){
- var data = this.checkedItems.map(function (item) {
- return item.dataset["o2Text"];
- });
- return data[0] || null;
- },
- toggle: function( ev ){
- var el = this.flow.getEl(ev, "o2flow-radio");
- if( this.checkedItems.contains( el ) ){
- if( this.options.cancelEnable )this.uncheck( el, true )
- }else{
- this.check( el )
- }
- },
- check: function(el){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- el.addClass("o2flow-radio-active");
- if( this.flow.options.mainColorEnable )el.addClass("mainColor_bg");
- el.getElement("i").removeClass("o2icon-icon_circle").addClass("o2icon-checkbox").addClass("o2flow-radio-icon");
- el.dataset["o2Checked"] = true;
- this.checkedItems.push(el);
- this.removeRequireStyle();
- this.fireEvent("check", [el, el.dataset["o2Value"]])
- },
- uncheck: function(el, isFire){
- el.removeClass("o2flow-radio-active");
- if( this.flow.options.mainColorEnable )el.removeClass("mainColor_bg");
- el.getElement("i").removeClass("o2icon-checkbox").addClass("o2icon-icon_circle").removeClass("o2flow-radio-icon");
- el.dataset["o2Checked"] = false;
- this.checkedItems.erase(el);
- if(isFire)this.fireEvent("uncheck", [el, el.dataset["o2Value"]])
- },
- setRequireStyle: function(){
- this.container.addClass("o2flow-invalid-bg");
- },
- removeRequireStyle: function(){
- if(this.container.hasClass("o2flow-invalid-bg")){
- this.container.removeClass("o2flow-invalid-bg");
- }
- },
- // over: function (ev) {
- // var el = this.flow.getEl(ev, "o2flow-radio");
- // if( !el.dataset["o2Checked"] ){
- // el.getElement("i").addClass("o2flow-radio-over");
- // }
- // },
- // out: function (ev) {
- // var el = this.flow.getEl(ev, "o2flow-radio");
- // el.getElement("i").removeClass("o2flow-radio-over")
- // }
- });
- MWF.ProcessFlow.widget.Radio2 = new Class({
- Extends: MWF.ProcessFlow.widget.Radio,
- options: {
- optionList: [],
- value: null,
- cancelEnable: true,
- activeIcon: "o2icon-radio-checked"
- },
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/widget/radio2.html";
- },
- setValue: function( values ){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- values = typeOf( values ) === "array" ? values : [values];
- this.container.getElements(".o2flow-radio2").each(function (el) {
- if(values.contains( el.dataset["o2Value"] ))this.check(el)
- }.bind(this))
- },
- toggle: function( ev ){
- var el = this.flow.getEl(ev, "o2flow-radio2");
- if( this.checkedItems.contains( el ) ){
- if( this.options.cancelEnable )this.uncheck( el, true )
- }else{
- this.check( el )
- }
- },
- check: function(el){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- el.addClass("o2flow-radio2-active");
- if( this.flow.options.mainColorEnable )el.addClass("mainColor_color");
- el.getElement("i").removeClass("o2icon-icon_circle").addClass(this.options.activeIcon).addClass("o2flow-radio2-icon");
- if( this.flow.options.mainColorEnable )el.getElement("i").addClass("mainColor_color");
- el.dataset["o2Checked"] = true;
- this.checkedItems.push(el);
- this.removeRequireStyle();
- this.fireEvent("check", [el, el.dataset["o2Value"]])
- },
- uncheck: function(el, isFire){
- el.removeClass("o2flow-radio2-active");
- if( this.flow.options.mainColorEnable )el.removeClass("mainColor_color");
- el.getElement("i").removeClass(this.options.activeIcon).addClass("o2icon-icon_circle").removeClass("o2flow-radio2-icon");
- if( this.flow.options.mainColorEnable )el.getElement("i").removeClass("mainColor_color");
- el.dataset["o2Checked"] = false;
- this.checkedItems.erase(el);
- if(isFire)this.fireEvent("uncheck", [el, el.dataset["o2Value"]])
- }
- });
- MWF.ProcessFlow.widget.Checkbox = new Class({
- Implements: [Options, Events],
- options: {
- optionList: [],
- values: []
- },
- initialize: function( container, flow, options ){
- this.container = container;
- this.flow = flow;
- this.lp = flow.lp;
- this.setOptions( options );
- },
- load: function(){
- this.checkedItems = [];
- this.container.loadHtml(this.getUrl(), {"bind": {"lp": this.lp, "optionList": this.options.optionList}, "module": this}, function(){
- if( this.options.values.length )this.setValue( this.options.values );
- this.fireEvent("load");
- }.bind(this));
- },
- getUrl: function(){
- return this.flow.path+this.flow.options.style+"/widget/checkbox.html";
- },
- setValue: function( values ){
- while( this.checkedItems.length ){
- this.uncheck( this.checkedItems[0] );
- }
- values = typeOf( values ) === "array" ? values : [values];
- this.container.getElements(".o2flow-radio").each(function (el) {
- if(values.contains( el.dataset["o2Value"] )){
- this.check(el)
- }
- }.bind(this))
- },
- getData: function( value ){
- if( !value )value = this.getValue();
- value = typeOf( value ) === "array" ? value : [value];
- var arr = this.options.optionList.filter(function (o) {
- return value.contains(o.value);
- });
- return arr;
- },
- getValue: function(){
- return this.checkedItems.map(function (item) {
- return item.dataset["o2Value"];
- });
- },
- getText: function(){
- return this.checkedItems.map(function (item) {
- return item.dataset["o2Text"];
- });
- },
- toggle: function( ev ){
- var el = this.flow.getEl(ev, "o2flow-radio");
- if( this.checkedItems.contains( el ) ){
- this.uncheck( el, true )
- }else{
- this.check( el )
- }
- },
- check: function(el){
- el.addClass("o2flow-radio-active");
- if( this.flow.options.mainColorEnable )el.addClass("mainColor_bg");
- el.getElement("i").removeClass("o2icon-icon_circle").addClass("o2icon-checkbox").addClass("o2flow-radio-icon");
- el.dataset["o2Checked"] = true;
- this.checkedItems.push(el);
- this.removeRequireStyle();
- this.fireEvent("check", [el, el.dataset["o2Value"]])
- },
- uncheck: function(el, isFire){
- el.removeClass("o2flow-radio-active");
- if( this.flow.options.mainColorEnable )el.removeClass("mainColor_bg");
- el.getElement("i").removeClass("o2icon-checkbox").addClass("o2icon-icon_circle").removeClass("o2flow-radio-icon");
- el.dataset["o2Checked"] = false;
- this.checkedItems.erase(el);
- if(isFire)this.fireEvent("uncheck", [el, el.dataset["o2Value"]])
- },
- checkAll: function(){
- this.container.getElements(".o2flow-radio").each(function (el) {
- this.check(el)
- }.bind(this))
- },
- uncheckAll: function(){
- this.container.getElements(".o2flow-radio").each(function (el) {
- this.uncheck(el)
- }.bind(this))
- },
- getUncheckData: function(){
- var value = this.getValue();
- return this.options.optionList.filter(function (o) {
- return !value.contains(o.value);
- });
- },
- setRequireStyle: function(){
- this.container.addClass("o2flow-invalid-bg");
- },
- removeRequireStyle: function(){
- if(this.container.hasClass("o2flow-invalid-bg")){
- this.container.removeClass("o2flow-invalid-bg");
- }
- }
- });
|