Browse Source

核销单放大镜逻辑/日期区间选择器样式

zhuth 7 years ago
parent
commit
1f6663e6f0

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

@@ -254,8 +254,9 @@ Ext.define('saas.util.FormUtil', {
                                 var detno = 0;
                                 var detnoColumn = grid.detnoColumn;
                                 var datas = [];
+                                var emptyRows = grid.emptyRows;
                                 
-                                Ext.Array.each(new Array(5), function() {
+                                Ext.Array.each(new Array(emptyRows), function() {
                                     detno += 1;
                                     var data = {};
                                     data[detnoColumn] = detno;

+ 6 - 1
frontend/saas-web/app/view/core/dbfind/MultiDbfindTrigger.js

@@ -26,6 +26,9 @@ Ext.define('saas.view.core.dbfind.MultiDbfindTrigger', {
     },
     //输入值之后进行模糊查询
     doQuery: function(queryString, forceAll, rawQuery) {
+        if(!this.fireEvent('beforequery', this)) {
+            return;
+        };
     	queryString = queryString || '';
     	var me = this;
     	if(me.lastQueryValue!=queryString){
@@ -129,7 +132,9 @@ Ext.define('saas.view.core.dbfind.MultiDbfindTrigger', {
     	}
     },
     onTriggerClick:function(f){
-        this.fireEvent('beforetriggerclick', this);
+        if(!this.fireEvent('beforetriggerclick', this)) {
+            return;
+        };
         f.blur(f);
         //判断dbfindtrigger归属
         f.judge(f);

+ 3 - 0
frontend/saas-web/app/view/core/dbfind/types/BankInfoDbfindTrigger.js

@@ -1,3 +1,6 @@
+/**
+ * 资金账户放大镜
+ */
 Ext.define('saas.view.core.dbfind.types.BankInfoDbfindTrigger', {
     extend: 'saas.view.core.dbfind.DbfindTrigger',
     xtype: 'bandinfoDbfindTrigger',

+ 1 - 1
frontend/saas-web/app/view/core/dbfind/types/BomDbfindTrigger.js

@@ -1,5 +1,5 @@
 /**
- * 客户资料放大镜
+ * BOM资料放大镜
  */
 Ext.define('saas.view.core.dbfind.types.BomDbfindTrigger', {
     extend: 'saas.view.core.dbfind.DbfindTrigger',

+ 5 - 3
frontend/saas-web/app/view/core/dbfind/types/OriOrderMutiDbfindTrigger.js

@@ -1,10 +1,12 @@
+/**
+ * 资金来源单据放大镜(多选)
+ */
 Ext.define('saas.view.core.dbfind.types.OriOrderMutiDbfindTrigger', {
     extend: 'saas.view.core.dbfind.MultiDbfindTrigger',
     xtype: 'oriOrderMutiDbfindTrigger',
-/**
- * 用于资金首付款单明细
- */
+   
     dataUrl: '/api/money/subledger/list',
+    // dataUrl: 'http://192.168.253.35:8880/subledger/list',
     addTitle: '源单资料',
     dbtpls: [{
         field: 'sl_code',

+ 26 - 0
frontend/saas-web/app/view/core/form/field/ConDateField.scss

@@ -0,0 +1,26 @@
+.x-condatefield {
+    .x-field {
+        background: #fff;
+    }
+
+    .x-field:first-child {
+        .x-form-trigger-wrap-default {
+            border-top-right-radius: 0;
+            border-bottom-right-radius: 0;
+        }
+    }
+    .x-field:nth-child(2) {
+        .x-form-trigger-wrap-default {
+            border-radius: 0;
+            border-left: 0;
+            border-right: 0;
+        }
+    }
+    .x-field:last-child {
+        .x-form-trigger-wrap-default {
+            border-top-left-radius: 0;
+            border-bottom-left-radius: 0;
+        }
+    }
+
+}

+ 3 - 1
frontend/saas-web/app/view/core/form/field/DetailGridField.js

@@ -27,6 +27,8 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
     allowEmpty: false, // 表格为空时校验合法
     showCount: true, // 显示合计栏
 
+    emptyRows: 5,
+
     // Clearing selection disables the Actions.
     allowDeselect: true,
     defaultActionType: 'button',
@@ -201,7 +203,7 @@ Ext.define('saas.view.core.form.field.DetailGridField', {
         selectedRecord = me.selModel.lastSelected,
         datas = [];
 
-        num = num || 3;
+        num = num || me.emptyRows;
 
         //当前行后序号全部加1
         var detno = selectedRecord ? selectedRecord.data[detnoColumn] : 0;

+ 49 - 20
frontend/saas-web/app/view/money/verification/FormPanel.js

@@ -78,7 +78,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
                     queryMode : "local",
                     store : null,
                     valueField : "value",
-                    xtype : "multidbfindtrigger"
+                    xtype : "oriOrderMutiDbfindTrigger"
                 }
             }, {
                 text: '业务类型',
@@ -173,7 +173,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
         detail2: {
             xtype: "detailGridField",
             storeModel: 'saas.model.money.Verification1',
-            detnoColumn: 'vd_detno',
+            detnoColumn: 'vcd_detno',
             deleteDetailUrl: '/api/money/verification/deleteDetail2/',
             columnWidth: 1,
             columns: [{
@@ -182,11 +182,11 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 hidden: true
             }, {
                 text: '来源ID',
-                dataIndex: 'vd_slid',
+                dataIndex: 'vcd_slid',
                 hidden: true
             }, {
                 text: '来源单号',
-                dataIndex: 'vd_slcode',
+                dataIndex: 'vcd_slcode',
                 width: 150,
                 editor:{
                     displayField : "display",
@@ -199,21 +199,21 @@ Ext.define('saas.view.money.verification.FormPanel', {
                     queryMode : "local",
                     store : null,
                     valueField : "value",
-                    xtype : "multidbfindtrigger"
+                    xtype : "oriOrderMutiDbfindTrigger"
                 }
             }, {
                 text: '业务类型',
-                dataIndex: "vd_slkind",
+                dataIndex: "vcd_slkind",
                 width: 110
             }, {
                 text: "单据日期",
-                dataIndex: "vd_sldate",
+                dataIndex: "vcd_sldate",
                 xtype: 'datecolumn',
                 width: 110
             }, {
                 text: "单据金额",
                 xtype: 'numbercolumn',
-                dataIndex: "vd_amount",
+                dataIndex: "vcd_amount",
                 width: 110,
                 renderer : function(v) {
                     var arr = (v + '.').split('.');
@@ -269,7 +269,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 text: "本次核销金额",
                 xtype: 'numbercolumn',
-                dataIndex: "vd_nowbalance",
+                dataIndex: "vcd_nowbalance",
                 width:150,
                 editor : {
                     xtype : "numberfield",
@@ -291,12 +291,12 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 }
             }]
         },
-        other: {
+        other: [{
             fieldLabel: '备注',
             xtype: 'textfield',
             columnWidth: 1,
             name: 'vc_remark'
-        },
+        }],
 
         // 预收冲应收
         receipts_offset_receivable : {
@@ -304,6 +304,9 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 xtype: 'hidden',
                 fieldLabel: '客户id',
                 name: 'vc_custid',
+                listeners: {
+                    change: 'clearDetails'
+                }
             }, {
                 fieldLabel: '客户编号',
                 xtype: 'hidden',
@@ -325,7 +328,10 @@ Ext.define('saas.view.money.verification.FormPanel', {
             main: [{
                 xtype: 'hidden',
                 name: 'vc_vendid',
-                fieldLabel: '供应商ID'
+                fieldLabel: '供应商ID',
+                listeners: {
+                    change: 'clearDetails'
+                }
             }, {
                 xtype: "hidden",
                 name: "vc_vendcode",
@@ -349,7 +355,10 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '客户id',
                 xtype: 'textfield',
                 name: 'vc_custid',
-                hidden: true
+                hidden: true,
+                listeners: {
+                    change: 'clearDetail0'
+                }
             }, {
                 fieldLabel: '客户编号',
                 xtype: 'textfield',
@@ -358,11 +367,14 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '客户名称',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_custname',
+                name: 'vc_custname'
             }, {
                 xtype: 'hidden',
                 name: 'vc_vendid',
-                fieldLabel: '供应商ID'
+                fieldLabel: '供应商ID',
+                listeners: {
+                    change: 'clearDetail1'
+                }
             }, {
                 xtype: "hidden",
                 name: "vc_vendcode",
@@ -386,7 +398,10 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转出客户id',
                 xtype: 'textfield',
                 name: 'vc_outcustid',
-                hidden: true
+                hidden: true,
+                listeners: {
+                    change: 'clearDetail0'
+                }
             }, {
                 fieldLabel: '转出客户编号',
                 xtype: 'textfield',
@@ -395,7 +410,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出客户',
                 xtype: 'customerDbfindTrigger',
-                name: 'vc_outcustname',
+                name: 'vc_outcustname'
             }, {
                 fieldLabel: '转入客户id',
                 xtype: 'textfield',
@@ -424,7 +439,10 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 fieldLabel: '转出供应商id',
                 xtype: 'textfield',
                 name: 'vc_outvendid',
-                hidden: true
+                hidden: true,
+                listeners: {
+                    change: 'clearDetail0'
+                }
             }, {
                 fieldLabel: '转出供应商编号',
                 xtype: 'textfield',
@@ -433,7 +451,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
             }, {
                 fieldLabel: '转出供应商',
                 xtype: 'vendorDbfindTrigger',
-                name: 'vc_outvendname',
+                name: 'vc_outvendname'
             }, {
                 fieldLabel: '转入供应商id',
                 xtype: 'textfield',
@@ -454,6 +472,17 @@ Ext.define('saas.view.money.verification.FormPanel', {
                 name: 'vc_date'
             }],
             details: ['detail1']
+        },
+
+        defaultConditions: {
+            receipts_offset_receivable: ['nvl(sl_custid,0)={vc_custid} and nvl(sl_preamount,0)<>0 and nvl(sl_namount,0)<>0',
+                'nvl(sl_custid,0)={vc_custid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0'],
+            prepaid_offset_payable: ['nvl(sl_vendid,0)={vc_vendid} and nvl(sl_preamount,0)<>0 and nvl(sl_namount,0)<>0',
+                'nvl(sl_vendid,0)={vc_vendid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0'],
+            receivable_offset_payable: ['nvl(sl_custid,0)={vc_custid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0',
+                'nvl(sl_vendid,0)={vc_vendid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0'],
+            receivable_to_receivable: ['nvl(sl_custid,0)={vc_outcustid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0'],
+            payable_to_payable: ['nvl(sl_vendtid,0)={vc_outvendid} and nvl(sl_preamount,0)=0 and nvl(sl_namount,0)<>0']
         }
     },
 
@@ -528,7 +557,7 @@ Ext.define('saas.view.money.verification.FormPanel', {
 
         base[0].defaultValue = acitveType;
 
-        items = Ext.Array.merge(base, mainItems, (details[0] ? [detail1] : []), (details[1] ? [detail2] : []), [other] );
+        items = Ext.Array.merge(base, mainItems, (details[0] ? [detail1] : []), (details[1] ? [detail2] : []), other );
 
         return items;
     },

+ 168 - 0
frontend/saas-web/app/view/money/verification/FormPanelController.js

@@ -110,6 +110,174 @@ Ext.define('saas.view.money.verification.FormPanelController', {
 
                 }
             },
+
+            // 来源单号1
+            'oriOrderMutiDbfindTrigger[name=vd_slcode]': {
+                beforerender: function (f) {
+                    Ext.apply(f, {
+                        dbfinds: [{
+                            from: 'id',
+                            to: 'vd_slid',ignore:true
+                        }, {
+                            from: 'sl_code',
+                            to: 'vd_slcode'
+                        },{
+                            from: 'sl_orderamount',
+                            to: 'vd_amount'
+                        },{
+                            from: 'sl_yamount',
+                            to: 'sl_yamount'
+                        },{
+                            from:'sl_date',
+                            to:'vd_sldate'
+                        },{
+                            from:'sl_kind',
+                            to:'vd_slkind'
+                        },{
+                            from: 'sl_namount',
+                            to: 'vd_nowbalance'
+                        }],
+                    });
+                },
+                beforequery: function(f) {
+                    var defaultCondition = this.getDefaultCondition(0);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                },
+                beforetriggerclick: function(f) {
+                    var defaultCondition = this.getDefaultCondition(0);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                }
+            },
+
+            // 来源单号2
+            'oriOrderMutiDbfindTrigger[name=vcd_slcode]': {
+                beforerender: function (f) {
+                    Ext.apply(f, {
+                        dbfinds: [{
+                            from: 'id',
+                            to: 'vd_slid',ignore:true
+                        }, {
+                            from: 'sl_code',
+                            to: 'vd_slcode'
+                        },{
+                            from: 'sl_orderamount',
+                            to: 'vd_amount'
+                        },{
+                            from: 'sl_yamount',
+                            to: 'sl_yamount'
+                        },{
+                            from:'sl_date',
+                            to:'vd_sldate'
+                        },{
+                            from:'sl_kind',
+                            to:'vd_slkind'
+                        },{
+                            from: 'sl_namount',
+                            to: 'vd_nowbalance'
+                        }],
+                    });
+                },
+                beforequery: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                },
+                beforetriggerclick: function(f) {
+                    var defaultCondition = this.getDefaultCondition(1);
+                    if(!defaultCondition) {
+                        return false;
+                    }
+                    Ext.apply(f, {
+                        defaultCondition: defaultCondition
+                    });
+                }
+            },
         });
     },
+
+    getDefaultCondition: function(idx) {
+        var me = this,
+        form = me.getView(),
+        viewModel = me.getViewModel(),
+        acitveType = form.acitveType,
+        etc = form.etc,
+        defaultConditions = etc.defaultConditions,
+        defaultConditionMode = defaultConditions[acitveType][idx];
+
+        var reg = /(.*){(.*)}(.*)/g;
+        var fieldName = defaultConditionMode.match(/(.*){(.*)}(.*)/)[2];
+        var fieldValue = viewModel.get(fieldName);
+        if(!fieldValue) {
+            // TODO 这里可以分情况提示具体字段
+            saas.util.BaseUtil.showErrorToast('请先录入主表必填字段');
+            return null;
+        }
+        var defaultCondition = defaultConditionMode.replace(reg, '$1' + fieldValue + '$3');
+
+        return defaultCondition;
+    },
+
+    /**
+     * 清空所有从表数据
+     */
+    clearDetails: function() {
+        var me = this;
+        
+        me.clearDetail0();
+        me.clearDetail1();
+    },
+
+    /**
+     * 清空第一个从表数据
+     */
+    clearDetail0: function(f, n, o) {
+        var me = this,
+        form = me.getView(),
+        grid = form.query('detailGridField')[0];
+        me.clearDetail(grid);
+    },
+
+    /**
+     * 清空第二个从表数据
+     */
+    clearDetail1: function() {
+        var me = this,
+        form = me.getView(),
+        grid = form.query('detailGridField')[1];
+        me.clearDetail(grid);
+    },
+
+    /**
+     * 清空一个从表数据
+     */
+    clearDetail: function(grid) {
+        var datas = [],
+        emptyRows = grid.emptyRows,
+        detnoColumn = grid.detnoColumn,
+        detno = 0,
+        store = grid.getStore();
+        
+        Ext.Array.each(new Array(emptyRows), function() {
+            detno += 1;
+            var data = {};
+            data[detnoColumn] = detno;
+            datas.push(data);
+        })
+        store.removeAll();
+        store.add(datas);
+    },
 });