Browse Source

多选组件双向绑定逻辑完善

zhuth 7 years ago
parent
commit
1c567ddfef

+ 32 - 8
frontend/saas-web/app/view/core/form/MultiCombo.js

@@ -6,6 +6,7 @@ Ext.define('saas.view.core.form.MultiCombo', {
     alias: 'widget.multicombo',
     editable : false,
     matchFieldWidth: true,
+    value: [],
     cachedConfig: {
         menuAlign: 'tl-bl?',
         destroyMenu: true
@@ -28,9 +29,6 @@ Ext.define('saas.view.core.form.MultiCombo', {
        this.showMenu();
     },
     onMouseLeave:function(a,b,c){
-        console.log(a);
-        console.log(b);
-        console.log(c);
         this.hideMenu(a.parentEvent?a:b);//el光标离开第二个参数为Event对象
     },
     onTriggerClick:function(){
@@ -58,12 +56,16 @@ Ext.define('saas.view.core.form.MultiCombo', {
             item,
             items = me.datas,
             itemsLn = me.datas.length,
-            menuItems = [];
+            menuItems = [],
+            value = me.value;
         for (; i < itemsLn; i++) {
             item = items[i];
+            var checked = !!value.find(function(v) {
+                return v.value = iem[0];
+            });
             menuItem = new Ext.menu.CheckItem({
                 text: item[1],
-                checked: item.checked,
+                checked: checked,
                 checkValue:item[0],
                 hideOnClick: false,
                 checkHandler: this.onCheckChange,
@@ -85,16 +87,39 @@ Ext.define('saas.view.core.form.MultiCombo', {
             }
         });
         this.setValue(checkedItems);
-        this.publishState('value', checkedItems);
     },
 
     setValue: function(items) {
-        var rawV = '';
+        var me = this, rawV = '',
+        datas = me.datas,
+        menu = me.menu;
+        if(!Ext.isArray(items)) {
+            items = [items]
+        }
+        items.map(function(item, index) {
+            if(Ext.isString(item)) {
+                var data = datas.find(function(d) {
+                    return d[0] == item;
+                });
+                items[index] = {
+                    text: data[1],
+                    value: data[0]
+                }
+            }
+        })
         rawV = items.map(function(item) {
             return item.text
         }).join(',');
         this.setRawValue(rawV);
         this.value = items;
+        if(menu) {
+            Ext.Array.each(menu.items.items, function(item) {
+                item.setChecked(!!items.find(function(i) {
+                    return i.value == item.checkValue;
+                }));
+            });
+        }
+        this.publishState('value', items);
     },
 
     showMenu: function (e, menu) {
@@ -121,7 +146,6 @@ Ext.define('saas.view.core.form.MultiCombo', {
         }
     },
     hideMenu: function(b) {
-        console.log(b);
         if (this.hasVisibleMenu()) {
             var target=b.parentEvent.relatedTarget;
             if(!((target.className && target.className.indexOf('x-menu')!=-1) || (target.name && target.name.indexOf(this.name)!=-1))){

+ 48 - 44
frontend/saas-web/app/view/purchase/purchase/QueryPanel.js

@@ -2,11 +2,12 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
     extend: 'saas.view.core.query.QueryPanel',
     xtype: 'purchase-purchase-querypanel',
 
+    controller: 'purchase-purchase-querypanel',
     viewModel: 'purchase-purchase-querypanel',
     viewName: 'purchase-purchase-formpanel',
-    _baseVastUrl:'http://192.168.253.58:8800/purchase/',
-    _idField:'pu_id',
-    _codeField:'pu_code',
+    _baseVastUrl: 'http://192.168.253.58:8800/purchase/',
+    _idField: 'pu_id',
+    _codeField: 'pu_code',
     queryFormItems: [{
         xtype: 'hidden',
         name: 'pu_id',
@@ -21,20 +22,21 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
         fieldLabel: '单据编号',
         allowBlank: true,
         columnWidth: 0.25,
-        dataUrl:'http://192.168.253.41:9480/api/document/vendor/getVendorsByCondition',
-        dbfinds:[{
-            from:'ve_code',to:'pu_code'
+        dataUrl: 'http://192.168.253.41:9480/api/document/vendor/getVendorsByCondition',
+        dbfinds: [{
+            from: 've_code',
+            to: 'pu_code'
         }],
-        dbColumns:[{
-            conditionCode:'ve_id',
+        dbColumns: [{
+            conditionCode: 've_id',
             "text": "供应商ID",
             "flex": 0,
             "dataIndex": "ve_id",
             "width": 0,
             "xtype": "",
             "items": null
-        },{
-            conditionCode:'ve_code',
+        }, {
+            conditionCode: 've_code',
             "text": "供应商编号",
             "flex": 1,
             "dataIndex": "ve_code",
@@ -42,14 +44,14 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
             "xtype": "",
             "items": null
         }, {
-            conditionCode:'ve_name',
+            conditionCode: 've_name',
             "text": "供应商名称",
             "flex": 1,
             "dataIndex": "ve_name",
             "xtype": "",
             "items": null
         }, {
-            conditionCode:'ve_type',
+            conditionCode: 've_type',
             "text": "供应商类型",
             "flex": 0,
             "dataIndex": "ve_type",
@@ -86,7 +88,7 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
         bind: '{pd_prodcode}',
         fieldLabel: '物料编号',
         fieldMode: 'DETAIL',
-        queryType:'VAG',
+        queryType: 'VAG',
         allowBlank: true,
         columnWidth: 0.25,
         configUrl: 'resources/json/purchase/vendorColumnsDbfind.json',
@@ -101,14 +103,14 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
     }, {
         xtype: 'combobox',
         name: 'pr_statuscode',
-       // bind: '{pr_statuscode}',
+        // bind: '{pr_statuscode}',
         fieldLabel: '审核状态',
         allowBlank: true,
         columnWidth: 0.25,
         queryMode: 'local',
-            displayField: 'pr_status',
-            valueField: 'pr_statuscode',
-            store: Ext.create('Ext.data.ArrayStore', {
+        displayField: 'pr_status',
+        valueField: 'pr_statuscode',
+        store: Ext.create('Ext.data.ArrayStore', {
             fields: ['pr_statuscode', 'pr_status'],
             data: [
                 ["$ALL", "全部"],
@@ -119,15 +121,17 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
     }, {
         xtype: 'multicombo',
         name: 'pu_acceptstatuscode',
-       // bind: '{pu_acceptstatuscode}',
+        bind: '{pu_acceptstatuscode}',
+        readOnly: false,
+        editable: false,
         fieldLabel: '入库状态',
         allowBlank: true,
         columnWidth: 0.25,
         datas: [
-                ["TURNOUT", "已入库"],
-                ["NOOUT", "未入库"],
-                ["PARTOUT", "部分入库"]
-            ]
+            ["TURNOUT", "已入库"],
+            ["NOOUT", "未入库"],
+            ["PARTOUT", "部分入库"]
+        ]
     }],
     moreQueryFormItems: [{
         xtype: 'textfield',
@@ -150,11 +154,11 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
         columnWidth: 1
     }],
     queryGridConfig: {
-        _idField:'pu_id',
-        _codeField:'pu_code',
-        _title:'采购单',
-        _addXtype:'test-order-formpanel',
-        _baseVastUrl:'http://192.168.253.58:8800/purchase/',
+        _idField: 'pu_id',
+        _codeField: 'pu_code',
+        _title: '采购单',
+        _addXtype: 'test-order-formpanel',
+        _baseVastUrl: 'http://192.168.253.58:8800/purchase/',
         _baseColumn: [{
             text: '序号',
             width: 80,
@@ -175,21 +179,21 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
         }, {
             text: '下单日期',
             dataIndex: 'pu_indate',
-            xtype:'datecolumn',
+            xtype: 'datecolumn',
             width: 200
-        },{
+        }, {
             text: '供应商名称',
             dataIndex: 'pu_vendname',
             width: 120
-        },{
+        }, {
             text: '含税金额',
             dataIndex: 'pu_taxtotal',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120
-        },{
+        }, {
             text: '金额',
             dataIndex: 'pu_total',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120,
             flex: 1
         }],
@@ -213,35 +217,35 @@ Ext.define('saas.view.purchase.purchase.QueryPanel', {
         }, {
             text: '下单日期',
             dataIndex: 'pu_indate',
-            xtype:'datecolumn',
+            xtype: 'datecolumn',
             width: 200
-        },{
+        }, {
             text: '供应商名称',
             dataIndex: 'pu_vendname',
             width: 120
-        },{
+        }, {
             text: '采购序号',
             dataIndex: 'pd_detno',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120
-        },{
+        }, {
             text: '物料编号',
             dataIndex: 'pd_prodcode',
             width: 120
-        },{
+        }, {
             text: '数量',
             dataIndex: 'pd_qty',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120
-        },{
+        }, {
             text: '单价',
             dataIndex: 'pd_price',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120
-        },{
+        }, {
             text: '已转数',
             dataIndex: 'pd_ytqy',
-            xtype:'numbercolumn',
+            xtype: 'numbercolumn',
             width: 120,
             flex: 1
         }]

+ 6 - 3
frontend/saas-web/app/view/test/order/FormPanel.js

@@ -128,9 +128,12 @@ Ext.define('saas.view.test.order.FormPanel', {
             {
                 text : "序号", 
                 dataIndex : "pd_detno", 
-                width : 80.0, 
+                width : 100, 
                 xtype : "rownumberer",
-                summaryType: 'count'
+                summaryType: 'count',
+                summaryRenderer: function(value, summaryData, dataIndex) {
+                    return Ext.String.format('合计: {0}条', value);
+                }
             }, 
             {
                 editor : {
@@ -156,7 +159,7 @@ Ext.define('saas.view.test.order.FormPanel', {
                 text : "单位", 
                 editor : {
                     xtype : "textfield"
-                }, 
+                },
                 dataIndex : "pd_unit", 
                 width : 120.0, 
                 xtype : "", 

+ 2 - 1
frontend/saas-web/app/view/test/query/QueryPanel.js

@@ -2,8 +2,9 @@ Ext.define('saas.view.test.query.QueryPanel', {
     extend: 'saas.view.core.query.QueryPanel',
     xtype: 'test-query-querypanel',
 
-    // controller: 'test-query-formcontroller',
+    controller: 'test-query-querypanel',
     viewModel: 'test-query-querypanel',
+    
     viewName: 'test-query-formpanel',
     _baseVastUrl:'http://192.168.253.58:8800/purchase/',
     _idField:'pu_id',