Browse Source

商机报价优化

zhuth 7 years ago
parent
commit
9a66518180

+ 35 - 57
frontend/saas-web/app/view/sale/b2b/Business.js

@@ -123,67 +123,47 @@ Ext.define('saas.view.sale.b2b.Business', {
                     text: '发布时间',
                     xtype: 'datecolumn',
                     dataIndex: 'startDate',
-                    format: 'Y-m-d H:i:s'
+                    format: 'Y-m-d H:i:s',
+                    width: 150
                 }, {
                     text: '截止时间',
                     xtype: 'datecolumn',
-                    dataIndex: 'endDate'
+                    dataIndex: 'endDate',
+                    format: 'Y-m-d H:i:s',
+                    width: 150
                 }, {
-                    text: '操作',
+                    text: '报价状态',
                     dataIndex: 'quoted',
+                    textAlign: 'center',
                     renderer:function(val, meta, record,x,y,store, view){
-                        if(val == 0){
-                            return '<a style="color: #35BAF6; cursor: pointer;">点击报价</a>';
-                        }
-                        var id = record.id;
-                        var grid = view.up('grid');
-                        
-                        if(!view.tip) {
-                            view.tip = Ext.create('Ext.tip.ToolTip', {
-                                hidden: true,
-                                target: view.el,
-                                delegate: '.x-grid-cell-'+meta.column.id,
-                                trackMouse: true,
-                                renderTo: Ext.getBody(),	
-                                maxWidth :830,
-                                layout:'anchor',
-                                listeners: {								          
-                                    beforeshow: function updateTipBody(tip) {
-                                        var dg = Ext.getCmp('grid-'+id);
-                                        var record = grid.focusRecord;
-                                        if(record.data.qutations.agreed) {
-                                            this.setHtml(null);
-                                            var replies = record.data.qutations.replies;
-                                            dg.store.loadData(replies);
-                                            dg.show();
-                                        }else {
-                                            dg.hide();
-                                            this.setHtml(record.data.qutations.refusereason || '无');
-                                        }
-                                    }
-                                },
-                                items : [Ext.create('Ext.grid.Panel', {
-                                    id: 'grid-'+id,
-                                    frame:true,
-                                    anchor: '100% 100%',
-                                    width:205,
-                                    store:[],
-                                    columns: [{
-                                        text: '分段数量',
-                                        dataIndex: 'lapQty',
-                                        width: 110
-                                    }, {
-                                        text: '分段价格',
-                                        dataIndex: 'price',
-                                        width: 90
-                                    }]
-                                })]
-                            });
+                        if(val == 0) {
+                            return '<div style="text-align: center;color: #35BAF6;">未报价</div>';
+                        }else {
+                            var qutations = record.data.qutations;
+                            if(qutations.agreed == null) {
+                                return '<div style="text-align: center;color: #FBBC05;">已报价</div>';
+                            }else if(qutations.agreed == 1){
+                                return '<div style="text-align: center;color: green;">被采纳</div>';
+                            }else if(qutations.agreed == 0) {
+                                return '<div style="text-align: center;color:#ff6c00;">被拒绝</div>';
+                            }
                         }
-                        if(record.data.qutations.agreed) {
-                            return '<div style="text-align: center;color: green;">查看报价信息</div>';
+                    }
+                }, {
+                    text: '操作',
+                    dataIndex: 'quoted',
+                    renderer:function(val, meta, record,x,y,store, view){
+                        if(val == 0) {
+                            return '<div style="text-align: center;color: #35BAF6;cursor: pointer;">点击报价</div>';
                         }else {
-                            return '<div style="text-align: center;color:#ff6c00;">查看拒绝理由</div>';
+                            var qutations = record.data.qutations;
+                            if(qutations.agreed == null) {
+                                return '<div style="text-align: center;color: #FBBC05;cursor: pointer;">查看报价信息</div>';
+                            }else if(qutations.agreed == 1){
+                                return '<div style="text-align: center;color: green;cursor: pointer;">查看报价信息</div>';
+                            }else if(qutations.agreed == 0) {
+                                return '<div style="text-align: center;color:#ff6c00;">查看报价信息</div>';
+                            }
                         }
                     },
                     listeners: {
@@ -191,10 +171,8 @@ Ext.define('saas.view.sale.b2b.Business', {
                             var dataIndex = this.dataIndex;
                             var record = tableView.store.getAt(rowIdx);
                             var value = record.get(dataIndex);
-                            
-                            if(value == '0') {
-                                me.getController().showQuoteWin(record);
-                            }
+
+                            me.getController().showQuoteWin(record, !!value);
                         },
                     }
                 }],

+ 5 - 2
frontend/saas-web/app/view/sale/b2b/BusinessController.js

@@ -2,15 +2,18 @@ Ext.define('saas.view.sale.b2b.BusinessController', {
     extend: 'saas.view.core.base.BasePanelController',
     alias: 'controller.sale-b2b-business',
 
-    showQuoteWin: function(record) {
+    showQuoteWin: function(record, quoted) {
         var me = this,
         view = me.getView();
 
         var win = Ext.getCmp();
         if(!win) {
             win = Ext.create('saas.view.sale.b2b.QuoteWin', {
+                width: view.getBox().width * 0.8,
+                height: view.getBox().height * 0.8,
                 record: record,
-                listView: view
+                listView: view,
+                quoted: quoted
             });
             view.add(win);
         }

+ 44 - 6
frontend/saas-web/app/view/sale/b2b/QuoteWin.js

@@ -3,7 +3,9 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
     xtype: 'quotewin',
 
     title: '报价信息',
-    width: 600,
+    width: '800',
+    height: '400',
+    scrollable: true,
     cls: 'x-window-dbfind',
     closlayout: 'fit',
     modal: true,
@@ -12,6 +14,7 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
     initComponent: function () {
         var me = this;
         var record = me.record;
+        var quoted = me.quoted;
         Ext.apply(me, {
             items: [{
                 xtype: 'form',
@@ -20,7 +23,7 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
                     margin: '0 0 10 0',
                     labelAlign: 'right',
                     labelWidth: 90,
-                    columnWidth: 0.5,
+                    columnWidth: 0.25,
                 },
                 isValid: function (values) {
                     var leadtimeField = this.getForm().findField('leadtime');
@@ -91,7 +94,7 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
                             name: 'no',
                             type: 'int'
                         }, {
-                            name: 'step',
+                            name: 'lapQty',
                             type: 'int'
                         }, {
                             name: 'price',
@@ -101,7 +104,7 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
                     }),
                     columns: [{
                         text: '梯度',
-                        dataIndex: 'step',
+                        dataIndex: 'lapQty',
                         xtype: 'numbercolumn',
                         editor: {
                             xtype: "numberfield",
@@ -124,12 +127,22 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
                             return saas.util.BaseUtil.numberFormat(v, 4, true);
                         },
                     }]
+                }, {
+                    xtype: 'textfield',
+                    name: 'message',
+                    columnWidth: 1,
+                    fieldLabel: '回复信息',
+                    hidden: true
                 }]
             }],
             buttonAlign: 'center',
             buttons: [{
-                text: '确定',
+                text: quoted && record.get('qutations') && record.get('qutations').agreed == 0 ? '重新发起报价' : '确定',
                 handler: function () {
+                    if(quoted && record.get('qutations') && record.get('qutations').agreed != 0) {
+                        me.close();
+                        return;
+                    }
                     var win = this.up('window'),
                         form = win.down('form'),
                         grid = form.down('grid');
@@ -155,6 +168,31 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
         me.callParent(arguments);
     },
 
+    listeners: {
+        afterrender: function() {
+            var me = this,
+            form = me.down('form'),
+            leadtimeField = form.getForm().findField('leadtime'),
+            taxrateField = form.getForm().findField('taxrate'),
+            messageField = form.getForm().findField('message'),
+            grid = form.down('grid'),
+            store = grid.store,
+            record = me.record,
+            qutations = record.get('qutations'),
+            quoted = me.quoted;
+
+            if(quoted) {
+                leadtimeField.setValue(qutations.leadTime);
+                taxrateField.setValue(qutations.taxRate);
+                store.loadData(qutations.replies || []);
+                if(qutations.agreed == 0) {
+                    messageField.setValue(qutations.refusereason);
+                    messageField.setVisible(true);
+                }
+            }
+        }
+    },
+
     onQuote: function (values) {
         var view = this;
         var params = {
@@ -173,7 +211,7 @@ Ext.define('saas.view.sale.b2b.QuoteWin', {
             leadtime: values.leadtime, // 交期
             replies: values.detail.map(function(d) {
                 return {
-                    lapQty: d.step,
+                    lapQty: d.lapQty,
                     price: d.price
                 }
             }), // 梯度价格,