Ext.namespace('Shipping'); Shipping.ReceiptEditGrid = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.ReceiptEditGrid.superclass.constructor.call(this); }; 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(), //second "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; } Ext.extend(Shipping.ReceiptEditGrid, Ext.Panel, { ParentWin: null, //弹出式 ParentPanel: null, //Tab页编辑模式 OpStatus: 'add', StoreBill: null, StoreCustType: null, EditRecord: null, RefBillNo: '*', DataLoading: true, stroplb: '', strBSNO: '', _First: true, OprationSwap: function () { var ret = new Array(); ret[0] = this.stroplb; ret[1] = this.storeDrOpReceipt; return ret; }, initUIComponents: function () { this.formname = "formRptOpReceiptIndex"; //页面名称 this.ReceiptDrSerialNo = 0; this.ReceiptDrBodyDel = []; this.Loading = true; this.StoreDrOpRange = Ext.create('DsExt.ux.RefTableStore', { model: 'MsReceiptOP', proxy: { url: '/MvcShipping/MsOpReceipt/GetReceiptOpRang' } }); //明细表-数据集 this.storeDrOpReceipt = Ext.create('Ext.data.Store', { model: 'MsOpReceiptEntity', remoteSort: false, proxy: { type: 'ajax', url: '/MvcShipping/MsOpReceipt/GetDataList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); this.storeOpCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.UserRefModel', proxy: { url: '/CommMng/BasicDataRef/GetUserLinkRefListRm' } }); this.comboxCUSTSERVICE = Ext.create('DsExt.ux.RefTableCombox', { store: this.storeOpCode, forceSelection: true, queryMode: 'remote', minChars: 0, queryParam: 'CODENAME', name: 'CUSTSERVICE', valueField: 'UserName', displayField: 'CodeAndName', value: SHOWNAME }); this.cellEditingDrOpReceipt = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.ReceiptDrGridCheckBoxModel = Ext.create('Ext.selection.CheckboxModel'); _this = this; //键值维护表_贸易方式 this.storeCrmKeyCodeCode = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.CrmKeyCodeModel', proxy: { url: '/CommMng/BasicDataRef/GetCrmKeyCodeList' } }); this.storeCrmKeyCodeCode.load({ params: { condition: " and KEYTYPE='单据类型'"} }); this.comboxRECEIPTTYPE = Ext.create('DsExt.ux.RefTableCombox', { //fieldLabel: '单据类型', store: this.storeCrmKeyCodeCode, forceSelection: true, name: 'RECEIPTTYPE', valueField: 'KEYVALUE', displayField: 'KEYVALUE' }); // this.columns = [{ sortable: true, dataIndex: 'GID', header: '惟一编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'BSNO', header: '业务编号', hidden: true, width: 0 }, { sortable: true, dataIndex: 'RECEIPTNO', header: '单据编号', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 100 }, { sortable: true, dataIndex: 'RECEIPTTYPE', header: '单据类型', editor: this.comboxRECEIPTTYPE, width: 80 }, { sortable: true, dataIndex: 'DOCNUM', header: '单据份数', //'件数', width: 60, editor: { xtype: 'numberfield', allowBlank: false, selectOnFocus: true } }, { sortable: true, dataIndex: 'RECEIVE_MAN', header: '接单人', //editor: SHOWNAME, editor: this.comboxCUSTSERVICE, width: 80 }, { sortable: true, dataIndex: 'RECEIVE_DATE', header: '接单日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), //format是'm/d/Y',结果是”09/24/2008” editor: { //dateFormat: Ext.util.Format.dateRenderer('Y-m-d'), format: 'Y-m-d', xtype: 'datefield', selectOnFocus: true }, width: 80 }, { sortable: true, dataIndex: 'SEND_MAN', header: '送单人', //editor: SHOWNAME, editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 80 }, { sortable: true, dataIndex: 'SEND_DATE', header: '送单日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), //format是'm/d/Y',结果是”09/24/2008” editor: { //dateFormat: Ext.util.Format.dateRenderer('Y-m-d'), format: 'Y-m-d', xtype: 'datefield', selectOnFocus: true }, width: 80 }, { sortable: true, dataIndex: 'TRANCER', header: '送单快递公司', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 80 }, { sortable: true, dataIndex: 'TRANCNO', header: '送单快递单号', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 80 }, { sortable: true, dataIndex: 'ISREPEAT', header: '是否回单', //xtype: "checkboxfield", //xtype:"booleancolumn", //trueText: "是", //falseText: " ", editor: { xtype: 'checkboxfield' }, width: 60 }, { sortable: true, dataIndex: 'REPEAT_MAN', header: '回单人', //editor: SHOWNAME, editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 80 }, { sortable: true, dataIndex: 'REPEAT_DATE', header: '回单日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), //format是'm/d/Y',结果是”09/24/2008” editor: { //dateFormat: Ext.util.Format.dateRenderer('Y-m-d'), format: 'Y-m-d', xtype: 'datefield', selectOnFocus: true }, width: 80 }, { sortable: true, dataIndex: 'ISRECEIVE', header: '是否还单', editor: { xtype: 'checkboxfield' }, width: 60 }, { sortable: true, dataIndex: 'RETURN_MAN', header: '还单人', //editor: SHOWNAME, editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 80 }, { sortable: true, dataIndex: 'RETURN_DATE', header: '还单日期', renderer: Ext.util.Format.dateRenderer('Y-m-d'), //format是'm/d/Y',结果是”09/24/2008” editor: { //dateFormat: Ext.util.Format.dateRenderer('Y-m-d'), format: 'Y-m-d', xtype: 'datefield', selectOnFocus: true }, width: 80 }, { sortable: true, dataIndex: 'RETURN_TRANCER', header: '还单的快递公司', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 100 }, { sortable: true, dataIndex: 'RETURN_TRANCNO', header: '还单的快递单号', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 100 }, { sortable: true, dataIndex: 'REMARK', header: '备注', editor: { xtype: 'textfield', selectOnFocus: true, enableKeyEvents: true, listeners: { keydown: function (textfield, e) { if (e.getKey() == 40) { _this.onNextKeyClick(17) } } } }, width: 200 }, { sortable: true, dataIndex: 'CORPID', header: '分公司代码', hidden: true, width: 0 }, { sortable: true, dataIndex: 'CREATEUSER', header: '创建人', width: 0 }, { sortable: true, dataIndex: 'CREATETIME', header: '创建时间', width: 0 }, { sortable: true, dataIndex: 'MODIFIEDUSER', header: '最后更改人', width: 0 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '最后更改时间', width: 0 }]; this.gridDrOpReceipt = new Ext.grid.GridPanel({ store: this.storeDrOpReceipt, enableHdMenu: false, region: 'center', id: 'gridDrOpReceipt', loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.cellEditingDrOpReceipt], selModel: this.ReceiptDrGridCheckBoxModel, selType: 'cellmodel', viewConfig: { autoFill: true // getRowClass: function (record, rowIndex, rowParams, store) { // var ReceiptStatus = record.get('ReceiptStatus'); // return Shipping.ReceiptGetRowClass(ReceiptStatus);//判断行颜色 // } }, tbar: [{ text: '', tooltip: '添加', iconCls: "btnadd", handler: function (button, event) { this.onAddDetailClick(button, event); }, scope: this }, '-', { text: '', tooltip: '保存', iconCls: "btnsave", handler: function (button, event) { this.onPostDetailClick(button, event); }, scope: this }, '-', { text: '', tooltip: '删除', iconCls: "btndelete", handler: function (button, event) { this.onDelDetailClick(button, event); }, scope: this }, '-', { text: '', tooltip: '取消修改', iconCls: "btncancel", handler: function (button, event) { this.onCancelDetailClick(button, event); }, scope: this }, '-', { text: '', tooltip: '刷新', iconCls: "btnrefresh", handler: function (button, event) { this.storeDrOpReceipt.load({ params: { billno: this.strBSNO, optype: this.stroplb} }); }, scope: this }, '-', { text: '', tooltip: '打印', iconCls: "btnprint", menu: [{ text: "打印账单", menu: [{ text: "所选打印", handler: function (menu, event) { _this.onPrintSelectDetailClick(menu, event); } }, { text: "所有打印", handler: function (menu, event) { _this.onPrintAllDetailClick(menu, event); } }] }, '-', ], scope: this }, '-', { text: "确认送单", //iconCls: "btnreset", handler: function (button, event) { this.onSetRECEIPT("SEND"); }, scope: this }, { text: "确认回单", //iconCls: "btnreset", handler: function (button, event) { this.onSetRECEIPT("REPEAT"); }, scope: this }, { text: "确认还单", //iconCls: "btnreset", handler: function (button, event) { this.onSetRECEIPT("RETURN"); }, scope: this }, '-', { text: "保存列表样式", id: "btntest", handler: function (button, event) { var formname = this.formname; var tempcolumns = this.gridDrOpReceipt.columns; DsTruck.SaveGridPanel(USERID, formname, tempcolumns, this.columns, 0, true); }, scope: this }], columns: this.columns }); _this = this; /////////////以下部分为获取存储的gridpanel显示样式 this.columns = DsTruck.GetGridPanel(USERID, this.formname, this.columns); //使用者id,表名 ,中间column数组,跳过一开始的几列 //this.girdcolums.unshift(new Ext.grid.RowNumberer()); this.gridDrOpReceipt.reconfigure(this.storeDrOpReceipt, this.columns); //////////////////////////// this.cellEditingDrOpReceipt.on('beforeedit', function (editor, e) { return this.cellEditingOpReceiptBeforeEdit(editor, e); }, this); this.gridDrOpReceipt.on('beforeload', function (store) { Ext.apply(store.proxy.extraParams, { billno: _this.strBSNO, optype: _this.stroplb }); }, this); //#endregion //#region 明细表-单据图片档案管理 this.storeISOPEN = Ext.create('Ext.data.Store', { fields: ['FSTATUS', 'NAME'] }); this.storeISOPEN.add({ "FSTATUS": "1", "NAME": "公开" }); this.storeISOPEN.add({ "FSTATUS": "0", "NAME": "不公开" }); this.comboxISOPEN = Ext.create('DsExt.ux.RefTableCombox', { // fieldLabel: '海运费', store: this.storeISOPEN, valueField: 'FSTATUS', displayField: 'NAME', // flex: 0.7, // labelWidth: 55, forceSelection: true, name: 'ISPUBLIC' }); this.storeDocList = Ext.create('Ext.data.Store', { model: 'ReceiptDocmb', remoteSort: true, proxy: { type: 'ajax', url: '/Import/ReceiptDoc/GetDocList', reader: { id: 'GID', root: 'data', totalProperty: 'totalCount' } } }); //明细表表格 this.DocListCellEditing = Ext.create('Ext.grid.plugin.CellEditing', { clicksToEdit: 1 }); this.DocCM = Ext.create('Ext.selection.CheckboxModel'); this.gridDocList = new Ext.grid.GridPanel({ store: this.storeDocList, enableHdMenu: false, region: 'center', // width: 350, loadMask: { msg: "数据加载中,请稍等..." }, trackMouseOver: true, disableSelection: false, plugins: [this.DocListCellEditing], selModel: this.DocCM, selType: 'cellmodel', tbar: [{ text: '删除', tooltip: '删除', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelFileClick(button, event); }, scope: this }, '-', { text: '上传附件', tooltip: '上传附件', iconCls: "btnadddetail", handler: function (button, event) { this.onUpLoadFileClick(button, event); }, scope: this }, '-', { text: '保存', tooltip: '保存', // iconCls: "btnadddetail", handler: function (button, event) { this.onPostFileClick(button, event); }, scope: this }], columns: [{ sortable: true, hidden: true, dataIndex: 'GID', header: 'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'R_GID', header: 'R_GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'BSNO', header: 'BSNO', width: 80 }, { sortable: true, dataIndex: 'URL', header: '文件名', width: 200, renderer: function (value, p, record) { return '' + value + ''; } }, { sortable: true, dataIndex: 'RECEIPTTYPE', header: '附件类型', width: 135 }, { sortable: true, hidden: true, dataIndex: 'Driect_URL', header: 'Driect_URL', width: 80 }, { sortable: true, hidden: true, dataIndex: 'MODIFIEDUSER', header: 'MODIFIEDUSER', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSERRef', header: '上传人', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: '上传时间', width: 135 }, { sortable: true, dataIndex: 'DOCUMENTATTACHEDCODE', header: '随附单证代码', //需求编号:SR2017081100003 width: 120 }, { sortable: true, dataIndex: 'DOCUMENTATTACHEDNO', header: '随附单证编号', //需求编号:SR2017081100003 width: 120 }, { sortable: true, dataIndex: 'ISPUBLIC', header: '是否公开', editor: this.comboxISOPEN, width: 80, renderer: function (value, cellmeta) { if (value == '1') { return "公开"; } else return "不公开"; } } ] }); this.storeDocList.on('beforeload', function (store) { var condition = _this.strBSNO; var condition2 = " BSNO='" + condition + "' "; Ext.apply(store.proxy.extraParams, { condition: condition2 }); }, this); // this.gridDocList.getSelectionModel().on('select', function (model, record, index) { // if (this.Loading == true) { // return; // } // var PICURL = record.data.Driect_URL; // if ((PICURL!=undefined)&&(PICURL!='')) // Ext.getCmp('panelPic').body.update(' '); // }, this); // this.panelPic = new Ext.Panel({ // id: "panelPic", // layout: "fit", // region: "center", // autoScroll: true, // frame: false, // html: ' '//ftp://bjes:@120.27.53.37/dhm-11111/2.jpg // }); this.panelDoc = new Ext.Panel({ id: "panelDoc", layout: "border", region: "center", //autoScroll: true, frame: false, split: true, items: [this.gridDocList] }); //#endregion this.panelReceipt = new Ext.Panel({ //layout: "anchor", layout: "border", anchor: '100% 50%', height: 350, region: 'north', items: [ this.gridDrOpReceipt ] }); //#region 布局 Ext.apply(this, { items: [this.panelReceipt, this.panelDoc, this.formtotal] }); //#endregion this.opStatus = 'add'; this.InitData(); }, //end initUIComponents //#region 加载数据 InitData: function () { var condition = ''; this.LoadData(this.opStatus, condition, this.RefBillNo); }, //end InitData LoadData: function (opstatus, condition, refbillno) { this.opStatus = opstatus; }, // end LoadDate //#endregion //#region 明细操作 onNextKeyClick: function (col) { var rows = this.gridDrOpReceipt.getSelectionModel().getSelection(); var row = rows[rows.length - 1]; var s = this.gridDrOpReceipt.getStore(); var number = s.indexOf(row) + 1; if (number == this.gridDrOpReceipt.getStore().getCount()) { this.onAddDetailClick(s, event); } else { this.cellEditingDrOpReceipt.startEditByPosition({ row: number, column: col }); } }, onAddDetailClick: function (button, event) { var store = this.storeDrOpReceipt; var newSerialno = this.GetHandleSerialNo(store); var newsort = store.getCount() + 1; var myDate = new Date(); //myDate = this.GetDateStr(0); var record = null; record = Ext.create('MsOpReceiptEntity', { GID: NewGuid(), // 惟一编号 BSNO: '*', // 关联编号/业务编号BSNO RECEIPTNO: '', // 单据编号 RECEIPTTYPE: '', // 单据类型 RECEIVE_MAN: SHOWNAME, // 接单人 RECEIVE_DATE: myDate, // 接单日期 DOCNUM:0, SEND_MAN: '', // 送单人 SEND_DATE: null, // 送单日期 TRANCER: '', // 送单的快递公司 TRANCNO: '', // 送单的快递单号 ISREPEAT: 'false', // 是否回单 REPEAT_MAN: '', // 回单人 REPEAT_DATE: null, // 回单日期 ISRECEIVE: 'false', // 是否还单 RETURN_MAN: '', // 还单人 RETURN_DATE: null, // 还单日期 RETURN_TRANCER: '', // 还单的快递公司 RETURN_TRANCNO: '', // 还单的快递单号 REMARK: '', // 备注 CORPID: '', // 分公司代码 CREATEUSER: USERID, // 创建人GID CREATETIME: null, // 创建时间 MODIFIEDUSER: USERID, // 更改操作人GID MODIFIEDTIME: null // 更改操作时间 //Sort: newSerialno, }); store.add(record); var editColumnIndex = 1; var cellediting = this.cellEditingDrOpReceipt; var n = store.getCount(); cellediting.startEditByPosition({ row: n - 1, column: editColumnIndex }); }, onCancelDetailClick: function (menu, event) { var store = this.storeDrOpReceipt; for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); member.reject(); } }, GetHandleSerialNo: function (store) { var result = 0; if (result == 0) { for (var i = 0; i < store.getCount(); i += 1) { var member = store.getAt(i); if (member.data.Sort > result) { result = member.data.Sort; } } } result = parseInt(result) + 1; return result; }, //获取日期 GetDateStr: function (AddDayCount) { var dd = new Date(); dd.setDate(dd.getDate() + AddDayCount); //获取AddDayCount天后的日期 var y = dd.getFullYear(); var m = dd.getMonth() + 1; //获取当前月份的日期 var d = dd.getDate(); return y + "-" + m + "-" + d; }, //#endregion //#region 单据确认 onSetRECEIPT: function (onSetType) { var ReceiptGIDSql = ''; var selectedRecords = this.ReceiptDrGridCheckBoxModel.selected.items; var candelete = this.CheckOpReceiptDelete(selectedRecords); if (candelete == false) { return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要操作的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要操作选中的数据吗?', function (btn) { if (btn == 'yes') { if (selectedRecords.length > 0) { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BSNO == "*") {//如果是新增但没有保存的数据,没有必要提交到后台 this.storeDrOpReceipt.remove(selectedRecords[i]); } else { var ReceiptGID = "'" + rec.data.GID + "'"; if (ReceiptGIDSql == '') { ReceiptGIDSql = ReceiptGID; } else { ReceiptGIDSql = ReceiptGIDSql + "," + ReceiptGID; } } } } _this = this; Ext.Msg.wait('正在操作数据...'); if (ReceiptGIDSql != '') { Ext.Ajax.request({ waitMsg: '正在操作数据...', url: '/MvcShipping/MsOpReceipt/onSetRECEIPT', params: { BSNO: _this.strBSNO, gids: ReceiptGIDSql, onSetType: onSetType }, callback: function (options, success, response) { if (success) { //Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { } this.storeDrOpReceipt.reload(); 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 }); }, scope: this }); //end Ext.Ajax.request } else { Ext.Msg.show({ title: '提示', msg: "操作成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } }, this); }, //#endregion //#region 删除 onDelDetailClick: function (button, event) { var ReceiptGIDSql = ''; var selectedRecords = this.ReceiptDrGridCheckBoxModel.selected.items; var candelete = this.CheckOpReceiptDelete(selectedRecords); if (candelete == false) { return; } if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要删除选中的数据吗?', function (btn) { if (btn == 'yes') { if (selectedRecords.length > 0) { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.BSNO == "*") {//如果是新增但没有保存的数据,没有必要提交到后台 this.storeDrOpReceipt.remove(selectedRecords[i]); } else { var ReceiptGID = "'" + rec.data.GID + "'"; if (ReceiptGIDSql == '') { ReceiptGIDSql = ReceiptGID; } else { ReceiptGIDSql = ReceiptGIDSql + "," + ReceiptGID; } } } } _this = this; Ext.Msg.wait('正在删除数据...'); if (ReceiptGIDSql != '') { Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpReceipt/Delete', params: { BSNO: _this.strBSNO, data: ReceiptGIDSql }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { this.storeDrOpReceipt.remove(selectedRecords[i]); } 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 } else { Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } }, this); }, //#endregion //#region 操作权限判断 CheckOpReceiptDelete: function (records) { for (var i = 0; i < records.length; i++) { var rec = records[i]; var MODIFIEDUSER = rec.data.MODIFIEDUSER; var recop = DsStoreQueryBy(this.StoreDrOpRange, 'OPID', MODIFIEDUSER); if (recop.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限操作此信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canDelete = false; } } return true; }, //#endregion //#region 保存 onPostDetailClick: function (button, event) { var bodyDrOpReceiptDatas = []; for (var i = 0; i < this.storeDrOpReceipt.getCount(); i += 1) { var memberyf = this.storeDrOpReceipt.getAt(i); bodyDrOpReceiptDatas.push(memberyf); }; var jsonOpReceiptBody = ConvertFeeRecordsToJson(bodyDrOpReceiptDatas); // _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpReceipt/Save', scope: this, params: { BSNO: _this.strBSNO, OpReceiptbody: jsonOpReceiptBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < this.storeDrOpReceipt.getCount(); i += 1) { var member = this.storeDrOpReceipt.getAt(i); member.set("BSNO", _this.strBSNO); member.commit(); } } 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 //#endregion //#region 表格的AfterEdit setHeadFieldValue: function (fieldName, value) { var field = this.formtotal.getForm().findField(fieldName); field.setValue(value); }, //#endregion //#region 修改权限判断 cellEditingOpReceiptBeforeEdit: function (editor, e) { var MODIFIEDUSER = e.record.get('MODIFIEDUSER'); var records = DsStoreQueryBy(this.StoreDrOpRange, 'OPID', MODIFIEDUSER); if (records.getCount() > 0) { } else { Ext.Msg.show({ title: '提示', msg: '你没有权限修改此信息!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); canedit = false; } return true; }, //#endregion //#region 其他 refBillNoSeChange: function (field, newValue, oldValue) { // if (newValue != oldValue) { // alert(newValue + "," + oldValue); // } }, getBillStatus: function () { // var basicForm = this.formEdit.getForm(); // var billStatus = basicForm.findField('BillStatus').value; // return billStatus; }, getCustName: function () { // var custName = this.formEdit.getForm().findField('RefCustomerName'); //return custName.getValue(); }, //#endregion //#region 保存 setSaveBtnStatus: function (enable) { var bsbtnSave = Ext.getCmp('pcbtnSave'); var bsbtnSaveAndClose = Ext.getCmp('pcbtnSaveAndClose'); var bsbtnSaveAndNew = Ext.getCmp('pcbtnSaveAndNew'); var pcbtnNew = Ext.getCmp('pcbtnNew'); if (enable) { bsbtnSave.enable(); bsbtnSaveAndClose.enable(); bsbtnSaveAndNew.enable(); pcbtnNew.enable(); } else { bsbtnSaveAndNew.disable(); pcbtnNew.disable(); } }, //#endregion //#region 上传图片 onAddFileClick: function (button, event) { var myDate = new Date(); var record = Ext.create('ReceiptDocmb', { GID: NewGuid(), RECEIPTTYPE: '', R_GID: '', BSNO: '', //ContractNo URL: '', Driect_URL: '', ISPUBLIC: '0', MODIFIEDUSER: SHOWNAME, MODIFIEDTIME: myDate.format('yyyy-MM-dd hh:mm:ss') }); this.storeDocList.add(record); var n = this.storeDocList.getCount(); this.DocListCellEditing.startEditByPosition({ row: n - 1, column: 5 }); } , onPostFileClick: function (button, event) { if (USERID == "") { alert("登录信息不全,请退出重新登录"); return; } var billno = this.strBSNO; var bodyDatas = []; var i; for (var i = 0; i < this.storeDocList.getCount(); i += 1) { var member = this.storeDocList.getAt(i); bodyDatas.push(member); } var DocBody = ConvertRecordsToJsonAll(bodyDatas); _this = this; //var Docdatas = []; //var DocBody = ConvertRecordsToJson(Docdatas); //var DocBodyDel = ConvertRecordsToJsonAll(this.DocDel); var _this = this; Ext.Msg.wait('正在保存数据, 请稍侯..'); Ext.Ajax.request({ waitMsg: '正在保存数据...', url: '/MvcShipping/MsOpReceipt/SaveUploadFile', scope: this, params: { data: DocBody }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var condition = _this.strBSNO; var condition2 = " BSNO='" + condition + "' "; _this.Loading = true; _this.storeDocList.load({ params: { condition: condition2 }, waitMsg: "正在查询数据...", scope: this, callback: function () { _this.Loading = false; } }); } 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'); } }); } //end save , onDelFileClick: function (button, event) { var feeGidSql = ''; var selectedRecords = []; selectedRecords = this.DocCM.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要删除的附件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm('提示', '确定要删除选中的附件吗?', function (btn) { if (btn == 'yes') { if (selectedRecords.length > 0) { for (var i = 0; i < selectedRecords.length; i++) { var rec = selectedRecords[i]; if (rec.data.GID == "*") //如果是新增但没有保存的数据,没有必要提交到后台 { this.storeDocList.remove(selectedRecords[i]); } else { var feeGId = "'" + rec.data.GID + "'"; if (feeGidSql == '') { feeGidSql = feeGId; } else { feeGidSql = feeGidSql + "," + feeGId; } } } } _this = this; Ext.Msg.wait('正在删除数据...'); if (feeGidSql != '') { Ext.Ajax.request({ waitMsg: '正在删除数据...', url: '/MvcShipping/MsOpReceipt/DeleteUploadFile', params: { data: feeGidSql }, callback: function (options, success, response) { if (success) { var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { for (var i = 0; i < selectedRecords.length; i++) { this.storeDocList.remove(selectedRecords[i]); } 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 } else { Ext.Msg.show({ title: '提示', msg: "删除成功!", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } }, this); } , onUpLoadFileClick: function (button, event) { var billno = this.EditRecord.get("CUSTNO"); //枚举维护表tSysEnumValue_附件类型97048 //需求编号:SR2017081100003 this.storeFileType = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.TSysEnumValueDataModel', proxy: { url: '/CommMng/BasicDataRef/GetTSysEnumValueList' } }); this.storeFileType.load({ params: { condition: " and EnumTypeID=97048"} }); var comboxFileType = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: '附件类型', store: this.storeFileType, forceSelection: true, id: 'FILETYPE', name: 'FILETYPE', valueField: 'EnumValueName', displayField: 'EnumValueName' }); me = this; var imgform = new Ext.FormPanel({ region: 'center', labelWidth: 40, frame: true, //bodyStyle: 'padding:5px 5px 0', //autoScroll: true, border: false, fileUpload: true, items: [{ xtype: 'fileuploadfield', id: 'LoadFile', name: 'LoadFile', emptyText: '请选择文件', fieldLabel: '文件', buttonText: '选择文件', allowBlank: false, buttonCfg: { iconCls: 'uploaddialog' }, anchor: '98%' }, comboxFileType, { xtype: 'textfield', id: 'DOCUMENTATTACHEDCODE', name: 'DOCUMENTATTACHEDCODE', fieldLabel: '随附单证代码'//需求编号:SR2017081100003 }, { xtype: 'textfield', id: 'DOCUMENTATTACHEDNO', name: 'DOCUMENTATTACHEDNO', fieldLabel: '随附单证编号'//需求编号:SR2017081100003 }], buttons: [{ text: '上传', type: 'submit', handler: function () { var UserFilePath = Ext.getCmp('LoadFile').getValue(); // if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) { // Ext.Msg.show({ title: '错误', msg: '请确认你上传的文件为图片文件!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); // return; // } if (!imgform.form.isValid()) { return; } imgform.form.submit({ url: '/MvcShipping/MsOpReceipt/UploadFile', waitMsg: '正在上传', method: 'POST', submitEmptyText: false, async: false, params: { CUSTNO: billno, BSNO: _this.strBSNO, TYPE: comboxFileType.getRawValue(), DOCUMENTATTACHEDCODE: Ext.getCmp('DOCUMENTATTACHEDCODE').getValue(), //需求编号:SR2017081100003 DOCUMENTATTACHEDNO: Ext.getCmp('DOCUMENTATTACHEDNO').getValue() //需求编号:SR2017081100003 }, success: function (form, action) { win.close(this); Ext.Msg.show({ title: '提示', msg: '上传成功!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); var condition = _this.strBSNO; var condition2 = " BSNO='" + condition + "' "; me.Loading = true; me.storeDocList.load({ params: { condition: condition2 }, waitMsg: "正在查询数据...", scope: this, callback: function () { me.Loading = false; } }); }, failure: function (form, action) { form.reset(); // if (action.failureType == Ext.form.Action.SERVER_INVALID) { // Ext.MessageBox.alert('警告', action.result.errors.msg); // } } }); } }, { text: '关闭', type: 'submit', handler: function () { win.close(this); } }] }); var win = new Ext.Window({ title: "上传文件", width: 360, height: 200, modal: true, resizable: false, border: false, items: imgform }); win.show(); } , //#endregion //#region 打印 onPrintSelectDetailClick: function (button, event) { var selectedRecords = this.ReceiptDrGridCheckBoxModel.selected.items; if (selectedRecords.length == 0) { Ext.Msg.show({ title: '提示', msg: '请先选择要打印的数据!', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } if (this.stroplb == 'op_Seae') { var printType = 'SEAEDRReceipt'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = 'APPLYDRReceipt'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = 'SEAIDRReceipt'; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_seai WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = 'BULKDRReceipt'; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_bulk WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = 'OpOtherReceipt'; var sql1 = /*"SET LANGUAGE 'us_english' " + */" select * from op_other WHERE BSNO = '" + this.strBSNO + "'"; }; var ReceiptGIDSql = ''; for (var i = 0; i < selectedRecords.length; i++) { var record = selectedRecords[i]; var ReceiptGID = "''" + record.get('GID') + "''"; if (ReceiptGIDSql == '') { ReceiptGIDSql = ReceiptGID; } else { ReceiptGIDSql = ReceiptGIDSql + "," + ReceiptGID; } }; var sql2 = ""; if (ReceiptGIDSql != '') { sql2 = sql2 + "select GID as 惟一编号,BSNO as 业务编号,RECEIPTNO as 单据编号,RECEIPTTYPE as 单据类型,RECEIVE_MAN as 接单人,convert(char(10),RECEIVE_DATE,20) as 接单日期,SEND_MAN as 送单人,convert(char(10),SEND_DATE,20) as 送单日期,TRANCER as 送单快递公司,TRANCNO as 送单快递单号,ISREPEAT as 是否回单,REPEAT_MAN as 回单人,convert(char(10),REPEAT_DATE,20) as 回单日期,ISRECEIVE as 是否还单,RETURN_MAN as 还单人,convert(char(10),RETURN_DATE,20) as 还单日期,RETURN_TRANCER as 还单快递公司,RETURN_TRANCNO as 还单快递单号,REMARK as 备注,(select top 1 [NAME] from [company] where gid=op_receipt.CORPID) as 分公司,(select top 1 SHOWNAME from [user] where gid=op_receipt.CREATEUSER) as 创建人,CREATETIME as 创建时间,(select top 1 SHOWNAME from [user] where gid=op_receipt.MODIFIEDUSER) as 最后更改人,MODIFIEDTIME as 最后更改时间 from op_receipt where GID in (" + ReceiptGIDSql + ") order by bsno,MODIFIEDTIME"; } var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); }, onPrintAllDetailClick: function (button, event) { if (this.stroplb == 'op_Seae') { var printType = 'SEAEDRReceiptALL'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seae WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Apply') { var printType = 'APPLYDRReceiptALL'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_apply WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Seai') { var printType = 'SEAIDRReceiptALL'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_seai WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_Bulk') { var printType = 'BULKDRReceiptALL'; var sql1 = "SET LANGUAGE 'us_english' " + " select * from op_bulk WHERE BSNO = '" + this.strBSNO + "'"; } else if (this.stroplb == 'op_other') { var printType = 'OpOtherReceipt'; var sql1 = "SET LANGUAGE 'us_english' " + "select * from op_other WHERE BSNO = '" + this.strBSNO + "'"; }; var sql2 = "SET LANGUAGE 'us_english' select GID as 惟一编号,BSNO as 业务编号,RECEIPTNO as 单据编号,RECEIPTTYPE as 单据类型,RECEIVE_MAN as 接单人,convert(char(10),RECEIVE_DATE,20) as 接单日期,SEND_MAN as 送单人,convert(char(10),SEND_DATE,20) as 送单日期,TRANCER as 送单快递公司,TRANCNO as 送单快递单号,ISREPEAT as 是否回单,REPEAT_MAN as 回单人,convert(char(10),REPEAT_DATE,20) as 回单日期,ISRECEIVE as 是否还单,RETURN_MAN as 还单人,convert(char(10),RETURN_DATE,20) as 还单日期,RETURN_TRANCER as 还单快递公司,RETURN_TRANCNO as 还单快递单号,REMARK as 备注,(select top 1 [NAME] from [company] where gid=op_receipt.CORPID) as 分公司,(select top 1 SHOWNAME from [user] where gid=op_receipt.CREATEUSER) as 创建人,CREATETIME as 创建时间,(select top 1 SHOWNAME from [user] where gid=op_receipt.MODIFIEDUSER) as 最后更改人,MODIFIEDTIME as 最后更改时间 from op_receipt where BSNO='" + this.strBSNO + "' order by bsno,MODIFIEDTIME"; var sql3 = ""; var sql4 = ""; var sql5 = ""; var sql6 = ""; PrintComm(printType, sql1, sql2, sql3, sql4, sql5, sql6); } //#endregion });