Ext.namespace('Shipping'); Shipping.MsChFeeAgentDcEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsChFeeAgentDcEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsChFeeAgentDcEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, editRecord: null, Editdata: null, MainEditRecord: null, oplb: '', initUIComponents: function () { this.serialNo = 0; //this.bodyDel = []; this.itemindex = 1; this.formname = "formMsChFeeAgentDcEdit"; //页面名称 var mainform = window.parent.panelEdit; this.MainEditRecord = mainform.editRecord; this.BsNo = this.MainEditRecord.get('BSNO'); this.oplb = mainform.stroplb; //权限范围 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpIDRang' } }); this.StoreOpRange.load({ params: { optype: "modOrderManagement" } }); _thisAgentFee = this; this.storeFM = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserLinkRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefList' } }); //客户加载_车队 this.storeAgent = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListAgent' } }); //车队 this.comboxAGENT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.AGENT, store: this.storeAgent, name: 'AGENT', queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', valueField: 'CustName', displayField: 'CodeAndName', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { this.formEdit.getForm().findField('FEEAGENT').setValue(combo.value); } } } }); //客户加载_车队 this.storeFeeAgent = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CustomRefModel', proxy: { url: '/CommMng/BasicDataRef/GetCustomRefListAgent' } }); //车队 this.comboxFeeAGENT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.FEEAGENT, store: this.storeAgent, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'FEEAGENT', valueField: 'CustName', displayField: 'CodeAndName' }); this.storeFeeNameRefDC = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' } }); this.storeFeeNameRefDC.load({ params: { condition: "" } }); this.comboxFeeNameRefDC = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRefDC, fieldLabel: Zi.LAN.FEENAME, forceSelection: true, name: 'FEENAME', valueField: 'Name', displayField: 'CodeAndName' }); this.StoreDateCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeDateCurrList' } }); this.StoreDateCurr.load({ params: { optype: "op_Seae", bsno: this.BsNo } }); this.StoreCurrDC = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurrDC.load({ params: { condition: "" } }); this.comboxCurrDC = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCurrDC, fieldLabel: Zi.LAN.CURRENCY, forceSelection: true, name: 'CURRENCY', valueField: 'CURR', displayField: 'CURR' }); this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsChFeeAgentDC', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsChFeeAgentDc/GetDCList', reader: { id: 'BSNO', root: 'data', totalProperty: 'totalCount' } } }); this.girdcolums = [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 150 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 150 }, { sortable: true, dataIndex: 'DCNO', header: Zi.LAN.DCNO, width: 120 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: Zi.LAN.CREATEUSERREF, width: 80 }, { sortable: true, dataIndex: 'CREATETIME', header: Zi.LAN.CREATETIME, width: 80 } ]; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'west', width: 300, loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhongQingShaoDeng}, trackMouseOver: true, disableSelection: false, columns: this.girdcolums, bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: Zi.LAN.displayMsg, emptyMsg: Zi.LAN.emptyMsg }) }); _this = this; this.gridList.addListener('itemclick', function (dataview, record, item, index, e, b) { _this.editRecord = record; _this.OpStatus = 'edit'; _this.LoadData("edit", "GID='" + record.data.GID + "'"); }, this); this.storeList.on('beforeload', function (store) { var sql = "BSNO='" + this.BsNo + "'"; Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.storeDetailList = Ext.create('Ext.data.Store', { model: 'MsChFeeAgentDCDetail', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsChFeeAgentDc/GetDCDetailList', reader: { id: 'CTN_ID', root: 'data', totalProperty: 'totalCount' } } }); //箱型_集装箱列表中的下拉框加载 this.storeFeeNameRef = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.FeeTypeRefModel', proxy: { url: '/MvcShipping/MsChFee/GetFeeTypeRefList' } }); this.storeFeeNameRef.load({ params: { condition: "" } }); this.comboxFeeNameRef = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeNameRef, forceSelection: true, name: 'FEENAME', valueField: 'Name', displayField: 'CodeAndName' }); this.StoreCurr = Ext.create('DsExt.ux.RefTableStore', { model: 'MsFeeCurr', proxy: { url: '/MvcShipping/MsChFee/GetFeeCurrList' } }); this.StoreCurr.load({ params: { condition: "" } }); this.comboxCurr = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreCurr, forceSelection: true, name: 'CURRENCY', valueField: 'CURR', displayField: 'CURR' }); this.storeFeeUnit = Ext.create('DsExt.ux.RefTableStore', { fields: ['UNIT'], proxy: { url: '/MvcShipping/MsCodeFeeTemplate/GetFeeUnit' } }); this.storeFeeUnit.load({ params: { condition: "" } }); this.comboxFeeUnit = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeFeeUnit, forceSelection: true, name: 'UNIT', valueField: 'UNIT', displayField: 'UNIT' }); this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.initgirdbillcolums = [{ sortable: true, dataIndex: 'GID', header: '编号', hidden: true, width: 0 }, { dataIndex: 'FEENAME', header: Zi.LAN.FEENAME , //'箱型', width: 125, editor: this.comboxFeeNameRef }, { dataIndex: 'FEEENAME', header: Zi.LAN.FeeDescription, //'重量', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'CURRENCY', header: Zi.LAN.CURRENCY, //'币别', editor: this.comboxCurr, width: 100 }, { dataIndex: 'EXCHANGERATE', header: Zi.LAN.EXCHANGERATE, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'DRPP', header: Zi.LAN.DRPP, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'DRCC', header: Zi.LAN.DRCC, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'CRPP', header: Zi.LAN.CRPP, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'CRCC', header: Zi.LAN.CRCC, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'FZPR', header: Zi.LAN.FZPR, //'重量', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'AMOUNTDR', header: Zi.LAN.AMOUNTDR, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'AMOUNTCR', header: Zi.LAN.AMOUNTCR, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'UNITPRICE', header: Zi.LAN.UNITPRICE, //'单价', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true }, align: 'right', width: 80 }, { sortable: true, dataIndex: 'UNIT', header: Zi.LAN.UNIT, //'标准', editor: this.comboxFeeUnit, width: 80 }, { dataIndex: 'QUANTITY', header: Zi.LAN.QUANTITY, //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'FEEDESCRIPTION', header: Zi.LAN.FEEDESCRIPTION, //'重量', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }]; this.girdbillcolums = this.initgirdbillcolums; this.gridListDetail = new Ext.grid.GridPanel({ store: this.storeDetailList, enableHdMenu: false, region: 'center', loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhongQingShaoDeng }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', tbar: [ { text: Zi.LAN.btnAddDetail, //'增加明细', tooltip: Zi.LAN.btnAddDetail, //'增加明细', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { this.addDetail(); }, scope: this }, '-', { text: Zi.LAN.templateAdd , tooltip: Zi.LAN.templateAdd , iconCls: "btnadddetail", handler: function (button, event) { this.templateAdd(); }, scope: this }, '-', { text: Zi.LAN.btnDeleteDetail , //'删除明细', tooltip: Zi.LAN.btnDeleteDetail , //'删除明细', id: "btndeldetail", iconCls: "btndeletedetail", handler: function (button, event) { this.deleteDetail(); }, scope: this }, { text: Zi.LAN.SavelistStyle, //保存列表样式 id: "btntestbody", menu: [ { text: Zi.LAN.btnSave, //保存 handler: function (button, event) { _this.girdbillcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridListDetail.columns, _this.girdbillcolums, 1, true); } }, { text: Zi.LAN.Initialization, //初始化 handler: function (menu, event) { _this.girdbillcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridListDetail.columns, _this.initgirdbillcolums, 1, true); } }], scope: this }], columns: this.girdbillcolums }); this.storeDetailList.on('beforeload', function (store) { var billNo = this.formEdit.getForm().findField('GID').getValue(); var condition = "DCGID='" + billNo + "'"; Ext.apply(store.proxy.extraParams, { condition: condition }); }, this); this.gridListDetail.on('edit', function (editor, e, eOpts) { this.gridListAfterEdit(editor, e, eOpts); }, this); this.girdbillcolums = DsTruck.GetGridPanel(USERID, this.formname, this.girdbillcolums, 1); //使用者id,表名,中间column数组,跳过一开始的几列 this.girdbillcolums.unshift(new Ext.grid.RowNumberer()); this.gridListDetail.reconfigure(this.storeDetailList, this.girdbillcolums); this.panelBodyDetail = new Ext.Panel({ // title: '集装箱信息', //'集装箱信息', layout: "border", height: 320, flex: 1, margin: '5 20', frame: true, items: [this.gridListDetail] }); //#region 编辑formEdit 派车通知 this.formEdit = Ext.widget('form', { region: 'center', // height: 120, frame: true, bodyPadding: 5, trackResetOnLoad: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 70, msgTarget: 'qtip' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '业务编号', name: 'BSNO', hidden: true }, { fieldLabel: 'GID', hidden: true, name: 'GID' }, { fieldLabel: 'ISCREATEFEE', hidden: true, name: 'ISCREATEFEE' }, { fieldLabel: 'CREATEUSER', hidden: true, name: 'CREATEUSER' } , { fieldLabel: Zi.LAN.DCNO, readOnly: true, name: 'DCNO' }, this.comboxAGENT , { fieldLabel: Zi.LAN.CREATEUSERREF, name: 'CREATEUSERREF' }, { fieldLabel: Zi.LAN.CREATETIME, name: 'CREATETIME' }, { fieldLabel: Zi.LAN.FEETYPEREF , name: 'DCTYPE' } ] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxFeeAGENT, this.comboxFeeNameRefDC, this.comboxCurrDC, { fieldLabel: Zi.LAN.EXCHANGERATE, //'汇率', xtype: 'numberfield', //labelWidth: 40, decimalPrecision: 6, name: 'EXCHANGERATE' }, { fieldLabel: Zi.LAN.ISCREATEFEEREF, name: 'ISCREATEFEEREF' }] }, this.panelBodyDetail , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.AMOUNTDR , readOnly: true, name: 'AMOUNTDR' }, { fieldLabel: Zi.LAN.AMOUNTCR, readOnly: true, name: 'AMOUNTCR' }, { fieldLabel: Zi.LAN.AMOUNTBAL, readOnly: true, name: 'AMOUNTBAL' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.AMOUNTTOTALSTR, readOnly: true, name: 'AMOUNTTOTALSTR' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, flex: 2, fieldLabel: Zi.LAN.REMARK , height: 60, name: 'REMARK', anchor: '100%' }] } ]//end items(fieldset 1) }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ id: 'btnESave', text: Zi.LAN.btnSave, iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: 'btnESaveAndNew', text: Zi.LAN.btnSaveAndNew, handler: function (button, event) { this.Save('2'); }, scope: this }, { text: Zi.LAN.btnAdd, handler: function (button, event) { this.LoadData('add', ''); }, scope: this }, '-', { text: Zi.LAN.btnDelete, iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: Zi.LAN.Print, iconCls: "btnprint", handler: function (button, event) { this.Print(); }, scope: this }, '-', { text: Zi.LAN.ISCREATEFEEREF , handler: function (button, event) { this.CreateFee(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 框架结构 this.panelpage = new Ext.Panel({ title: Zi.LAN.panelpage, layout: "border", region: 'center', animate: true, autoScroll: true, // containerScroll: true, frame: false, items: [this.formEdit] }); Ext.apply(this, { items: [this.panelBtn, this.gridList, this.panelpage] }); //#endregion //#region 其他 parentWin = window.parent.opener; this.InitData(); //#endregion }, //end initUIComponents //#region 加载事件 InitData: function () { this.opStatus = 'add'; var condition = ''; _this = this; this.storeList.load({ params: { condition: "BSNO='" + this.BsNo + "'" }, callback: function (r, options, success) { if (success) { if (this.storeList.getCount() > 0) { var member = this.storeList.getAt(0); _this.LoadData("edit", "GID='" + member.data.GID + "'"); } else { _this.LoadData('add', ''); } } }, scope: this }); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; //this.bodyDel = []; this.opStatus = opstatus; //if (this.opStatus == 'add') { // this.formEdit.getForm().reset(); // var AGENTID = this.MainEditRecord.get('AGENTID'); // this.formEdit.getForm().findField('AGENT').setValue(AGENTID); // this.formEdit.getForm().findField('FEEAGENT').setValue(AGENTID); //} else { Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, url: '/MvcShipping/MsChFeeAgentDc/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: Zi.LAN.TiShi, msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } data = result.data; this.storeDetailList.load({ params: { condition: "DCGID='" + data.GID + "'" } }); this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); this.formEdit.getForm().findField('BSNO').setValue(this.BsNo); if (this.opStatus == 'add') { var AGENTID = this.MainEditRecord.get('AGENTID'); this.formEdit.getForm().findField('AGENT').setValue(AGENTID); this.formEdit.getForm().findField('FEEAGENT').setValue(AGENTID); } this.GetEditStatus(); } else { Ext.MessageBox.alert(Zi.LAN.FuWuQiXiangYingChuCuo, response.responseText); } }, scope: this }); //} }, // end LoadDate //#endregion //#region 保存 Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } this.setAllTotal(); var data = this.formEdit.getForm().getValues(false, false, false); var bodydatas = []; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJsonAll(bodydatas); // Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, url: '/MvcShipping/MsChFeeAgentDc/SaveAgentDC', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody }, 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().reset(); this.formEdit.getForm().setValues(returnData); // if (this.opStatus == 'add') { var arrNewRecords = this.storeList.add(returnData); this.editRecord = arrNewRecords[0]; var editp = Ext.create('MsChFeeAgentDC', returnData); this.formEdit.getForm().findField('GID').setValue(editp.get('GID')); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChFeeAgentDC', 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(); } var LE_ID = this.formEdit.getForm().findField('GID').getValue(); for (var j = 0; j < this.storeDetailList.getCount(); j += 1) { var memberbody = this.storeDetailList.getAt(j); memberbody.set("DCGID", LE_ID); memberbody.commit(); }; if (type == '0') { this.opStatus = 'edit'; } else if (type == '1') { window.close(); } else if (type == '2') { this.LoadData('add', ''); } } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save //#endregion templateAdd: function () { DsOpenEditWin("/MvcShipping/MsCodeFeeTemplateAgent/AddFee", "模板引入费用"); }, onDeleteClick: function (button, event) { var selections = this.gridList.getSelectionModel().getSelection(); if (selections.length == 0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeXinXi, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; Ext.MessageBox.confirm(Zi.LAN.TiShi, Zi.LAN.QueDingShanChuGaiJiLuMa, function (btn) { if (btn == 'yes') { Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, url: '/MvcShipping/MsChFeeAgentDc/Delete', params: { data: Ext.JSON.encode(record.data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeList.remove(record); if (this.storeList.getCount() > 0) { var member = this.storeList.getAt(0); this.LoadData("edit", "GID='" + member.data.GID + "'"); this.editRecord = member; } else { this.LoadData('add', ''); } Ext.Msg.show({ title: Zi.LAN.TiShi, msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: Zi.LAN.JingGao, msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, success: function (response, options) { }, scope: this }); //end Ext.Ajax.request } }, this); }, addDetail: function () { store = this.storeDetailList; var newSerialno = this.GetHandleSerialNo(store); var exchange = 0; var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR','USD'); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; exchange = DEFRATE; } else { var DFrecords = DsStoreQueryBy(this.StoreCurrDC, 'CURR','USD'); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; exchange = DEFRATE; } else { exchange =1; } } var record = Ext.create('MsChFeeAgentDCDetail', { GID: NewGuid(), DCGID: '*', FEENAME: '', FEEENAME: '', CURRENCY: 'USD', FEEDESCRIPTION: '', EXCHANGERATE: exchange, DRPP: 0, DRCC: 0, CRPP: 0, CRCC: 0, FZPR: '100', AMOUNTDR: 0, AMOUNTCR: 0, UNIT: '', UNITPRICE: 0, QUANTITY: 0, SORT: newSerialno }); this.storeDetailList.add(record); var n = this.storeDetailList.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 }); }, GetHandleSerialNo: function (store) { var result = 0; if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (parseInt(member.data.SORT) > parseInt(result)) { result = member.data.SORT; } } } result = parseInt(result) + 1; return result; }, deleteDetail: function () { var selectedRecords = this.gridListDetail.selModel.getSelection(); var bodyAddDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.DCGID == "" || rec.data.DCGID == "*")//如果是新增但没有保存的数据,没有必要提交到后台 { this.storeDetailList.remove(selectedRecords[i]); this.setAllTotal(); } else { bodyAddDatas.push(rec); } //this.storeBodyList.remove(selectedRecords[i]); } var jsonbodyAddDatas = ConvertRecordsToJsonAll(bodyAddDatas); Ext.MessageBox.confirm(Zi.LAN.TiShi, Zi.LAN.QueDingShanChuGaiJiLuMa, function (btn) { if (btn == 'yes') { Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在删除数据...', url: '/MvcShipping/MsChFeeAgentDc/DeleteDetailList', params: { data: jsonbodyAddDatas }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.storeDetailList.reload(); this.setAllTotal(); Ext.Msg.show({ title: Zi.LAN.TiShi, msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: Zi.LAN.JingGao, msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); }, scope: this }); //end Ext.Ajax.request } }, this); }, gridListAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; if (e.field == 'FZPR' || e.field == 'DRPP' || e.field == 'DRCC' || e.field == 'CRPP' || e.field == 'CRCC') { var FZPR = e.record.data['FZPR']; if (FZPR == '' || FZPR == null) return; var taxrateb = Div(FZPR, 100, 4); var DRPP = e.record.data['DRPP']; var DRCC = e.record.data['DRCC']; var CRPP = e.record.data['CRPP']; var CRCC = e.record.data['CRCC']; var ppamount = Mul(Add(DRPP, -CRPP), taxrateb); var ccamount = Mul(Add(DRCC, -CRCC), taxrateb); var amount = Add(ppamount, - ccamount); if (amount > 0) { e.record.set('AMOUNTDR', 0); e.record.set('AMOUNTCR', amount); } else { e.record.set('AMOUNTDR', Mul(amount, -1)); e.record.set('AMOUNTCR', 0); } this.setAllTotal(); } else if (e.field == 'FEENAME') { var records = DsStoreQueryBy(this.storeFeeNameRef, 'Name', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; var ENAME = data.Description; e.record.set('FEEENAME', ENAME); } } if (e.field == 'CURRENCY') { if (e.value == LOCALCURR) { e.record.set('EXCHANGERATE', 1); } else { var FFrecords = DsStoreQueryBy(this.StoreDateCurr, 'CURR', e.value); if (FFrecords.getCount() > 0) { var ffdata = FFrecords.getAt(0).data; var DEFRATE = ffdata.DEFRATE; e.record.set('EXCHANGERATE', DEFRATE); } else { var DFrecords = DsStoreQueryBy(this.StoreCurrDC, 'CURR', e.value); if (DFrecords.getCount() > 0) { var dfdata = DFrecords.getAt(0).data; var DEFRATE = dfdata.DEFRATE; e.record.set('EXCHANGERATE', DEFRATE); } else { e.record.set('EXCHANGERATE', 0); } } } this.setAllTotal(); } else if (e.field == 'UNITPRICE' || e.field == 'QUANTITY') { var UNITPRICE = e.record.data['UNITPRICE']; var QUANTITY = e.record.data['QUANTITY']; var amount = Mul(UNITPRICE, QUANTITY); e.record.set('AMOUNTDR', amount); } }, setAllTotal: function () { var cntrstr = ''; var AMOUNTDR = 0; var AMOUNTCR = 0; var AMOUNTBAL = 0; var CURRENCY = ''; var EXCHANGERATE = 0; for (var j = 0; j < _this.storeDetailList.getCount(); j += 1) { var memberbody = _this.storeDetailList.getAt(j); AMOUNTDR = Add(AMOUNTDR, memberbody.data.AMOUNTDR); AMOUNTCR = Add(AMOUNTCR, memberbody.data.AMOUNTCR); CURRENCY = memberbody.data.CURRENCY; EXCHANGERATE = memberbody.data.EXCHANGERATE; } this.formEdit.getForm().findField('AMOUNTDR').setValue(AMOUNTDR); this.formEdit.getForm().findField('AMOUNTCR').setValue(AMOUNTCR); if (AMOUNTDR > AMOUNTCR) { AMOUNTBAL = Add(AMOUNTDR, -AMOUNTCR); this.formEdit.getForm().findField('DCTYPE').setValue('DEBIT'); } else { AMOUNTBAL = Add(AMOUNTCR, -AMOUNTDR); this.formEdit.getForm().findField('DCTYPE').setValue('CREDIT'); } this.formEdit.getForm().findField('AMOUNTBAL').setValue(AMOUNTBAL); var amtstr = ToEn(AMOUNTBAL.toString()).toUpperCase(); this.formEdit.getForm().findField('AMOUNTTOTALSTR').setValue('SAY:US DOLLARS ' + amtstr +' ONLY.'); this.formEdit.getForm().findField('AMOUNTBAL').setValue(AMOUNTBAL); this.formEdit.getForm().findField('CURRENCY').setValue(CURRENCY); this.formEdit.getForm().findField('EXCHANGERATE').setValue(EXCHANGERATE); }, CreateFee: function () { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } var data = this.formEdit.getForm().getValues(false, false, false); if (data.FEEAGENT == '') { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.feiyongdailibunengweikong, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.FEENAME == '') { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.feiyongmingchengbunengweikong, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.CURRENCY == '') { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.bibiebunengweikong, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.AMOUNTBAL ==0) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.jieyujineweiling, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var bodydatas = []; for (var i = 0; i < this.storeDetailList.getCount(); i += 1) { var member = this.storeDetailList.getAt(i); bodydatas.push(member); } var jsonBody = ConvertRecordsToJsonAll(bodydatas); // Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, url: '/MvcShipping/MsChFeeAgentDc/CreateFee', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data), body: jsonBody }, 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().reset(); this.formEdit.getForm().setValues(returnData); // if (this.opStatus == 'add') { var arrNewRecords = this.storeList.add(returnData); this.editRecord = arrNewRecords[0]; var editp = Ext.create('MsChFeeAgentDC', returnData); this.formEdit.getForm().findField('GID').setValue(editp.get('GID')); } else if (this.opStatus == 'edit') { var editp = Ext.create('MsChFeeAgentDC', 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(); } var LE_ID = this.formEdit.getForm().findField('GID').getValue(); for (var j = 0; j < this.storeDetailList.getCount(); j += 1) { var memberbody = this.storeDetailList.getAt(j); memberbody.set("DCGID", LE_ID); memberbody.commit(); }; this.opStatus = 'edit'; } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: '请重试', msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //end save //#region //#endregion //#region 编辑时按钮等的状态 GetEditStatus: function () { var canedit = true; this.setSaveBtnStatus(canedit); }, setSaveBtnStatus: function (enable) { var btnESave = Ext.getCmp('btnESave'); var btnESaveAndNew = Ext.getCmp('btnESaveAndNew'); if (enable) { btnESave.enable(); btnESaveAndNew.enable(); } else { btnESave.disable(); btnESaveAndNew.disable(); } }, //#endregion //#region 打印 Print: function () { var basicForm = this.formEdit.getForm(); var billNo = basicForm.findField('GID').value; var bsNo = basicForm.findField('BSNO').value; if (billNo == '*' || billNo == '' || billNo == NaN) { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: Zi.LAN.BAOCUNHOUZAIDAYIN, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; } var MBLNO = this.MainEditRecord.get('MBLNO') + 'DC NOTE'; var printType = 'MSAGENTDCNOTE'; var sql1 = "SET LANGUAGE 'us_english' SELECT * FROM ch_fee_agentdc WHERE GID = '" + billNo + "'"; var sql2 = "SET LANGUAGE 'us_english' SELECT * FROM ch_fee_agentdc_detail WHERE DCGID = '" + billNo + "' order by SORT "; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6, MBLNO, '', '', '', bsNo); } // #endregion });