You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
DS7/DSWeb/Areas/SysMng/ViewJs/USERINFO/USERINFOEdit.js

434 lines
13 KiB
JavaScript

3 years ago
Ext.namespace('DsTruck');
DsTruck.USERINFOEdit = function (config) {
Ext.applyIf(this, config);
this.initUIComponents();
window.DsTruck.USERINFOEdit.superclass.constructor.call(this);
};
Ext.extend(DsTruck.USERINFOEdit, Ext.Panel, {
ParentWin: null,
OpStatus: 'add',
StoreList: null,
EditRecord: null,
initUIComponents: function () {
this.serialNo = 0;
this.bodyDel = [];
//#region 编辑form
//枚举参照相关(编辑form)
//表参照相关(编辑form)
//编辑form
this.formEdit = Ext.widget('form', {
// layout: "border",
region: 'center', id: "formEdit",
frame: true,
bodyPadding: 2,
trackResetOnLoad: true,
fieldDefaults: {
margins: '1 1 1 1',
labelAlign: 'right',
flex: 5,
//labelWidth: 90,//label标签宽度
msgTarget: 'qtip',
sourcelabelWidth: '100'
//,split:true
},
items: [
{//fieldset 1
xtype: 'fieldset',
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'GID',
name: 'GID',
hidden: true,
flex: 1
}, {
fieldLabel: '姓名',
name: 'SHOWNAME', readOnly: true, flex: 1
}, { xtype: 'hiddenfield', flex: 3 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '英文名',
name: 'USERNAME', flex: 1
}, { xtype: 'hiddenfield', flex: 3 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '旧密码',
name: 'OLDPASSWORD', flex: 1
, inputType: 'password'
}, { xtype: 'hiddenfield', flex: 3 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '新密码',
name: 'PASSWORD', flex: 1
, inputType: 'password'
}, { xtype: 'hiddenfield', flex: 3 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '重复新密码',
name: 'PASSWORD2', flex: 1
, inputType: 'password'
}, { xtype: 'hiddenfield', flex: 3 }
]
}
]//end items(fieldset 1)
}//end fieldset 1
////////////////////////////////
]//end root items
}); //end this.formEdit
//编辑form
this.formBody = Ext.widget('form', {
region: 'center',
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: 'GID',
name: 'GID',
hidden: true,
flex: 1
}, {
fieldLabel: 'USERID',
name: 'USERID',
hidden: true,
flex: 1
}, {
fieldLabel: '办公电话',
name: 'OFFICEPHONE', flex: 1
}, {
fieldLabel: '家庭电话',
name: 'HOMEPHONE', flex: 1
}, { xtype: 'hiddenfield', flex: 2 }
]
}, {
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '手机',
name: 'MOBILE', flex: 1
}, {
fieldLabel: '传真',
name: 'FAX', flex: 1
}, { xtype: 'hiddenfield', flex: 2 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [,{
fieldLabel: '电子邮箱1',
name: 'EMAIL1', flex: 1
}, { xtype: 'hiddenfield', flex: 1 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [, {
fieldLabel: '电子邮箱2',
name: 'EMAIL2', flex: 1
}, { xtype: 'hiddenfield', flex: 1 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: 'QQ',
name: 'QQ', flex: 1
}, { xtype: 'hiddenfield', flex: 1 }
]
},
{
xtype: 'container',
layout: 'hbox',
defaultType: 'textfield',
items: [{
fieldLabel: '家庭住址',
name: 'HOMEADDRESS', flex: 1
}, { xtype: 'hiddenfield', flex: 1 }
]
}
]//end items(fieldset 1)
}//end fieldset 1
////////////////////////////////
]//end root items
}); //end this.formEdit
//#endregion
//#region 按钮Toolbar
this.panelBtn = new Ext.Panel({
region: "north",
tbar: [
{
text: "保存",
iconCls: "btnsave",
handler: function (button, event) {
this.Save('0');
},
scope: this
},
{
text: "保存并关闭",
handler: function (button, event) {
this.Save('1');
},
scope: this
}
]
}); //end 按钮Toolbar
//#endregion
//#region 布局
//控件布局
this.panelTop = new Ext.Panel({
layout: "border",
region: "north",
height: 200,
width: 600,
items: [this.panelBtn, this.formEdit]
});
Ext.apply(this, {
items: [this.panelTop, this.formBody]
});
//#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.LoadData();
}, //end InitData
LoadData: function () {
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SysMng/USERINFO/GetData',
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: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
data.PASSWORD = "";
this.formEdit.getForm().reset();
this.formEdit.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
Ext.Ajax.request({
waitMsg: '正在查询主表数据...',
url: '/SysMng/USERINFO/GetUSERINFOData',
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: '提示',
msg: result.Message,
icon: Ext.MessageBox.ERROR,
buttons: Ext.Msg.OK
});
return;
}
var data = result.data;
this.formBody.getForm().reset();
this.formBody.getForm().setValues(data);
} else {
Ext.MessageBox.alert('请求出现错误,请重试', response.responseText);
}
},
scope: this
});
}, // end LoadDate
Save: function (type) {
var basicForm = this.formEdit.getForm();
var BodyForm = this.formBody.getForm();
if (!basicForm.isValid()) {
return;
}
//判断表格数据是否合法
/*
if (!validateEditorGridPanel(this.gridList)) {
return;
}
if (!this.checkedit()) {
return;
}*/
var data = basicForm.getValues();
if (data.OLDPASSWORD != "" && (data.PASSWORD == "" || data.PASSWORD2 == "")) {
alert("密码不能为空");
return;
}
if (data.PASSWORD != "" || data.PASSWORD2 != "") {
if (data.PASSWORD != data.PASSWORD2) {
alert("两个新密码内容不同");
return;
}
}
var bodydatas = [];
var bodyDel = [];
var member = Ext.create('USERmb', "");
member.data = BodyForm.getValues();
bodydatas.push(member);
var jsonBody = ConvertRecordsToJsonAll(bodydatas);
var jsonDelBody = ConvertRecordsToJsonAll(bodyDel);
Ext.Msg.wait('正在保存数据, 请稍侯..');
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SysMng/USERINFO/Save',
scope: this,
params: {
opstatus: this.opStatus,
data: Ext.JSON.encode(data),
body: jsonBody,
Delbody: jsonDelBody
},
callback: function (options, success, response) {
if (success) {
Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
} else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
} else {
Ext.Msg.show({ title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
}
});
} //end save
});