/**
* softVersionLib的Form
*/
Ext.define('erp.view.scm.product.SoftVersionLibForm',{
extend: 'Ext.form.Panel',
alias: 'widget.erpSoftVersionLibForm',
id: 'form',
title : '软件版本维护',
frame : true,
layout: 'column',
autoScroll : true,
defaultType : 'textfield',
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
},
FormUtil: Ext.create('erp.util.FormUtil'),
BaseUtil: Ext.create('erp.util.BaseUtil'),
items : [{
allowBlank:false,
allowDecimals:false,
cls:"form-field-allowBlank-hidden",
columnWidth:0.25,
dataIndex:"sl_id",
editable:true,
fieldLabel:"ID",
fieldStyle:"background:#E0E0FF;color:#515151;",
id:"sl_id",
labelAlign:"left",
name:"sl_id",
readOnly:true,
table:"SoftVersionLib",
xtype:"hidden"
},{
allowBlank:false,
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_code",
editable:true,
fieldLabel:"版本号",
labelSeparator : ":",
fieldStyle:"background:#FFFAFA;color:#515151;",
id:"sl_code",
labelAlign:"left",
name:"sl_code",
table:"SoftVersionLib",
xtype:"textfield"
},{
allowBlank:false,
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_name",
editable:true,
fieldLabel:"版本名称",
labelSeparator : ":",
fieldStyle:"background:#FFFAFA;color:#515151;",
id:"sl_name",
labelAlign:"left",
name:"sl_name",
table:"SoftVersionLib",
xtype:"textfield"
},{
allowBlank:true,
allowDecimals:false,
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_platform",
editable:true,
fieldLabel:"平台",
fieldStyle:"background:#FFFAFA;color:#515151;",
labelSeparator : ":",
id:"sl_platform",
labelAlign:"left",
name:"sl_platform",
table:"SoftVersionLib",
xtype:"textfield"
},{
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_status",
editable:true,
fieldLabel:"状态",
labelSeparator : ":",
fieldStyle:"background:#E0E0FF;color:#515151;",
id:"sl_status",
labelAlign:"left",
name:"sl_status",
readOnly:true,
table:"SoftVersionLib",
value:"在录入",
xtype:"textfield"
},{
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_inman",
editable:true,
fieldLabel:"录入人",
labelSeparator : ":",
fieldStyle:"background:#E0E0FF;color:#515151;",
id:"sl_inman",
labelAlign:"left",
name:"sl_inman",
readOnly:true,
table:"SoftVersionLib",
value:"",
xtype:"textfield"
},{
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_indate",
editable:true,
fieldLabel:"录入日期",
labelSeparator : ":",
fieldStyle:"background:#E0E0FF;color:#515151;",
id:"sl_indate",
labelAlign:"left",
name:"sl_indate",
readOnly:true,
table:"SoftVersionLib",
value:"",
xtype:"datefield"
},{
cls:"form-field-allowBlank",
columnWidth:0.25,
dataIndex:"sl_statuscode",
editable:true,
fieldLabel:"状态码",
id:"sl_statuscode",
labelAlign:"left",
name:"sl_statuscode",
table:"SoftVersionLib",
value:"ENTERING",
xtype:"hidden"
},{
cls:"form-field-allowBlank",
columnWidth:0.5,
dataIndex:"sl_remark",
editable:true,
fieldLabel:"备注",
fieldStyle:"background:#FFFAFA;color:#515151;",
id:"sl_remark",
labelAlign:"left",
name:"sl_remark",
table:"SoftVersionLib",
value:"",
xtype:"textfield"
}],
buttonAlign:'center',
buttons:[{
xtype: 'erpAddButton',
id:"addButton"
},{
xtype: 'erpSaveButton',
id:"saveButton"
},{
xtype: 'erpUpdateButton',
id:"updateButton"
},{
xtype: 'erpEnableButton',
id:"enableButton"
},{
xtype: 'erpForBiddenButton',
id:"forbiddenButton"
},{
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: 'expand',
tooltip: '查看流程处理',
listeners:{
click: function(btn){
var form = btn.ownerCt.ownerCt;
if(!form.statuscodeField){
btn.disable(true);
} else {
var f = form.statuscodeField;
if(!Ext.getCmp(f) || Ext.getCmp(f).value == 'ENTERING'){
btn.disable(true);
} else {
var id = Ext.getCmp(form.keyField).value;
if(id != null && id != 0){
form.getProcess(id);
}
}
}
}
}
},{
type: 'gear',
tooltip: '设置流程处理人',
listeners:{
click: function(btn){
var form = btn.ownerCt.ownerCt;
if(!form.statuscodeField){
btn.disable(true);
} else {
var f = form.statuscodeField;
if(!Ext.getCmp(f) || Ext.getCmp(f).value == 'ENTERING'){
btn.disable(true);
} else {
var id = Ext.getCmp(form.keyField).value;
if(id != null && id != 0){
form.SetNodeDealMan(id);
}
}
}
}
}
},{
type: 'collapse',
tooltip: '查看列表',
listeners:{
click: function(btn){
if(parent.Ext) {
Ext.Ajax.request({
url: basePath + 'common/getFieldData.action',
params: {
caller: 'Datalist',
field: 'count(*)',
condition: 'dl_caller=\'' + caller + '\''
},
callback: function(opt, s, r) {
var rs = Ext.decode(r.responseText);
if(rs.exceptionInfo) {
showError(localJson.exceptionInfo);return null;
} else if(rs.success && rs.data){
var datalist = parent.Ext.getCmp(datalistId);
if(!datalist){
var form = btn.ownerCt.ownerCt;
var url = 'jsps/common/datalist.jsp?whoami=' + caller;
if(btn.urlcondition){
url += '&urlcondition=' + btn.urlcondition;
}
form.FormUtil.onAdd(caller + '_scan', parent.Ext.getCmp('content-panel').getActiveTab().title + 'DataList', url);
} else {
datalist.ownerCt.setActiveTab(datalist);
}
}
}
});
}
}
}
},{
type: 'restore',
tooltip: '关联查询',
listeners:{
click: function(btn){
var form = btn.ownerCt.ownerCt;
form.showRelativeQuery();
}
}
},{
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();
}
}
},{
type: 'task',
cls : 'custom-tool',
tooltip: '添加任务',
listeners : {
click : function(btn) {
var form = btn.ownerCt.ownerCt;
if(!form.codeField){
btn.disable(true);
}
else form.addTask(form);
}
}
},{
type:'prev',
id: 'prev',
tooltip: '上一条',
listeners:{
render: function(btn){
if(parent.Ext) {
var datalist = parent.Ext.getCmp(datalistId);
if(datalist){
var datalistStore = datalist.currentStore;
Ext.each(datalistStore, function(){
if(this.selected == true){
if(this.prev == null){
btn.disable(true);
}
}
});
} else {
btn.disable(true);
}
}
},
click: function(btn){
var datalist = parent.Ext.getCmp(datalistId);
if(datalist){
var datalistStore = datalist.currentStore;
var form = Ext.getCmp('form');
var newId = 0;
var idx = 0;
Ext.each(datalistStore, function(s, index){
if(this.selected == true){
if(this.prev != null){
newId = this.prev;
idx = index;
}
}
});
datalistStore[idx].selected = false;
datalistStore[idx-1].selected = true;
var url = window.location.href;
if(form.keyField) {
url = url.replace(/formCondition=(\w*)(IS|=)(\d*)/, 'formCondition=$1$2' + newId);
url = url.replace(/gridCondition=(\w*)(IS|=)(\d*)/, 'gridCondition=$1$2' + newId);
}
window.location.href = url;
}
}
}
},{
type: 'next',
id: 'next',
tooltip: '下一条',
listeners:{
render: function(btn){
if(parent.Ext) {
var datalist = parent.Ext.getCmp(datalistId);
if(datalist){
var datalistStore = datalist.currentStore;
Ext.each(datalistStore, function(){
if(this.selected == true){
if(this.next == null){
btn.disable(true);
}
}
});
} else {
btn.disable(true);
}
}
},
click: function(btn){
var datalist = parent.Ext.getCmp(datalistId);
if(datalist){
var datalistStore = datalist.currentStore;
var form = Ext.getCmp('form');
var newId = 0;
var idx = 0;
Ext.each(datalistStore, function(s, index){
if(s.selected == true){
if(s.next != null){
newId = s.next;
idx = index;
}
}
});
datalistStore[idx].selected = false;
datalistStore[idx+1].selected = true;
var url = window.location.href;
if(form.keyField) {
url = url.replace(/formCondition=(\w*)(IS|=)(\d*)/, 'formCondition=$1$2' + newId);
url = url.replace(/gridCondition=(\w*)(IS|=)(\d*)/, 'gridCondition=$1$2' + newId);
}
window.location.href = url;
}
}
}
},{
type : 'pin',
tooltip : '凭证制作',
listeners : {
click : function(t) {
var form = t.ownerCt.ownerCt;
if (form.voucherConfig) {
form.createVoucher(form.voucherConfig);
}
}
}
},{
type: 'unpin',
tooltip: '使用条例与规则',
listeners:{
click: function(t){
var form = t.ownerCt.ownerCt, foid = form.fo_id;
Ext.Ajax.request({//拿到grid的columns
url : basePath + "common/getFieldData.action",
params: {
caller: 'FormBook',
field: 'fb_content',
condition: "fb_foid='" + foid + "'"
},
method : 'post',
async: false,
callback : function(options,success,response){
var res = new Ext.decode(response.responseText);
if(res.exceptionInfo){
showError(res.exceptionInfo);return;
}
if(res.success){
var win = new Ext.window.Window({
title: '使用条例与规则',
height: "90%",
width: "95%",
maximizable : true,
buttonAlign : 'center',
layout : 'anchor',
items: [{
xtype : 'container',
anchor : '100% 100%',
html : res.data,
style: 'padding: 20px;background: #fff'
}]
});
win.show();
}
}
});
}
}
},{
type:'plus',
tooltip:'单据样例',
listeners:{
click: function(t){
var form = t.ownerCt.ownerCt;
Ext.Ajax.request({//拿到grid的columns
url : basePath + 'common/form/reqDemo.action',
async: false,
params: {
caller: caller
},
method : 'post',
callback : function(options,success,response){
window.open(response.responseText);
//var res = new Ext.decode(response.responseText);
}
});
}
}
},{
type: 'help',
tooltip: '帮助文档',
listeners:{
click: function(t){
var form = t.ownerCt.ownerCt;
form.showHelpWindow();
}
}
}];
},
/**
* 拿到操作日志
*/
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();
}
});
}
},
showHelpWindow:function(){
var me = this,
win = Ext.getCmp('ext-help'),path;
Ext.Ajax.request({
url : basePath + 'ma/help/scan.action',
params: {
caller:caller
},
method : 'get',
async:false,
callback : function(opt, s, res){
var r = new Ext.decode(res.responseText);
if(r.exceptionInfo){
showError(r.exceptionInfo);
} else if(r.success){
path=r.path;
}
}
});
if(!win) {
win = Ext.create('Ext.Window', {
id: 'ext-help',
width: '90%',
height: '100%',
closeAction: 'hide',
title: '帮助文档',
modal:true,
layout: 'border',
items: [{
region:'center',
tag : 'iframe',
layout : 'fit',
html : ''
}]
});
}
win.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/product/getSoftVersionLibData.action',
params: {
caller: caller,
id: formCondition.split("IS")[1],
_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();
if(res.data.sl_statuscode=='ENTERING'){
Ext.getCmp("enableButton").hide();
}else{
Ext.getCmp('sl_code').setReadOnly(true);
Ext.getCmp('sl_code').setFieldStyle("background:#E0E0FF;color:#515151;");
Ext.getCmp('sl_name').setReadOnly(true);
Ext.getCmp('sl_name').setFieldStyle("background:#E0E0FF;color:#515151;");
Ext.getCmp('sl_platform').setReadOnly(true);
Ext.getCmp('sl_platform').setFieldStyle("background:#E0E0FF;color:#515151;");
Ext.getCmp('sl_remark').setReadOnly(true);
Ext.getCmp('sl_remark').setFieldStyle("background:#E0E0FF;color:#515151;");
Ext.getCmp("updateButton").hide();
Ext.getCmp("forbiddenButton").hide();
}
//
me.setFormValues(res.data);
}
}
});
}else{
Ext.Ajax.request({
url : basePath + "scm/product/getNow.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("sl_inman").setValue(res.man);
Ext.getCmp("sl_indate").setValue(res.date);
}
Ext.getCmp("updateButton").hide();
Ext.getCmp("enableButton").hide();
Ext.getCmp("forbiddenButton").hide();
}
});
}
},
setFormValues : function(data){
var form = Ext.getCmp('form');
form.getForm().setValues(data);
}
});