Browse Source

从表为空isValid逻辑

zhuth 7 years ago
parent
commit
99a5ccf34f

+ 2 - 1
frontend/saas-web/app/util/FormUtil.js

@@ -108,7 +108,8 @@ Ext.define('saas.util.FormUtil', {
                             });
                             });
 
 
                             columns.push({
                             columns.push({
-                                flex: 1
+                                flex: 1,
+                                allowBlank: true
                             });
                             });
 
 
                             cnames.push(item.detnoColumn);
                             cnames.push(item.detnoColumn);

+ 47 - 7
frontend/saas-web/app/view/core/form/field/DetailGridField.js

@@ -26,6 +26,7 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
     showIndex: true,
     showIndex: true,
     configUrl: '',
     configUrl: '',
     editable: true,
     editable: true,
+    allowEmpty: true, // 校验时只校验dirty数据
 
 
     initComponent: function() {
     initComponent: function() {
         var me = this;
         var me = this;
@@ -40,17 +41,28 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
         };
         };
 
 
         Ext.apply(me, {
         Ext.apply(me, {
-            viewConfig: {
+            normalViewConfig: {
                 deferEmptyText: false,
                 deferEmptyText: false,
                 emptyText: '无数据'
                 emptyText: '无数据'
             },
             },
+            lockedGridConfig: {
+                // scrollable: {
+                //     x: false,
+                //     y: true
+                // }
+            },
             lockedViewConfig: {
             lockedViewConfig: {
+                // scrollable: false,
+                scrollable: {
+                    x: false,
+                    y: true
+                },
                 deferEmptyText: false,
                 deferEmptyText: false,
                 emptyText: '<div style="width: 100%; text-align: center; cursor: pointer; color: green;" class="fa fa-plus" title="新增行" onclick="addRows(\'' + me.id + '\')"></div>',
                 emptyText: '<div style="width: 100%; text-align: center; cursor: pointer; color: green;" class="fa fa-plus" title="新增行" onclick="addRows(\'' + me.id + '\')"></div>',
             },
             },
             listeners: {
             listeners: {
-                edit: function() {
-                    me.fireEvent('validChange');
+                edit: function(grid) {
+                    grid.fireEvent('validChange');
                 },
                 },
                 itemmouseenter: function(view, record, item, index, e, eOpts) {
                 itemmouseenter: function(view, record, item, index, e, eOpts) {
                     if(!view.up('detailGridField').editable) {
                     if(!view.up('detailGridField').editable) {
@@ -302,9 +314,10 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
      */
      */
     isValid: function() {
     isValid: function() {
         var me = this,
         var me = this,
+        allowEmpty = me.allowEmpty;
         columns = me.columns,
         columns = me.columns,
-        dirtyData = me.getDirtyData(),
-        valid = true;
+        data = allowEmpty ? me.getDirtyData() : me.getAllData(),
+        valid = allowEmpty;
 
 
         // 判断列必填
         // 判断列必填
         a:
         a:
@@ -315,8 +328,9 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
             var isValid = c.isValid;
             var isValid = c.isValid;
             
             
             b:
             b:
-            for(var j = 0; j < dirtyData.length; j++) {
-                var d = dirtyData[j];
+            for(var j = 0; j < data.length; j++) {
+                valid = true;
+                var d = data[j];
                 var value = d[cname];
                 var value = d[cname];
 
 
                 if(typeof isValid == 'function') {
                 if(typeof isValid == 'function') {
@@ -337,6 +351,32 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
         return valid;
         return valid;
     },
     },
 
 
+    /**
+     * 获得所有数据
+     */
+    getAllData: function() {
+        var me = this,
+        store = me.getStore(),
+        storeData = store.getData().items,
+        allData = [];
+
+        Ext.Array.each(storeData, function(item){
+            var d = Object.assign({}, item.data);
+
+            if((typeof d.id) != "number" && d.id.indexOf('-')>-1){
+                d.id = 0;
+            }
+            for(k in d) {
+                if(Ext.isDate(d[k])) {
+                    d[k] = Ext.Date.format(d[k], 'Y-m-d H:i:s');
+                }
+            }
+            allData.push(d);
+        });
+
+        return allData;
+    },
+
     /**
     /**
      * 获得已修改的数据
      * 获得已修改的数据
      */
      */

+ 1 - 0
frontend/saas-web/app/view/purchase/purchase/FormPanel.js

@@ -91,6 +91,7 @@ Ext.define('saas.view.purchase.purchase.FormPanel', {
         storeModel:'saas.model.purchase.Purchasedetail',
         storeModel:'saas.model.purchase.Purchasedetail',
         detnoColumn:  'pd_detno',
         detnoColumn:  'pd_detno',
         deleteDetailUrl:'/api/purchase/purchase/deleteDetail/',
         deleteDetailUrl:'/api/purchase/purchase/deleteDetail/',
+        allowEmpty: false,
         columns : [
         columns : [
             {
             {
                 text : "id", 
                 text : "id", 

+ 1 - 1
frontend/saas-web/app/view/sale/saleOut/FormPanel.js

@@ -196,7 +196,7 @@ Ext.define('saas.view.sale.saleout.FormPanel', {
                 text : "销售序号", 
                 text : "销售序号", 
                 dataIndex : "pd_orderdetno", 
                 dataIndex : "pd_orderdetno", 
                 xtype : "numbercolumn",
                 xtype : "numbercolumn",
-                flex:1
+                width : 120.0
             }
             }
         ]
         ]
     }, {
     }, {