Ext.namespace('Shipping'); Shipping.PiLiangServiceFeeEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.PiLiangServiceFeeEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.PiLiangServiceFeeEdit, Ext.Panel, { PageSize: 15, ParentWin: null, OprationStatus: null, //仅当弹出界面时使用 EditRecord: null, strbsno: '', initUIComponents: function () { this.storeServiceFeeTemplete = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeServiceFeeTemplate', proxy: { url: '/MvcShipping/MsCodeServiceFeeTemplate/GetDataList' } }); this.storeServiceFeeTemplete.load({ params: { condition: "OPTYPE='7'"} }); this.comboxServiceFeeTemplete = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeServiceFeeTemplete, forceSelection: true, name: 'GID', valueField: 'GID', displayField: 'NAME', listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var GID = records[0].data.GID; this.storeBodyList.load({ params: { condition: " TemplateID='" + GID + "'"} }); var CUSTOMERNAME = this.formEdit.getForm().findField('CUSTOMERNAME'); CUSTOMERNAME.setValue(records[0].data.CUSTOMERNAME); var DESCRIPTION = this.formEdit.getForm().findField('DESCRIPTION'); DESCRIPTION.setValue(records[0].data.DESCRIPTION); } } } }); //编辑form this.formEdit = Ext.widget('form', { region: 'north', frame: true, height: 55, 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: [this.comboxServiceFeeTemplete, { fieldLabel: '客户名称', readOnly: true, name: 'CUSTOMERNAME' }, { fieldLabel: '模板说明', readOnly: true, name: 'DESCRIPTION' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); //end this.formEdit //#region 明细表 //明细表表格相关 //明细表-数据集 this.storeBodyList = Ext.create('Ext.data.Store', { model: 'MsCodeServiceFeeTemplateDetail', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCodeServiceFeeTemplate/GetBodyList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.gridList = new Ext.grid.GridPanel({ store: this.storeBodyList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, selType: 'cellmodel', columns: [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'TemplateID', header: 'TemplateID', hidden: true, width: 100 }, { sortable: true, dataIndex: 'CustomerType', header: '客户类别', width: 160 }, { sortable: true, dataIndex: 'CustomerName', header: '客户名称', width: 160 }, { sortable: true, dataIndex: 'OPField', header: '服务项目', renderer: function (value, p, record) { if (value == null || value == '') return ''; else return record.data.SERVICENAME; }, width: 160 }, { sortable: true, dataIndex: 'FeeName', header: '费用名称', width: 160 }, { sortable: true, dataIndex: 'FeeType', header: '收/付', width: 160, renderer: function (value, p, record) { if (value == 2) return '付'; else return '收'; } }, { sortable: true, dataIndex: 'Unit', header: '单位标准', width: 60 }, { sortable: true, dataIndex: 'UnitPrice', header: '单价', width: 80, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { try { var lsValue = usMoney(value, 2, '', false); if (lsValue != "NaN") { value = lsValue; if (parseFloat(lsValue) < 0) { return '' + lsValue + ''; } } else { return value; } } catch (e) { return value; } return value; } }, { sortable: true, dataIndex: 'Currency', header: '币别', width: 40 }, { sortable: true, dataIndex: 'ExchangeRate', header: '汇率', width: 60 }, { sortable: true, dataIndex: 'Remark', header: '备注', width: 150 } ] }); this.panelService = new Ext.Panel({ title: '费用方案明细', layout: "border", region: 'center', margin: '5 10', items: [this.gridList] }); //#endregion 明细表 this.girdcolums = [{ sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 80 }, { sortable: true, id: '', dataIndex: 'BSSTATUSREF', header: '业务锁定', align: 'center', width: 60, renderer: function (value, cellmeta) { if (value == '锁定') { return ""; } } }, { sortable: true, id: '', dataIndex: 'FEESTATUSREF', header: '费用锁定', align: 'center', width: 60, renderer: function (value, cellmeta) { if (value == '锁定') { return ""; } } }, { sortable: true, dataIndex: 'OPLBNAME', header: '业务类型', hidden: true, width: 80 }, { sortable: true, dataIndex: 'CUSTOMERNAME', header: '委托单位', width: 80 }, { sortable: true, dataIndex: 'MBLNO', header: '主提单号', width: 80 }, { sortable: true, dataIndex: 'CONTRACTNO', header: '合同号', width: 80 }, { sortable: true, dataIndex: 'CUSTNO', header: '委托编号', width: 80 }, { sortable: true, id: '', dataIndex: 'ORDERNO', header: '订舱编号', width: 120 }, { sortable: true, dataIndex: 'HBLNO', header: '分提单号', width: 80 }, { sortable: true, dataIndex: 'BSDATE', header: '接单日期', width: 80 }, { sortable: true, dataIndex: 'ACCDATE', header: '会计期间', width: 80 }, { sortable: true, dataIndex: 'ETD', header: '业务日期', width: 80 }, { sortable: true, dataIndex: 'OP', header: '操作', width: 80 }, { sortable: true, dataIndex: 'SALE', header: '销售', width: 80 }, { sortable: true, dataIndex: 'CUSTSERVICE', header: '客服', width: 80 }, { sortable: true, dataIndex: 'BSSOURCE', header: '业务来源', width: 80 }, { sortable: true, dataIndex: 'BSSOURCEDETAIL', header: '来源明细', width: 80 }, { sortable: true, dataIndex: 'TRADETYPE', header: '贸易方式', width: 80 }, { sortable: true, dataIndex: 'TRANSTYPE', header: '运输类型', width: 80 }, { sortable: true, dataIndex: 'VESSEL', header: '运输工具', width: 80 }, { sortable: true, dataIndex: 'VOYNO', header: '班次号', width: 80 }, { sortable: true, dataIndex: 'PORTLOAD', header: '装货港', width: 80 }, { sortable: true, dataIndex: 'PORTDISCHARGE', header: '卸货港', width: 80 }, { sortable: true, dataIndex: 'GOODSNAME', header: '品名', width: 80 }, { sortable: true, dataIndex: 'KGS', header: '毛重', width: 80 }, { sortable: true, dataIndex: 'NETWEIGHT', header: '净重', width: 80 }, { sortable: true, dataIndex: 'CBM', header: '尺码', width: 80 }, { sortable: true, dataIndex: 'PKGS', header: '件数', width: 80 }, { sortable: true, dataIndex: 'KINDPKGS', header: '件数包装', width: 80 }, { sortable: true, dataIndex: 'VOUNO', header: '凭证号', width: 80 }, { sortable: true, dataIndex: 'CREATEUSER', header: '创建人', width: 80 }, { sortable: true, dataIndex: 'CREATETIME', header: '创建日期', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSER', header: '修改人', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '修改日期', width: 80 }, { sortable: true, dataIndex: 'ORDERNO', header: '订舱编号', width: 80 }, { sortable: true, dataIndex: 'REMARK', header: '备注', width: 200 }, { sortable: true, dataIndex: 'IsSERVICE1', header: '服务项目1', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE2', header: '服务项目2', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE3', header: '服务项目3', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE4', header: '服务项目4', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE5', header: '服务项目5', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE6', header: '服务项目6', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE7', header: '服务项目7', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE8', header: '服务项目8', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE9', header: '服务项目9', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }, { sortable: true, dataIndex: 'IsSERVICE10', header: '服务项目10', hidden: true, width: 100, renderer: function (value, meta, record) { if (value == true || value == '1') return '√'; else return ''; } }]; this.storeBodyAddList = Ext.create('Ext.data.Store', { model: 'MsOpOtherEntity' }); //明细表表格 this.gridAddList = new Ext.grid.GridPanel({ store: this.storeBodyAddList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolums }); parentWin = window.parent.opener; this.InitData(); //#endregion //#region 按钮ToolBar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新建", iconCls: "btnadd", handler: function (button, event) { this.addDetail(); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.deleteDetail(); }, scope: this }, '-', { text: "生成费用", iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event); }, scope: this } ] }); //#endregion //#region 布局 this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 250, items: [this.panelBtn, this.formEdit, this.gridList] }); this.panelFee = new Ext.Panel({ layout: "border", region: "center", items: [ this.gridAddList ] }); Ext.apply(this, { items: [this.panelTop, this.panelFee] }); //#endregion this.InitGrid(); // this.SetBtnRight(); }, //end initUIComponents InitData: function () { var condition = ''; _this = this; if (parentWin) { var ret = parentWin.OprationSwap(); var AddList = ret[5]; for (var j = 0; j < AddList.getCount(); j += 1) { var memberbody = AddList.getAt(j); this.storeBodyAddList.add(memberbody); }; } }, InitGrid: function () { var agirdcolums = this.girdcolums; this.storecodeservice = Ext.create('DsExt.ux.RefTableStore', { model: 'MsCodeOpService', proxy: { url: '/MvcShipping/MsCodeOpService/GetDataList' } }); this.storecodeservice.load({ params: { condition: "OPTYPE='7'" }, callback: function (r, options, success) { if (success) { if (r.length != 0) { for (i = 0; i < this.storecodeservice.getCount(); i += 1) { var memberyf = this.storecodeservice.getAt(i); for (var j = 0; j < agirdcolums.length; j++) { if (agirdcolums[j].dataIndex == memberyf.data.OPField) { agirdcolums[j].header = memberyf.data.SERVICENAME + '(状态)'; agirdcolums[j].hidden = false; } else if (agirdcolums[j].dataIndex == 'Is' + memberyf.data.OPField) { agirdcolums[j].header = memberyf.data.SERVICENAME; agirdcolums[j].hidden = false; } } }; } this.gridAddList.reconfigure(this.storeBodyAddList, agirdcolums); } }, scope: this }); }, addDetail: function () { var newSerialno = DsGetNewSerialNo(this.storeList, 0); var n = this.storeList.getCount(); var myDate = new Date(); var mydatestr = Ext.util.Format.date(myDate, 'Y-m-d'); var record = Ext.create('MsOpStatus', { ST_ID: NewGuid(), BSNO: '*', ORDNO: n + 1, STATUS: '', COMPTIME: mydatestr, COMPOP: SHOWNAME, REMARK: '' }); this.storeList.add(record); var n = this.storeList.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 2 }); }, deleteDetail: function () { var selectedRecords = this.CheckBoxModel.selected.items; Ext.MessageBox.confirm('提示', '确定要删除选中的明细吗?', function (btn) { if (btn == 'yes') { var bodyDatas = []; for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.BSNO == "" || rec.BSNO == "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.storeList.remove(selectedRecords[i]); } else { bodyDatas.push(rec); } } var jsonBody = ConvertRecordsToJsonAll(bodyDatas); _this = this; Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpStatus/Delete', params: { bsno: _this.BsNo, data: jsonBody }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { this.storeList.remove(selectedRecords[i]); } 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); }, onPostDetailClick: function (button, event) { var bodyBillDatas = []; for (i = 0; i < this.storeBodyAddList.getCount(); i += 1) { var memberyf = this.storeBodyAddList.getAt(i); bodyBillDatas.push(memberyf); }; var jsonbodyBill = ConvertRecordsToJsonAll(bodyBillDatas); var bodyFeeDatas = []; for (i = 0; i < this.storeBodyList.getCount(); i += 1) { var memberyf = this.storeBodyList.getAt(i); bodyFeeDatas.push(memberyf); }; var jsonbodyFee = ConvertRecordsToJsonAll(bodyFeeDatas); _this = this; Ext.Msg.wait('正在生成数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在生成数据...', url: '/MvcShipping/MsOpOther/PiliangServiceFee', scope: this, params: { bill: jsonbodyBill, fee: jsonbodyFee }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { 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 }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } });