//支取支票的统一记录 Ext.namespace('DsTruck'); DsTruck.ChequeCheckIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.DsTruck.ChequeCheckIndex.superclass.constructor.call(this); }; //20140513 Ext.extend(DsTruck.ChequeCheckIndex, Ext.Panel, { PageSize: 500, VISIBLERANGE: 0, OPERATERANGE: 0, OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { this.bodyDel = []; //定义数据集 this.storeList = Ext.create('Ext.data.Store', { pageSize: this.PageSize, idProperty: 'GID', model: 'CHEQUEmb', remoteSort: true, proxy: { type: 'ajax', url: '/OA/ChequeCheck/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); Ext.define('Checkedmb', { extend: 'Ext.data.Model', fields: [ { name: 'CheckedID', type: 'string' }, { name: 'CheckedName', type: 'string' } ] }); var CheckedData = [{ "CheckedID": "0", "CheckedName": "已借出支票" }, { "CheckedID": "1", "CheckedName": "已取密码" }, { "CheckedID": "2", "CheckedName": "已支取"}]; this.storeChecked = Ext.create('Ext.data.Store', { model: 'Checkedmb', data: CheckedData }); this.comboxChecked = Ext.create('Ext.ux.form.field.BoxSelect', { fieldLabel: '支票状态', autosize: true, bodyPadding: 5, flex:3,name:'Checked', width: 500, labelWidth: 90, store: this.storeChecked, queryMode: 'local', triggerOnClick: false, valueField: 'CheckedID', displayField: 'CheckedName' }); Ext.define('TFmb', { extend: 'Ext.data.Model', fields: [ { name: 'TFID', type: 'string' }, { name: 'TFName', type: 'string' } ] }); var TFData = [{ "TFID": "0", "TFName": "否" }, { "TFID": "1", "TFName": "是" }/*, { "PayTypeID": "2", "PayTypeName": "原单原转"}*/]; this.storeTF = Ext.create('Ext.data.Store', { model: 'TFmb', data: TFData }); this.comboxTF = Ext.create('DsExt.ux.RefEnumCombox', { //fieldLabel: '是否', forceSelection: true, store: this.storeTF, name: 'ISOVER', valueField: 'TFID', displayField: 'TFName' }); this.comboxTF_1 = Ext.create('DsExt.ux.RefEnumCombox', { fieldLabel: '已经完成', forceSelection: true, store: this.storeTF, name: 'ISOVER', valueField: 'TFID', displayField: 'TFName' }); this.storeDEPT = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.DEPTRefModel', proxy: { url: '/CommMng/BasicDataRef/GetDeptList_All_Group' }//proxy: { url: '/CommMng/BasicDataRef/GetDeptList' } }); this.storeDEPT.load(); this.comboxDEPT = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '部门', store: this.storeDEPT, name: 'DEPT', valueField: 'GID', displayField: 'DeptName' }); this.storeUser = Ext.create('DsExt.ux.RefTableStore', { model: 'DsTruckMng.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserRefList' } }); this.storeUser.load({ params: { condition: ""} }); this.comboxUser = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '借款人', store: this.storeUser, name: 'CREATUSER', valueField: 'GID', displayField: 'CodeAndName' }); this.comboxCustName = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeUser, name: 'CHEQUECUSTNAME', valueField: 'UserName', displayField: 'CodeAndName' }); this.formname = "ChequeCheck"; this.column = [{ sortable: false, dataIndex: '', header: '', width: 120 }, { sortable: true,hidden:true, dataIndex: 'GID', header: 'GID', width: 80, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'CHEQUENO', header: '支票号', width: 80 }, { sortable: true, dataIndex: 'BILLNO', header: '借款单序列号', width: 80 }, { sortable: true, dataIndex: 'CHEQUEMAKETIME', header: '支取时间', width: 80, renderer: Ext.util.Format.dateRenderer('Y-m-d'), editor: { xtype: 'datefield', selectOnFocus: true } },{ sortable: true, dataIndex: 'PRINTTIME', header: '密码时间', width: 80, renderer: Ext.util.Format.dateRenderer('Y-m-d'), editor: { xtype: 'datefield', selectOnFocus: true } },{ sortable: true, dataIndex: 'ENTERDATE', header: '借款时间', width: 80 }, { sortable: true, dataIndex: 'PASSWORD', header: '密码', width: 80, editor: { xtype: 'textfield', selectOnFocus: true } }, { sortable: true, dataIndex: 'CHEQUECUSTNAME', header: '密码领取人', width: 80, editor: this.comboxCustName }, { sortable: true, dataIndex: 'CHEQUEAMOUNT', header: '支取金额', width: 80, editor: { xtype: 'textfield', selectOnFocus: true }, 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: 'CHEQUEAMOUNTUPPER', 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: 'BXAMOUNT', 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: 'JKAMOUNT', 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: 'JKREMAIN', 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: 'COMPANYNAME', header: '分公司', width: 80 },{ sortable: true, dataIndex: 'DEPTNAME', header: '部门', width: 80 },{ dataIndex: 'SHOWNAME', header: '报销人', width: 80 },{ sortable: true, dataIndex: 'BXGID', header: '报销单序列号', width: 80 }, { sortable: true, dataIndex: 'BXNO', header: '报销单号', width: 80 }/*, { sortable: true, dataIndex: 'CUSTNO', header: '相关业务编号', width: 80 }*/, { sortable: true, dataIndex: 'COMPANYID',hidden:true, header: 'COMPANYID', width: 80 }, { sortable: true, dataIndex: 'DEPTID',hidden:true, header: 'DEPTID', width: 80 }, { sortable: true, dataIndex: 'USERID',hidden:true, header: 'USERID', width: 80 }]; this.cellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); //this.ChequeCheckCBModel = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); //定义Grid this.gridList = new Ext.grid.GridPanel({ store: this.storeList, enableHdMenu: false, region: 'center', trackResetOnLoad: true, //height: 160, title: '支票状态明细', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditing], stateful: false, //selModel: this.ChequeCheckCBModel, selType: 'cellmodel', viewConfig: { enableTextSelection: true }, columns: [new Ext.grid.RowNumberer()], bbar: Ext.create('Ext.PagingToolbar', { store: this.storeList, displayInfo: true, displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录', emptyMsg: "没有数据" }) }); /////////////以下部分为获取存储的gridpanel显示样式 this.column = DsTruck.GetGridPanel(USERID, this.formname, this.column, 1,false); /* Ext.each(this.column, function (item) { if (item.dataIndex=="CHEQUENO"){ item= { sortable: true, dataIndex: 'CHEQUENO', header: '支票号', width: 80, editor: { xtype: 'textfield', selectOnFocus: true }}; } });*/ //使用者id,表名 ,中间column数组,跳过一开始的几列 this.gridList.reconfigure(this.storeList, this.column); this.gridList.columns[0] = new Ext.grid.RowNumberer(); //////////////////////////// //#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: [ this.comboxDEPT, this.comboxUser, { fieldLabel: '借款单序列号', name: 'BILLNO', flex: 1 }, { fieldLabel: '金额大于', name: 'Amount_min', flex: 1, 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; } }, { fieldLabel: '金额小于', name: 'Amount_max', flex: 1, 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; } }] } ]//end items(fieldset 1) }, //end fieldset 1 {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' },//是否已支取 借款时间-范围 支取时间-范围 items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: '支票号', name: 'CHEQUENO', flex: 1 }, { fieldLabel: '从..借款时间', format: 'Y-m-d', xtype: 'datefield', name: 'ENTERDATE_min' }, { fieldLabel: '到..借款时间', format: 'Y-m-d', xtype: 'datefield', name: 'ENTERDATE_max' }, { fieldLabel: '从..密码时间', format: 'Y-m-d', xtype: 'datefield', name: 'PRINTDATE_min' }, { fieldLabel: '到..密码时间', format: 'Y-m-d', xtype: 'datefield', name: 'PRINTDATE_max' } ] } ]//end items(fieldset 2) }//end fieldset 2 , {//fieldset 2 xtype: 'container', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [ this.comboxChecked,{ fieldLabel: '相关业务编号', name: 'CUSTNO', flex: 1 }, { fieldLabel: '从..支取时间', format: 'Y-m-d', xtype: 'datefield', name: 'CHEQUEMAKETIME_min' }, { fieldLabel: '到..支取时间', format: 'Y-m-d', xtype: 'datefield', name: 'CHEQUEMAKETIME_max' } ] }]//end items(fieldset 2) }//end fieldset 2 ]//end root items }); //查询工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: "执行查询", iconCls: "btnrefresh", handler: function (button, event) { this.onRefreshClick(button, event); }, scope: this }, { text: "导出Excel", id: "btnExportExcel", iconCls: 'btnexportexcel', handler: function (button, event) { this.onExportClick(button, event); }, scope: this }, { text: "保存列表样式", id: "btntest", handler: function (button, event) { this.column = DsTruck.SaveGridPanel(USERID, this.formname, this.gridList.columns, this.column, 1, false); //alert(this.column[0].id); }, scope: this },'-',/*{ text: '增加明细', tooltip: '增加明细', iconCls: "btnadddetail", handler: function (button, event) { this.onAddProjectClick(button, event); }, scope: this }, { text: '删除明细', tooltip: '删除明细', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelProjectClick(button, event); }, scope: this },*/{ id: "btnSave", text: '保存更改', tooltip: '保存更改', iconCls: "btnsave", handler: function (button, event) { this.Save(); //alert(USERID); }, scope: this }, '-' ] }); //#endregion this.panelTop = new Ext.Panel({ layout: "border", region: "north", height: 120, items: [this.formSearch, this.panelBtn] }); Ext.apply(this, { items: [this.panelTop, this.gridList] }); this.storeList.on('beforeload', function (store) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); Ext.apply(store.proxy.extraParams, { condition: sql }); }, this); this.gridList.on('edit', function (editor, e, eOpts) { this.ProjectAfterEdit(editor, e, eOpts); }, this); this.cellEditing.on('beforeedit', function (editor, e) { //Ext.getCmp("zongshu").setText("1234"); return this.ChequeBeforeEdit(editor, e); }, this); //#region 根据报销单权限 管理是否可见 Ext.Ajax.request({ waitMsg: '正在查询用户权限...', url: '/CommMng/BasicDataRef/GetAuthorityRange', params: { modName: "mod_Baoxiao", USERID: USERID }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); rec = result.data; //可操作为0则全都可见,3为可提交/驳回,2为可审核/驳回,1为只能看 /*0 审核通过 1 录入状态 2 提交审核 3 申请修改 4 申请删除 5 取消申请 6 驳回提交*/ this.VISIBLERANGE = rec.VISIBLERANGE; this.OPERATERANGE = rec.OPERATERANGE; if (this.OPERATERANGE == '0') { Ext.getCmp("btnSave").enable(); } else if (this.OPERATERANGE == '1') { Ext.getCmp("btnSave").disable(); } else if (this.OPERATERANGE == '2') { Ext.getCmp("btnSave").enable(); } else if(this.OPERATERANGE == '3') {//3 Ext.getCmp("btnSave").disable(); } } else Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); }, scope: this }); //request over }, //end initUIComponents ChequeBeforeEdit: function (editor, e) { var canedit = true; if (this.OPERATERANGE == '0') { canedit = true; } else if (this.OPERATERANGE == '1') { canedit = false; } else if (this.OPERATERANGE == '2') { canedit = true; } else {//3 canedit = false; } return canedit; }, ProjectAfterEdit: function(editor, e, eOpts) { if (e.field == 'ISOVER') { var records = DsStoreQueryBy(this.storeTF, 'TFID', e.value); if (records.getCount() > 0) { var data = records.getAt(0).data; e.record.set('ISOVER_DEF', data.TFName); } else { e.record.set('ISOVER_DEF', ''); } } }, onAddProjectClick: function (button, event) { function newID() { var guid = ""; for (var i = 1; i <= 32; i++) { var n = Math.floor(Math.random() * 16.0).toString(16); guid += n; if ((i == 8) || (i == 12) || (i == 16) || (i == 20)) guid += "-"; } return guid.toUpperCase(); } var record = Ext.create('Projectmb', { 'GID': newID(), 'PROJECTNO': '', 'BLNO': '', 'PROTYPE': '', 'BLNOTYPE': '', 'ISOVER': '0', 'OVERDATE': '', 'INSERTED': '' }); this.storeList.add(record); var n = this.storeList.getCount(); this.cellEditing.startEditByPosition({ row: n - 1, column: 2 }); }, onDelProjectClick:function (button,event) { var selectedRecords = this.gridList.selModel.getSelection(); Ext.MessageBox.confirm('提示', '确定删除记录吗?', function (btn) { if (btn == 'yes') { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.INSERTED != "" ) //如果是新增但没有保存的数据,没有必要提交到后台 { this.bodyDel.push(rec); } this.storeList.remove(selectedRecords[i]); } } }, this); }, OprationSwap: function () { var ret = new Array(); ret[0] = this.OprationStatus; ret[1] = this.storeList; ret[2] = this.SelectedRecord; return ret; }, onRefreshClick: function (button, event) { if (!this.checkSearchCondition()) return; var sql = this.getCondition(); this.storeList.load({ params: { start: 0, limit: this.PageSize, condition: sql }, waitMsg: "正在查询数据...", scope: this }); this.bodyDel = []; }, getCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return ''; } var sql = ''; var CHEQUENO = form.findField('CHEQUENO').getValue(); sql = sql + getAndConSql(sql, CHEQUENO, "CHEQUENO like '%" + CHEQUENO + "%'"); var DEPT = form.findField('DEPT').getValue(); sql = sql + getAndConSql(sql, DEPT, "DEPTID = '" + DEPT + "'"); var CREATUSER = form.findField('CREATUSER').getValue(); sql = sql + getAndConSql(sql, CREATUSER, "USERID = '" + CREATUSER + "'"); var BILLNO = form.findField('BILLNO').getValue(); sql = sql + getAndConSql(sql, BILLNO, "BILLNO like '%" + BILLNO + "%'"); var Amount_min = form.findField('Amount_min').getValue(); sql = sql + getAndConSql(sql, Amount_min, "chequeamount >=" + Amount_min + ""); var Amount_max = form.findField('Amount_max').getValue(); sql = sql + getAndConSql(sql, Amount_max, "chequeamount <=" + Amount_max + ""); var CUSTNO = form.findField('CUSTNO').getValue(); sql = sql + getAndConSql(sql, CUSTNO, "CUSTNO like '%" + CUSTNO + "%'"); var ENTERDATE_min = form.findField('ENTERDATE_min').getRawValue(); sql = sql + getAndConSql(sql, ENTERDATE_min, "ENTERDATE >= '" + ENTERDATE_min + "'"); var ENTERDATE_max = form.findField('ENTERDATE_max').getRawValue(); sql = sql + getAndConSql(sql, ENTERDATE_max, "ENTERDATE <= '" + ENTERDATE_max + " 23:59:59'"); var PRINTDATE_min = form.findField('PRINTDATE_min').getRawValue(); sql = sql + getAndConSql(sql, PRINTDATE_min, "PRINTDATE >= '" + PRINTDATE_min + "'"); var PRINTDATE_max = form.findField('PRINTDATE_max').getRawValue(); sql = sql + getAndConSql(sql, PRINTDATE_max, "PRINTDATE <= '" + PRINTDATE_max + " 23:59:59'"); var CHEQUEMAKETIME_min = form.findField('CHEQUEMAKETIME_min').getRawValue(); sql = sql + getAndConSql(sql, CHEQUEMAKETIME_min, "CHEQUEMAKETIME >= '" + CHEQUEMAKETIME_min + "'"); var CHEQUEMAKETIME_max = form.findField('CHEQUEMAKETIME_max').getRawValue(); sql = sql + getAndConSql(sql, CHEQUEMAKETIME_max, "CHEQUEMAKETIME <= '" + CHEQUEMAKETIME_max + " 23:59:59'"); /* var CheckedData = [{ "CheckedID": "0", "CheckedName": "已借出支票" }, { "CheckedID": "1", "CheckedName": "已取密码" }, { "CheckedID": "2", "CheckedName": "已支取"}];*/ var Checked = this.comboxChecked.getValue(); if (Checked.indexOf("0") >= 0) { sql = sql + getAndConSql(sql, Checked, " chequeno<>'' "); } if (Checked.indexOf("1") >= 0) { sql = sql + getAndConSql(sql, Checked, " password<>'' "); } if (Checked.indexOf("2") >= 0) { sql = sql + getAndConSql(sql, Checked, " CHEQUEMAKETIME<>'' "); } return sql; }, checkSearchCondition: function () { var form = this.formSearch.getForm(); if (!form.isValid()) { Ext.Msg.alert('提示', '查询条件赋值错误,请检查。'); return false; } return true; }, onExportClick: function (button, event) { GridExportExcelPage(this.gridList); }, getStrValue: function (list) { var _list = []; for (var _i = 0; _i < list.length; _i++) { _list.push("'" + list[_i] + "'"); } return _list; }, Save: function (type) { //费用 var bodyList = []; for (i = 0; i < this.storeList.getCount(); i += 1) { var member = this.storeList.getAt(i); bodyList.push(member); /* var BLNO = member.data.BLNO; var PROJECTNO = member.data.PROJECTNO; if (BLNO == ''||PROJECTNO == '') { Ext.Msg.show({ title: '警告', msg: '项目单号和项目编码均不允许为空,请修改后再保存', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); return; }*/ }; var jsonBody = ConvertRecordsToJson(bodyList); if (jsonBody == '' ){ return; } Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/OA/ChequeCheck/Save', scope: this, params: { ChequeBody: jsonBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { //alert("保存成功"); var returnData = jsonresult.Data; this.storeList.commitChanges(); } 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 }); } //alert('03'); } }); }, });