//2013-03-15 删除固定费用 Ext.namespace('DsTruck'); DsTruck.MsWlBsEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.MsWlBsEdit.superclass.constructor.call(this); }; Ext.extend(DsTruck.MsWlBsEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, initUIComponents: function () { this.ctnSerialNo = 0; this.ctnBodyDel = []; this.fixSerialNo = 0; this.fixBodyDel = []; this.feeSerialNo = 0; this.feeBodyDel = []; //#region 编辑Form //枚举参照相关(编辑form) this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeBsType.load({ params: { enumTypeId: 99025} }); this.comboxBsType = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '托单类型', store: this.storeBsType, name: 'BsType' }); //表参照相关(编辑form) this.storeCustContact = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomContactRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomContactList' } }); this.comboxCustContact = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '客户联系人', store: this.storeCustContact, name: 'CustLikeManName', valueField: 'Name', displayField: 'Name', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeCustContact, 'Name', records[0].data.Name); var custTel = this.formEdit.getForm().findField('CustTel'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; custTel.setValue(data.Tel); } else { custTel.setValue(''); } } } } }); this.storeCustCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustCode.load({ params: { condition: "ISCONTROLLER='1'"} }); this.storeCustCode.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "ISCONTROLLER='1'" }); }, this); this.comboxCustCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '委托单位代码', typeAhead: true, store: this.storeCustCode, name: 'CustCode', valueField: 'CustCode', displayField: 'CodeAndName', //queryMode: 'remote', // displayTpl: Ext.create('Ext.XTemplate', // '', // '{CustCode}-{CustName}', // '' // ), // tpl: Ext.create('Ext.XTemplate', // '', // '
{CustCode} - {CustName}
', // '
' // ), listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeCustCode, 'CustCode', records[0].data.CustCode); var custname = this.formEdit.getForm().findField('CustName'); var custLikeManName = this.formEdit.getForm().findField('CustLikeManName'); var custTel = this.formEdit.getForm().findField('CustTel'); var billRises1 = this.formEdit.getForm().findField('BillRises1'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; custname.setValue(data.CustName); this.storeCustContact.load({ scope: this, params: { custCode: data.CustCode }, callback: function (records, operation, success) { if (success) { if (records.length > 0) { var recordData = records[0].data; custLikeManName.setValue(recordData.Name); custTel.setValue(recordData.Tel); billRises1.setValue(recordData.BillRises1); } else { custLikeManName.setValue(''); custTel.setValue(''); billRises1.setValue(''); } } else { custLikeManName.setValue(''); custTel.setValue(''); } } }); } else //if (recs.getCount() > 0) { custname.setValue(''); custLikeManName.setValue(''); custTel.setValue(''); } } } } }); this.storeVoyVeg = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.VoyRefModel', proxy: { url: '/CommMng/BasicDataRef/GetVoyRefList' } }); this.storeVoyVeg.load({ params: { condition: ""} }); this.comboxVoyVeg = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '船名航次', store: this.storeVoyVeg, name: 'VoyVeg', valueField: 'VoyCode', displayField: 'CodeAndName' }); this.comboxVoyVegSe = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '二程船名航次', store: this.storeVoyVeg, name: 'VoyVegSe', valueField: 'VoyCode', displayField: 'CodeAndName' }); this.storeSalesCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeSalesCode.load({ params: { condition: ""} }); this.comboxSalesCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '揽货人', store: this.storeSalesCode, name: 'SalesCode', valueField: 'UserCode', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeSalesCode, 'UserCode', records[0].data.UserCode); var custname = this.formEdit.getForm().findField('SalesName'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; custname.setValue(data.UserName); } else { custname.setValue(''); } } } } }); this.storeDispatchCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeDispatchCode.load({ params: { condition: ""} }); this.comboxDispatchCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '调度员', store: this.storeDispatchCode, name: 'DispatchCode', valueField: 'UserCode', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeDispatchCode, 'UserCode', records[0].data.UserCode); var custname = this.formEdit.getForm().findField('DispatchName'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; custname.setValue(data.UserName); } else { custname.setValue(''); } } } } }); this.storeSendYardCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeSendYardCode.load({ params: { condition: "ISYARD='1'"} }); this.comboxSendYardCode = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '拖箱场站编码', store: this.storeSendYardCode, name: 'SendYardCode', valueField: 'CustCode', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var recs = DsStoreQueryBy(this.storeSendYardCode, 'CustCode', records[0].data.CustCode); var custname = this.formEdit.getForm().findField('SendYardName'); if (recs.getCount() > 0) { var data = recs.getAt(0).data; custname.setValue(data.CustName); } else { custname.setValue(''); } } } } }); //编辑form this.formEdit = Ext.widget('form', { region: 'center', frame: true, bodyPadding: 5, autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '录入日期', name: 'LrDate', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '记账日期', name: 'JzDate', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '用户编码', name: 'UserCode', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '用户姓名', name: 'UserName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '组织编码', name: 'OrgCode', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '组织名称', name: 'OrgName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '委托单位', name: 'CustName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '揽货人姓名', name: 'SalesName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '调度员姓名', name: 'DispatchName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '拖箱场站', name: 'SendYardName', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '返箱场站编码', name: 'RtnYardCode', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '返箱场站', name: 'RtnYard', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '单据锁定状态', name: 'BillStatus', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '费用锁定状态', name: 'FeeStatus', flex: 0, hidden: true, margins: '0' }, { fieldLabel: 'GId', name: 'GId', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '时间戳', name: 'TimeMark', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '发票抬头', name: 'BillRises1', flex: 0, hidden: true, margins: '0' }, { fieldLabel: '物流号', allowBlank: false, disabled: true, name: 'BillNo' }, this.comboxBsType, this.comboxCustCode ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxCustContact, { fieldLabel: '客户联系人电话', name: 'CustTel' }, { fieldLabel: '货名', name: 'GoodsName' }//, { xtype: 'hiddenfield' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '要求起运日期', format: 'Y-m-d', xtype: 'datefield', name: 'NeadLoadDate' }, { fieldLabel: '要求到达日期', format: 'Y-m-d', xtype: 'datefield', name: 'NeedArriveDate' }, this.comboxSalesCode//{ xtype: 'hiddenfield' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '委托日期', format: 'Y-m-d', xtype: 'datefield', name: 'CustDate' }, { fieldLabel: '截港日期', format: 'Y-m-d', xtype: 'datefield', name: 'EndPortDate' }, { fieldLabel: '开船(到港)日期', format: 'Y-m-d', xtype: 'datefield', name: 'EtDate' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxVoyVeg, { fieldLabel: '提单号', name: 'MblNo' }, this.comboxVoyVegSe ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxDispatchCode, this.comboxSendYardCode, { fieldLabel: '目的地', name: 'DstArea' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '工厂地址', name: 'DetiNation' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '工厂联系电话', name: 'DetiLinkTel' }, { fieldLabel: '工厂联系人', name: 'DetiLinkMan' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textarea', items: [{ fieldLabel: '备注', name: 'Remark' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { id: 'bsbtnSave', text: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: 'bsbtnSaveAndClose', text: "保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { id: 'bsbtnSaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, // { // text: "派车", // handler: function (button, event) { // this.DispatchTruck(); // }, // scope: this // }, '-', { text: "关闭", handler: function (button, event) { window.close(); }, scope: this }, { id: 'bsbtnNew', text: "新建", handler: function (button, event) { this.LoadData('add', ''); var basicForm = this.formEdit.getForm(); basicForm.findField('BillNo').setDisabled(false); }, scope: this }, '-', { text: "打印", iconCls: "btnprint", handler: function (button, event) { this.Print(); }, scope: this } // , {xtype: 'label', // text: '' + '单据已锁定' + '', // style: { // width: '95%', // marginBottom: '10px' // } // } // , // { // text: "Test", // handler: function (button, event) { // for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) { // var member = this.storeBodyFix.getAt(i); // member.set("BillNo", this.editRecord.get('BillNo')); // member.commit(); // }; // var removeRecords = this.storeBodyFix.getRemovedRecords(); // for (var i = 0; i < removeRecords.length; i++) { // var memberyf = removeRecords[i]; // }; // }, // scope: this // } ] }); //end 按钮Toolbar //#endregion //#region 集装箱部分 //明细表表格相关 this.storeContainerTypeRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CtnRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCtnRefList' } }); this.storeContainerTypeRef.load({ params: { condition: ""} }); this.comboxContainerTypeRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeContainerTypeRef, name: 'ContainerType', valueField: 'CtnName', displayField: 'CtnName' }); this.storeBodyCtn = Ext.create('Ext.data.Store', { model: 'MsWlBsCtn', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsWlBs/GetCtnBodyList', reader: { id: 'BillNo,SerialNo', root: 'data', totalProperty: 'totalCount' } } }); this.cellEditingCtn = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridListCtn = new Ext.grid.GridPanel({ title: '托单集装箱信息', store: this.storeBodyCtn, plugins: [this.cellEditingCtn], enableHdMenu: false, region: 'east', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, width: 220, tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event, '0'); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelDetailClick(button, event, '0'); }, scope: this }], columns: [{ sortable: true, dataIndex: 'BillNo', header: '单据号', hidden: true, width: 120 }, { dataIndex: "SerialNo", header: "序号", width: 40 }, { sortable: true, dataIndex: 'ContainerType', header: '箱型', // renderer: function (value, p, record) { // if (value == null || value == '') // return ''; // else // return value + '-' + record.data.ContainerType_Ref; // }, editor: this.comboxContainerTypeRef, width: 40 }, { sortable: true, dataIndex: 'ContainerQty', header: '箱量', editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true }, width: 40 }, { sortable: true, dataIndex: 'ContainerNo', header: '箱号', editor: { xtype: 'textfield', selectOnFocus: true }, width: 80 }, { sortable: true, dataIndex: 'SealNo', header: '封号', editor: { xtype: 'textfield', selectOnFocus: true }, width: 60 } ] }); this.gridListCtn.on('edit', function (editor, e, eOpts) { this.gridListCtnAfterEdit(editor, e, eOpts); }, this); //#endregion 集装箱部分定义 //#region 固定费用明细表(删除) // //明细表表格相关 // this.storeCreditDebitRef = Ext.create('DsExt.ux.RefEnumStore', {}); // this.storeCreditDebitRef.load({ params: { enumTypeId: 99020} }); // this.comboxCreditDebitRef = Ext.create('DsExt.ux.RefEnumCombox', { // store: this.storeCreditDebitRef, // name: 'CreditDebit' // }); // this.storeFeeTypeCodeRef = Ext.create('DsExt.ux.RefTableStore', { // model: 'DsTruckMng.ux.FeeTypeRefModel', // proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' } // }); // this.storeFeeTypeCodeRef.load({ params: { condition: "ISTRUCKING='1' and ISTRUCKINGFIXED ='1'"} }); // this.comboxFeeTypeCodeRef = Ext.create('DsExt.ux.RefTableCombox', { // store: this.storeFeeTypeCodeRef, // name: 'FeeTypeCode', // valueField: 'FeeCode', // displayField: 'CodeAndName' // }); // //明细表-数据集 // this.storeBodyFix = Ext.create('Ext.data.Store', { // model: 'MsWlBsFixed', // remoteSort: true, // proxy: { // type: 'ajax', // url: '/TruckMng/MsWlBs/GetFeeBodyList', // reader: { // id: 'BillNo,SerialNo', // root: 'data', // totalProperty: 'totalCount' // } // } // }); // //明细表表格 // this.cellEditingFix = Ext.create('Ext.grid.plugin.CellEditing', { // id: 'cellEditingFix', // clicksToEdit: 1 // }); // this.gridListFix = new Ext.grid.GridPanel({ // store: this.storeBodyFix, // enableHdMenu: false, // region: 'center', // loadMask: { msg: "数据加载中,请稍等..." }, // trackMouseOver: true, // disableSelection: false, // plugins: [this.cellEditingFix], // selType: 'cellmodel', // tbar: [{ // text: '增加明细', // tooltip: '增加明细', // iconCls: "btnadddetail", // handler: function (button, event) { // this.onAddDetailClick(button, event, '1'); // }, // scope: this // }, '-', { // text: '删除明细', // tooltip: '删除明细', // iconCls: "btndeletedetail", // handler: function (button, event) { // this.onDelDetailClick(button, event, '1'); // }, // scope: this // }], // columns: [{ // sortable: true, // dataIndex: 'BillNo', // header: '单据号', // hidden: true, // width: 120 // }, { // sortable: true, // hidden: true, // dataIndex: 'SerialNo', // header: '序号', // width: 40 // }, { // sortable: true, // dataIndex: 'FeeTypeCode', // header: '费用编码', // renderer: function (value, p, record) { // if (value == null || value == '') // return ''; // else // return value + '-' + record.data.FeeTypeCode_Ref; // }, // editor: this.comboxFeeTypeCodeRef, // width: 80 // }, { // sortable: true, // dataIndex: 'FeeTypeName', // header: '费用名称', // hidden: true, // width: 120 // }, { // sortable: true, // dataIndex: 'FsTotal', // header: '金额', // editor: { // xtype: 'numberfield', // allowBlank: false, // selectOnFocus: true // }, // width: 60 // }, { // sortable: true, // dataIndex: 'Remark', // header: '备注', // editor: { // xtype: 'textfield', // selectOnFocus: true // }, // width: 150 // } // // , { // // sortable: true, // // dataIndex: 'CreditDebit', // // header: '收付方式', // // renderer: function (value, p, record) { // // if (value == null || value == '') // // return ''; // // else // // return value + '-' + record.data.CreditDebit_Ref; // // }, // // editor: this.comboxCreditDebitRef, // // width: 80 // // } // ] // }); // this.gridListFix.on('edit', function (editor, e, eOpts) { // this.gridListFixAfterEdit(editor, e, eOpts); // }, this); // this.cellEditingFix.on('beforeedit', function (editor, e) { // return this.cellEditingFixBeforeEdit(editor, e); // }, this); //#endregion //#region 费用表 //明细表表格相关 this.storeFeeTypeRef = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeFeeTypeRef.load({ params: { enumTypeId: 99020} }); this.comboxFeeTypeRef = Ext.create('DsExt.ux.RefEnumCombox', { store: this.storeFeeTypeRef, name: 'FeeType' }); this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.FeeTypeRefModel', proxy: { url: '/CommMng/BasicDataRef/GetFeeTypeRefList' } }); this.storeFeeNameRef.load({ params: { condition: "ISTRUCKING='1' "} }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, name: 'FeeName', valueField: 'Name', displayField: 'CodeAndName' }); this.storeCustomerNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefList' } }); this.storeCustomerNameRef.load({ params: { condition: ""} }); this.comboxCustomerNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeCustomerNameRef, name: 'CustomerName', valueField: 'CustName', displayField: 'CodeAndName' }); //明细表-数据集 this.storeBodyChFee = Ext.create('Ext.data.Store', { model: 'MsChFee', remoteSort: false, proxy: { type: 'ajax', url: '/TruckMng/MsChFee/GetDataList', reader: { id: 'GId', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.cellEditingChFee = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.feeGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridListChFee = new Ext.grid.GridPanel({ store: this.storeBodyChFee, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingChFee], selModel: this.feeGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true, enableTextSelection: true, getRowClass: function (record, rowIndex, rowParams, store) { var feeStatus = record.get('FeeStatus'); return DsTruck.MsChFeeGetRowClass(feeStatus); } }, tbar: [{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddDetailClick(button, event, '2'); }, scope: this }, '-', { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelDetailClick(button, event, '2'); }, scope: this }, '-', { text: '提交审核', tooltip: '提交审核', iconCls: 'btnsubmitaudit', handler: function (button, event) { this.onSubmitAuditClick(button, event); }, scope: this }], columns: [{ sortable: true, dataIndex: 'GId', header: '惟一编号', hidden: true, width: 160 }, { sortable: true, dataIndex: 'BsNo', header: '业务编号', hidden: true, width: 200 }, { sortable: true, dataIndex: 'FeeStatus', header: '费用状态', renderer: function (value, p, record) { return record.data.FeeStatus_Ref; }, width: 66 }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', editor: this.comboxFeeNameRef, width: 100 }, { sortable: true, dataIndex: 'FeeType', header: '收付方式', renderer: function (value, p, record) { if (value == null || value == '') return value; else return value + '-' + record.data.FeeType_Ref; }, editor: this.comboxFeeTypeRef, width: 66 }, { sortable: true, dataIndex: 'FeeDescription', header: '费用英文名称', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', hidden: true, width: 200 }, { sortable: true, dataIndex: 'CustomerName', header: '结算对象', editor: this.comboxCustomerNameRef, width: 120 }, { sortable: true, dataIndex: 'Unit', header: '单位标准', hidden: true, width: 200 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', editor: { xtype: 'numberfield', selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'Quantity', header: '数量', editor: { xtype: 'numberfield', selectOnFocus: true }, width: 60 }, { sortable: true, dataIndex: 'Amount', header: '金额', width: 60 }, { sortable: true, dataIndex: 'Remark', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true }, width: 150 } ] }); this.gridListChFee.on('edit', function (editor, e, eOpts) { this.gridListChFeeAfterEdit(editor, e, eOpts); }, this); this.cellEditingChFee.on('beforeedit', function (editor, e) { return this.cellEditingChFeeBeforeEdit(editor, e); }, this); //#endregion //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 300, items: [this.panelBtn, this.formEdit, this.gridListCtn] }); /* this.panelBodyFix = new Ext.Panel({ title: '协议运费', layout: "border", region: 'west', width: 270, margin: '5 10', items: [this.gridListFix] });*/ this.panelBodyChFee = new Ext.Panel({ title: '费用', layout: "border", region: 'center', margin: '5 10', items: [this.gridListChFee] }); this.panelFee = new Ext.Panel({ layout: "border", region: "center", items: [ this.panelBodyChFee ] }); Ext.apply(this, { items: [this.panelTop, this.panelFee] }); //#endregion parentWin = window.parent.opener; this.InitData(); }, //end initUIComponents //#region 加载数据 InitData: function () { this.opStatus = 'add'; var condition = ''; if (parentWin) { var ret = parentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; } if (this.opStatus == 'edit') condition = " BillNo='" + this.editRecord.get('BillNo') + "'"; this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { this.ctnSerialNo = 0; this.ctnBodyDel = []; this.fixSerialNo = 0; this.fixBodyDel = []; this.feeSerialNo = 0; this.feeBodyDel = []; this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/TruckMng/MsWlBs/GetData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; var recordCustCode = Ext.create('DsTruckMng.ux.CustomRefModel', { GId: NewGuid(), CustCode: data.CustCode, CustName: data.CustName, CodeAndName: data.CustCode + '-' + data.CustName }); this.storeCustCode.add(recordCustCode); this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); if (data.BillStatus == '0') { this.setSaveBtnStatus(true); } else { this.setSaveBtnStatus(false); } this.storeCustContact.load({ params: { custCode: data.CustCode} }); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); var billno = '*'; var gid = '*'; if (this.opStatus == 'edit') { billno = this.editRecord.get('BillNo'); gid = this.editRecord.get('GId'); } this.storeBodyCtn.load({ params: { billno: gid} }); //this.storeBodyFix.load({ params: { billno: gid} }); this.storeBodyChFee.load({ params: { billno: gid} }); }, // end LoadDate //#endregion Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } basicForm.findField('BillNo').setDisabled(false); var data = basicForm.getValues(); basicForm.findField('BillNo').setDisabled(true); var bodyCtnDatas = []; var i; for (i = 0; i < this.storeBodyCtn.getCount(); i += 1) { var member = this.storeBodyCtn.getAt(i); bodyCtnDatas.push(member); }; var jsonCtnBody = ConvertRecordsToJson(bodyCtnDatas); var jsonCtnDelBody = ConvertRecordsToJsonAll(this.ctnBodyDel); var bodyFixdatas = []; var jsonFixBody = ConvertRecordsToJson(bodyFixdatas); var jsonFixDelBody = ConvertRecordsToJsonAll(this.fixBodyDel); var bodyChFeeDatas = []; for (i = 0; i < this.storeBodyChFee.getCount(); i += 1) { var memberyf = this.storeBodyChFee.getAt(i); bodyChFeeDatas.push(memberyf); var amount = memberyf.data.Amount; if (amount == 0) { Ext.Msg.show({ title: '警告', msg: '费用的金额不允许为0,请修改后再保存', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } }; var jsonChFeeBody = ConvertRecordsToJson(bodyChFeeDatas); var jsonChFeeDelBody = ConvertRecordsToJsonAll(this.feeBodyDel); Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/TruckMng/MsWlBs/Save', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), ctnbody: jsonCtnBody, ctndelbody: jsonCtnDelBody, fixbody: jsonFixBody, fixdelbody: jsonFixDelBody, chfeebody: jsonChFeeBody, chfeedelbody: jsonChFeeDelBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); if (this.opStatus == 'add') { //var p = Ext.create('MsWlBsHead', returnData); // Ext.create('WlBsCardHead', data, NewGuid()); //或者new WlBsCardHead(data, NewGuid()); //var p=this.StoreList.add(returnData); //parentWin.AddNewRecord(returnData); //this.editRecord = p[0]; var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsWlBsHead', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } if (type == '0') { this.opStatus = 'edit'; basicForm.findField('BillNo').setDisabled(true); // for (var i = 0; i < this.storeBodyFix.getCount(); i += 1) { // var member = this.storeBodyFix.getAt(i); // member.set("BillNo", this.editRecord.get('BillNo')); // member.commit(); // }; for (var i = 0; i < this.storeBodyCtn.getCount(); i += 1) { var member = this.storeBodyCtn.getAt(i); member.set("BillNo", this.editRecord.get('BillNo')); member.commit(); }; // for (var i = 0; i < this.storeBodyChFee.getCount(); i += 1) { // var member = this.storeBodyChFee.getAt(i); // //member.set("BsNo", this.editRecord.get('BillNo')); // member.commit(); // }; let gid = this.editRecord.get('GId'); let billno = this.editRecord.get('BillNo') this.storeBodyChFee.load({ params: { condition: "Bsno='" + gid + "' or Bsno='" + billno + "'" } }); } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); } } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save //#region 明细操作 onAddDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 0) { store = this.storeBodyCtn; } else if (type == 1) { store = this.storeBodyFix; } else if (type == 2) { store = this.storeBodyChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var newSerialno = this.GetHandleSerialNo(store, type); var record = null; if (type == 0) { record = Ext.create('MsWlBsCtn', { BillNo: '*', SerialNo: newSerialno, ContainerType: '', ContainerQty: 0 } ); } else if (type == 1) { record = Ext.create('MsWlBsFixed', { GId: NewGuid(), BillNo: '*', SerialNo: newSerialno, FeeStatus: 1, FeeStatus_Ref: '录入状态', AuditStatus: 0, CreditDebit: '2', CreditDebit_Ref: '应付', FeeTypeCode: '', DistCount: 0, Price: 0, FsTotal: 0, JsTotal: 0, Remark: '' }); } else if (type == 2) { record = Ext.create('MsChFee', { GId: NewGuid(), BsNo: '*', FeeStatus: 1, FeeStatus_Ref: '录入状态', FeeType: 1, FeeType_Ref: '应收', FeeName: '', FeeName_Ref: '', FeeDescription: '', CustomerType: '', CustomerName: this.getCustName(), CustomerName_Ref: '', Unit: '', UnitPrice: 0, Quantity: 1, Amount: 0, Currency: 'RMB', ExChangerate: 1, Reason: '', Remark: '', Commissionrate: 0, Settlement: 0, Invoice: 0, OrderAmount: 0, OrderInvoice: 0, SubmitDate: null, Auditoperator: '', AuditDate: null, EnteroPerator: GetCookie_UserId(), EnterDate: null, DebitNo: '', IsDebit: "0", IsOpen: "0", IsAdvancedpay: "0", Sort: "0", IsInvoice: "0", FeeFrt: '', IsCrmOrderFee: "0", AuditStatus: 0, InvoiceNum: '', ChequeNum: '', WmsOutBsNo: '' }); } store.add(record); var editColumnIndex = 0; var cellediting = null; if (type == 0) { cellediting = this.cellEditingCtn; editColumnIndex = 2; } else if (type == 1) { cellediting = this.cellEditingFix; editColumnIndex = 2; } else if (type == 2) { cellediting = this.cellEditingChFee; editColumnIndex = 4; } var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex }); }, GetHandleSerialNo: function (store, type) { var result = 0; if (type == 0) { result = this.ctnSerialNo; } else if (type == 1) { result = this.fixSerialNo; } else if (type == 2) { result = this.feeSerialNo; } if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (member.data.SerialNo > result) { result = member.data.SerialNo; } } } result = result + 1; if (type == 0) { this.ctnSerialNo = result; } else if (type == 1) { this.fixSerialNo = result; } else if (type == 2) { this.feeSerialNo = result; } return result; }, onDelDetailClick: function (button, event, type) { var allow = this.getAllowOperationDetail(); if (allow == false) { return; } var store = null; if (type == 0) { store = this.storeBodyCtn; } else if (type == 1) { store = this.storeBodyFix; } else if (type == 2) { store = this.storeBodyChFee; } else { alert('函数(onAddDetailClick)的参数type类型设置的不对'); return; } var result = 0; if (type == '0') { result = this.ctnSerialNo; } else if (type == '1') { result = this.fixSerialNo; } else if (type == '2') { result = this.feeSerialNo; } if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (member.data.SerialNo > this.giSerialNo) { result = member.data.SerialNo; } } } if (type == '0') { this.ctnSerialNo = result; } else if (type == '1') { this.fixSerialNo = result; } else if (type == '2') { this.feeSerialNo = result; } var selectedRecords = []; if (type == '0') { selectedRecords = this.gridListCtn.selModel.getSelection(); } else if (type == '1') { selectedRecords = this.gridListFix.selModel.getSelection(); } else if (type == '2') { selectedRecords = this.gridListChFee.selModel.getSelection(); var candelete = DsTruck.CheckChFeeDelete(selectedRecords); if (candelete == false) return; } if (selectedRecords.length > 0) { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.BillNo != "" || rec.BillNo != "*") //如果是新增但没有保存的数据,没有必要提交到后台 { if (type == '0') this.ctnBodyDel.push(rec); else if (type == '1') { this.fixBodyDel.push(rec); } else if (type == '2') { this.feeBodyDel.push(rec); } } if (type == '0') { this.storeBodyCtn.remove(selectedRecords[i]); } else if (type == '1') { this.storeBodyFix.remove(selectedRecords[i]); } else if (type == '2') { this.storeBodyChFee.remove(selectedRecords[i]); } } } }, getAllowOperationDetail: function () { var feeStatus = this.getFeeStatus(); if (feeStatus == '0') return true; else { Ext.Msg.show({ title: '错误', msg: "费用已锁定,不允许操作费用!", icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return false; } }, //#endregion //#region 表格的AfterEdit gridListCtnAfterEdit: function (editor, e, eOpts) { }, gridListFixAfterEdit: function (editor, e, eOpts) { if (e.field == 'FeeTypeCode') { var records = DsStoreQueryBy(this.storeFeeTypeCodeRef, 'FeeCode', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; e.record.set('FeeTypeCode_Ref', data.Name); e.record.set('FeeTypeName', data.Name); } else { e.record.set('FeeTypeCode_Ref', ''); e.record.set('FeeTypeName', ''); } } else if (e.field == 'CreditDebit') { var recordsCreditDebit = DsStoreQueryBy(this.storeCreditDebitRef, 'EnumValueId', e.value); if (recordsCreditDebit.getCount() > 0) { var dataCreditDebit = recordsCreditDebit.getAt(0).data; e.record.set('CreditDebit_Ref', dataCreditDebit.EnumValueName); } else { e.record.set('CreditDebit_Ref', ''); } } }, gridListChFeeAfterEdit: function (editor, e, eOpts) { if (e.field == 'FeeType') { var records = DsStoreQueryBy(this.storeFeeTypeRef, 'EnumValueId', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; e.record.set('FeeType_Ref', data.EnumValueName); } else { e.record.set('FeeType_Ref', ''); } } else if (e.field = 'UnitPrice' || e.field == 'Quantity') { var unitPrice = e.record.data['UnitPrice']; var quantity = e.record.data['Quantity']; e.record.set('Amount', (unitPrice * quantity).toFixed(2)); } }, //#endregion GetBillNo: function () { if (this.editRecord == null) return '*'; else { return this.editRecord.get('BillNo'); } }, cellEditingFixBeforeEdit: function (editor, e) { var feeStatus = this.getFeeStatus(); var billStatus = this.getBillStatus(); var canedit = feeStatus == '0' && billStatus == '0'; return canedit; }, cellEditingChFeeBeforeEdit: function (editor, e) { var chfeefeeStatus = e.record.get('FeeStatus'); var canedit = chfeefeeStatus == 1 || chfeefeeStatus == 6; if (canedit) { var feeStatus = this.getFeeStatus(); var billStatus = this.getBillStatus(); canedit = feeStatus == '0' && billStatus == '0'; } return canedit; }, getCustName: function () { var custName = this.formEdit.getForm().findField('CustName'); return custName.getValue(); }, onSubmitAuditClick: function (button, event) { var records = this.feeGridCheckBoxModel.selected.items; DsTruck.MsChFeeAudit(records, 2, '正在提交审核数据, 请稍侯..' ); this.InitData(); }, setSaveBtnStatus: function (enable) { var bsbtnSave = Ext.getCmp('bsbtnSave'); var bsbtnSaveAndClose = Ext.getCmp('bsbtnSaveAndClose'); var bsbtnSaveAndNew = Ext.getCmp('bsbtnSaveAndNew'); if (enable) { bsbtnSave.enable(); bsbtnSaveAndClose.enable(); bsbtnSaveAndNew.enable(); } else { bsbtnSave.disable(); bsbtnSaveAndClose.disable(); bsbtnSaveAndNew.disable(); } }, getFeeStatus: function () { var basicForm = this.formEdit.getForm(); var feeStatus = basicForm.findField('FeeStatus').value; return feeStatus; } , getBillStatus: function () { var basicForm = this.formEdit.getForm(); var billStatus = basicForm.findField('BillStatus').value; return billStatus; }, Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('BillNo').value; if (billNo == '*' || billNo == '') { Ext.Msg.show({ title: '错误', msg: '单据还没有保存,请保存后再打印', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var gid = basicForm.findField('GId').value; Ext.Ajax.request({ waitMsg: '正在查询数据...', url: '/TruckMng/MsWlBs/GetIsPrint', async: false, params: { billno: billNo, Gid: gid }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } else { var printType = 'MSWLBS'; var sql1 = "SET LANGUAGE 'us_english ' " + " select * from vMsWlBsHeadPrint WHERE BillNo = '" + billNo + "' order by BillNo"; var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + gid + "'"; //var sql3 = "SET LANGUAGE 'us_english' " // + " select * from vMsWlPcHeadPrint where RefBillNo='" + billNo + "' order by RefBillNo"; //var sql4 = "SET LANGUAGE 'us_english' select * from ch_fee where BSNO in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BsNo"; var sql3 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A, ch_fee B where A.Gid=B.BsNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo"; //var sql4 = "SET LANGUAGE 'us_english' select * from tMsWlPcFixed where BillNo in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BillNo"; var sql4 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A,tMsWlPcFixed B where A.Gid=B.BillNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo"; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); // var printType = 'MSWLBS'; // var sql1 = "SET LANGUAGE 'us_english ' " // + " select * from vMsWlBsHeadPrint WHERE BillNo = '" + billNo + "' order by BillNo"; // var sql2 = "SET LANGUAGE 'us_english' SELECT * from ch_fee where BsNo='" + gid + "'"; // //var sql3 = "SET LANGUAGE 'us_english' " // // + " select * from vMsWlPcHeadPrint where RefBillNo='" + billNo + "' order by RefBillNo"; // //var sql4 = "SET LANGUAGE 'us_english' select * from ch_fee where BSNO in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BsNo"; // var sql3 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A, ch_fee B where A.Gid=B.BsNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo"; // //var sql4 = "SET LANGUAGE 'us_english' select * from tMsWlPcFixed where BillNo in (select Gid from tMswlpcHead where RefBillNo='" + billNo + "') order by BillNo"; // var sql4 = "SET LANGUAGE 'us_english' select A.*,B.* from vMsWlPcHeadPrint A,tMsWlPcFixed B where A.Gid=B.BillNo and A.RefBillNo='" + billNo + "' order by A.RefBillNo"; // var sql5 = ""; // var sql6 = ""; // PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, DispatchTruck: function () { }, setBtnOnlyQuery: function () { var bsbtnSave = Ext.getCmp('bsbtnSave'); var bsbtnSaveAndClose = Ext.getCmp('bsbtnSaveAndClose'); var bsbtnSaveAndNew = Ext.getCmp('bsbtnSaveAndNew'); var bsbtnNew = Ext.getCmp('bsbtnNew'); bsbtnSave.setVisible(false); bsbtnSaveAndClose.setVisible(false); bsbtnSaveAndNew.setVisible(false); bsbtnNew.setVisible(false); } });