Browse Source

Merge branch 'wrdp' into 'develop'

Wrdp

See merge request o2oa/o2oa!2717
蔡祥熠 5 years ago
parent
commit
712fde2012

+ 2 - 2
o2web/source/o2_core/o2.js

@@ -1882,14 +1882,14 @@ if (!window.Promise){
             if (p.some(function(e){ return (e && o2.typeOf(e.then)=="function") })){
             if (p.some(function(e){ return (e && o2.typeOf(e.then)=="function") })){
                 return Promise.all(p);
                 return Promise.all(p);
             }else{
             }else{
-                return { "then": function(s){ s(p); return this;} };
+                return { "then": function(s){ return s(p) || this;} };
                 //return new Promise(function(s){s(p); return this;});
                 //return new Promise(function(s){s(p); return this;});
             }
             }
         }else{
         }else{
             if (p && o2.typeOf(p.then)=="function"){
             if (p && o2.typeOf(p.then)=="function"){
                 return Promise.resolve(p);
                 return Promise.resolve(p);
             }else{
             }else{
-                return { "then": function(s){ s(p); return this;} };
+                return { "then": function(s){ return s(p) || this;} };
                 //return new Promise(function(s){s(p); return this;});
                 //return new Promise(function(s){s(p); return this;});
             }
             }
         }
         }

+ 46 - 11
o2web/source/x_component_process_Xform/Log.js

@@ -379,9 +379,9 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         td = tr.insertCell(8).setStyles(css);
         td = tr.insertCell(8).setStyles(css);
         td.set("html", arrivedUsers);
         td.set("html", arrivedUsers);
 
 
+        var atts = [];
         if (task.properties.mediaOpinion){
         if (task.properties.mediaOpinion){
             var mediaIds = task.properties.mediaOpinion.split(",");
             var mediaIds = task.properties.mediaOpinion.split(",");
-            var atts = [];
             if (this.form.businessData.attachmentList){
             if (this.form.businessData.attachmentList){
                 this.form.businessData.attachmentList.each(function(att){
                 this.form.businessData.attachmentList.each(function(att){
                     if (att.site==="$mediaOpinion"){
                     if (att.site==="$mediaOpinion"){
@@ -391,6 +391,14 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             }
             }
             if (atts.length) this.loadMediaOpinion(atts, opinionTd.getFirst(), "table");
             if (atts.length) this.loadMediaOpinion(atts, opinionTd.getFirst(), "table");
         }
         }
+
+        this.fireEvent("postLoadLine",[{
+            "data" : task,
+            "node" : tr,
+            "atts" : atts,
+            "log" : this,
+            "type" : isTask ? "task" : "taskCompleted"
+        }]);
     },
     },
     loadRecordLogDefault: function(list, container){
     loadRecordLogDefault: function(list, container){
         var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode_record}).inject(container || this.node);
         var logActivityNode = new Element("div", {"styles": this.form.css.logActivityNode_record}).inject(container || this.node);
@@ -450,6 +458,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         }
         }
         var html;
         var html;
         var company = "";
         var company = "";
+        var atts = [];
         if (!isTask){
         if (!isTask){
             company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
             company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
             html = this.json.textStyle;
             html = this.json.textStyle;
@@ -545,7 +554,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             var imgNode = textNode.getElement(".mwf_log_img");
             var imgNode = textNode.getElement(".mwf_log_img");
             if (task.properties.mediaOpinion){
             if (task.properties.mediaOpinion){
                 var mediaIds = task.properties.mediaOpinion.split(",");
                 var mediaIds = task.properties.mediaOpinion.split(",");
-                var atts = [];
+                // var atts = [];
                 if (this.form.businessData.attachmentList){
                 if (this.form.businessData.attachmentList){
                     this.form.businessData.attachmentList.each(function(att){
                     this.form.businessData.attachmentList.each(function(att){
                         if (att.site==="$mediaOpinion"){
                         if (att.site==="$mediaOpinion"){
@@ -578,6 +587,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         }
         }
         this.fireEvent("postLoadLine",[{
         this.fireEvent("postLoadLine",[{
             "data" : task,
             "data" : task,
+            "atts" : atts,
             "node" : logTaskNode,
             "node" : logTaskNode,
             "log" : this,
             "log" : this,
             "type" : isTask ? "task" : "taskCompleted"
             "type" : isTask ? "task" : "taskCompleted"
@@ -604,7 +614,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             this.loadRecordTaskLine_text(log, container || this.node, false);
             this.loadRecordTaskLine_text(log, container || this.node, false);
         }
         }
     },
     },
-    loadRecordTaskLine_text: function(task, node, log, isTask){
+    loadRecordTaskLine_text: function(task, node, isTask){
         this.loadRecordTaskLine_default(task, node, isTask, "0px", false, true, true);
         this.loadRecordTaskLine_default(task, node, isTask, "0px", false, true, true);
     },
     },
 
 
@@ -634,8 +644,18 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
                     }
                     }
                 }.bind(this));
                 }.bind(this));
             }
             }
+            var isCompleted = !!task.recordTime;
             task.completedTime = task.recordTime;
             task.completedTime = task.recordTime;
-            if (atts.length) this.loadMediaOpinion_show(atts, task, container);
+            var node = new Element("div").inject( container || this.node );
+            if (atts.length) this.loadMediaOpinion_show(atts, task, node);
+
+            this.fireEvent("postLoadLine",[{
+                "data" : task,
+                "atts" : atts,
+                "node" : node,
+                "log" : this,
+                "type" : isCompleted ? "taskCompleted" : "task"
+            }]);
         }
         }
     },
     },
 
 
@@ -1023,7 +1043,16 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
                     }
                     }
                 }.bind(this));
                 }.bind(this));
             }
             }
