Ext.namespace('Shipping'); Shipping.MsBillNoSetEdiIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsBillNoSetEdiIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsBillNoSetEdiIndex, Ext.Panel, { OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { //定义数据集 this.storeAddDCType = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeAddDCType.add({ "DC": "1", "NAME": "是" }); this.storeAddDCType.add({ "DC": "0", "NAME": "否" }); this.comboxaddDCType = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeAddDCType, valueField: 'DC', displayField: 'NAME', forceSelection: true, name: 'DC' }); this.storeList = Ext.create('Ext.data.Store', { model: 'SysBillType', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsSysBillNoSet/GetBillTypeDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCellEditing], selType: 'cellmodel', columns: [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'BillCode', header: '编码规则代码', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'BillName', header: '规则名称', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'BillGrp', header: '规则分类', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'IsPrefix', header: '启用头部字符', width: 100, editor: this.comboxaddDCType, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'PrefixLen', header: '头部字符长度', width: 160, editor: { xtype: 'numberfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'PrefixNo', header: '头部字符', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'IsDate', header: '启用日期', width: 100, editor: this.comboxaddDCType, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'DateFmt', header: '日期格式', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'YearNo', header: '开始年', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'MonthNo', header: '开始月', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'DayNo', header: '开始日', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'SerialLen', header: '序号长度', width: 160, editor: { xtype: 'numberfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'BillHeadTbl', header: '编号表', width: 160, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'IsOrgPrefix', header: '启用公司编码', width: 100, editor: this.comboxaddDCType, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'IsEmpPrefix', header: '启用人员编码', width: 100, editor: this.comboxaddDCType, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } } ] }); this.storeListSet = Ext.create('Ext.data.Store', { model: 'SysBillNoSet', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsSysBillNoSet/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.comboxBillType = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeList, forceSelection: true, valueField: 'BillCode', displayField: 'BillName' }); this.storeBsType = Ext.create('DsExt.ux.RefEnumStore', {}); this.storeBsType.load({ params: { enumTypeId: 97019} }); this.comboxBsType = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeBsType, valueField: 'EnumValueName', displayField: 'EnumValueName', forceSelection: true }); this.StoreDATETYPE = Ext.create('Ext.data.Store', { fields: ['DATETYPE'] }); this.StoreDATETYPE.add({ "DATETYPE": "业务日期" }); this.StoreDATETYPE.add({ "DATETYPE": "会计期间" }); this.StoreDATETYPE.add({ "DATETYPE": "自然日期" }); this.comboxDATETYPE = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreDATETYPE, forceSelection: true, valueField: 'DATETYPE', displayField: 'DATETYPE' }); this.StoreNOTYPE = Ext.create('Ext.data.Store', { fields: ['DATETYPE'] }); this.StoreNOTYPE.add({ "DATETYPE": "委托编号" }); this.StoreNOTYPE.add({ "DATETYPE": "分提单号" }); this.comboxNOTYPE = Ext.create('DsExt.ux.RefTableCombox', { store: this.StoreNOTYPE, forceSelection: true, valueField: 'DATETYPE', displayField: 'DATETYPE', }); this.storeISAUTO = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeISAUTO.add({ "DC": "1", "NAME": "是" }); this.storeISAUTO.add({ "DC": "0", "NAME": "否" }); this.comboxISAUTO = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeISAUTO, valueField: 'DC', displayField: 'NAME', forceSelection: true }); this.storeISOPADD = Ext.create('Ext.data.Store', { fields: ['DC', 'NAME'] }); this.storeISOPADD.add({ "DC": "1", "NAME": "是" }); this.storeISOPADD.add({ "DC": "0", "NAME": "否" }); this.comboxISOPADD = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeISOPADD, valueField: 'DC', displayField: 'NAME', forceSelection: true }); this.gridListCustCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); //定义Grid this.gridListSet = new Ext.grid.GridPanel({ store: this.storeListSet, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.gridListCustCellEditing], selType: 'cellmodel', columns: [{ sortable: true, dataIndex: 'GID', header: 'GID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'OPLBNAME', header: '业务模块', width: 160, editor: this.comboxBsType }, { sortable: true, dataIndex: 'RULEBLNO', header: '编号类别', width: 100, editor: this.comboxNOTYPE }, { sortable: true, dataIndex: 'BILLTYPE', header: '编码规则', width: 100, editor: this.comboxBillType, renderer: function (value, p, record) { return record.data.BILLTYPEREF; } }, { sortable: true, dataIndex: 'RULEDATETYPE', header: '日期类型', width: 160, editor: this.comboxDATETYPE }, { sortable: true, dataIndex: 'ISEDIT', header: '允许手动编辑', width: 100, editor: this.comboxaddDCType, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'ISOPADD', header: '允许手动生成', width: 100, editor: this.comboxISOPADD, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'ISAUTO', header: '自动生成', width: 100, editor: this.comboxISAUTO, renderer: function (value, p, record) { if (value == "1") return "是"; else return "否"; } }, { sortable: true, dataIndex: 'CUSTOMHEAD', header: '自定义头部字符', width: 180, //'备注', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true } } ] }); //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "新增", iconCls: "btnadd", handler: function (button, event) { this.addDetail(); // this.OprationStatus = 'add'; // window.open('/MvcShipping/MsCodeYardDataSet/Edit', "CODEYARDDATASET", 'width=800,height=600,top=0,left=0,resizable=yes,status=yes,menubar=no,scrollbars=yes'); }, scope: this }, { text: "保存", iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event); }, scope: this }, '-', { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this } ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 30, items: [this.panelBtn] }); this.panelCtn = new Ext.Panel({ layout: "border", title: '编码规则设置', id: 'pnlctn', region: "center", items: [this.gridList] }); this.panelCust = new Ext.Panel({ layout: "border", title: '业务编码设置', id: 'pnlcust', region: "center", items: [this.gridListSet] }); this.MainCenter = new Ext.TabPanel({ activeTab: 0, autoWidth: true, border: true, frame: false, region: 'center', enableTabScroll: true, items: [ this.panelCust,this.panelCtn ] }); Ext.apply(this, { items: [this.panelTop, this.MainCenter] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); // this.gridList.on('edit', function (editor, e, eOpts) { // this.gridListAfterEdit(editor, e, eOpts); // }, this); this.storeListSet.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.gridListSet.on('edit', function (editor, e, eOpts) { this.gridListAfterEdit(editor, e, eOpts); }, this); this.onRefreshClick(); }, //end initUIComponents onRefreshClick: function (button, event) { var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: 500, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); this.storeListSet.load({ params: { start: 0, limit: 500, sort: '', condition: sql }, waitMsg: "正在查询数据...", scope: this }); }, addDetail: function () { //var newSerialno = DsGetNewSerialNo(this.storeBodyList, this.serialNo); if (this.MainCenter.activeTab.id == 'pnlctn') { var record = Ext.create('SysBillType', { GID: '*', BillCode: '', BillName: '', BillGrp: '', IsRule: '1', NoLength: 6, SerialLen: 5, IsPrefix: '1', PrefixLen: 2, PrefixNo: '', IsDate: '1', DateFmt: 'YYYYMM', YearNo: '', MonthNo: '', DayNo: '', BillHeadTbl: '', IsOrgPrefix: '0' }); this.storeList.add(record); var n = this.storeList.getCount(); this.gridListCellEditing.startEditByPosition({ row: n - 1, column: 1 }); } else if (this.MainCenter.activeTab.id == 'pnlcust') { var record = Ext.create('SysBillNoSet', { GID: '*', OPLBNAME: '', BILLTYPE: '', BILLTYPEREF: '', RULEBLNO: '委托编号', RULEDATETYPE:'自然日期', ISEDIT:'0' }); this.storeListSet.add(record); var n = this.storeListSet.getCount(); this.gridListCustCellEditing.startEditByPosition({ row: n - 1, column: 1 }); } }, onPostDetailClick: function (button, event) { if (this.MainCenter.activeTab.id == 'pnlctn') { this.onPostCtnDetailClick(button, event); } else if (this.MainCenter.activeTab.id == 'pnlcust') { this.onPostCustDetailClick(button, event); } }, onPostCtnDetailClick: function (button, event) { var bodyDrChFeeDatas = []; var i; for (i = 0; i < this.storeList.getCount(); i += 1) { var memberyf = this.storeList.getAt(i); var BillCode = memberyf.data.BillCode; if (BillCode == '') { Ext.Msg.show({ title: '提示', msg: '编码不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } else { if (BillCode.length>4){ Ext.Msg.show({ title: '提示', msg: '编码长度不能超过4位!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } } var BillName = memberyf.data.BillName; if (BillName == '') { Ext.Msg.show({ title: '提示', msg: '规则名称不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var SerialLen = memberyf.data.SerialLen; if (SerialLen == 0) { Ext.Msg.show({ title: '提示', msg: '序号长度不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var IsPrefix = memberyf.data.IsPrefix; if (IsPrefix == '') { Ext.Msg.show({ title: '提示', msg: '是否启用头部字符不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } else if (IsPrefix=='1'){ var PrefixLen = memberyf.data.PrefixLen; if (PrefixLen ==0) { Ext.Msg.show({ title: '提示', msg: '头部字符长度不能为0!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var PrefixNo = memberyf.data.PrefixNo; if (PrefixNo == '') { Ext.Msg.show({ title: '提示', msg: '头部字符不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } var IsDate = memberyf.data.IsDate; if (IsDate == '') { Ext.Msg.show({ title: '提示', msg: '启用日期不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if (IsDate == '1'){ var DateFmt = memberyf.data.DateFmt; if (DateFmt == '') { Ext.Msg.show({ title: '提示', msg: '日期类型不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; } var BillHeadTbl = memberyf.data.BillHeadTbl; if (BillHeadTbl == '') { Ext.Msg.show({ title: '提示', msg: '编号表不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var IsOrgPrefix = memberyf.data.IsOrgPrefix; if (IsOrgPrefix == '') { Ext.Msg.show({ title: '提示', msg: '是否启用组织代码不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; bodyDrChFeeDatas.push(memberyf); }; var jsonChFeeBody = ConvertGIDRecordsToJson(bodyDrChFeeDatas); _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsSysBillNoSet/SaveBillTypeDetail', scope: this, params: { body: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.onRefreshClick(); } 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 onPostCustDetailClick: function (button, event) { var bodyDrChFeeDatas = []; var i; for (i = 0; i < this.storeListSet.getCount(); i += 1) { var memberyf = this.storeListSet.getAt(i); var OPLBNAME = memberyf.data.OPLBNAME; if (OPLBNAME == '') { Ext.Msg.show({ title: '提示', msg: '业务类别不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var BILLTYPE = memberyf.data.BILLTYPE; if (BILLTYPE == '') { Ext.Msg.show({ title: '提示', msg: '编码规则不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var RULEBLNO = memberyf.data.RULEBLNO; if (RULEBLNO == '') { Ext.Msg.show({ title: '提示', msg: '编号不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; var RULEDATETYPE = memberyf.data.RULEDATETYPE; if (RULEDATETYPE == '') { Ext.Msg.show({ title: '提示', msg: '日期类型不能为空!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; }; if (OPLBNAME != ''&&BILLTYPE != ''&&RULEBLNO != ''&&RULEDATETYPE != '') bodyDrChFeeDatas.push(memberyf); }; var jsonChFeeBody = ConvertGIDRecordsToJson(bodyDrChFeeDatas); _thisfee = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsSysBillNoSet/SaveDetail', scope: this, params: { body: jsonChFeeBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { this.onRefreshClick(); } 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 onDeleteClick: function (button, event) { if (this.MainCenter.activeTab.id == 'pnlctn') { this.onDeleteCtnClick(button, event); } else if (this.MainCenter.activeTab.id == 'pnlcust') { this.onDeleteCustClick(button, event); } }, onDeleteCtnClick: 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/MsSysBillNoSet/DeleteBillType', 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); 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); }, //onDeleteClick onDeleteCustClick: function (button, event) { var selections = this.gridListSet.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/MsSysBillNoSet/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.storeListSet.remove(record); 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); }, //onDeleteClick gridListAfterEdit: function (editor, e, eOpts) { if (e.value == e.originalValue) return; if (e.field == 'BILLTYPE') { var selectrecords = DsStoreQueryBy(this.storeList, 'BillCode', e.value); if (selectrecords.getCount() > 0) { var selectdata = selectrecords.getAt(0).data; e.record.set('BILLTYPEREF', selectdata.BillName); } else { e.record.set('BILLTYPEREF', ''); } } }, getCondition: function () { // var form = this.formSearch.getForm(); // if (!form.isValid()) { // Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); // return ''; // } var sql = ''; // var SERVICENAME = form.findField('EDINAME').getValue(); // sql = sql + getAndConSql(sql, SERVICENAME, "EDINAME like '%" + SERVICENAME + "%'"); return sql; }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });