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/SysUserOPRange/SysUserOPRange.js

801 lines
27 KiB
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

Ext.namespace('Shipping');
Shipping.SysUserOPRange = function (config) { //创造函数
Ext.applyIf(this, config);
this.initUIComponents();
window.Shipping.SysUserOPRange.superclass.constructor.call(this);
};
Ext.extend(Shipping.SysUserOPRange, Ext.Panel, {
PageSize: 50,
OprationStatus: null, //仅当弹出界面时使用
SelectedRecord: null,
DEPTNAME:"",
COMPANYID: "",
SELECTUSERID:"",
initUIComponents: function () { //页面初始化函数
_this = this;
//#region 左侧人员列表
Ext.define('ModuleModel', { //公司人员树形图的Model
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'GID', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'DESCRIPTION', type: 'string' },
{ name: 'MODULEURL', type: 'string' },
{ name: 'SORT', type: 'number' },
{ name: 'PARENTID', type: 'string' },
{ name: 'PARENTNAME', type: 'string' },
{ name: 'TYPE', type: 'string' },
{ name: 'leaf', type: 'bool' },
{ name: 'expanded', type: 'bool' }
]
});
this.treestore = new Ext.data.TreeStore({ //树列表数据集
model: 'ModuleModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
timeout: 120000,
url: '/SysMng/SysUser/GetUserTreeRefList',
reader: {
id: 'GID',
root: 'data', //data 对应controller里返回的json里的data
totalProperty: 'totalCount'
}
},
autoLoad: true,
root: {
name: '根节点',
expanded: true,
id: '0'
}
});
var _this = this;
this.tabtree = new Ext.tree.Panel({ //树形图
region: 'west',
title: '分公司/部门信息', //'业务信息',
split: true,
width: 320,
collapsible: true,
margins: '0 0 0 0',
store: this.treestore,
useArrows: true,
rootVisible: false,
hideHeaders: true,
animate: true,
lines: false,
columns: [{
xtype: 'treecolumn',
text: '分公司/部门信息', //'模块名称',
width: 318,
dataIndex: 'DESCRIPTION'
}],
listeners: {
scope: this,
'itemclick': function (_this, record, item, index, e, eOpts) {
if (record.data.TYPE == '0') {
this.COMPANYID = record.data.GID;
this.DEPTNAME = "";
this.SELECTUSERID = "";
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
}
if (record.data.TYPE == '1') {
this.COMPANYID = "";
this.DEPTNAME = record.data.DESCRIPTION;
this.SELECTUSERID = "";
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
}
if (record.data.TYPE == '2') {
this.SELECTUSERID = record.data.GID;
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
}
}
}
});
//#endregion
//#region 模块权限的树形结构
Ext.define('treeModel', {
extend: 'Ext.data.Model',
fields: [
{ name: 'id', type: 'string' },
{ name: 'GID', type: 'string' },
{ name: 'NAME', type: 'string' },
{ name: 'DESCRIPTION', type: 'string' },
{ name: 'MODULEURL', type: 'string' },
{ name: 'SORT', type: 'number' },
{ name: 'PARENTID', type: 'string' },
{ name: 'PARENTNAME', type: 'string' },
{ name: 'TYPE', type: 'string' },
{ name: 'leaf', type: 'bool' },
{ name: 'expanded', type: 'bool' },
//{ name: 'icon', type: 'string' },
{ name: 'checked', type: 'bool' }
]
});
this.UserOPRangeTreestore = new Ext.data.TreeStore({
model: 'treeModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
timeout: 120000,
url: '/SysMng/SysUserOPRange/GetUserOPRangTreeList',
params: { USERID: "1" },
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
},
autoLoad: false,
root: {
name: '根节点',
id: '0',
expanded: true
//,
//loadOnce: true,
//checked: false
}
});
this.Usertabtree = new Ext.tree.Panel({
region: 'center',
//xtype: "nav",
//title: '角色可视模块信息',
//split: true,
//width: 200,
//collapsible: true,
bodyStyle: 'border-width:0 0 0 0;',
margins: '0 0 0 0',
store: this.UserOPRangeTreestore,
useArrows: true,
rootVisible: false,
hideHeaders: true,
animate: true,
lines: true,
columns: [{
xtype: 'treecolumn',
//text: '人员信息', //'模块名称',
width: 318,
dataIndex: 'DESCRIPTION'
}],
listeners: {
"checkchange": function (node, checked, eOpts) {
travelChildrenChecked(node, checked, eOpts);
travelParentUnChecked(node, checked, eOpts);
}
}
});
this.OPRangeTreestore = new Ext.data.TreeStore({
model: 'treeModel',
nodeParam: 'PARENTID',
proxy: {
type: 'ajax',
timeout: 120000,
url: '/SysMng/SysUserOPRange/GetOPRangTreeList',
reader: {
id: 'id',
root: 'data',
totalProperty: 'totalCount'
}
},
//autoLoad: true,
root: {
id: '0',
name: '根节点',
expanded: true,
loadOnce: true,
checked: false
}
});
this.OPRangetabtree = new Ext.tree.Panel({
split: true,
region: 'center',
bodyStyle: 'border-width:0 0 0 0;',
margins: '0 0 0 0',
store: this.OPRangeTreestore,
useArrows: true,
rootVisible: false,
hideHeaders: true,
animate: true,
lines: true,
columns: [{
xtype: 'treecolumn',
//text: '公司结构', //'模块名称',
width: 318,
dataIndex: 'DESCRIPTION'
}],
listeners: {
"checkchange": function (node, checked, eOpts) {
travelChildrenChecked(node, checked, eOpts);
travelParentChecked(node, checked, eOpts);
}
}
});
//#endregion
//#region 添加删除按钮
var btnposition = '0 0 0 0';
this.panelBtn = new Ext.Panel({
layout: "border",
//title: 'test',
region: "east",
width: 31,
bodyStyle: 'border-width:0 0 0 0;'
,
items: [{//fieldset 1
xtype: 'container',
style: {
marginTop: '150px',//距顶部高度
marginLeft: '5px'//,//距左边宽度
//marginBottom: '10px',//距底部高度
//marginRight: '10px'//距右边宽度
},
defaultType: 'textfield',
layout: 'anchor',
defaults: {
anchor: '100%'
},
items: [
{
xtype: 'button',
//text: "tianjia",//添加权限
id:"btnedit_right",
//iconCls: "edit_right",
cls: "arrow_right",
width: 26,
height:24,
handler: function (button, event) {
if (isNullorEmpty(this.SELECTUSERID)) {
alert("请先选择一个用户");
} else {
this.onAddClick(this.OPRangetabtree);
}
},
scope: this
},
{
xtype: 'button',
//text: "shanchu",//从当前用户删除权限
//iconCls: "edit_left",
cls:"arrow_red_left",
width: 26,
height: 24,
handler: function (button, event) {
if (isNullorEmpty(this.SELECTUSERID)) {
alert("请先选择一个用户");
} else {
this.onDeleteClick(this.Usertabtree);
}
},
scope: this
}
]
}]
});
//#endregion
//#region 用于复制权限的组件
//定义数据集
this.storeList = Ext.create('Ext.data.Store', {
model: 'SysUsermb',
remoteSort: true,
pageSize: this.PageSize,
proxy: {
type: 'ajax',
url: '/SysMng/SysUser/GetDataList',
reader: {
idProperty: 'GID',
root: 'data',
totalProperty: 'totalCount'
}
}
});
Ext.grid.RowNumberer = Ext.extend(Ext.grid.RowNumberer, { //此类为一个辅助类它可以传递到Ext.grid.column.Column中作为column列配置项
//并作为一个可以自动生成数字,为每行提供编号的列。
width: 50 //checkbox后面的一个格宽度
});
this.column = [{
sortable: true,
hidden: true,
dataIndex: 'GID', //对应JS的MODEL
header: 'GID',
width: 80
},
{
sortable: true,
dataIndex: 'CODENAME',
header: '代码',
width: 80
},
{
sortable: true,
dataIndex: 'SHOWNAME',
header: '姓名',
width: 80
},
{
sortable: true,
dataIndex: 'COMPANYNAME',
header: '所属分公司',
width: 80
},
{
sortable: true,
dataIndex: 'DEPTNAME',
header: '所属部门',
width: 80
}
];
//#region 定义Grid
this.Pagenum = Ext.create('Ext.form.field.Number', { //页码条
name: 'bottles',
fieldLabel: '每页记录数',
labelAlign: 'right',
value: this.PageSize,
maxValue: 100000,
width: 180,
minValue: 0,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
});
this.MainCB = Ext.create('Ext.selection.CheckboxModel', { checkOnly: true }); //一个选择模式它将渲染一列可以选中或者反选的复选框. 默认选择模型是多选.
this.gridList = new Ext.grid.GridPanel({ //数据列表
store: this.storeList,
enableHdMenu: false,
region: 'center',
loadMask: { msg: "数据加载中,请稍等..." },
trackMouseOver: true,
disableSelection: false,
stripeRows: true,
selModel: this.MainCB,
viewConfig: {
enableTextSelection: true
},
columns: [new Ext.grid.RowNumberer()],
bbar: [Ext.create('Ext.PagingToolbar', {
store: this.storeList,
displayInfo: true,
displayMsg: '当前显示 {0} - {1}条记录 /共 {2}条记录',
emptyMsg: "没有数据"
}), this.Pagenum]
});
this.column.unshift(new Ext.grid.RowNumberer()); //将提供编号的类加到column[]数组最前面
this.gridList.reconfigure(this.storeList, this.column); //用心的store和新的column配置新的grid
//#endregion
//#region combox定义
//所属部门
this.storeDept = Ext.create('DsExt.ux.RefTableStore', {
model: 'DsShipping.ux.DeptModel',
proxy: { url: '/CommMng/BasicDataRef/GetDeptList_All' }
});
//this.storeDept.load();
this.comboxDept = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所属部门',
allowBlank: false,
store: this.storeDept,
labelWidth: 60,
width:200,
forceSelection: true,
name: 'DEPTNAME',
id:'DEPTNAME_SEARCH',
valueField: 'DeptName',
displayField: 'DeptName'
//,hidden: true
});
this.storeCompany = Ext.create('DsExt.ux.RefTableStore', {
model: 'companymb', proxy: { url: '/CommMng/BasicDataRef/GetcompanyList' }
});
this.storeCompany.load({
params: { condition: " ISDISABLE=0 and exists(select 1 from sys_dept where linkid=company.gid) " }
});
this.comboxCompany = Ext.create('DsExt.ux.RefTableCombox', {
fieldLabel: '所属公司',
allowBlank: false,
forceSelection: true,
store: this.storeCompany,
labelWidth: 60,
width: 200,
name: 'COMPANYID',
id: "COMPANYID_SEARCH",
valueField: 'gid',
displayField: 'name',
listeners: {
blur: function (combo, records, field, eOpts) {
_this.storeDept.load({ params: { condition: " linkid='" + combo.value + "'" } });
}
}
});
//#endregion
this.panelBtn_Copy = new Ext.Panel({
region: "north",
tbar: [
this.comboxCompany,
this.comboxDept,
{
id: 'USERNAME_SEARCH',
fieldLabel: '用户名字',
labelWidth: 60,
xtype: 'textfield',
name: 'findtextname',
width: 150,
listeners: {
specialkey: function (field, e) {
if (e.getKey() == e.ENTER) {
_this.onRefreshClick();
}
}
}
},
{
text: "执行查询",
iconCls: "btnrefresh",
handler: function (button, event) {
this.onRefreshClick(button, event);
},
scope: this
},'-',
{
text: "复制权限至选定用户",
iconCls: "btncopy",
handler: function (button, event) {
this.onCopyAuthClick(button, event);
},
scope: this
}
]
});
//#endregion
//布局
this.panelLeft = new Ext.Panel({
layout: "border",
title: '全部模块',
region: "west",
width: 280,
bodyStyle: 'border-width:0 0 0 0;',
//margins: '0 0 0 0',
split:true,
items: [this.OPRangetabtree, this.panelBtn]
});
this.panelRight = new Ext.Panel({
layout: "border",
title: '用户可见模块',
region: "center",
bodyStyle: 'border-width:0 0 0 0;',
//margins: '0 0 0 0',
split: true,
items: [
this.Usertabtree]
});
this.panelcenter = new Ext.Panel({
title: '用户权限',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
bodyStyle: 'border-width:0 0 0 0;',
// containerScroll: true,
frame: false,
items: [ this.panelLeft, this.panelRight]
});
this.panelCopy = new Ext.Panel({
title: '复制用户权限',
layout: "border",
region: 'center',
animate: true,
autoScroll: true,
bodyStyle: 'border-width:0 0 0 0;',
// containerScroll: true,
frame: false,
items: [this.panelBtn_Copy, this.gridList ]
});
this.MainTab = new Ext.tab.Panel({
layout: "border",
region: "center",
items: [this.panelcenter, this.panelCopy]
});
//Ext.apply(this, {
// items: [this.panelBtn, this.panelTop, this.gridList]
//});
Ext.apply(this, {
items: [this.tabtree, this.MainTab]
});
//this.gridList.addListener('itemcontextmenu', this.itemcontextmenu);
}, //end initUIComponents
getCondition: function () {
//var form = this.panelBtn.getForm();
//if (!form.isValid()) {
// Ext.Msg.alert('提示', '查询条件赋值错误,请检查。');
// return '';
//}
var sql = '';
var COMPANYID = this.COMPANYID;
sql = sql + getAndConSql(sql, COMPANYID, " uc.COMPANYID = '" + COMPANYID + "'");
var DEPTNAME = this.DEPTNAME;
sql = sql + getAndConSql(sql, DEPTNAME, " B.DEPTNAME = '" + DEPTNAME + "'");
var showname = Ext.getCmp('USERNAME').getValue();
sql = sql + getAndConSql(sql, showname, " U.showname like '%" + showname + "%'");
return sql;
}
,
onAddClick: function (tree) {
var selNodes = tree.getChecked();
var IDList = [];
//遍历获取所有的节点数据
Ext.each(selNodes, function (node) {
IDList.push(node.data.GID);
});
var IDStr = ConvertStringListToJson(IDList);
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SysMng/SysUserOPRange/AddRange',
scope: this,
params: {
IDList: IDStr
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
} else {
Ext.Msg.show({ title: '执行结果', msg: jsonresult.Message, icon: Ext.Msg.Info, buttons: Ext.Msg.OK });
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
}
} else {
Ext.Msg.show({
title: '请重试',
msg: '服务器响应出错',
icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK
});
}
//alert('03');
}
});
},
onDeleteClick: function (tree) {
var selNodes = tree.getChecked();
var IDList = [];
//遍历获取所有的节点数据
Ext.each(selNodes, function (node) {
IDList.push(node.data.GID);
});
var IDStr = ConvertStringListToJson(IDList);
Ext.Ajax.request({
waitMsg: '正在保存数据...',
url: '/SysMng/SysUserOPRange/DelRange',
scope: this,
params: {
IDList: IDStr
},
callback: function (options, success, response) {
if (success) {
//Ext.MessageBox.hide();
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
this.UserOPRangeTreestore.load({
params: { PARENTID: '0', USERID: this.SELECTUSERID },
waitMsg: "正在刷新数据...",
timeout: 6000000, //60秒
scope: this
});
} 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
});
}
//alert('03');
}
});
}
,
getCondition: function () {
var sql = '';
var COMPANYID = Ext.getCmp("COMPANYID_SEARCH").getValue();
sql = sql + getAndConSql(sql, COMPANYID, " uc.COMPANYID = '" + COMPANYID + "'");
var DEPTNAME = Ext.getCmp("DEPTNAME_SEARCH").getValue();
sql = sql + getAndConSql(sql, DEPTNAME, " B.DEPTNAME = '" + DEPTNAME + "'");
var showname = Ext.getCmp("USERNAME_SEARCH").getValue();
sql = sql + getAndConSql(sql, showname, " U.showname like '%" + showname + "%'");
return sql;
},
onRefreshClick: function (button, event) {
var condition = this.getCondition();
//不允许无条件查询
if (isNullorEmpty(condition)) return;
this.PageSize = 100;
this.storeList.pageSize = this.PageSize;
this.storeList.load({
params: { start: 0, limit: this.PageSize, sort: '', condition: condition }, //传到controller的参数
waitMsg: "正在查询数据...",
scope: this
});
},
onCopyAuthClick: function (button, event) {
errormsg = "";
_this = this;
if (this.SELECTUSERID == "") errormsg = " 请先在左边选择一个权限来源人员 ";
var selections = this.gridList.getSelectionModel().getSelection();
if (selections.length == 0) {
errormsg += " 请在右边选择至少一个被覆盖权限的人员! ";
}
if (!isNullorEmpty(errormsg)) {
Ext.Msg.show({ title: '提示', msg: errormsg, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
var useridliststr = "";
for (var _i = 0; _i < selections.length; _i++) {
if (useridliststr != "") useridliststr += ",";
_record = selections[_i];
if (_record.data.GID == _this.SELECTUSERID) {
Ext.Msg.show({ title: '提示', msg: "不能选择与来源用户相同的目标用户", icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
return;
}
useridliststr += _record.data.GID;
}
Ext.MessageBox.confirm('提示', '覆盖设置权限将会用左边选中的人员的权限与权限范围,来设定右边选定的人员。此操作无法撤回,确定要进行该操作吗?',
function (btn) {
if (btn == 'yes') {
Ext.Msg.wait('正在设置权限...');
Ext.Ajax.request({
waitMsg: '正在设置权限...',
url: '/SoftMng/Auth/CopyAuth',
params: {
FromUSERID: _this.SELECTUSERID,
ToUSERIDLIST: useridliststr
},
callback: function (options, success, response) {
if (success) {
var jsonresult = Ext.JSON.decode(response.responseText);
if (jsonresult.Success) {
Ext.Msg.show({ title: '提示', msg: jsonresult.Message, icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
}
else {
Ext.Msg.show({ title: '错误', msg: jsonresult.Message, icon: Ext.Msg.ERROR, buttons: Ext.Msg.OK });
}
}
},
failure: function (response, options) {
Ext.Msg.show({ title: '警告', msg: '服务器响应出错,请重试', icon: Ext.Msg.INFO, buttons: Ext.Msg.OK });
},
success: function (response, options) {
},
scope: this
}); //end Ext.Ajax.request
}
}, this);
/**/
}
});