-            if (atts.length) this.loadMediaOpinion_show(atts, task, container);
+            var node = new Element("div").inject( container || this.node );
+            if (atts.length) this.loadMediaOpinion_show(atts, task, node);
+
+            this.fireEvent("postLoadLine",[{
+                "data" : task,
+                "atts" : atts,
+                "node" : node,
+                "log" : this,
+                "type" : !!task.completedTime ? "taskCompleted" : "task"
+            }]);
         }
         }
     },
     },
     loadMediaOpinion_show: function(atts, task, container, noName){
     loadMediaOpinion_show: function(atts, task, container, noName){
@@ -1098,10 +1127,6 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             }
             }
         }).inject(imgNode);
         }).inject(imgNode);
 
 
-
-
-
-
         // var size = img.getSize();
         // var size = img.getSize();
         // var x_y = size.x/size.y;
         // var x_y = size.x/size.y;
         // if (size.y>260){
         // if (size.y>260){
@@ -1276,9 +1301,10 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         opinion = (task.processingType=="empower") ? "授权给"+ o2.name.cn(task.empowerToIdentity || "") : "<div style='line-height: 28px; float:left'>" + (task.opinion || "")+"</div>";
         opinion = (task.processingType=="empower") ? "授权给"+ o2.name.cn(task.empowerToIdentity || "") : "<div style='line-height: 28px; float:left'>" + (task.opinion || "")+"</div>";
         td.set("html", opinion);
         td.set("html", opinion);
 
 
