| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206 |
- Ext.define('saas.view.sale.b2b.QuoteWin', {
- extend: 'Ext.window.Window',
- xtype: 'quotewin',
- title: '报价信息',
- width: 600,
- cls: 'x-window-dbfind',
- closlayout: 'fit',
- modal: true,
- bodyPadding: 20,
- initComponent: function () {
- var me = this;
- var record = me.record;
- Ext.apply(me, {
- items: [{
- xtype: 'form',
- layout: 'column',
- fieldDefaults: {
- margin: '0 0 10 0',
- labelAlign: 'right',
- labelWidth: 90,
- columnWidth: 0.5,
- },
- isValid: function (values) {
- var leadtimeField = this.getForm().findField('leadtime');
- var taxrateField = this.getForm().findField('taxrate');
- var grid = this.down('grid');
- var gridData = grid.store.getData().items;
- var flag = gridData.length > 0;
- for (var x = 0; x < gridData.length; x++) {
- var d = gridData[x];
- if (!d.get('step') || !d.get('price')) {
- flag = false
- }
- }
- if(flag) {
- flag = leadtimeField.getValue() && taxrateField.getValue();
- }
- return flag;
- },
- items: [{
- xtype: 'textfield',
- fieldLabel: '品牌',
- name: 'prodBrand',
- readOnly: true,
- value: record.get('prodBrand')
- }, {
- xtype: 'textfield',
- fieldLabel: '名称',
- name: 'prodName',
- readOnly: true,
- value: record.get('prodName')
- }, {
- xtype: 'textfield',
- fieldLabel: '型号',
- name: 'prodOrispeccode',
- readOnly: true,
- value: record.get('prodOrispeccode')
- }, {
- xtype: 'textfield',
- fieldLabel: '规格',
- name: 'prodSpec',
- readOnly: true,
- value: record.get('prodSpec')
- }, {
- xtype: 'numberfield',
- fieldLabel: '交期(天)',
- name: 'leadtime',
- allowBlank: false,
- beforeLabelTextTpl: "<font color=\"red\" style=\"position:relative; top:2px;right:2px; font-weight: bolder;\">*</font>"
- }, {
- xtype: 'numberfield',
- fieldLabel: '税率',
- name: 'taxrate',
- minValue: 0,
- maxValue: 100,
- allowBlank: false,
- beforeLabelTextTpl: "<font color=\"red\" style=\"position:relative; top:2px;right:2px; font-weight: bolder;\">*</font>"
- }, {
- xtype: 'detailGridField',
- detnoColumn: 'no',
- minHeight: 145,
- emptyRows: 3,
- showCount: false,
- width: 280,
- store: Ext.create('Ext.data.Store', {
- fields: [{
- name: 'no',
- type: 'int'
- }, {
- name: 'step',
- type: 'int'
- }, {
- name: 'price',
- type: 'float'
- }],
- data: []
- }),
- columns: [{
- text: '梯度',
- dataIndex: 'step',
- xtype: 'numbercolumn',
- editor: {
- xtype: "numberfield",
- decimalPrecision: 0,
- minValue: 0
- },
- renderer: function (v, m, r) {
- return saas.util.BaseUtil.numberFormat(v, 0, false);
- },
- }, {
- text: '单价',
- dataIndex: 'price',
- xtype: 'numbercolumn',
- editor: {
- xtype: "numberfield",
- decimalPrecision: 4,
- minValue: 0
- },
- renderer: function (v, m, r) {
- return saas.util.BaseUtil.numberFormat(v, 4, true);
- },
- }]
- }]
- }],
- buttonAlign: 'center',
- buttons: [{
- text: '确定',
- handler: function () {
- var win = this.up('window'),
- form = win.down('form'),
- grid = form.down('grid');
- if (form.isValid()) {
- var values = form.getValues();
- Ext.Object.mergeIf(values, record.data);
- values.detail = grid.store.getData().items.map(function(r) {
- return r.data;
- })
- me.onQuote(values);
- } else {
- saas.util.BaseUtil.showErrorToast('表单校验失败,请检查字段是否合法');
- }
- }
- }, {
- text: '取消',
- handler: function () {
- me.close();
- }
- }]
- });
- me.callParent(arguments);
- },
- onQuote: function (values) {
- var view = this;
- var params = {
- sourceId: values.sourceId,
- inquiry: {
- id: values.sourceId,
- enUU: values.enUU,
- recorderUU: values.recorderUU,
- code: values.inquiryCode,
- },
- userUU: values.userUU,
- userName: values.userName,
- userTel: values.userTel,
- currency: "RMB",
- taxrate: values.taxrate,
- leadtime: values.leadtime, // 交期
- replies: values.detail.map(function(d) {
- return {
- lapQty: d.step,
- price: d.price
- }
- }), // 梯度价格,
- date: Ext.Date.format(new Date(), 'Y-m-d H:i:s'), // 当前日期
- qutoApp: "sp", // 固定标识
- endDate: values.endDate,
- prodTitle: values.prodName,
- spec: values.prodSpec,
- cmpCode: values.prodOrispeccode,
- inbrand: values.prodBrand,
- isReplace: 0,
- };
- view.setLoading(true);
- saas.util.BaseUtil.request({
- // url: 'http://10.1.80.23:8560/api/sale/sale/businessChance/saveQuote',
- url: '/api/sale/sale/businessChance/saveQuote',
- params: JSON.stringify(params),
- method: 'POST'
- }).then(function (res) {
- view.setLoading(false);
- saas.util.BaseUtil.showSuccessToast('报价成功');
- view.close();
- view.listView.refresh();
- }).catch(function (e) {
- view.setLoading(false);
- saas.util.BaseUtil.showErrorToast('报价失败: ' + e.message);
- });
- },
- });
|