Просмотр исходного кода

添加表单组件的isEmpty 方法

unknown 5 лет назад
Родитель
Сommit
cab09e330f

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

@@ -216,6 +216,9 @@ MWF.xApplication.process.Xform.$Input = MWF.APP$Input =  new Class({
         var text = (this.node.getFirst()) ? this.node.getFirst().get("text") : this.node.get("text");
         var text = (this.node.getFirst()) ? this.node.getFirst().get("text") : this.node.get("text");
 		return {"value": [value || ""] , "text": [text || value || ""]};
 		return {"value": [value || ""] , "text": [text || value || ""]};
 	},
 	},
+    isEmpty : function(){
+	    return !!this.getData();
+    },
 	getData: function(when){
 	getData: function(when){
         if (this.json.compute == "save") this._setValue(this._computeValue());
         if (this.json.compute == "save") this._setValue(this._computeValue());
 		return this.getInputData();
 		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));
         }.bind(this));
 
 
     },
     },
+    isEmpty : function(){
+        var data = this.getData();
+        if( typeOf(data) === "array" ){
+            return data.length !== 0
+        }else{
+            return !!data;
+        }
+    },
     getData: function () {
     getData: function () {
         return (this.attachmentController) ? this.attachmentController.getAttachmentNames() : null;
         return (this.attachmentController) ? this.attachmentController.getAttachmentNames() : null;
     },
     },

+ 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});
             this.combox.setOptions({"list": list});
         }
         }
 	},
 	},
+    isEmpty : function(){
+        var data = this.getData();
+        if( typeOf(data) === "array" ){
+            return data.length !== 0;
+        }else{
+            return !!data;
+        }
+    },
     getInputData: function(){
     getInputData: function(){
         if (this.combox) return this.combox.getData();
         if (this.combox) return this.combox.getData();
         return this._getBusinessData();
         return this._getBusinessData();

+ 9 - 0
o2web/source/x_component_process_Xform/DatagridMobile.js

@@ -1133,6 +1133,15 @@ MWF.xApplication.process.Xform.DatagridMobile = new Class({
     getTotal: function(){
     getTotal: function(){
         this._loadTotal();
         this._loadTotal();
         return this.totalResaults;
         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(){
 	getData: function(){
         if (this.editable!=false){
         if (this.editable!=false){

+ 9 - 0
o2web/source/x_component_process_Xform/DatagridPC.js

@@ -984,6 +984,15 @@ MWF.xApplication.process.Xform.DatagridPC = new Class({
         this._loadTotal();
         this._loadTotal();
         return this.totalResaults;
         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(){
 	getData: function(){
         if (this.editable!=false){
         if (this.editable!=false){
 			if (this.isEdit) this._completeLineEdit();
 			if (this.isEdit) this._completeLineEdit();

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

@@ -1796,6 +1796,11 @@ debugger;
             this._repage();
             this._repage();
         }.bind(this));
         }.bind(this));
     },
     },
+    isEmpty: function(){
+        var data = this.getData();
+        if( typeOf(data) !== "object" )return true;
+        return !!data.filetext;
+    },
     getData: function(){
     getData: function(){
         //if (this.editMode){
         //if (this.editMode){
         if (this.layout_copies) this.data.copies = this.layout_copies.get("text");
         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));
             //        this.setModifedData(data[i], pathList.push(i));
             //    }
             //    }
             //}
             //}
-        } else if (typeOf(data) !== "null") {
+        } else if (typeOf(data) !== "null") { //后台对null是忽略处理的,认为值没有变化
             var od = this.getOrigianlPathData(pathList);
             var od = this.getOrigianlPathData(pathList);
             if (typeOf(data) !== typeOf(od) || data !== od) {
             if (typeOf(data) !== typeOf(od) || data !== od) {
                 this.setModifedDataByPathList(data, pathList);
                 this.setModifedDataByPathList(data, pathList);

+ 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.fileUploadNode = this.uploadFileAreaNode.getFirst();
         this.uploadFileAreaNode.inject(this.officeForm);
         this.uploadFileAreaNode.inject(this.officeForm);
     },
     },
+    isEmpty : function(){
+        var data = this.getData();
+        return !!data;
+    },
     getData: function(){
     getData: function(){
         if (this.officeOCX && (this.officeOCX.DocType==1 || this.officeOCX.DocType==6)){
         if (this.officeOCX && (this.officeOCX.DocType==1 || this.officeOCX.DocType==6)){
             this.officeOCX.ActiveDocument.Application.Selection.WholeStory();
             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) ? v.join(", ") : "");
         this.setData(v);
         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(){
     getInputData: function(){
         if (this.json.isInput){
         if (this.json.isInput){
             if (this.combox)return this.combox.getData();
             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();
             value = this._computeValue();
         }
         }
         return value || "";
         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){
 	getData: function(when){
 		if (this.json.compute == "save") this._setValue(this._computeValue());
 		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) ? v.join(", ") : "");
         this.setData(v);
         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(){
     getInputData: function(){
         if (this.json.isInput){
         if (this.json.isInput){
             if (this.combox) return this.combox.getData();
             if (this.combox) return this.combox.getData();

+ 7 - 0
o2web/source/x_component_process_Xform/Stat.js

@@ -37,6 +37,13 @@ MWF.xApplication.process.Xform.Stat = MWF.APPStat =  new Class({
             });
             });
         }.bind(this));
         }.bind(this));
     },
     },
+    isEmpty: function(){
+        var data = this.getData();
+        debugger;
+        if( typeOf(data) !== "array" )return true;
+        if( data.length === 0 )return true;
+        return false;
+    },
     getData: function(){
     getData: function(){
         if (!this.stat) return null;
         if (!this.stat) return null;
         if (!this.stat.stat) return null;
         if (!this.stat.stat) return null;