📄 nav_corp.js
字号:
Ext.onReady(function() {
var corpForm = new Ext.form.FormPanel({
id : 'form1',
name : 'corpForm',
frame : true,
closeAction:'hide',//保证关闭之后再次点击树节点能够再次显示此界面
renderTo : 'tab_nav_corp',
layout : 'form',
defaultType : 'textfield',
labelAlign : 'right',
labelWidth:80,
defaults : {
labelSeparator : ':'
},
items : [{
xtype : 'panel',
layout : 'column',
border : false,
items : [{
/* the first column */
columnWidth : .25,
layout : 'form',
border : false,
defaultType : 'textfield',
items : [{
id : 'corp_name',
name : 'name',
fieldLabel : '单位名称',
allowBlank : false
}, {
name : 'regicode',
fieldLabel : '注册编号'
}, {
name : 'addr',
fieldLabel : '单位地址'
}, {
name : 'tel',
fieldLabel : '联系电话'
}]
}, {
/* The Second column */
columnWidth : .25,
layout : 'form',
border : false,
defaultType : 'textfield',
items : [new Ext.form.ComboBox({
hiddenName : 'corptype',
xtype : 'combo',
fieldLabel : '单位类型',
blankText : '请选择单位类型!',
width : 110,
mode : 'local',
store : new Ext.data.SimpleStore({
fields : ['abbr',
'name'],
data : Ext.refers.corpType
}),
displayField : 'name',
valueField : 'abbr',
loadingText : '加载中...',
typeAhead : true,
forceSelection : true,
selectOnFocus : true,
triggerAction : 'all'
}), {
name : 'regicapital',
fieldLabel : '注册资本'
}, {
name : 'postcode',
fieldLabel : '邮政编码'
}, {
name : 'tel2',
fieldLabel : '联系电话2'
}]
}, {
/* the third column */
columnWidth : .25,
layout : 'form',
border : false,
defaultType : 'textfield',
items : [new Ext.form.ComboBox({
hiddenName : 'industry',
xtype : 'combo',
fieldLabel : '行业',
blankText : '请选择行业!',
width : 110,
mode : 'local',
store : new Ext.data.SimpleStore({
fields : ['abbr',
'name'],
data : Ext.refers.industry
}),
displayField : 'name',
valueField : 'abbr',
loadingText : '加载中...',
typeAhead : true,
forceSelection : true,
selectOnFocus : true,
triggerAction : 'all'
}), {
name : 'website',
fieldLabel : '公司网站',
vtype : 'url'
}, {
name : 'fax',
fieldLabel : '传真'
}]
}, {
/* the fourth column */
columnWidth : .25,
layout : 'form',
border : false,
defaultType : 'textfield',
items : [{
name : 'legelperson',
fieldLabel : '法人代表'
}, {
name : 'regiorg',
fieldLabel : '注册机关'
}, {
name : 'email',
fieldLabel : 'eMail',
vtype : 'email'
}]
}]
}, {
xtype : 'panel',
layout : 'column',
border : false,
items : [{
columnWidth : 1,
layout : 'form',
border : false,
items : [{
name : 'content',
fieldLabel : '经营内容',
xtype : 'textarea',
width : 700
}, {
name : 'goal',
fieldLabel : '单位目标',
xtype : 'textarea',
width : 700
}, {
name : 'devcourse',
fieldLabel : '发展历程',
xtype : 'textarea',
width : 700
}, {
name : 'honor',
fieldLabel : '所获荣誉',
xtype : 'textarea',
width : 700
}]
}]
}],
reader : new Ext.data.JsonReader({
root : 'data'
}, [{
name : 'name',
mapping : 'name',
type : 'string'
}, {
name : 'addr',
mapping : 'addr',
type : 'string'
}, {
name : 'postcode',
mapping : 'postcode',
type : 'string'
}, {
name : 'legalperson',
mapping : 'legalperson',
type : 'string'
}, {
name : 'regicode',
mapping : 'regicode',
type : 'string'
}, {
name : 'regicapital',
mapping : 'regicapital',
type : 'string'
}, {
name : 'regiorg',
mapping : 'regiorg',
type : 'string'
}, {
name : 'corptype',
mapping : 'corptype',
type : 'string'
}, {
name : 'industry',
mapping : 'industry',
type : 'string'
}, {
name : 'website',
mapping : 'website',
type : 'string'
}, {
name : 'email',
mapping : 'email',
type : 'string'
}, {
name : 'tel',
mapping : 'tel',
type : 'string'
}, {
name : 'tel2',
mapping : 'tel2',
type : 'string'
}, {
name : 'fax',
mapping : 'fax',
type : 'string'
}]),
tbar : [{
id : 'edit_corp',
text : '修改',
handler : function(btn) {
btn.disable();
var fields = getFields(corpForm);
if ((fields != null) && (fields.length != 0)) {
for (var i = 0;i < fields.length;i++) {
fields[i].enable();
}
corpForm.findById('corp_name').disable();
}
var saveBtn = Ext.getCmp('save_corp');
saveBtn.enable();
}
}, {
id : 'save_corp',
text : '保存',
disabled : true,
handler : function(btn) {
if (corpForm.form.isValid()) {
corpForm.form.submit({
url : 'update.do?type=corp',
method : 'POST',
waitText : '正在处理你的请求...',
success : function(form, action) {
try {
var flag = action.result.success;
if (flag === false) {
Ext.Msg
.alert(
'提示',
action.result.message);
} else if (flag === true) {
Ext.Msg
.alert(
'提示',
action.result.message);
}
} catch (e) {
e.toString();
}
},
failure : function(form, action) {
try {
Ext.MessageBox.alert('提示',
action.result.message);
} catch (e) {
e.toString();
}
}
});
}
}
}, '-']
});
corpForm.form.load({
url : 'getCorp.do',
method : 'GET',
success : function(form, action) {
var fields = getFields(corpForm);
var fieldstr = '';
if ((fields != null) && (fields.length != 0)) {
for (var i = 0; i < fields.length; i++) {
fieldstr += ' ' + fields[i].getName();
fields[i].disable();
}
}
},
failure : function(form, action) {
Ext.Msg.alert('提示', '加载失败!');
}
});
});
function getFields(fPanel) {
var textArray = fPanel.findByType('textfield');
var comboArray = fPanel.findByType('combo');
var dateArray = fPanel.findByType('datefield');
var areaArray = fPanel.findByType('textarea');
var fieldsArray = new Array();
fieldsArray = textArray.concat(comboArray,dateArray,areaArray);
return fieldsArray;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -