Parcourir la source

Merge branch 'feature/Process.module_add_isEmpty_method' into 'develop'

Merge of feature/【流程管理】流程表单组件添加isEmpty方法 to develop

See merge request o2oa/o2oa!590
蔡祥熠 il y a 5 ans
Parent
commit
8efb9dd16f

+ 4 - 0
o2web/source/x_component_process_Xform/$Input.js

@@ -216,6 +216,10 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         var text = (this.node.getFirst()) ? this.node.getFirst().get("text") : this.node.get("text");
 		return {"value": [value || ""] , "text": [text || value || ""]};
 	},
+    isEmpty : function(){
+	    var data = this.getData();
+	    return !data || !data.trim();
+    },
 	getData: function(when){
         if (this.json.compute == "save") this._setValue(this._computeValue());
 		return this.getInputData();

+ 8 - 0
o2web/source/x_component_process_Xform/Attachment.js

@@ -1104,6 +1104,14 @@ MWF.xApplication.process.Xform.Attachment = MWF.APPAttachment = new Class({
         }.bind(this));
 
     },
+    isEmpty : function(){
+        var data = this.getData();
+        if( typeOf(data) === "array" ){
+            return data.length == 0
+        }else{
+            return !data;
+        }
+    },
     getData: function () {
         return (this.attachmentController) ? this.attachmentController.getAttachmentNames() : null;
     },

+ 6 - 0
o2web/source/x_component_process_Xform/Checkbox.js

@@ -180,6 +180,12 @@ MWF.xApplication.process.Xform.Checkbox = MWF.APPCheckbox =  new Class({
 		//}
 		//return (value.length==1) ? value[0] : value;
     //},
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "array" )return true;
+        if( data.length === 0 )return true;
+        return false;
+    },
     getInputData: function(){
         if (this.readonly || this.json.isReadonly ){
             return this._getBusinessData();

+ 8 - 0
o2web/source/x_component_process_Xform/Combox.js

@@ -179,6 +179,14 @@ MWF.xApplication.process.Xform.Combox = MWF.APPCombox =  new Class({
             this.combox.setOptions({"list": list});
         }
 	},
+    isEmpty : function(){
+        var data = this.getData();
+        if( typeOf(data) === "array" ){
+            return data.length === 0;
+        }else{
+            return !data;
+        }
+    },
     getInputData: function(){
         if (this.combox) return this.combox.getData();
         return this._getBusinessData();

+ 17 - 8
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -582,10 +582,13 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             this.close();
         }, null, null, this.form.json.confirmStyle);
     },
-    _completeLineEdit: function(){
-        if (!this.editValidation()){
-            return false;
+    _completeLineEdit: function( ev, ignoreValidation ){
+	    if( !ignoreValidation ){
+            if (!this.editValidation()){
+                return false;
+            }
         }
+
         this.isEdit = false;
         //var flag = true;
 
@@ -1109,7 +1112,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
         this.setData(this._getValue());
     },
     setData: function(data){
-	    debugger;
+        // if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
         if (data){
             this._setBusinessData(data);
             this.gridData = data;
@@ -1117,10 +1120,7 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
             this.gridData = this._getValue();
         }
 
-        if (this.isEdit) {
-            this._completeLineEdit();
-        }
-
+        if (this.isEdit) this._completeLineEdit( null,true );
         if (this.gridData){
 
             var divs = this.node.getElements(".dataDiv");
@@ -1190,6 +1190,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
     getTotal: function(){
         this._loadTotal();
         return this.totalResaults;
+    },
+    isEmpty: function(){
+	    var data = this.getData();
+	    if( !data )return true;
+	    if( typeOf( data ) === "object" ){
+	        if( typeOf( data.data ) !== "array" )return true;
+	        if( data.data.length === 0 )return true;
+        }
+	    return false;
     },
 	getData: function(){
         if (this.editable!=false){

+ 18 - 6
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -405,11 +405,13 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
 		}, null, null, this.form.json.confirmStyle);
 
 	},
-	_completeLineEdit: function(){
+	_completeLineEdit: function( ev, ignoreValidation ){
 		//this.currentEditLine.getElemets(td);
-        if (!this.editValidation()){
-            return false;
-        }
+		if( !ignoreValidation ){
+			if (!this.editValidation()){
+				return false;
+			}
+		}
 
 		this.isEdit = false;
 		
@@ -938,14 +940,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
         this.setData(this._getValue());
     },
     setData: function(data){
-        if (data){
+		// if( typeOf( data ) === "object" && typeOf(data.data) === "array"  ){
+		if (data){
             this._setBusinessData(data);
             this.gridData = data;
         }else{
             this.gridData = this._getValue();
         }
 
-        if (this.isEdit) this._completeLineEdit();
+        if (this.isEdit) this._completeLineEdit(  null,true );
         if (this.gridData){
             var trs = this.table.getElements("tr");
             for (var i=1; i<trs.length-1; i++){
@@ -984,6 +987,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
         this._loadTotal();
         return this.totalResaults;
     },
+	isEmpty: function(){
+		var data = this.getData();
+		if( !data )return true;
+		if( typeOf( data ) === "object" ){
+			if( typeOf( data.data ) !== "array" )return true;
+			if( data.data.length === 0 )return true;
+		}
+		return false;
+	},
 	getData: function(){
         if (this.editable!=false){
 			if (this.isEdit) this._completeLineEdit();

+ 5 - 0
o2web/source/x_component_process_Xform/Documenteditor.js

@@ -1796,6 +1796,11 @@ debugger;
             this._repage();
         }.bind(this));
     },
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "object" )return true;
+        return !data.filetext || data.filetext===this.json.defaultValue.filetext;
+    },
     getData: function(){
         //if (this.editMode){
         if (this.layout_copies) this.data.copies = this.layout_copies.get("text");

+ 1 - 1
o2web/source/x_component_process_Xform/Form.js

@@ -1082,7 +1082,7 @@ MWF.xApplication.process.Xform.Form = MWF.APPForm = new Class({
             //        this.setModifedData(data[i], pathList.push(i));
             //    }
             //}
-        } else if (typeOf(data) !== "null") {
+        } else if (typeOf(data) !== "null") { //后台对null是忽略处理的,认为值没有变化
             var od = this.getOrigianlPathData(pathList);
             if (typeOf(data) !== typeOf(od) || data !== od) {
                 this.setModifedDataByPathList(data, pathList);

+ 3 - 0
o2web/source/x_component_process_Xform/Htmleditor.js

@@ -372,6 +372,9 @@ MWF.xApplication.process.Xform.Htmleditor = MWF.APPHtmleditor =  new Class({
     resetData: function(){
         this.setData(this._getBusinessData());
     },
+    isEmpty : function(){
+        return !this.getData().trim();
+    },
     getData: function(){
         this.clearEcnetNodes();
         return this.editor.getData();

+ 3 - 0
o2web/source/x_component_process_Xform/ImageClipper.js

@@ -86,6 +86,9 @@ MWF.xApplication.process.Xform.ImageClipper = MWF.APPImageClipper =  new Class({
         var value = this._getBusinessData() || "";
         return {"value": [value], "text": [value]};
     },
+    isEmpty : function(){
+        return !this.getData();
+    },
     getData: function( data ){
         return this._getBusinessData() || "";
     },

+ 3 - 1
o2web/source/x_component_process_Xform/Number.js

@@ -3,7 +3,9 @@ MWF.xApplication.process.Xform.Number = MWF.APPNumber =  new Class({
     Implements: [Events],
     Extends: MWF.APPTextfield,
     iconStyle: "numberIcon",
-
+    isEmpty : function(){
+        return !this.getData();
+    },
     getInputData: function(){
         if (this.node.getFirst()){
             var v = this.node.getElement("input").get("value");

+ 4 - 0
o2web/source/x_component_process_Xform/Office.js

@@ -1203,6 +1203,10 @@ MWF.xApplication.process.Xform.Office = MWF.APPOffice =  new Class({
         this.fileUploadNode = this.uploadFileAreaNode.getFirst();
         this.uploadFileAreaNode.inject(this.officeForm);
     },
+    isEmpty : function(){
+        var data = this.getData();
+        return !data.trim();
+    },
     getData: function(){
         if (this.officeOCX && (this.officeOCX.DocType==1 || this.officeOCX.DocType==6)){
             this.officeOCX.ActiveDocument.Application.Selection.WholeStory();

+ 6 - 0
o2web/source/x_component_process_Xform/Org.js

@@ -323,6 +323,12 @@ MWF.xApplication.process.Xform.Org = MWF.APPOrg =  new Class({
         //this.setData((v) ? v.join(", ") : "");
         this.setData(v);
     },
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "array" )return true;
+        if( data.length === 0 )return true;
+        return false;
+    },
     getInputData: function(){
         if (this.json.isInput){
             if (this.combox)return this.combox.getData();

+ 6 - 0
o2web/source/x_component_process_Xform/Orgfield.js

@@ -276,6 +276,12 @@ MWF.xApplication.process.Xform.Orgfield = MWF.APPOrgfield =  new Class({
             value = this._computeValue();
         }
         return value || "";
+    },
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "array" )return true;
+        if( data.length === 0 )return true;
+        return false;
     },
 	getData: function(when){
 		if (this.json.compute == "save") this._setValue(this._computeValue());

+ 6 - 0
o2web/source/x_component_process_Xform/Personfield.js

@@ -394,6 +394,12 @@ MWF.xApplication.process.Xform.Personfield = MWF.APPPersonfield =  new Class({
         //this.setData((v) ? v.join(", ") : "");
         this.setData(v);
     },
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "array" )return true;
+        if( data.length === 0 )return true;
+        return false;
+    },
     getInputData: function(){
         if (this.json.isInput){
             if (this.combox) return this.combox.getData();