+
+        var atts = [];
         if (task.mediaOpinion){
         if (task.mediaOpinion){
             var mediaIds = task.mediaOpinion.split(",");
             var mediaIds = task.mediaOpinion.split(",");
-            var atts = [];
             if (this.form.businessData.attachmentList){
             if (this.form.businessData.attachmentList){
                 this.form.businessData.attachmentList.each(function(att){
                 this.form.businessData.attachmentList.each(function(att){
                     if (att.site==="$mediaOpinion"){
                     if (att.site==="$mediaOpinion"){
@@ -1288,6 +1314,13 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             }
             }
             if (atts.length) this.loadMediaOpinion(atts, td.getFirst(), "table");
             if (atts.length) this.loadMediaOpinion(atts, td.getFirst(), "table");
         }
         }
+        this.fireEvent("postLoadLine",[{
+            "data" : task,
+            "atts" : atts,
+            "node" : tr,
+            "log" : this,
+            "type" : isTask ? "task" : "taskCompleted"
+        }]);
     },
     },
 
 
 
 
@@ -1504,6 +1537,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         }
         }
         var html;
         var html;
         var company = "";
         var company = "";
+        var atts = [];
         if (!isTask){
         if (!isTask){
             company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
             company = (task.unitList) ? task.unitList[task.unitList.length-1] : "";
             var html = this.json.textStyle;
             var html = this.json.textStyle;
@@ -1568,7 +1602,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
             var imgNode = textNode.getElement(".mwf_log_img");
             var imgNode = textNode.getElement(".mwf_log_img");
             if (task.mediaOpinion){
             if (task.mediaOpinion){
                 var mediaIds = task.mediaOpinion.split(",");
                 var mediaIds = task.mediaOpinion.split(",");
-                var atts = [];
+                // var atts = [];
                 if (this.form.businessData.attachmentList){
                 if (this.form.businessData.attachmentList){
                     this.form.businessData.attachmentList.each(function(att){
                     this.form.businessData.attachmentList.each(function(att){
                         if (att.site==="$mediaOpinion"){
                         if (att.site==="$mediaOpinion"){
@@ -1598,6 +1632,7 @@ MWF.xApplication.process.Xform.Log = MWF.APPLog =  new Class(
         this.fireEvent("postLoadLine",[{
         this.fireEvent("postLoadLine",[{
             "data" : task,
             "data" : task,
             "node" : logTaskNode,
             "node" : logTaskNode,
+            "atts" : atts,
             "log" : this,
             "log" : this,
             "type" : isTask ? "task" : "taskCompleted"
             "type" : isTask ? "task" : "taskCompleted"
         }]);
         }]);

+ 60 - 18
o2web/source/x_component_process_Xform/Number.js

@@ -33,31 +33,72 @@ MWF.xApplication.process.Xform.Number = MWF.APPNumber =  new Class({
     //     if ((isNaN(n))) {this.setData('0')};
     //     if ((isNaN(n))) {this.setData('0')};
     //     return (isNaN(n)) ? 0 : n;
     //     return (isNaN(n)) ? 0 : n;
     // },
     // },
-    validationFormat: function(){
 
 
-        if( !this.node.getElement("input") )return true;
-        var n = this.node.getElement("input").get("value");
-        if (isNaN(n)) {
-            this.notValidationMode(MWF.xApplication.process.Xform.LP.notValidation_number);
-            return false;
-        }
-        var v = n.toFloat();
+    formatNumber: function(str){
+        var v = str.toFloat();
         if (v){
         if (v){
             if (this.json.decimals && (this.json.decimals!="*")){
             if (this.json.decimals && (this.json.decimals!="*")){
-                var p = Math.pow(10,this.json.decimals);
+
+                var decimals = this.json.decimals.toInt();
+
+                var p = Math.pow(10,decimals);
                 var f_x = Math.round(v*p)/p;
                 var f_x = Math.round(v*p)/p;
-                var s_x = f_x.toString();
-                var pos_decimal = s_x.indexOf('.');
-                if (pos_decimal < 0){
-                    pos_decimal = s_x.length;
-                    s_x += '.';
-                }
-                while (s_x.length <= pos_decimal + 2){
-                    s_x += '0';
+                str = f_x.toString();
+
+                if (decimals>0){
+                    var pos_decimal = str.indexOf('.');
+                    if (pos_decimal < 0){
+                        pos_decimal = str.length;
+                        str += '.';
+                    }
+                    decimalStr = (str).substr(pos_decimal+1, (str).length);
+                    while (decimalStr.length < decimals){
+                        str += '0';
+                        decimalStr += 0;
+                    }
                 }
                 }
-                this.node.getFirst().set("value", s_x);
             }
             }
         }
         }
+        return str;
+    },
+
+    validationFormat: function(){
+debugger;
+        if( !this.node.getElement("input") )return true;
+        var n = this.node.getElement("input").get("value");
+        if (isNaN(n)) {
+            this.notValidationMode(MWF.xApplication.process.Xform.LP.notValidation_number);
+            return false;
+        }
+
+        this.node.getFirst().set("value", this.formatNumber(n));
+
+        // var v = n.toFloat();
+        // if (v){
+        //     if (this.json.decimals && (this.json.decimals!="*")){
+        //
+        //         var decimals = this.json.decimals.toInt();
+        //
+        //         var p = Math.pow(10,decimals);
+        //         var f_x = Math.round(v*p)/p;
+        //         var s_x = f_x.toString();
+        //
+        //         if (decimals>0){
+        //             var pos_decimal = s_x.indexOf('.');
+        //             if (pos_decimal < 0){
+        //                 pos_decimal = s_x.length;
+        //                 s_x += '.';
+        //             }
+        //             decimalStr = (s_x).substr(pos_decimal+1, (s_x).length);
+        //             while (decimalStr.length < decimals){
+        //                 s_x += '0';
+        //                 decimalStr += 0;
+        //             }
+        //         }
+        //
+        //         this.node.getFirst().set("value", s_x);
+        //     }
+        // }
         return true;
         return true;
     },
     },
     validationConfigItem: function(routeName, data){
     validationConfigItem: function(routeName, data){
@@ -211,6 +252,7 @@ MWF.xApplication.process.Xform.Number = MWF.APPNumber =  new Class({
         if (this.moduleValueAG) return this.moduleValueAG;
         if (this.moduleValueAG) return this.moduleValueAG;
         var value = this._getBusinessData();
         var value = this._getBusinessData();
         if (!value) value = this._computeValue();
         if (!value) value = this._computeValue();
+        value = this.formatNumber(value);
         return value || "0";
         return value || "0";
     },
     },
     __setValue: function(value){
     __setValue: function(value){

+ 2 - 2
o2web/source/x_component_process_Xform/Org.js

@@ -1200,8 +1200,8 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class(
             }
             }
         }.bind(this), function(){});
         }.bind(this), function(){});
 
 
-        this.moduleValueAG = p;
-        if (p) p.then(function(){
+        this.moduleValueAG = Promise.resolve(p);
+        if (p & p.then) p.then(function(){
             this.moduleValueAG = null;
             this.moduleValueAG = null;
         }.bind(this), function(){
         }.bind(this), function(){
             this.moduleValueAG = null;
             this.moduleValueAG = null;