Ext.namespace('Shipping'); Shipping.MsInfoClientContractEdit = function (config) { Ext.applyIf(this, config); this.initUIComponents(); window.Shipping.MsInfoClientContractEdit.superclass.constructor.call(this); }; Ext.extend(Shipping.MsInfoClientContractEdit, Ext.Panel, { ParentWin: null, OpStatus: 'add', StoreList: null, EditRecord: null, MainEditRecord: null, strBSNO: '', //需求编号:SR2017061200005-1 initUIComponents: function () { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; //#region 编辑form //枚举参照相关(编辑form) //表参照相关(编辑form) //所属部门 this.storeDept = Ext.create('DsExt.ux.RefTableStore', { model: 'DsShipping.ux.DeptModel', proxy: { url: '/CommMng/BasicDataRef/GetDeptList' } }); this.storeDept.load(); this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', { fieldLabel: Zi.LAN.DEPTGID, //'签订部门', store: this.storeDept, forceSelection: true, name: 'DEPTGID', valueField: 'GID', displayField: 'DeptName' //,hidden: true }); //编辑form this.formEdit = Ext.widget('form', { region: 'north', frame: true, bodyPadding: 5, autoScroll: true, fieldDefaults: { margins: '2 2 2 2', labelAlign: 'right', flex: 1, labelWidth: 90, msgTarget: 'qtip' }, items: [ {//fieldset 1 xtype: 'fieldset', defaultType: 'textfield', layout: 'anchor', defaults: { anchor: '100%' }, items: [{ xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.GID, //'GID', name: 'GID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: Zi.LAN.LINKID, //'LINKID', name: 'LINKID', flex: 0, hidden: true, margins: '0' }, { fieldLabel: Zi.LAN.CREATEUSER, //'CREATEUSER', name: 'CREATEUSER', flex: 0, hidden: true, margins: '0' }, { fieldLabel: Zi.LAN.CONTRACTNO, //'合同号', name: 'CONTRACTNO' }, { fieldLabel: Zi.LAN.CHIEF, //'负责人', name: 'CHIEF' }, this.comboxDept ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.SIGNINGDATE, //'签订日期', format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'SIGNINGDATE' }, { fieldLabel: Zi.LAN.STARTDATE, //'生效日期', format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'STARTDATE' }, { fieldLabel: Zi.LAN.CANCELDATE, //'结束日期', format: 'Y-m-d', flex: 1, xtype: 'datefield', name: 'CANCELDATE' } ] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ fieldLabel: Zi.LAN.CREATEUSERREF, //'录入人', name: 'CREATEUSERREF' }, { fieldLabel: Zi.LAN.CREATETIME, //'录入日期', name: 'CREATETIME' }, { xtype: 'hiddenfield', flex: 1}] }, { xtype: 'container', layout: 'hbox', defaultType: 'textfield', items: [{ xtype: 'textareafield', grow: true, fieldLabel: Zi.LAN.REMARK, //'备 注', height: 60, name: 'REMARK', anchor: '100%' }] } ]//end items(fieldset 1) }//end fieldset 1 ] }); //end this.formEdit //#endregion //#region 按钮Toolbar this.panelBtn = new Ext.Panel({ region: "north", tbar: [ { text: Zi.LAN.btnESave, //"保存", iconCls: "btnsave", handler: function (button, event) { this.Save('0'); }, scope: this }, { text: Zi.LAN.btnESaveAndClose, //"保存并关闭", handler: function (button, event) { this.Save('1'); }, scope: this }, '-', { text: Zi.LAN.btnESaveAndNew, //"保存并新建", handler: function (button, event) { this.Save('2'); }, scope: this } ] }); //end 按钮Toolbar //#endregion //#region 明细表-单据图片档案管理 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: Zi.LAN.ShuJuJiaZaiZhong }, //"数据加载中,请稍等..." trackMouseOver: true, disableSelection: false, plugins: [this.DocListCellEditing], selModel: this.DocCM, selType: 'cellmodel', tbar: [{ text: Zi.LAN.btnDelete, //'删除', tooltip: Zi.LAN.btnDelete, //'删除', iconCls: "btndeletedetail", handler: function (button, event) { this.onDelFileClick(button, event); }, scope: this }, '-', { text: Zi.LAN.onUpLoadFileClick, //'上传附件', tooltip: Zi.LAN.onUpLoadFileClick, //'上传附件', iconCls: "btnadddetail", handler: function (button, event) { this.onUpLoadFileClick(button, event); }, scope: this }], columns: [{ sortable: true, hidden: true, dataIndex: 'GID', header: Zi.LAN.GID, //'GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'R_GID', header: Zi.LAN.R_GID, //'R_GID', width: 80 }, { sortable: true, hidden: true, dataIndex: 'BSNO', header: Zi.LAN.BSNO, //'BSNO', width: 80 }, { sortable: true, dataIndex: 'URL', header: Zi.LAN.URL, //'文件名', width: 140, renderer: function (value, p, record) { return '' + value + ''; } }, { sortable: true, hidden: true, dataIndex: 'Driect_URL', header: Zi.LAN.Driect_URL, //'Driect_URL', width: 80 }, { sortable: true, hidden: true, dataIndex: 'MODIFIEDUSER', header: Zi.LAN.MODIFIEDUSER, //'MODIFIEDUSER', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDUSERRef', header: Zi.LAN.MODIFIEDUSERRef, //'上传人', width: 80 }, { sortable: true, dataIndex: 'MODIFIEDTIME', header: Zi.LAN.MODIFIEDTIMERef, //'上传时间', width: 135 } ] }); // 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.panelCenter = new Ext.Panel({ id: "panelCenter", layout: "border", region: "center", autoScroll: true, items: [this.formEdit, this.panelDoc] }); //#region 布局 //控件布局 Ext.apply(this, { items: [this.panelBtn, this.panelCenter] }); //#endregion //绑定查询窗体 this.ParentWin = window.parent.opener; //初始化数据 this.InitData(); }, //end initUIComponents InitData: function () { this.opStatus = 'add'; var condition = ''; if (this.ParentWin) { var ret = this.ParentWin.OprationSwap(); this.opStatus = ret[0]; this.StoreList = ret[1]; this.editRecord = ret[2]; this.MainEditRecord = ret[3]; } if (this.opStatus == 'edit') { condition = " GID='" + this.editRecord.get('GID') + "'"; this.strBSNO = this.editRecord.get('GID'); this.storeDocList.load({ params: { condition: "BSNO='" + this.editRecord.get('GID') + "'"} }); } this.LoadData(this.opStatus, condition); }, //end InitData LoadData: function (opstatus, condition) { this.serialNo = 0; this.workSerialNo = 0; this.bodyDel = []; this.opStatus = opstatus; Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, //'正在查询主表数据...', url: '/MvcShipping/MsInfoClient/GetContractData', params: { handle: opstatus, condition: condition }, callback: function (options, success, response) { if (success) { var result = Ext.JSON.decode(response.responseText); if (!result.Success) { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: result.Message, icon: Ext.MessageBox.ERROR, buttons: Ext.Msg.OK }); return; } var data = result.data; this.formEdit.getForm().reset(); this.formEdit.getForm().setValues(data); this.strBSNO = data.GID; if (this.opStatus == 'add') { this.formEdit.getForm().findField('LINKID').setValue(this.MainEditRecord.GID); } } else { Ext.MessageBox.alert(Zi.LAN.FuWuQiXiangYingChuCuo, response.responseText); } }, scope: this }); }, // end LoadDate Save: function (type) { var basicForm = this.formEdit.getForm(); if (!basicForm.isValid()) { return; } basicForm.findField('GID').setDisabled(false); var data = basicForm.getValues(); basicForm.findField('GID').setDisabled(true); if (this.opStatus == 'add') { data.GID = NewGuid(); } Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...', url: '/MvcShipping/MsInfoClient/SaveContract', scope: this, params: { opstatus: this.opStatus, data: Ext.JSON.encode(data) }, callback: function (options, success, response) { if (success) { Ext.MessageBox.hide(); var jsonresult = Ext.JSON.decode(response.responseText); if (jsonresult.Success) { var returnData = jsonresult.Data; this.formEdit.getForm().setValues(returnData); this.strBSNO = returnData.GID; if (this.opStatus == 'add') { var arrNewRecords = this.StoreList.add(returnData); this.editRecord = arrNewRecords[0]; } else if (this.opStatus == 'edit') { var editp = Ext.create('MsInfoClientContractModel', returnData); this.editRecord.fields.each(function (field) { if (field.persist) { name = field.name; if (name != 'id') this.editRecord.set(name, editp.get(name)); } }, this); this.editRecord.commit(); } this.opStatus = 'edit'; if (type == '0') { this.opStatus = 'edit'; basicForm.findField('GID').setDisabled(true); } else if (type == '1') { window.close(); } else { this.LoadData('add', ''); basicForm.findField('GID').setDisabled(false); } } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.FuWuQiXiangYingChuCuo, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } }); }, //#region 上传图片 onAddFileClick: function (button, event) { var myDate = new Date(); var record = Ext.create('ReceiptDocmb', { GID: NewGuid(), RECEIPTTYPE: '', R_GID: '', BSNO: '', //ContractNo URL: '', Driect_URL: '', 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(Zi.LAN.QingChongXinDengLu); //"登录信息不全,请退出重新登录" return; } var billno = this.strBSNO; var bodyDatas = []; var i; var DocBody = ConvertRecordsToJsonAll(bodyDatas); _this = this; //var Docdatas = []; //var DocBody = ConvertRecordsToJson(Docdatas); //var DocBodyDel = ConvertRecordsToJsonAll(this.DocDel); var _this = this; Ext.Msg.wait(Zi.LAN.ZhengZaiCaoZuoShuJu); Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在保存数据...', url: '/Import/ReceiptDoc/SaveDoc', scope: this, params: { BSNO: _this.strBSNO, DocBody: 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: Zi.LAN.ZhengZaiChaXunShuJu, scope: this, callback: function () { _this.Loading = false; } }); } else { Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK }); } } else { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.FuWuQiXiangYingChuCuo, 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: Zi.LAN.TiShi, msg: Zi.LAN.QingXianXuanZeXinXi, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); return; } Ext.MessageBox.confirm(Zi.LAN.TiShi, '确定要删除选中的附件吗?', 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(Zi.LAN.ZhengZaiCaoZuoShuJu); if (feeGidSql != '') { Ext.Ajax.request({ waitMsg: Zi.LAN.ZhengZaiCaoZuoShuJu, //'正在删除数据...', 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: 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 } else { Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.CaoZuoChengGong, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); } } }, this); } , onUpLoadFileClick: function (button, event) { var billno = this.MainEditRecord.SHORTNAME; me = this; if (this.opStatus == 'add') { alert('请先保存合同信息!'); //"登录信息不全,请退出重新登录" return; } 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: Zi.LAN.LoadFile, //'选择文件', fieldLabel: Zi.LAN.LoadFile, //'选择文件', buttonText: Zi.LAN.LoadFile, //'选择文件', allowBlank: false, buttonCfg: { iconCls: 'uploaddialog' }, anchor: '98%' }], buttons: [{ text: Zi.LAN.submit, //'上传', type: 'submit', handler: function () { var UserFilePath = Ext.getCmp('LoadFile').getValue(); // if (!CheckFileExt(UserFilePath, /.jpg|.gif|.png|.bmp|.pdf/i)) { // Ext.Msg.show({ title: Zi.LAN.CuoWu, msg: Zi.LAN.QingQueRenNiShangChuanDeWenJianWeiTuPianWenJian, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); // return; // } if (!imgform.form.isValid()) { return; } imgform.form.submit({ url: '/MvcShipping/MsOpReceipt/UploadFile', waitMsg: Zi.LAN.ZhengZaiShangChuan, //'正在上传', method: 'POST', submitEmptyText: false, async: false, params: { CUSTNO: billno, BSNO: me.strBSNO }, success: function (form, action) { win.close(this); Ext.Msg.show({ title: Zi.LAN.TiShi, msg: Zi.LAN.CaoZuoChengGong, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK }); var condition = me.strBSNO; var condition2 = " BSNO='" + condition + "' "; me.Loading = true; me.storeDocList.load({ params: { condition: condition2 }, waitMsg: Zi.LAN.ZhengZaiChaXunShuJu, scope: this, callback: function () { me.Loading = false; } }); }, failure: function (form, action) { form.reset(); if (action.failureType == Ext.form.Action.SERVER_INVALID) Ext.MessageBox.alert(Zi.LAN.JingGao, action.result.errors.msg); } }); } }, { text: Zi.LAN.btnClose, //'关闭', type: 'submit', handler: function () { win.close(this); } }] }); var win = new Ext.Window({ title: Zi.LAN.ShangChuanWenJian, //"上传文件", width: 360, height: 120, modal: true, resizable: false, border: false, items: imgform }); win.show(); } //#endregion });