/** * setBarcodeRule的Form */ Ext.define('erp.view.scm.reserve.SetBarcodeRuleForm',{ extend: 'Ext.form.Panel', alias: 'widget.erpSetBarcodeRuleForm', id: 'form', title : caller=='BarCodeSet!BATCH'?'条码产生规则维护':'包装箱号产生规则维护', frame : true, layout: 'column', autoScroll : true, defaultType : 'textfield', labelSeparator : ':', buttonAlign : 'center', cls: 'u-form-default', enableTools: true, fieldDefaults : { fieldStyle : "background:#FFFAFA;color:#515151;", focusCls: 'x-form-field-cir-focus', labelAlign : "right", msgTarget: 'side', blankText : $I18N.common.form.blankText }, //requires: ['erp.view.common.JProcess.SetNodeGridPanel','erp.view.oa.task.TaskPanel'], FormUtil: Ext.create('erp.util.FormUtil'), BaseUtil: Ext.create('erp.util.BaseUtil'), items : [{ xtype : "container", html : '
'+(caller=='BarCodeSet!BATCH'?"P+V+D+N":"P+N")+'
', columnWidth:1, style:"padding-bottom: 4px;" },{ allowBlank:false, allowDecimals:false, cls:"form-field-allowBlank-hidden", columnWidth:0.25, dataIndex:"bs_id", editable:true, fieldLabel:"ID", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_id", labelAlign:"left", name:"bs_id", readOnly:true, table:"BarcodeSet", xtype:"hidden" },{ allowBlank:false, allowDecimals:false, cls:"form-field-allowBlank-hidden", columnWidth:0.25, dataIndex:"bs_type", editable:true, fieldLabel:"类型", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_type", labelAlign:"left", name:"bs_type", readOnly:true, value : formCondition.split("=")[1].replace(/'/g,""), table:"BarcodeSet", xtype:"hidden" },{ allowBlank:false, allowDecimals:false, cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_lenprid", editable:true, fieldLabel:"物料长度(P)", fieldStyle:"background:#FFFAFA;color:#515151;", id:"bs_lenprid", labelAlign:"left", name:"bs_lenprid", table:"BarcodeSet", xtype:"numberfield" },{ allowBlank:false, allowDecimals:false, cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_lenveid", editable:true, fieldLabel:"供应商长度(V)", fieldStyle:"background:#FFFAFA;color:#515151;", id:"bs_lenveid", labelAlign:"left", name:"bs_lenveid", table:"BarcodeSet", xtype:caller=='BarCodeSet!BATCH'?"numberfield":"hidden" },{ allowBlank:true, allowDecimals:false, cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_datestr", displayField: 'display', valueField: 'value', editable:true, fieldLabel:"日期信息(D)", fieldStyle:"background:#FFFAFA;color:#515151;", id:"bs_datestr", labelAlign:"left", name:"bs_datestr", table:"BarcodeSet", xtype:caller=='BarCodeSet!BATCH'?"combo":"hidden", store:Ext.create("Ext.data.Store",{ fields:["display","value"], data : [{display: "YYMMDD", value: "YYMMDD"}, {display: "YYMM", value: "YYMM"}, {display: "MMDD", value: "MMDD"}, {display: "无", value: "0"}] }) },{ allowBlank:true, allowDecimals:false, cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_lennum", editable:true, fieldLabel:"流水长度(N)", fieldStyle:"background:#FFFAFA;color:#515151;", id:"bs_lennum", labelAlign:"left", name:"bs_lennum", table:"BarcodeSet", xtype:"numberfield" },{ xtype : "container", html : '
其他信息
', columnWidth:1, style:"padding-bottom: 4px;" },{ cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_maxnum", editable:true, fieldLabel:"当前流水", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_maxnum", labelAlign:"left", name:"bs_maxnum", readOnly:true, table:"BarcodeSet", value:"0", xtype:"textfield" },{ cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_totallen", editable:true, fieldLabel:"总长度", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_totallen", labelAlign:"left", name:"bs_totallen", readOnly:true, table:"BarcodeSet", value:"", xtype:"numberfield" },{ cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_recorder", editable:true, fieldLabel:"录入人", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_recorder", labelAlign:"left", name:"bs_recorder", readOnly:true, table:"BarcodeSet", value:"", xtype:"textfield" },{ cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_date", editable:true, fieldLabel:"录入日期", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_date", labelAlign:"left", name:"bs_date", readOnly:true, table:"BarcodeSet", value:"", xtype:"datefield" },{ cls:"form-field-allowBlank", columnWidth:0.25, dataIndex:"bs_maxdate", editable:true, fieldLabel:"上次日期", fieldStyle:"background:#E0E0FF;color:#515151;", id:"bs_maxdate", labelAlign:"left", name:"bs_maxdate", readOnly:true, table:"BarcodeSet", value:"", xtype:caller=='BarCodeSet!BATCH'?"textfield":"hidden" }], buttonAlign:'center', buttons:[{ xtype: 'erpSaveButton', id:"saveButton" },{ xtype: 'erpUpdateButton', id:"updateButton" },{ xtype: 'erpCloseButton', id:'close' }], initComponent : function(){ var me = this; me.FormUtil=Ext.create('erp.util.FormUtil'); me.GridUtil=Ext.create('erp.util.GridUtil'); me.BaseUtil=Ext.create('erp.util.BaseUtil'); formCondition = getUrlParam('formCondition'); this.getData(); this.callParent(arguments); if(this.enableTools) { me.setTools(); } }, /** * FormHeader Tools * 包括:查看日志、查看流程、查看列表、最大化、最小化、刷新、关闭、上一条、下一条 */ setTools: function(){ var datalistId = getUrlParam('datalistId'); this.tools = [{ type: 'search', tooltip: '查看单据日志', listeners:{ click: function(btn){ var form = Ext.getCmp('form'); var id = Ext.getCmp(form.keyField).value; if(id != null && id != 0){ form.getLogs(id); } } } },{ type: 'save', tooltip: '导出Excel', listeners:{ click: function(btn){ var form = Ext.getCmp('form'); var id = Ext.getCmp(form.keyField).value; form.saveAsExcel(id,caller); } } },{ type: 'maximize', tooltip: '最大化', listeners:{ click: function(btn){ var height = window.screen.height*0.87; var width = window.screen.width; //弹出框显示,可以锁定住地址栏和工具栏,防止用户不合理操作 window.open(window.location.href, '', 'width=' + width + ',height=' + height + ',top=0,left=0,toolbar=no, menubar=no, scrollbars=no, resizable=no,location=no, status=no'); } } },{ type: 'minus', tooltip: '最小化', listeners:{ click: function(btn){ var p = parent.Ext.getCmp('content-panel'); if(p){ var t = p.getActiveTab(); var b = parent.Ext.getCmp('bottom'); if(b){ b.insert(4, { text: t.title, tooltip: t.tabConfig.tooltip, tab: t, handler: function(btn){ var a = p.add(btn.tab); p.setActiveTab(a); btn.destroy(); } }); p.remove(t, false);//并不销毁 } } } } },{ type: 'refresh', tooltip: '刷新', listeners:{ click: function(btn){ var form = btn.up('form'); if(typeof form.refresh === 'function') form.refresh.call(null, form); else window.location.reload(); } } }]; }, /** * 拿到操作日志 */ getLogs: function(id){ if(Ext.getCmp('win' + id)){ Ext.getCmp('win' + id).show(); } else { Ext.Ajax.request({//拿到grid的columns url : basePath + 'common/getMessageLogs.action', async: false, params: { caller: caller, id: id }, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exception || res.exceptionInfo){ showError(res.exceptionInfo); return; } var logs = res.logs; logs = logs.length == 0 ? [{ml_date: $I18N.common.grid.emptyText, ml_man: $I18N.common.grid.emptyText, ml_content: $I18N.common.grid.emptyText, ml_result: $I18N.common.grid.emptyText}] : logs; Ext.create('Ext.window.Window', { id : 'win' + id, title: '操作日志', iconCls: 'x-button-icon-set', closeAction: 'hide', height: "100%", width: "80%", maximizable : true, buttonAlign : 'center', layout : 'anchor', items: [{ anchor: '100% 100%', xtype: 'gridpanel', ignore: true, bodyStyle: 'background:#f1f1f1;', autoScroll: true, store: Ext.create('Ext.data.Store', { fields: ['ml_date', 'ml_man', 'ml_content', 'ml_result'], data: logs }), columnLines: true, columns: [ { header: '时间', dataIndex: 'ml_date', flex: 1.5 , renderer: function(val){ if(val != '无数据'){ return Ext.Date.format(new Date(val), 'Y-m-d H:i:s'); } }}, { header: '操作人员', dataIndex: 'ml_man', flex: 1 ,renderer: function(val){ if(val == em_name){ return '' + val + ''; } else { return val; } }}, { header: '操作', dataIndex: 'ml_content', flex: 1.5}, { header: '结果', dataIndex: 'ml_result', flex: 3} ] }], buttons : [{ text : '关 闭', iconCls: 'x-button-icon-close', cls: 'x-btn-gray', handler : function(){ Ext.getCmp('win' + id).close(); } }] }).show(); } }); } }, saveAsExcel:function(id,caller){ if(id==null || id =='') showMessage('提示','无法导出空数据单据',1000); else window.location.href=basePath+'excel/savePanelAsExcel.action?id='+id+"&caller="+caller+"&_noc=1"; }, getData:function(){ var me = this; //从url解析参数 if(formCondition != null && formCondition != ''){ Ext.Ajax.request({ url : basePath + 'scm/reserve/getBarcodeRuleData.action', params: { caller: caller, condition: formCondition.split("&")[0], _noc: (getUrlParam('_noc') || me._noc) }, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exceptionInfo != null){ showError(res.exceptionInfo);return; }else{ Ext.getCmp("saveButton").hide(); me.setFormValues(res.data); } } }); }else{ Ext.Ajax.request({ url : basePath + "scm/reserve/getCurrent.action", params: {}, method : 'post', callback : function(options,success,response){ var res = new Ext.decode(response.responseText); if(res.exceptionInfo != null){ showError(res.exceptionInfo);return; } if(res.man&&res.date){ Ext.getCmp("bs_recorder").setValue(res.man); Ext.getCmp("bs_date").setValue(res.date); } } }); Ext.getCmp("updateButton").hide(); } }, setFormValues : function(data){ var form = Ext.getCmp('form'); form.getForm().setValues(data); } });