📄 sysinit.js
字号:
Ext.onReady(function() {
Ext.QuickTips.init();
Ext.form.Field.prototype.msgTarget = 'side';
var rolename;// 在创建用户时需要的角色名称
var corpForm = new Ext.form.FormPanel({
id : 'form1',
name : 'corpForm',
title : '<div style="text-align:left">第一步:创建公司</div>',
frame : true,
renderTo : 'main',
layout : 'form',
defaultType : 'textfield',
labelAlign : 'right',
defaults : {
labelSeparator : ':'
},
items : [{
xtype : 'panel',
layout : 'column',
border : false,
items : [{
/* the first column */
columnWidth : .25,
layout : 'form',
border : false,
defaultType : 'textfield',
items : [{
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 : '单位类型',
emptyText : '选择单位类型...',
blankText : '请选择单位类型!',
width : 125,
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 : '行业',
emptyText : '选择行业...',
blankText : '请选择行业!',
width : 125,
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
}]
}]
}],
buttons : [{
text : '提交',
handler : doSubmit
}, {
text : '重置',
handler : function() {
Ext.MessageBox.confirm('确认提示', '此操作将置空所有内容,你将继续吗?',
function(btn) {
if (btn == "yes")
wizard.items.item('form1').getForm()
.reset();
});
}
}]
});
function doSubmit() {
if (corpForm.getForm().isValid()) {
corpForm.getForm().submit({
url : 'new.do?type=corp',
method : 'POST',
waitTitle : '提示',
waitMsg : '正在处理您的请求,请稍候...',
success : function(form, action) {
try {
/*
* 候选方法:手动解析Json数据 var jsonobject =
* Ext.util.JSON.decode(action.response.responseText);//将返回的JSON数据转换成JSON对象,转换失败即报错.
* Ext.Msg.alert("msg,oject",jsonobject.message);//用JSON对象获取JSON数据的值
*/
var flag = action.result.success;
if (flag === false) {
Ext.Msg.alert('提示', action.result.message);
} else if (flag === true) {
Ext.Msg.alert('提示', action.result.message);
wizard.getBottomToolbar().enable();
}
} catch (e) {
Ext.MessageBox.alert('提示',
'对不起,您无法连接系统,如果您的网络正常,请联系系统管理员!' + '\n'
+ e.toString());
}
},
failure : function(form, action) {
/* corpForm.disable(); */
try {
Ext.MessageBox.alert('提示', action.result.message);
} catch (e) {
Ext.MessageBox.alert('提示',
'对不起,您无法连接系统,如果您的网络正常,请联系系统管理员');
}
}
});
}
}
var userForm = new Ext.form.FormPanel({
id : 'form2',
title : '<div style="text-align:left">第二步:创建用户</div>',
frame : true,
renderTo : 'main',
labelAlign : 'right',
buttonAlign : 'left',
defaults : {
labelSeparator : ':'
},
bodyStyle : 'padding:5px 5px 0',
items : [{
id : 'user_fieldset',
name : 'userinfo',
title : '用户信息',
xtype : 'fieldset',
defaultType : 'textfield',
collapsible : false,
autoHeight : true,
defaults : {
width : 200
},
anchor : '30%',
items : [{
name:'usertype',
fieldLabel : '用户类型',
value : 'sysadmin',
readOnly : true
}, {
name : 'username',
fieldLabel : '用户名',
vtype : 'alphanum',
allowBlank : false
}, {
name : 'pwd',
fieldLabel : '密码',
inputType : 'password',
vtype : 'alphanum',
allowBlank : false
}, {
name : 'email',
fieldLabel : 'Email',
vtype : 'email'
}, {
name : 'userduty',
fieldLabel : '用户职责',
xtype : 'textarea'
},{
name:'isemp',
hidden:true,
hideLabel:true,
value:false
},{
name:'pkEmp',
hidden:true,
hideLabel:true,
value:null
}]
}],
buttons : [{
text : '提交',
handler : function() {
if (userForm.getForm().isValid()) {
userForm.getForm().submit({
url : 'newUser.do',
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);
window.location.href = "login.jsp";
}
} catch (e) {
Ext.MessageBox.alert('提示',
'对不起,您无法连接系统,如果您的网络正常,请联系系统管理员!'
+ '\n' + e.toString());
}
},
failure : function(form, action) {
try {
Ext.MessageBox.alert('提示',
action.result.message);
} catch (e) {
Ext.MessageBox
.alert('提示',
'对不起,您无法连接系统,如果您的网络正常,请联系系统管理员');
}
}
});
}
}
}, {
text : '重置',
handler : function() {
Ext.MessageBox.confirm('确认提示', '此操作将置空所有内容,你将继续吗?',
function(btn) {
if (btn == "yes")
userForm.getForm().reset();
});
}
}]
});
var wizard = new Ext.Panel({
id : 'wizard',
title : '系统初始化向导',
frame : true,
bodyStyle : 'padding:5px 5px 0 5px',
layout : 'card',
activeItem : 0,
renderTo : 'main',
items : [corpForm, userForm],
bbar : [{
id:'next',
text : '下一步',
disabled : true,// TODO:set to true
handler : function(btn) {
var activeItem = wizard.layout.activeItem;
var index = wizard.items.indexOf(activeItem);
if (activeItem.id == 'form1') {
wizard.layout.setActiveItem(wizard.getComponent(index + 1));
btn.setVisible(false);
btn.disable();
}
}
}]
});
});
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -