From 038d42131bcfd2c46c0b1e96845af0074bdda804 Mon Sep 17 00:00:00 2001 From: huqi Date: Wed, 14 Jul 2021 17:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9Org=E7=BB=84=E4=BB=B6?= =?UTF-8?q?=EF=BC=8C=E5=85=BC=E5=AE=B9=E5=90=8C=E6=AD=A5=E6=A8=A1=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Module/Org/org.html | 7 ++ .../x_component_process_FormDesigner/lp/en.js | 1 + .../lp/zh-cn.js | 1 + .../x_component_process_Xform/$Input.js | 6 +- .../x_component_process_Xform/$Module.js | 2 + o2web/source/x_component_process_Xform/Org.js | 90 +++++++++++-------- 6 files changed, 66 insertions(+), 41 deletions(-) diff --git a/o2web/source/x_component_process_FormDesigner/Module/Org/org.html b/o2web/source/x_component_process_FormDesigner/Module/Org/org.html index 2c7ccb2565..10f566fd02 100644 --- a/o2web/source/x_component_process_FormDesigner/Module/Org/org.html +++ b/o2web/source/x_component_process_FormDesigner/Module/Org/org.html @@ -48,6 +48,13 @@ {{$.lp.simple}} + + {{$.lp.asyncMode}}: + + {{$.lp.yes}} + {{$.lp.no}} + + {{$.lp.separator}}: diff --git a/o2web/source/x_component_process_FormDesigner/lp/en.js b/o2web/source/x_component_process_FormDesigner/lp/en.js index a153144bd8..49cbdea62d 100644 --- a/o2web/source/x_component_process_FormDesigner/lp/en.js +++ b/o2web/source/x_component_process_FormDesigner/lp/en.js @@ -430,6 +430,7 @@ MWF.xApplication.process.FormDesigner.LP = { "complete": "Complete", "simple": "Simple", "separator": "Separator", + "asyncMode": "Async Mode", "identity": "Identity", "unit": "Unit", diff --git a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js index befc19fa9d..90b900ea62 100644 --- a/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js +++ b/o2web/source/x_component_process_FormDesigner/lp/zh-cn.js @@ -428,6 +428,7 @@ MWF.xApplication.process.FormDesigner.LP = { "complete": "完整", "simple": "精简", "separator": "分隔符", + "asyncMode": "异步模式", "identity": "身份", "unit": "组织", diff --git a/o2web/source/x_component_process_Xform/$Input.js b/o2web/source/x_component_process_Xform/$Input.js index 058d9ed29c..9020f120ff 100644 --- a/o2web/source/x_component_process_Xform/$Input.js +++ b/o2web/source/x_component_process_Xform/$Input.js @@ -223,11 +223,6 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input = new Class( this.__setValue(v); }.bind(this), function(){}); this.moduleValueAG = p; - p.then(function(){ - this.moduleValueAG = null; - }.bind(this), function(){ - this.moduleValueAG = null; - }.bind(this)); }else{ this.moduleValueAG = null; this.__setValue(value); @@ -238,6 +233,7 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input = new Class( }, __setValue: function(value){ + this.moduleValueAG = null; this._setBusinessData(value); if (this.node.getFirst()) this.node.getFirst().set("value", value || ""); if (this.readonly || this.json.isReadonly) this.node.set("text", value); diff --git a/o2web/source/x_component_process_Xform/$Module.js b/o2web/source/x_component_process_Xform/$Module.js index 4d00f3fd14..bb93a495c2 100644 --- a/o2web/source/x_component_process_Xform/$Module.js +++ b/o2web/source/x_component_process_Xform/$Module.js @@ -102,6 +102,8 @@ MWF.xApplication.process.Xform.$Module = MWF.APP$Module = new Class( this._afterLoaded(); this.fireEvent("postLoad"); this.fireEvent("load"); + + this.moduleLoaded = true; } }, _loadUserInterface: function(){ diff --git a/o2web/source/x_component_process_Xform/Org.js b/o2web/source/x_component_process_Xform/Org.js index 24e50a487c..626b6c6655 100644 --- a/o2web/source/x_component_process_Xform/Org.js +++ b/o2web/source/x_component_process_Xform/Org.js @@ -1178,47 +1178,65 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg = new Class( if (typeOf(value)!=="array") value = (!!value) ? [value] : []; //value = (value.flat) ? value.flat() : value.flatten(); - var p = o2.promiseAll(value).then(function(d){ - if (typeOf(d)!=="array") d = (!!d) ? [d] : []; - d.each(function(da){ - if (typeOf(da)!=="array") da = (!!da) ? [da] : []; - da.each(function(dd){ - if (dd){ - if (typeOf(dd)==="string"){ - var pp = this.getOrgAction()[this.getValueMethod(dd)](function(json){ - return MWF.org.parseOrgData(json.data, true, simple); - }.bind(this), null, dd, true).catch(function(e){ - console.log("error:" + e); - console.log(e); - }); - ags.push(pp); - }else{ - values.push(dd); + if (value.some(function(e){ return (e && o2.typeOf(e.then)=="function") }) || this.json.asyncMode==="yes"){ + var p = Promise.all(value).then(function(d){ + if (typeOf(d)!=="array") d = (!!d) ? [d] : []; + d.each(function(da){ + if (typeOf(da)!=="array") da = (!!da) ? [da] : []; + da.each(function(dd){ + if (dd){ + if (typeOf(dd)==="string"){ + var pp = this.getOrgAction()[this.getValueMethod(dd)](function(json){ + return MWF.org.parseOrgData(json.data, true, simple); + }.bind(this), null, dd, true).catch(function(e){ + console.log("error:" + e); + console.log(e); + }); + ags.push(pp); + }else{ + values.push(dd); + } } - } + }.bind(this)); }.bind(this)); - }.bind(this)); - if (ags.length){ - return o2.promiseAll(ags).then(function(data){ - values = values.concat(data); + if (ags.length){ + return Promise.all(ags).then(function(data){ + values = values.concat(data); + flag = true; + this.__setValue(values); + return values; + }.bind(this), function(){}); + }else{ flag = true; this.__setValue(values); - return values; - }.bind(this), function(){}); - }else{ - flag = true; - this.__setValue(values); - return values - } - }.bind(this), function(){}); + return values + } + }.bind(this), function(){}); + + this.moduleValueAG = p; + if (p && p.then) p.then(function(){ + this.moduleValueAG = null; + }.bind(this), function(){ + this.moduleValueAG = null; + }.bind(this)); + return p; + }else{ + value.each(function(dd){ + if (dd){ + if (typeOf(dd)==="string"){ + this.getOrgAction()[this.getValueMethod(dd)](function(json){ + values.push(MWF.org.parseOrgData(json.data, true, simple)); + }.bind(this), null, dd, false); + }else{ + values.push(dd); + } + } + }.bind(this)); + this.__setValue(values); + return values + } + - this.moduleValueAG = p; - if (p && p.then) p.then(function(){ - this.moduleValueAG = null; - }.bind(this), function(){ - this.moduleValueAG = null; - }.bind(this)); - return p; // var ag = o2.AG.all(value).then(function(d) { // if (typeOf(d)!=="array") d = (d) ? [d.toString()] : []; -- GitLab