Ext.namespace('Shipping'); String.prototype.trim = function () { return this.replace(/(^\s*)|(\s*$)/g, ""); } //#region 当前日期格式 Date.prototype.format = function (format) { var o = { "M+": this.getMonth() + 1, //month "d+": this.getDate(), //day "h+": this.getHours(), //hour "m+": this.getMinutes(), //minute "s+": this.getSeconds(), //cond "q+": Math.floor((this.getMonth() + 3) / 3), //quarter "S": this.getMilliseconds() //millisecond } if (/(y+)/.test(format)) format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length)); for (var k in o) if (new RegExp("(" + k + ")").test(format)) format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length)); return format; } var xhr = new XMLHttpRequest(); var currdate = new Date(); xhr.open("HEAD", location.href, true); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var datestr = xhr.getResponseHeader("Date"); currdate = new Date(datestr); } } xhr.send(null); //#endregion Shipping.MsCwCarryOverIndex = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsCwCarryOverIndex.superclass.constructor.call(this); }; Ext.extend(Shipping.MsCwCarryOverIndex, Ext.Panel, { OprationStatus: null, //仅当弹出界面时使用 SelectedRecord: null, initUIComponents: function () { this.formname = "formMsCwCarryOverIndex"; //期末结转 //#region formSearch 下拉框信息加载 //汇兑收益科目加载 this.storeCwAccitems = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems.load({ params: { condition: "DETAILED=1 and ISENABLE=1"} }); this.comboxACCNAME = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '汇兑收益科目', store: this.storeCwAccitems, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'ExchangeGains', name: 'ExchangeGains', width: 533, valueField: 'ACCID', displayField: 'ACCIDNAME', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 118) {//F7 DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 150), (window.screen.availWidth / 2 - 500)); } }, scope: this } } }); //汇兑损失科目加载 this.storeCwAccitems1 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems1.load({ params: { condition: "DETAILED=1 and ISENABLE=1"} }); this.comboxACCNAME1 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '汇兑损失科目', store: this.storeCwAccitems1, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'ExchangeLoss', name: 'ExchangeLoss', width: 533, valueField: 'ACCID', displayField: 'ACCIDNAME', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 118) {//F7 DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 150), (window.screen.availWidth / 2 - 500)); } }, scope: this } } }); //本年利润科目加载 this.storeCwAccitems2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems2.load({ params: { condition: "DETAILED=1 and ISENABLE=1"} }); this.comboxACCNAME2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '本年利润科目', store: this.storeCwAccitems2, forceSelection: true, //输入值是否严格为待选列表中存在的值 id: 'CurrentYearProfits', name: 'CurrentYearProfits', width: 533, valueField: 'ACCID', displayField: 'ACCIDNAME', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 118) {//F7 DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 150), (window.screen.availWidth / 2 - 500)); } }, scope: this } } }); //以前年度损益调整科目的结转科目 this.storeCwAccitems3 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CwAccitemsGlModel', proxy: { url: '/CommMng/BasicDataRef/GetCwAccitemsGl' } }); this.storeCwAccitems3.load({ params: { condition: "DETAILED=1 and ISENABLE=1"} }); this.comboxACCNAME3 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '以前年度损益调整科目的结转科目', store: this.storeCwAccitems3, forceSelection: false, //输入值是否严格为待选列表中存在的值 id: 'UndistributedProfit', name: 'UndistributedProfit', width: 533, valueField: 'ACCID', displayField: 'ACCIDNAME', allowBlank: false, enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 118) {//F7 DsOpenEditWin('/MvcShipping/MsCwAccitemsGl/Index', "科目信息", "500", "800", (window.screen.availHeight / 2 - 150), (window.screen.availWidth / 2 - 500)); } }, scope: this } } }); //键值维护表_凭证字1 this.storeCrmKeyCodeCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CrmKeyCodeModel', proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' } }); this.storeCrmKeyCodeCode.load({ params: { condition: " and KEYTYPE='凭证字'"} }); this.comboxVKNO = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '凭证字', labelWidth: 50, store: this.storeCrmKeyCodeCode, forceSelection: true, name: 'VKNO', width: 100, valueField: 'KEYVALUE', displayField: 'KEYVALUE', value: '记', allowBlank: false, listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var VKNO = records[0].data.KEYVALUE; var VOUDATE = this.formQMTH.getForm().findField('VOUDATE').getRawValue();; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsCwCarryOver/GetMaxVou', params: { VKNO: VKNO, vktype: '1', VOUDATE:VOUDATE }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } // data = result.data; this.formQMTH.getForm().findField('VOUNO').setValue(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } } // }); //键值维护表_凭证字2 this.storeCrmKeyCodeCode2 = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CrmKeyCodeModel', proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' } }); this.storeCrmKeyCodeCode2.load({ params: { condition: " and KEYTYPE='凭证字'"} }); this.comboxVKNO2 = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '凭证字', labelWidth: 50, store: this.storeCrmKeyCodeCode2, forceSelection: true, name: 'VKNO2', width: 100, valueField: 'KEYVALUE', displayField: 'KEYVALUE', value: '记', allowBlank: false, listeners: { scope: this, 'select': function (combo, records, eOpts) { if (records.length > 0) { var VKNO = records[0].data.KEYVALUE; var VOUDATE = this.formJZSY.getForm().findField('VOUDATE2').getRawValue();; Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsCwCarryOver/GetMaxVou', params: { VKNO: VKNO, vktype: '2', VOUDATE: VOUDATE }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } // data = result.data; this.formJZSY.getForm().findField('VOUNO2').setValue(data); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); } } } // }); //#endregion //#region 编辑formHead 基本信息 this.formHead = Ext.widget('form', { region: 'north', frame: true, items: [{ xtype: 'hiddenfield', height: 10 }, { xtype: 'displayfield', style: 'font-size: 20px; color: #336699; font-weight: bold;', id: 'lbTitle', name: 'lbTitle', width: 650, allowBlank: false }] }); this.formQMTH = Ext.widget('form', { region: 'north', //layout: "border", //height: 35, style: 'border:0px solid black; border-top:0;', //隐藏边框 frame: true, fieldDefaults: { labelAlign: 'right', labelWidth: 70 }, items: [{ xtype: 'hiddenfield', height: 10 }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxVKNO, { fieldLabel: '', id: 'VOUNO', name: 'VOUNO', width: 60, xtype: 'numberfield', nanText: '请输入有效整数', value: 0, allowBlank: false }, { xtype: 'label', labelWidth: 50, text: "号", style: 'vertical-align: text-bottom;' }, { fieldLabel: '日期', id: 'VOUDATE', name: 'VOUDATE', xtype: 'datefield', format: 'Y-m-d', value: currdate.format('yyyy-MM-dd'), width: 160, labelWidth: 50, allowBlank: false }, { fieldLabel: '凭证摘要', id: 'EXPLAN', name: 'EXPLAN', value: '结转汇兑收益', labelWidth: 70, allowBlank: false }] }, { xtype: 'hiddenfield', height: 10 }, { xtype: "checkbox", //checkbox控件 id: "cbHLTZB", name: "cbHLTZB", boxLabel: "是否需要生成汇率调整凭证", fieldLabel: "汇率调整表", inputValue: "true", //选中的值 uncheckedValue: "false", //未选中的值 checked: true //绘制时的选中状态 }]//end items(fieldset 1) }); this.formJZSY = Ext.widget('form', { title: '结转损益', region: 'north', //layout: "border", //height: 35, frame: true, collapsible: true, //将激活折叠功能 fieldDefaults: { labelAlign: 'right', labelWidth: 90 }, items: [{ xtype: 'hiddenfield', height: 10 }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxVKNO2, { fieldLabel: '', id: 'VOUNO2', name: 'VOUNO2', width: 60, xtype: 'numberfield', nanText: '请输入有效整数', value: 0, allowBlank: false }, { xtype: 'label', labelWidth: 50, text: "号", style: 'vertical-align: text-bottom;' }, { fieldLabel: '日期', id: 'VOUDATE2', name: 'VOUDATE2', xtype: 'datefield', format: 'Y-m-d', value: currdate.format('yyyy-MM-dd'), width: 160, labelWidth: 50, allowBlank: false }, { fieldLabel: '凭证摘要', id: 'EXPLAN2', name: 'EXPLAN2', labelWidth: 70, value: '结转本期损益', allowBlank: false }] }, { xtype: 'hiddenfield', height: 30}]//end items(fieldset 1) }); this.formGJSZ = Ext.widget('form', { title: '高级设置', region: 'north', //layout: "border", //height: 35, frame: true, collapsible: true, //将激活折叠功能 fieldDefaults: { labelAlign: 'right', labelWidth: 200 }, items: [{ xtype: 'hiddenfield', height: 10 }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'fieldset', id: 'cType', title: '凭证分类', autoHeight: true, defaultType: 'radio', //设置fieldset内的默认元素为radio layout: 'hbox', width: 533, items: [ { boxLabel: '分别生成收益凭证和损失凭证', name: 'cType', inputValue: '1', width: 200 }, { boxLabel: '生成一张凭证,既包括收益也包括损失', name: 'cType', inputValue: '2', checked: true } ] }] }, { xtype: "checkbox", //checkbox控件 id: "cbJZFS", name: "cbJZFS", boxLabel: "按科目余额反向结转", fieldLabel: "结转方式", inputValue: "true", //选中的值 uncheckedValue: "false" //未选中的值 //checked: false, //绘制时的选中状态 }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxACCNAME] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxACCNAME1] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxACCNAME2] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [this.comboxACCNAME3] }, { xtype: 'hiddenfield', height: 30}]//end items(fieldset 1) }); this.formBlank = Ext.widget('form', { region: 'south', height: 30, style: 'border:0px solid black; border-top:0;', //隐藏边框 frame: true, items: [{ xtype: 'container'}] }); //#endregion //#region 定义数据集 this.storeList = Ext.create('Ext.data.Store', { model: 'MsCwVouitemsGl2Model', proxy: { type: 'ajax', url: '/MvcShipping/MsCwCarryOver/GetDataList', reader: { id: 'GID', root: 'data' } }, autoLoad: true }); //#endregion //#region 列定义 this.girdcolums = [{ sortable: false, dataIndex: 'GID', text: '唯一编码', width: 0 }, { sortable: false, text: '币别', dataIndex: 'FCYNO', width: 100, align: 'center' }, { sortable: false, text: '币别名称', dataIndex: 'FCYNAME', width: 100, align: 'center' }, { sortable: false, text: '当前汇率', dataIndex: 'FCYEXRATE', width: 100, align: 'right', //renderer: Ext.util.Format.numberRenderer('00.00000'), renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 5, '', true); return value; } }, { sortable: false, text: '调整汇率(当前)', dataIndex: 'FCYEXRATE2', width: 100, align: 'right', //renderer: Ext.util.Format.numberRenderer('00.00000'), editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true, //得到焦点时自动选择文本 allowDecimals: true, //允许输入小数 decimalPrecision: 5, //允许保留的小数位数,并四舍五入 nanText: '请输入有效小数', keyNavEnabled: false, //键盘导航是否可用,启用后可以通过键盘的上下箭头调整数值 hideTrigger: false, //是否隐藏上下调节按钮 mouseWheelEnabled: true, //鼠标滚轮是否可用,启用后可以通过滚动鼠标滚轮调整数值 //step: 2,//通过调节按钮、键盘、鼠标滚轮调节数值时的大小 enableKeyEvents: true, //激活键盘事件 listeners: { scope: this, 'keyup': { fn: function (_field, e) { if (e.getKey() == 40) { this.onCodeKey40Click(40); } else if (e.getKey() == 38) { this.onCodeKey40Click(38); } }, scope: this } } }, renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) { value = usMoney(value, 5, '', true); return value; } }]; //#endregion //#region gridList列表显示信息 this.gridListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 //1单击,2双击 }); this.gridList = new Ext.grid.GridPanel({ region: 'center', width: 537, store: this.storeList, enableHdMenu: false, //是否显示表格列的菜单 hideHeaders: false, //是否隐藏表头 rowLines: true, columnLines: true, loadMask: { msg: "数据加载中,请稍等..." }, plugins: [this.gridListCellEditing], selType: 'cellmodel', columns: this.girdcolums }); //this.storeList.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { condition: "" }); }, this); //this.storeList.load({ params: { condition: "" }, waitMsg: "正在查询数据...", scope: this }); //#endregion //#region 按钮工具条 this.panelBtn = new Ext.Panel({ region: "north", tbar: [{ text: '生成凭证', tooltip: '生成凭证', id: "btnadd", iconCls: "btnadd", handler: function (button, event) { this.onAddClick(button, event); }, scope: this }, '-', { id: 'btnsave', text: "结转到下期", tooltip: '结转到下期', iconCls: "btnsave", handler: function (button, event) { this.Save(); }, scope: this }, '-', { id: 'btnSaveReturn', text: "返结转到上期", tooltip: '返结转到上期', iconCls: "btnsave", handler: function (button, event) { this.SaveReturn(); }, scope: this }, '-', { text: "刷新", iconCls: "btnrefresh", handler: function (button, event) { this.InitData(); }, scope: this }] }); //end 按钮Toolbar //#endregion //#region 页面布局 this.panelQMTH = new Ext.Panel({ title: '期末调汇', //layout: "anchor", //layout: "border", region: 'north', frame: true, collapsible: true, //将激活折叠功能 items: [this.formQMTH, this.gridList, this.formBlank] }); Ext.apply(this, { items: [this.panelBtn, this.formHead, this.panelQMTH, this.formJZSY, this.formGJSZ] }); //#endregion //加载事件 this.InitData(); }, //end initUIComponents //#region 加载事件 InitData: function () { Ext.Ajax.request({ waitMsg: '正在查询主表数据...', url: '/MvcShipping/MsCwCarryOver/GetData', params: { condition: "" }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: '提示', msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } // data = result.data; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); this.formQMTH.getForm().reset(); this.formQMTH.getForm().setValues(data); this.formJZSY.getForm().reset(); this.formJZSY.getForm().setValues(data); this.formGJSZ.getForm().reset(); this.formGJSZ.getForm().setValues(data); // Ext.getCmp('VOUDATE').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE').setMaxValue(data.VOUDATE2); // Ext.getCmp('VOUDATE2').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE2').setMaxValue(data.VOUDATE2); // this.storeList.reload(); this.onBtnHidden(data.VOUNUM, data.VOUNUM_ISCHECKED, data.VOUNUM_ISCARRY, data.isCarryOverType); } else { Ext.MessageBox.alert('请求出现错误,请重试', response.responseText); } }, scope: this }); }, //end InitData //#endregion //#region 按钮函数 onCodeKey40Click: function (codeKey) { if (codeKey == 40) {//向下方向键 var rows = this.gridList.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridList.getStore(); var n = this.storeList.getCount(); var number = s.indexOf(row); if ((number + 1) < n) { number = number + 1; } this.gridListCellEditing.startEditByPosition({ row: number, column: 4 }); } else if (codeKey == 38) {//向上方向键 var rows = this.gridList.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridList.getStore(); var number = s.indexOf(row); if ((number - 1) >= 0) { number = number - 1; } this.gridListCellEditing.startEditByPosition({ row: number, column: 4 }); } }, onBtnHidden: function (VOUNUM, VOUNUM_ISCHECKED, VOUNUM_ISCARRY, isCarryOverType) { if (VOUNUM == 0) { Ext.getCmp('btnadd').disable(); //隐藏 Ext.getCmp('btnsave').enable(); //显示 if (VOUNUM_ISCARRY != 0) { Ext.getCmp('btnadd').disable(); //隐藏 Ext.getCmp('btnsave').disable(); //隐藏 } } else { if (VOUNUM_ISCHECKED > 0) { Ext.getCmp('btnadd').disable(); //隐藏 Ext.getCmp('btnsave').disable(); //隐藏 } else { Ext.getCmp('btnadd').enable(); //显示 Ext.getCmp('btnsave').enable(); //显示 // if (isCarryOverType == "true") { Ext.getCmp('btnadd').disable(); //隐藏 Ext.getCmp('btnsave').enable(); //显示 // if (VOUNUM_ISCARRY != 0) { Ext.getCmp('btnadd').disable(); //隐藏 Ext.getCmp('btnsave').disable(); //隐藏 } } else { Ext.getCmp('btnadd').enable(); //显示 Ext.getCmp('btnsave').enable(); //显示 // if (VOUNUM_ISCARRY != 0) { Ext.getCmp('btnadd').enable(); //显示 Ext.getCmp('btnsave').disable(); //隐藏 } } } } // if (VOUNUM == VOUNUM_ISCHECKED) { //Ext.getCmp('btnSaveReturn').enable(); //显示 } else { //Ext.getCmp('btnSaveReturn').disable(); //隐藏 } }, //#endregion //#region 生成凭证 onAddClick: function (button, event) { if (!this.formHead.getForm().isValid()) { return; } if (!this.formQMTH.getForm().isValid()) { return; } if (!this.formJZSY.getForm().isValid()) { return; } if (!this.formGJSZ.getForm().isValid()) { return; } // var dataHead = this.formHead.getForm().getValues(false, false, false); var dataQMTH = this.formQMTH.getForm().getValues(false, false, false); var dataJZSY = this.formJZSY.getForm().getValues(false, false, false); var dataGJSZ = this.formGJSZ.getForm().getValues(false, false, false); // var j = 0; var bodydatas = []; for (var i = 0; i < this.storeList.getCount(); i += 1) { var member = this.storeList.getAt(i); bodydatas.push(member); } var jsonBody; if (bodydatas.length > 0) { jsonBody = ConvertRecordsToJsonAll(bodydatas); } // Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsCwCarryOver/AddEdit', scope: this, params: { dataHead: Ext.JSON.encode(dataHead), dataQMTH: Ext.JSON.encode(dataQMTH), dataJZSY: Ext.JSON.encode(dataJZSY), dataGJSZ: Ext.JSON.encode(dataGJSZ), jsonBody: jsonBody }, 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.MessageBox.INFO, buttons: Ext.Msg.OK }); //this.storeList.load({ params: { condition: "" }, waitMsg: "正在刷新数据...", scope: this }); this.InitData(); } 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 }); } } }); }, //#endregion //#region 结转 Save: function (button, event) { if (!this.formHead.getForm().isValid()) { return; } if (!this.formQMTH.getForm().isValid()) { return; } if (!this.formJZSY.getForm().isValid()) { return; } if (!this.formGJSZ.getForm().isValid()) { return; } // Ext.MessageBox.confirm('提示', '结账之后本期不能再输入新的记账凭证,所有的财务资料都无法在修改,所以结账操作一定要慎重,确定要结转本期数据吗?', function (btn) { if (btn == 'yes') { var dataHead = this.formHead.getForm().getValues(false, false, false); var dataQMTH = this.formQMTH.getForm().getValues(false, false, false); var dataJZSY = this.formJZSY.getForm().getValues(false, false, false); var dataGJSZ = this.formGJSZ.getForm().getValues(false, false, false); // var j = 0; var bodydatas = []; for (var i = 0; i < this.storeList.getCount(); i += 1) { var member = this.storeList.getAt(i); bodydatas.push(member); } var jsonBody; if (bodydatas.length > 0) { jsonBody = ConvertRecordsToJsonAll(bodydatas); } // Ext.Msg.wait('正在操作数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在操作数据...', url: '/MvcShipping/MsCwCarryOver/isSave', scope: this, params: { dataHead: Ext.JSON.encode(dataHead), dataQMTH: Ext.JSON.encode(dataQMTH), dataJZSY: Ext.JSON.encode(dataJZSY), dataGJSZ: Ext.JSON.encode(dataGJSZ), jsonBody: jsonBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (!jsonresult.Success) { Ext.MessageBox.confirm('提示', jsonresult.Message.toString(), function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在操作数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在操作数据...', url: '/MvcShipping/MsCwCarryOver/Save', params: { dataHead: Ext.JSON.encode(dataHead), dataQMTH: Ext.JSON.encode(dataQMTH), dataJZSY: Ext.JSON.encode(dataJZSY), dataGJSZ: Ext.JSON.encode(dataGJSZ), jsonBody: jsonBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var data = jsonresult.Data; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); this.formQMTH.getForm().reset(); this.formQMTH.getForm().setValues(data); this.formJZSY.getForm().reset(); this.formJZSY.getForm().setValues(data); this.formGJSZ.getForm().reset(); this.formGJSZ.getForm().setValues(data); // Ext.getCmp('VOUDATE').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE').setMaxValue(data.VOUDATE2); // Ext.getCmp('VOUDATE2').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE2').setMaxValue(data.VOUDATE2); // this.InitData(); } 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 }); } }, timeout: 5000000, //30秒 scope: this }); } }, this); } else { Ext.Msg.wait('正在操作数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在操作数据...', url: '/MvcShipping/MsCwCarryOver/Save', params: { dataHead: Ext.JSON.encode(dataHead), dataQMTH: Ext.JSON.encode(dataQMTH), dataJZSY: Ext.JSON.encode(dataJZSY), dataGJSZ: Ext.JSON.encode(dataGJSZ), jsonBody: jsonBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var data = jsonresult.Data; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); this.formQMTH.getForm().reset(); this.formQMTH.getForm().setValues(data); this.formJZSY.getForm().reset(); this.formJZSY.getForm().setValues(data); this.formGJSZ.getForm().reset(); this.formGJSZ.getForm().setValues(data); // Ext.getCmp('VOUDATE').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE').setMaxValue(data.VOUDATE2); // Ext.getCmp('VOUDATE2').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE2').setMaxValue(data.VOUDATE2); // this.InitData(); } 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 }); } }, timeout: 5000000, //30秒 scope: this }); } } else { Ext.Msg.show({ title: '请重试', msg: '服务器响应出错', icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); } }, this); }, //end save //#endregion //#region 返结 SaveReturn: function (button, event) { Ext.MessageBox.confirm('提示', '“反结账”可以将当前的会计期间反结转到上期,请慎重考虑,确定返结转到上期吗?', function (btn) { if (btn == 'yes') { Ext.Msg.wait('正在返结数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在返结数据...', url: '/MvcShipping/MsCwCarryOver/SaveReturn', scope: this, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var data = jsonresult.Data; this.formHead.getForm().reset(); this.formHead.getForm().setValues(data); this.formQMTH.getForm().reset(); this.formQMTH.getForm().setValues(data); this.formJZSY.getForm().reset(); this.formJZSY.getForm().setValues(data); this.formGJSZ.getForm().reset(); this.formGJSZ.getForm().setValues(data); // Ext.getCmp('VOUDATE').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE').setMaxValue(data.VOUDATE2); // Ext.getCmp('VOUDATE2').setMinValue(data.ACCDATE + "-01"); Ext.getCmp('VOUDATE2').setMaxValue(data.VOUDATE2); // this.InitData(); } 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 }); } } }); } }, this); } //end save //#endregion });