Ext.namespace('Shipping'); Shipping.MsCompanysIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCompanysIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCompanysIndex, Ext.Panel, { PageSize: 100, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { this.formname = "formMsCompanysIndex"; //页面名称 //#region 定义数据集 this.StoreOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsOP', proxy: { url: '/MvcShipping/MsBaseInfo/GetOpRang' } }); this.StoreOpRange.load({ params: { optype: "modCompanys"} }); // this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, model: 'MsCompanysEntity', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCompanys/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //#endregion //#region 定义Grid this.girdcolums = [{ sortable: true, dataIndex: 'GID', header: '业务编号', hidden: true }, { sortable: true, dataIndex: 'CODENAME', header: '公司代码', width: 80 }, { sortable: true, dataIndex: 'NAME', header: '公司简称', width: 100 }, { sortable: true, dataIndex: 'FULLNAME', header: '公司全称', width: 200 }, { sortable: true, dataIndex: 'ENNAME', header: '英文名称', width: 100 }, { sortable: true, dataIndex: 'ADDRESS', header: '公司地址', width: 100 }, { sortable: true, dataIndex: 'ENADDRESS', header: '英文地址', width: 100 }, { sortable: true, dataIndex: 'POSTCODE', header: '邮政编码', width: 60 }, { sortable: true, dataIndex: 'OFFICEPHONE', header: '办公电话', width: 100 }, { sortable: true, dataIndex: 'FAX', header: '传真', width: 100 }, { sortable: true, dataIndex: 'EMAIL', header: '电子邮箱', width: 100 }, { sortable: true, dataIndex: 'WEBSITEURL', header: '公司网址', width: 100 }, { sortable: true, dataIndex: 'LICENSECODE', header: '工商登记号', width: 100 }, { sortable: true, dataIndex: 'TAXCODE', header: '税务登记号', width: 100 }, { sortable: true, dataIndex: 'BANKSHEAD', header: '票号头字符', width: 70 }, { sortable: true, dataIndex: 'BILLRISES', header: '发票抬头', width: 100 }, { sortable: true, dataIndex: 'CHEQUEPAYABLE', header: '支票抬头', width: 100 }, { sortable: true, dataIndex: 'PRTHEADXML1', header: '打印抬头1', width: 100 }, { sortable: true, dataIndex: 'PRTHEADXML2', header: '打印抬头2', width: 100 }, { sortable: true, dataIndex: 'PRTHEADXML3', header: '打印抬头3', width: 100 }, { sortable: true, dataIndex: 'PRTHEADXML4', header: '打印抬头4', width: 100 }, { sortable: true, dataIndex: 'PRTHEADXML5', header: '打印抬头5', width: 100 }, { sortable: true, dataIndex: 'MODIFIEDUSERNAME', header: '更新人', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '更新时间', width: 130 }, { sortable: true, dataIndex: 'ISDISABLE', header: '是否停用', width: 80 }]; this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, columns: this.girdcolums, viewConfig: { enableTextSelection: true, //允许复制数据 autoFill: true }, // paging bar on the bottom bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsCompanys/Edit', "企业信息", "600", "1000", 200, 200); }, this); //#endregion //#region 页面布局 this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ text: "新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/MvcShipping/MsCompanys/Edit', "企业信息", "600", "900", 200, 200); }, scope: this }, { text: "删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: "刷新", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, '-', { text: "打印", iconCls: 'btnprint', handler: function (button, event) { this.Print(); }, scope: this }] }); Ext.apply(this, { items: [this.panelBtn, this.gridList] }); //#endregion //#region 加载数据 this.onRefreshClick(); this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, this); //#endregion }, //end initUIComponents onRefreshClick: function (button, event) { this.storeList.load({ params: { start: 0, limit: this.PageSize, sort: '', condition: "" }, waitMsg: "正在查询数据...", scope: this }); }, 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; } // if (this.StoreOpRange.getCount() == 0) { Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } else { var MODIFIEDUSERNAME = selections[0].data.MODIFIEDUSERNAME; var records = DsStoreQueryBy(this.StoreOpRange, 'OPID', MODIFIEDUSERNAME); if (records.getCount() > 0) { } else { canedit = false; Ext.Msg.show({ title: '警告', msg: '权限不足,不允许删除!', icon: Ext.Msg.WARNING, buttons: Ext.Msg.OK }); return; } } // Ext.MessageBox.confirm('提示', '确定删除该记录吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在删除数据...'); Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsCompanys/Delete', params: { data: Ext.JSON.encode(selections[0].data) }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //this.storeList.remove(selections[0]); this.onRefreshClick(); 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); }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, Print: function () { if (this.storeList.getCount() == 0) { return; } Ext.Msg.wait('正在组织数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在组织数据...', url: '/MvcShipping/MsCompanys/GetDataListStr', scope: this, params: { condition: "", printstr: 'true' }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnstr = jsonresult.data; var printType = 'MsCompanysList'; var sql1 = returnstr; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } 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 }); } } }); } });