Ext.namespace('Shipping'); Shipping.MsCwAccitemsFtIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCwAccitemsFtIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCwAccitemsFtIndex, Ext.Panel, { OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, sqlcontext: '', //需求编号:SR2017061200005-3 initUIComponents: function () { //定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'MsCwAccitemsFt', remoteSort: true, proxy: { type: 'ajax', url: '/MvcShipping/MsCwAccitemsFt/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //定义Grid this.GridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', loadMask: { msg: Zi.LAN.ShuJuJiaZaiZhong }, trackMouseOver: true, selModel: this.GridCheckBoxModel, disableSelection: false, columns: [{ sortable: true, dataIndex: 'GID', header: Zi.LAN.GID, //'GID', hidden: true, width: 120 }, { sortable: true, dataIndex: 'ACCID', header: Zi.LAN.ACCID, //'模板名称', width: 160 }, { sortable: true, dataIndex: 'ACCNAME', header: Zi.LAN.ACCNAME, //'业务种类', width: 160 }, { sortable: true, dataIndex: 'CREATEUSERREF', header: Zi.LAN.CREATEUSERREF, //'录入人', width: 100 }, { sortable: true, dataIndex: 'CREATETIME', header: Zi.LAN.CREATETIME, //'录入日期', width: 100 } ] }); this.gridList.addListener('itemdblclick', function (dataview, record, item, index, e, b) { this.SelectedRecord = record; this.OprationStatus = 'edit'; DsOpenEditWin('/MvcShipping/MsCwAccitemsFt/Edit'); }, this); //#region formSearch this.formSearch = Ext.widget('form', { frame: true, region: 'center', bodyPadding: 5, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.ACCID, //'模板名称', name: 'ACCID' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' }, { xtype: 'hiddenfield' } ] } ]//end items(fieldset 1) }//end fieldset 1 ]//end root items }); _this = this; //#endregion formSearch //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: Zi.LAN.btnAdd, //"新建", iconCls: "btnadd", handler: function (button, event) { this.OprationStatus = 'add'; DsOpenEditWin('/MvcShipping/MsCwAccitemsFt/Edit'); }, scope: this }, { text: Zi.LAN.btnDelete, //"删除", iconCls: "btndelete", handler: function (button, event) { this.onDeleteClick(button, event); }, scope: this }, '-', { text: Zi.LAN.btnRefresh, //"执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: Zi.LAN.btnReset, //"重置条件", iconCls: "btnreset", handler: function (button, event) { }, scope: this }, '-', { text: "打印", //"打印", iconCls: 'btnprint', menu: [ { text: "全部", //"全部", handler: function (menu, event) { _this.Print(); } }, { text: "选择打印", //"选择打印", handler: function (menu, event) { _this.PrintSelect(); } }], scope: this } ] }); this.panelZQ = new Ext.Panel({ layout: "border", region: "east", width: 500, style: 'text-align:right;', border: false, items: [{ xtype: 'displayfield', id: 'lbTitle2', name: 'lbTitle2', value: "  " }] }); this.panelTopF = new Ext.Panel({ layout: "border", region: "north", height: 26, //border: false, items: [this.panelBtn, this.panelZQ] }); this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 65, border: false, items: [this.panelTopF, this.formSearch] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.InitData(); this.onRefreshClick(); }, //end initUIComponents InitData: function () { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/RptCwGenlegAccitems/GetData', callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { return; } data = result.data; var arrtmp = data.toString().split("&"); this.strCwSTARTGID = arrtmp[0].toString(); var strCwSTARTNAME = arrtmp[1].toString(); var strCwACCDATE = arrtmp[2].toString(); var sYear = arrtmp[3].toString(); var sMonth = arrtmp[4].toString(); // var sZQ = "  当前登录账套:“" + strCwSTARTNAME + "”  当前财务账期:“" + sYear + "年第" + sMonth + "期”  "; Ext.getCmp("lbTitle2").setValue(sZQ); } else { //Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, //end InitData onRefreshClick: function (button, event) { var sql = this.getCondition(); this.sqlcontext = sql; this.storeList.load({ params: { start: 0, limit: 500, sort: '', condition: sql }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //"正在查询数据...", scope: this }); }, 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/MsCwAccitemsFt/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); 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); }, //onDeleteClick getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert(Zi.LAN.TiShi, Zi.LAN.ChaXunTiaoJianFuZhiCuoWu); return ''; } var sql = ''; var ACCID = form.findField('ACCID').getValue(); sql = sql + getAndConSql(sql, ACCID, "ACCID='" + ACCID + "'"); return sql; }, //#region 打印 Print: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var sortstr = 'NAME '; Ext.Msg.wait('正在查询'); Ext.Ajax.request({ waitMsg: '正在操作数据', url: '/MvcShipping/MsCwAccitemsFt/GetDataListStr', scope: this, params: { condition: _this.sqlcontext, sort: sortstr }, 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 = 'MSCWACCITEMSFTLIST'; 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 }); } } }); }, PrintSelect: function () { _this = this; if (this.storeList.getCount() == 0) { return; } var selectedRecords = []; var storeadd = null; selectedRecords = this.GridCheckBoxModel.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title:'提示', msg:'请选择模板', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } var sortstr = 'NAME '; var feeGidSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var feeGId = "'" + record.get('GID') + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } }; var printType = 'MSCODEFEETEMPAUTOLISTSELECT'; var sql1 = "select * from code_fee_template_auto WHERE GID IN (" + feeGidSql + ") order by " + sortstr; var sql2 = ""; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6,''); }, //#endregion OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; } });