Browse Source

销售b2b模块界面调整/核销单审核时也自动计算amount值

zhuth 6 years ago
parent
commit
87be95769f

+ 9 - 1
frontend/saas-web/app/view/money/verification/FormPanelController.js

@@ -379,7 +379,15 @@ Ext.define('saas.view.money.verification.FormPanelController', {
         viewModel = me.getViewModel(),
         detailCount = form.detailCount,
         codeField = form.getForm().findField(form._codeField),
-        codeModified = !form.initId || (codeField && codeField.isDirty());;
+        codeModified = !form.initId || (codeField && codeField.isDirty()),
+        store1 = viewModel.get('detail0').detailStore,
+        store2 = viewModel.get('detail1').detailStore;
+
+        var sum_detail1 = store1.sum('vd_nowbalance'); // 从表1核销合计
+        var sum_detail2 = store2.sum('vcd_nowbalance'); // 从表2核销合计
+
+        viewModel.set("vc_amount1",sum_detail1);
+        viewModel.set("vc_amount2",sum_detail2);
 
         //form里面数据
         var formData = form.getFormData();

+ 107 - 376
frontend/saas-web/app/view/purchase/b2b/sendQuotation/DataList.js

@@ -2,184 +2,123 @@
  * 发起询价
  */
 Ext.define('saas.view.purchase.b2b.sendQuotation.DataList', {
-    extend: 'Ext.grid.Panel',
+    extend: 'saas.view.core.base.BasePanel',
     xtype: 'purchase-b2b-sendquotation-datalist',
-    controller: 'purchase-b2b-sendquotation-datalist',
-    viewModel: 'purchase-b2b-sendquotation-datalist',
-    autoScroll: true,
-    layout:'fit',
-    style:'border:1px solid #fff',
-    dataUrl:'/api/document/product/list',                 
-    sendQuotationUrl:'/api/purchase/purchase/inquiry/send',
-
-    plugins: [{
-        ptype: 'menuclipboard'
-    }],
-
-    selModel: {
-        checkOnly:true,
-        type:'checkboxmodel'
-	},
-
-    tbar: [{
-        width: 310,
-        name: 'search',
-        xtype: 'textfield',
-        emptyText : '请输入物料编号/品牌/名称/型号',
-        enableKeyEvents: true,
-        getCondition: function (value) {
-            return ' (pr_code like\'%' + value + '%\' or pr_detail like \'%' + value + '%\' or pr_brand like \'%' + value + '%\' or pr_orispeccode like \'%' + value + '%\') ';
-        },
-        listeners: {
-            keydown: {
-                fn: function(th, e, eOpts) {
-                    if(e.keyCode == 13) {
-                        var grid = th.up('grid');
-                        grid.condition = grid.getConditions();
-                        grid.store.loadPage(1);
-                    }
-                }
-            }
-        }
-    },{
-        cls:'x-formpanel-btn-blue',
-        xtype:'button',
-        text:'查询',
-        listeners: {
-            click:function(b){
-                var grid = b.ownerCt.ownerCt;
-                grid.condition = grid.getConditions();
-                grid.store.loadPage(1);
-            }
-        }
-    },{
-        margin:'0 10 0 30',
-        width: 180,
-        name: 'endDate',
-        xtype: 'numberfield',
-        decimalPrecision:0,
-        minValue:0,
-        fieldLabel : '报价截至天数'
-    },{
-        cls:'x-formpanel-btn-blue',
-        xtype:'button',
-        text:'发起询价',
-        listeners: {
-            click: function(){
-                var grid = this.ownerCt.ownerCt;
-                var endDate = grid.down('[name=endDate]');
-                if(!endDate.value||endDate.value==0){
-                    saas.util.BaseUtil.showErrorToast('请填写报价截至天数');
-                    return false;
-                }
-                grid.onVastDeal(grid.sendQuotationUrl,endDate.value);
-            }
-        }
-    },'->',{
-        ignore:true,
-        style:'text-align: center;',
-        xtype:'displayfield',
-        value:'<a href=\"javascript:saas.util.BaseUtil.openTab(\'purchase-quotationList-datalist\',\'询价信息查询\',\'maintab-query-quotationList\')\">询价信息查询</a>'
-    }],
 
-    columns : [{
-        text : 'id', 
-        width : 0, 
-        dataIndex : 'id', 
-        xtype : 'numbercolumn', 
-        hidden:true
-    },{
-        text : '物料编号', 
-        width : 200.0, 
-        dataIndex : 'pr_code', 
-        xtype : '', 
-    }, 
-    {
-        text : '品牌', 
-        dataIndex : 'pr_brand', 
-        width : 110.0, 
-        xtype : '', 
-    }, 
-    {
-        text : '名称', 
-        dataIndex : 'pr_detail', 
-        width : 150.0
-    },{
-        text : '型号', 
-        dataIndex : 'pr_orispeccode',
-        width : 110.0
-    },{
-        text : '规格', 
-        dataIndex : 'pr_spec',
-        width : 110.0
-    },{
-        text : '单位', 
-        dataIndex : 'pr_unit',
-        width : 110.0
-    }, {
-        dataIndex: '',
-        flex: 1
-    }],
-
-    dbSearchFields: [],
-    condition:'',
+    viewName: 'purchase-b2b-sendquotation-datalist',
+    dataUrl: '/api/document/product/list',
+    sendQuotationUrl:'/api/purchase/purchase/inquiry/send',
 
-    initComponent: function() {
+    initComponent: function () {
         var me = this;
-        if(me.columns){
-            var fields = me.columns.map(column => column.dataIndex);
-            me.columns = me.insertFirstColumn(me.columns);
-            me.store = Ext.create('Ext.data.Store',{
-                fields:fields,
-                autoLoad: true,
-                pageSize: 15,
-                data: [],
-                proxy: {
-                    timeout:8000,
-                    type: 'ajax',
-                    headers:{
-                        'Access-Control-Allow-Origin': '*',
-                        "Content-Type": 'application/json;charset=UTF-8'
-                    },
-                    url: me.dataUrl,
-                    actionMethods: {
-                        read: 'GET'
-                    },
-                    reader: {
-                        type: 'json',
-                        rootProperty: 'data.list',
-                        totalProperty: 'data.total',
-                    }
+        Ext.apply(this, {
+            searchField: [{
+                width: 310,
+                name: 'search',
+                xtype: 'textfield',
+                emptyText : '请输入物料编号/品牌/名称/型号',
+                getCondition: function (value) {
+                    return ' (pr_code like\'%' + value + '%\' or pr_detail like \'%' + value + '%\' or pr_brand like \'%' + value + '%\' or pr_orispeccode like \'%' + value + '%\') ';
                 },
+            }],
+
+            toolButtons: [{
+                margin:'0 10 0 30',
+                width: 180,
+                name: 'endDate',
+                xtype: 'numberfield',
+                decimalPrecision:0,
+                minValue:0,
+                ignore: true,
+                fieldLabel : '报价截至天数'
+            },{
+                cls:'x-formpanel-btn-blue',
+                xtype:'button',
+                text:'发起询价',
                 listeners: {
-                    beforeload: function (store, op) {
-                        var condition = me.condition;
-                        if (Ext.isEmpty(condition)) {
-                            condition = '';
+                    click: function(){
+                        var p = this.ownerCt.ownerCt;
+                        var endDate = p.down('[name=endDate]');
+                        if(!endDate.value||endDate.value==0){
+                            saas.util.BaseUtil.showErrorToast('请填写报价截至天数');
+                            return false;
                         }
-                        Ext.apply(store.proxy.extraParams, {
-                            number: op._page,
-                            size: store.pageSize,
-                            condition: JSON.stringify(condition)
-                        });
+                        p.onVastDeal(p.sendQuotationUrl,endDate.value);
                     }
                 }
-            });
-
-            Ext.apply(me, {
-                dockedItems:[{
-                    xtype: 'pagingtoolbar',
-                    dock: 'bottom',
-                    displayInfo: true,
-                    store: me.store
-                }]
-            });
-        }
-        me.callParent(arguments);
+            },'->',{
+                ignore:true,
+                style:'text-align: center;',
+                xtype:'displayfield',
+                ignore: true,
+                value:'<a href=\"javascript:saas.util.BaseUtil.openTab(\'purchase-b2b-quotationList-datalist\',\'询价信息查询\',\'maintab-query-quotationList\')\">询价信息查询</a>'
+            }],
+
+            gridConfig: {
+                dataUrl: me.dataUrl,
+                actionColumn: [],
+                selModel: {
+                    checkOnly:true,
+                    type:'checkboxmodel'
+                },
+                hiddenTools: true,
+                data: [],
+                columns: [{
+                    text : 'id', 
+                    width : 0, 
+                    dataIndex : 'id', 
+                    xtype : 'numbercolumn', 
+                    hidden:true
+                },{
+                    text : '物料编号', 
+                    width : 200.0, 
+                    dataIndex : 'pr_code', 
+                    xtype : '', 
+                }, {
+                    text : '品牌', 
+                    dataIndex : 'pr_brand', 
+                    width : 110.0, 
+                    xtype : '', 
+                }, {
+                    text : '名称', 
+                    dataIndex : 'pr_detail', 
+                    width : 150.0
+                },{
+                    text : '型号', 
+                    dataIndex : 'pr_orispeccode',
+                    width : 110.0
+                },{
+                    text : '规格', 
+                    dataIndex : 'pr_spec',
+                    width : 110.0
+                },{
+                    text : '单位', 
+                    dataIndex : 'pr_unit',
+                    width : 110.0
+                }],
+                getGridSelected:function(leadTime){
+                    var me = this,
+                    items = me.selModel.getSelection(),
+                    data = new Array() ;
+                    Ext.each(items, function(item, index){
+                        var o = new Object();
+                        o['prodCode']=item.get('pr_code');
+                        o['prodName']=item.get('pr_detail');
+                        o['prodSpec']=item.get('pr_spec');
+                        o['prodOrispeccode']=item.get('pr_orispeccode');
+                        o['prodBrand']=item.get('pr_brand');
+                        o['leadTime']=leadTime;
+                        data.push(o);
+                    });
+                    return data;
+                },
+            },
+        });
+        this.callParent(arguments);
     },
-
     onVastDeal:function(url,leadTime){
-        var grid = this;
+        var me = this,
+        grid = me.down('grid');
         var data = grid.getGridSelected(leadTime);
         if(!data){
             saas.util.BaseUtil.showErrorToast('请勾选符合条件的行进行操作。');
@@ -210,214 +149,6 @@ Ext.define('saas.view.purchase.b2b.sendQuotation.DataList', {
         }else{
             saas.util.BaseUtil.showErrorToast('请勾选至少一条明细。');
         }
-    },
-
-    listeners:{
-        boxready: function(grid, width, height, eOpts) {
-            var store = grid.getStore(),
-            gridBodyBox = grid.body.dom.getBoundingClientRect(),
-            gridBodyBoxHeight = gridBodyBox.height;
-
-            var pageSize = Math.floor(gridBodyBoxHeight / 32);
-
-            store.setPageSize(pageSize);
-
-            grid.ownerCt.el.dom.style.left = '8px';
-            grid.el.dom.style.padding = '0px'
-        },
-        itemClick: function(view,record,a,index,c) {
-            var classList = c.target.classList.value;
-            var grid = this;
-            if(classList.indexOf('fa-pencil')>-1){
-                var form = this.ownerCt;
-                this.dialog = form.getController().getView().add({
-                    xtype: 'sys-maxnumbers-window',
-                    bind: {
-                        title: '修改单据编码规则'
-                    },
-                    _parent:form,
-                    _combo:this,
-                    record:record,
-                    session: true
-                });
-                this.dialog.show();
-            }else if(classList.indexOf('fa-trash-o')>-1){
-                //删除
-                var id = record.get('id');
-                if(id){
-                    saas.util.BaseUtil.request({
-                        url: grid.deleteUrl+id,
-                        method: 'POST',
-                    })
-                    .then(function(localJson) {
-                        if(localJson.success){
-                            //解析参数
-                            saas.util.BaseUtil.showSuccessToast('删除成功');
-                            view.ownerCt.store.load();
-                        }
-                    })
-                    .catch(function(e) {
-                        saas.util.BaseUtil.showErrorToast('删除失败: ' + e.message);
-                    });
-                }
-            }
-        }
-    },
-
-    insertFirstColumn:function(columns){
-        var me=this;
-        return columns;
-    },
-
-    getGridSelected:function(leadTime){
-        var me = this,
-        items = me.selModel.getSelection(),
-        data = new Array() ;
-        Ext.each(items, function(item, index){
-            var o = new Object();
-            o['prodCode']=item.get('pr_code');
-            o['prodName']=item.get('pr_detail');
-            o['prodSpec']=item.get('pr_spec');
-            o['prodOrispeccode']=item.get('pr_orispeccode');
-            o['prodBrand']=item.get('pr_brand');
-            o['leadTime']=leadTime;
-            data.push(o);
-        });
-		return data;
-    },
-
-    /**
-     * 获得过滤条件
-     */
-    getConditions: function() {
-        var me = this,
-        tbar = me.getDockedItems()[0],
-        items = Ext.Array.filter(tbar.items.items, function(item) {
-            return !!item.name;
-        }),
-        conditions = [];
-        for(var i = 0; i < items.length; i++) {
-            var item = items[i];
-            var field = item.name,
-            func = item.getCondition,
-            value = item.value,
-            condition;
-
-            if(value&&value!=''&&!item.ignore){
-                if(typeof func == 'function') {
-                    condition = {
-                        type: 'condition',
-                        value: func(value)
-                    }
-                }else {
-                    var type = item.fieldType || me.getDefaultFieldType(item),
-                    operation = item.operation || me.getDefaultFieldOperation(item),
-                    conditionValue = me.getConditionValue(item, value);
-        
-                    if(!conditionValue) {
-                        continue;
-                    }
-                    condition = {
-                        type: type,
-                        field: field,
-                        operation: operation,
-                        value: conditionValue
-                    }
-                }
-                conditions.push(condition);
-            }
-        }
-
-        return conditions;
-    },
-
-    /**
-     * 只要arr1和arr2中存在相同项即返回真
-     */
-    isContainsAny: function (arr1, arr2) {
-        for (var i = 0; i < arr2.length; i++) {
-            var a2 = arr2[i];
-            if (!!arr1.find(function (a1) {
-                    return a1 == a2
-                })) {
-                return true;
-            }
-        }
-        return false;
-    },
-
-    getDefaultFieldType: function (field) {
-        var me = this,
-            xtypes = field.getXTypes().split('/'),
-            type;
-
-        if (me.isContainsAny(xtypes, ['numberfield'])) {
-            type = 'number';
-        } else if (me.isContainsAny(xtypes, ['datefield', 'condatefield', 'conmonthfield'])) {
-            type = 'date';
-        } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
-            type = 'enum';
-        } else if (me.isContainsAny(xtypes, ['combobox', 'multicombo', 'combo', 'radiofield', 'radio'])) {
-            type = 'enum';
-        } else {
-            type = 'string';
-        }
-
-        return type;
-    },
-
-    getDefaultFieldOperation: function (field) {
-        var me = this,
-            xtypes = field.getXTypes().split('/'),
-            operation;
-
-        if (me.isContainsAny(xtypes, ['numberfield', 'datefield', 'dbfindtrigger'])) {
-            operation = '=';
-        } else if (me.isContainsAny(xtypes, ['condatefield', 'conmonthfield'])) {
-            operation = 'between';
-        } else if (me.isContainsAny(xtypes, ['multidbfindtrigger', 'combobox', 'multicombo', 'combo'])) {
-            operation = 'in';
-        } else {
-            operation = 'like';
-        }
-
-        return operation;
-    },
-
-    /**
-     * 处理部分字段值
-     */
-    getConditionValue: function (field, value) {
-        var me = this,
-            xtypes = field.getXTypes().split('/'),
-            conditionValue;
-        if (me.isContainsAny(xtypes, ['datefield'])) {
-            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d H:i:s');
-        } else if (me.isContainsAny(xtypes, ['conmonthfield'])) {
-            var from = value.from,
-                to = value.to;
-
-            conditionValue = from + ',' + to;
-        } else if (me.isContainsAny(xtypes, ['condatefield'])) {
-            var from = value.from,
-                to = value.to;
-
-            conditionValue = Ext.Date.format(new Date(from), 'Y-m-d 00:00:00') + ',' + Ext.Date.format(new Date(to), 'Y-m-d 23:59:59');
-        } else if (me.isContainsAny(xtypes, ['dbfindtrigger'])) {
-            conditionValue = value;
-        } else if (me.isContainsAny(xtypes, ['combobox', 'combo'])) {
-            conditionValue = '\'' + value + '\'';
-        } else if (me.isContainsAny(xtypes, ['multicombo'])) {
-            conditionValue = value.map ? value.map(function (v) {
-                return '\'' + v.value + '\'';
-            }).join(',') : '';
-        } else {
-            conditionValue = value;
-        }
-
-        return conditionValue;
     }
-
-})
-
+});