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: '国外代理', 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: '费用代理', 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: '费用名称', 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: '币别', 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: '账单编号', width: 120 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: '录入人', width: 80 }, { sortable: true, dataIndex: 'CREATETIME', header: '录入日期', width: 80 } ]; //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'west', width: 300, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolums, bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', 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: '费用名称', //'箱型', width: 125, editor: this.comboxFeeNameRef }, { dataIndex: 'FEEENAME', header: '费用英文名', //'重量', width: 120, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'CURRENCY', header: '币别', //'币别', editor: this.comboxCurr, width: 100 }, { dataIndex: 'EXCHANGERATE', header: '汇率', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'DRPP', header: '应收PP', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'DRCC', header: '应收CC', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'CRPP', header: '应付PP', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'CRCC', header: '应付CC', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'FZPR', header: '分账比例%', //'重量', width: 80, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'AMOUNTDR', header: '应收金额', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'AMOUNTCR', header: '应付金额', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'UNITPRICE', header: '单价', //'单价', editor: { xtype: 'numberfield', keyNavEnabled: false, selectOnFocus: true, hideTrigger: true, mouseWheelEnabled: false, enableKeyEvents: true }, align: 'right', width: 80 }, { sortable: true, dataIndex: 'UNIT', header: '标准', //'标准', editor: this.comboxFeeUnit, width: 80 }, { dataIndex: 'QUANTITY', header: '数量', //'箱量', width: 100, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { dataIndex: 'FEEDESCRIPTION', header: '费用说明', //'重量', 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: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', tbar: [ { text: '增加明细', //'增加明细', tooltip: '增加明细', //'增加明细', id: "btnadddetail", iconCls: "btnadddetail", handler: function (button, event) { this.addDetail(); }, scope: this }, '-', { text: '模板引入', tooltip: '模板引入', iconCls: "btnadddetail", handler: function (button, event) { this.templateAdd(); }, scope: this }, '-', { text: '删除明细', //'删除明细', tooltip: '删除明细', //'删除明细', id: "btndeldetail", iconCls: "btndeletedetail", handler: function (button, event) { this.deleteDetail(); }, scope: this }, { text: '保存列表样式', //保存列表样式 id: "btntestbody", menu: [ { text: '保存', //保存 handler: function (button, event) { _this.girdbillcolums = DsTruck.SaveGridPanel(USERID, _this.formname, _this.gridListDetail.columns, _this.girdbillcolums, 1, true); } }, { text: '初始化', //初始化 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: '账单编号', readOnly: true, name: 'DCNO' }, this.comboxAGENT , { fieldLabel: '录入人', name: 'CREATEUSERREF' }, { fieldLabel: '录入时间', name: 'CREATETIME' }, { fieldLabel: '类型', name: 'DCTYPE' } ] } , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxFeeAGENT, this.comboxFeeNameRefDC, this.comboxCurrDC, { fieldLabel: '对美元汇率', //'汇率', xtype: 'numberfield', //labelWidth: 40, decimalPrecision: 6, name: 'EXCHANGERATE' }, { fieldLabel: '生成费用', name: 'ISCREATEFEEREF' }] }, this.panelBodyDetail , { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '应收金额', readOnly: true, name: 'AMOUNTDR' }, { fieldLabel: '应付金额', readOnly: true, name: 'AMOUNTCR' }, { fieldLabel: '结余金额', readOnly: true, name: 'AMOUNTBAL' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '金额大写', readOnly: true, name: 'AMOUNTTOTALSTR' }] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, flex: 2, fieldLabel: '备注', 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: "保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { id: 'btnESaveAndNew', text: "保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this }, { text: "新建", handler: function (button, event) { this.LoadData('add', ''); }, scope: this }, '-', { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "打印", iconCls: "btnprint", handler: function (button, event) { this.Print(); }, scope: this }, '-', { text: "生成费用", handler: function (button, event) { this.CreateFee(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 框架结构 this.panelpage = new Ext.Panel({ title: 'D/C NOTE详细信息', 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: '正在查询主表数据...', 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: '提示', 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('请求出现错误,请重试', 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('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', 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: '错误', 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 //#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: '提示', msg: '请先选择业务!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var record = selections[0]; Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', 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: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', 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('提示', '确定要删除此记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在操作数据'); Ext.Ajax.request({ waitMsg: '正在操作数据', //'正在删除数据...', 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.remove(rec); this.setAllTotal(); Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } else { Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }, failure: function (response, options) { Ext.Msg.show({ title: '警告', msg: '服务器响应出错!', 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.ISCREATEFEE == 'true') { // Ext.Msg.show({ title: '提示', msg: '已生成费用,不能重复生成!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); // return; //} if (data.FEEAGENT == '') { Ext.Msg.show({ title: '提示', msg: '费用代理不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.FEENAME == '') { Ext.Msg.show({ title: '提示', msg: '费用名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.CURRENCY == '') { Ext.Msg.show({ title: '提示', msg: '币别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (data.AMOUNTBAL ==0) { Ext.Msg.show({ title: '提示', msg: '结余金额为0,无法生成!', 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('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', 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: '错误', 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 //#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: '错误', msg: 'D/C NOTE还没有保存,请保存后再打印', 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 });