?? rightmanage.js
字號:
// 權限管理
Ext.namespace("CRM.rightManage");
// 編輯。。。。
function showEditWin() {
var panel = new rightManagePanel();
panel.edit();
}
// 刪除。。。。
function showDelWin() {
var panel = new rightManagePanel();
panel.delData();
}
// 存儲器。。。
var rightStort = new Ext.data.JsonStore({
url : 'right.do?actionType=doList',
root : 'data', // 數據源。。
totalProperty : 'rowCount', // 總行數。。。
remoteSort : true,
fields : ["rightCode", "rightText", "rightUrl", "rightTip"]
});
var rightManageColm = new Ext.grid.ColumnModel([new Ext.grid.RowNumberer(), {
header : '編號',
sortable : true,
dataIndex : 'rightCode',
width : 220
}, {
header : '權限',
sortable : true,
dataIndex : 'rightText',
width : 240
}, {
header : '訪問路徑',
sortable : true,
dataIndex : 'rightUrl',
width : 220
}, {
header : '操作',
dataIndex : 'rightTip',
width : 150,
renderer : function() {
return '<img src="images/bt_edit.gif" title="編輯" onclick="showEditWin()">'
+ ' '
+ '<img src="images/bt_del.gif" title="刪除" onclick="showDelWin()">';
}
}]);
var rightManageGrid = new Ext.grid.GridPanel({
store : rightStort,
cm : rightManageColm,
height : 300,
stripeRows : true,
pageSize : 15,
tbar : [{}, {
text : '添加',
iconCls : 'add',
pressed : false,
handler : function() {
var panel = new rightManagePanel();
panel.create();
}
}],
bbar : new Ext.PagingToolbar({
pageSize : 15,
store : rightStort,
grid : rightManageGrid,
displayInfo : true,
displayMsg : '當前顯示 {0} - {1}條記錄 共有 {2} 條記錄',
emptyMsg : "沒有記錄"
})
});
CRM.rightManage.right = Ext.extend(Ext.Panel, {
closable : true,
autoScroll : true,
layout : 'fit',
maskDisabled : false,
girdViewConfig : {
animate : true
},
initWin : function(width, title) {
var win = new Ext.Window({
width : width,
autoHeight : true,
buttonAlign : "center",
title : title,
modal : true,
closeAction : "hide",
resizable : false,
plain : true,
items : [this.fp],
buttons : [{
text : "保存",
handler : this.save,
tooltip : '點擊該按鈕將執行確認操作',
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();
},
// 關閉窗體操作。。。
closeWin : function() {
if (this.win)
this.win.close();
this.win = null;
},
// 編輯
edit : function() {
var record = rightManageGrid.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 : 'right.do?actionType=doSaveorUpdate',
method : 'POST',
success : function(form, action) {
Ext.Msg.alert("系統消息", action.result.msg);
this.closeWin();
rightStort.reload();
},
failure : function(form, action) {
Ext.Msg.alert('系統消息', action.result.msg);
},
scope : this
});
}
},
// 刪除
delData : function() {
var record = rightManageGrid.getSelectionModel().getSelected();
if (!record) {
Ext.Msg.alert("提示", "請先選擇要刪除的行!");
return;
}
Ext.MessageBox.confirm("確認刪除", "確認刪除所選數據?", function(button) {
if (button == "yes") {
Ext.Ajax.request({
url : this.baseUrl + '?actionType=doDel',
params : {
rightCode : record.get("rightCode")
},
method : 'POST',
success : function(response) {
Ext.Msg.alert("提示信息", response.responseText,
function() {
rightStort.reload();
}, this);
},
scope : this
});
}
}, this);
},
initComponent : function() {
CRM.rightManage.right.superclass.initComponent.call(this);
rightStort.load({
params : {
start : 0,
limit : 15
}
});
this.add(rightManageGrid);
}
});
// 權限面板。。。
rightManagePanel = new Ext.extend(CRM.rightManage.right, {
id : 'right',
baseUrl : 'right.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,
defaultType : 'textfield',
columnWidth : .5,
items : [{
xtype : 'hidden',
name : 'rightCode'
}, {
name : 'rightText',
fieldLabel : '權 限',
allowBlank : false,
blankText : '權限不能為空'
}, {
name : 'rightUrl',
fieldLabel : '訪問路徑'
}]
}]
}]
});
return formPanel;
},
createWin : function() {
return this.initWin(300, '權限管理');
},
initComponent : function() {
rightManagePanel.superclass.initComponent.call(this);
}
});
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -