?? userinfouser.js
字號:
// 用戶管理
Ext.namespace("CRM.userinfoManage");
function showEditUserinfoWin() {
var panel = new userinfoUserPanel();
panel.edit();
}
function showDelUserinfoWin() {
var panel = new userinfoUserPanel();
panel.removeData();
}
// 存儲器
var userinfoUserStore = new Ext.data.JsonStore({
url : 'userinfo.do?actionType=doList',
root : "data",// 數(shù)據(jù)源
totalProperty : "rowCount",// 總行數(shù)
// 參數(shù)
baseParams : {
usrName : null,
roleId : null
},
remoteSort : true,
fields : ["usrId", "usrName", "usrPassword", "usrRoleId", "usrFlag",
"roleName", "rightText"]
});
var rightTextStore = new Ext.data.JsonStore({
url : 'userinfo.do?actionType=doFindAllRight',
method : 'POST',
root : 'data',
totalProperty : 'rowCount',
fields : ['rightCode', 'rightText']
})
var userinfoUserColm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : '用戶編號',
sortable : true,
dataIndex : 'usrId',
width : 167
}, {
header : '用戶名稱',
sortable : true,
dataIndex : 'usrName',
width : 167
}, {
header : '角色名稱',
sortable : true,
dataIndex : 'roleName',
width : 167
}, {
header : '權(quán)限名稱',
sortable : true,
dataIndex : 'rightText',
width : 167
}, {
header : '操作',
dataIndex : 'chcStatus',
width : 160,
renderer : function() {
var operation = '';
operation += ' ';
operation += '<img src="images/bt_edit.gif" title="編輯" onclick="showEditUserinfoWin()"/>'
operation += ' '
+ '<img src="images/bt_del.gif" title="刪除" onclick="showDelUserinfoWin()">';
return operation;
}
}]);
// 建立數(shù)據(jù)源,用來加載角色名稱
var DateStore = new Ext.data.JsonStore({
url : 'userinfo.do?actionType=doFindAllRole',
method : 'POST',
root : 'data',
totalProperty : 'rowCount',
fields : ['roleName', 'roleId']
});
// 表格
var userinfoUserGrid = new Ext.grid.GridPanel({
store : userinfoUserStore,
cm : userinfoUserColm,
height : 300,
stripeRows : true,
pageSize : 15,
loadMask : true,
tbar : [{
text : '添加',
id : 'add',
iconCls : 'add',
pressed : false,
handler : function() {
var panel = new userinfoUserPanel();
panel.create();
},
scope : this
}, new Ext.Toolbar.Fill(), '用戶名稱', {
xtype : 'textfield',
name : 'usrName',
width : 150
}, ' ', '角色名稱', {
xtype : "combo",
hiddenName : 'roleId',
width : 150,
store : DateStore,
displayField : 'roleName',
valueField : 'roleId',
forceSelection : true,
triggerAction : 'all',
emptyText : '--請選擇--',
editable : true
}, {
text : '查詢',
iconCls : 'search',
pressed : true,
handler : function() {
var panel = new userinfoUserPanel();
panel.search();
},
scope : this
}, ' '],
bbar : new Ext.PagingToolbar({
pageSize : 15,
store : userinfoUserStore,
grid : userinfoUserGrid,
displayInfo : true,
displayMsg : '當(dāng)前顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
// 自定義
CRM.userinfoManage.userinfoUser = Ext.extend(Ext.Panel, {
closable : true,
autoScroll : true,
layout : "fit",
maskDisabled : false,
gridViewConfig : {
animate : true
},
initWin : function(width, height, title) {
var win = new Ext.Window({
width : width,
height : height,
buttonAlign : "center",
title : title,
modal : true,
closeAction : "hide",
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : "保存",
handler : this.save,
tooltip : '點擊該按鈕將執(zhí)行確認(rèn)操作',
scope : this
}, {
text : "清空",
handler : this.reset,
scope : this
}, {
text : "取消",
id : 'cancel',
handler : function() {
this.closeWin();
},
scope : this
}]
});
return win;
},
showWin : function() {
if (!this.win) {
if (!this.fp) {
this.fp = this.createForm();
}
this.win = this.createWin();
this.win.on("close", function() {
this.win = null;
this.fp = null;
}, this);
}
this.win.show();
},
// 新建
create : function() {
this.showWin();
this.reset();
},
// 重置
reset : function() {
if (this.win)
this.fp.form.reset();
},
// 關(guān)閉
closeWin : function() {
if (this.win)
this.win.close();
this.win = null;
},
// 查詢
search : function() {
userinfoUserStore.baseParams.usrName = Ext.get('usrName').getValue();
userinfoUserStore.baseParams.roleId = Ext.get('roleId').getValue();
userinfoUserStore.load({
params : {
start : 0,
limit : 15
}
});
},
// 編輯
edit : function() {
var record = userinfoUserGrid.getSelectionModel().getSelected();
if (!record) {
Ext.Msg.alert("提示", "請選擇要編輯的行!");
return;
}
this.showWin();
this.fp.form.loadRecord(record);
},
// 保存
save : function() {
if (this.fp.form.isValid()) {
this.fp.form.submit({
waitTitle : '請稍候',
waitMsg : '正在保存......',
url : 'userinfo.do?actionType=doSaveorUpdate',
method : 'POST',
success : function(form, action) {
Ext.Msg.alert("系統(tǒng)消息", action.result.msg, function() {
this.closeWin();
userinfoUserStore.reload();
}, this);
},
failure : function(form, action) {
Ext.Msg.alert('系統(tǒng)消息', action.result.msg);
},
scope : this
});
}
},
// 刪除
removeData : function() {
var record = userinfoUserGrid.getSelectionModel().getSelected();
if (!record) {
Ext.Msg.alert("提示", "請先選擇要刪除的行!");
return;
}
Ext.MessageBox.confirm("確認(rèn)刪除", "確認(rèn)刪除所選數(shù)據(jù)?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url : this.baseUrl + '?actionType=doDel',
params : {
usrId : record.get("usrId")
},
method : 'POST',
success : function(response) {
Ext.Msg.alert("提示信息", response.responseText,
function() {
userinfoUserStore.reload();
}, this);
},
scope : this
});
}
}, this);
},
initComponent : function() {
CRM.userinfoManage.userinfoUser.superclass.initComponent.call(this);
// 右擊表格事件
userinfoUserGrid.addListener("rowContextmenu", this.showMenu, this);
// 數(shù)據(jù)載
userinfoUserStore.load({
params : {
start : 0,
limit : 15
}
});
DateStore.load();
rightTextStore.load({
params : {
start : 0,
limit : 10
}
});
this.add(userinfoUserGrid);
}
});
// 用戶管理面板
userinfoUserPanel = Ext.extend(CRM.userinfoManage.userinfoUser, {
id : 'userinfoUser',
baseUrl : 'userinfo.do',
createForm : function() {
var formPanel = new Ext.form.FormPanel({
labelWidth : 80,
frame : true,
autoHeight : true,
resizable : false,
labelAlign : 'right',
defaultType : 'textfield',
items : [{
xtype : 'fieldset',
title : ' ',
autoHeight : true,
items : [{
layout : 'form',
border : false,
columnWidth : .5,
defaultType : 'textfield',
items : [{
name : 'usrName',
fieldLabel : '用戶名稱',
allowBlank : false,
blankText : '用戶名稱為必填項'
}, {
name : 'usrPassword',
inputType : 'password',
fieldLabel : '用戶密碼',
allowBlank : false,
blankText : '用戶密碼為必填項'
}, {
xtype : 'hidden',
name : 'usrId'
}, {
hiddenName : 'roleName',
xtype : 'combo',
fieldLabel : '角色名稱',
width : 125,
allowBlank : false,
blankText : '角色名稱為必填項',
store : DateStore,
displayField : 'roleName',
valueField : 'roleId',
forceSelection : true,
triggerAction : 'all',
editable : false
}, {
name : 'usrFlag',
fieldLabel : '標(biāo)記',
allowBlank : false,
blankText : '標(biāo)記為必填項',
width : 125
}]
}]
}]
});
return formPanel;
},
createWin : function() {
return this.initWin(280, 220, '用戶信息管理');
},
initComponent : function() {
userinfoUserPanel.superclass.initComponent.call(this);
}
});
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -