You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
306 lines
12 KiB
306 lines
12 KiB
4 years ago
|
|
||
|
define(function(require, exports, module) {
|
||
|
var Biz = require('system/base/biz');
|
||
|
var ActRightWin = require('apps/edp/frs/frs002/ActRightWin');
|
||
|
var CopyActRight = require('apps/edp/frs/frs002/CopyActRight');
|
||
|
var multiWindow = require("system/views/pages/multiwindow/multiwindow");
|
||
|
var userType = Store.logOn.userType;
|
||
|
var userOrgId = Store.logOn.rightCtrlOrgCode;
|
||
|
|
||
|
function ActRightBiz(vm) {
|
||
|
Biz.call(this, vm);
|
||
|
};
|
||
|
|
||
|
inherits(ActRightBiz, Biz);
|
||
|
|
||
|
ActRightBiz.prototype.initCompleted = function() {
|
||
|
this.super('initCompleted');
|
||
|
};
|
||
|
|
||
|
ActRightBiz.prototype.beforeRefresh = function() {
|
||
|
// if (userType !== '0')
|
||
|
// this.dsMaster.fixQuery['RightCtrlOrgId'] = Store.logOn.rightCtrlOrgId;
|
||
|
return this.super('beforeRefresh');
|
||
|
};
|
||
|
|
||
|
ActRightBiz.prototype.beforeAdd = function() {
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_01); //登录用户为普通用户,不允许增加角色信息。
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return this.super('beforeAdd');
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.beforeEdit = function() {
|
||
|
var self = this;
|
||
|
var currentRow = self.dsMaster.currentRow;
|
||
|
if (currentRow === null) return false;
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_02); //登录用户为普通用户,不允许修改角色信息。
|
||
|
return false;
|
||
|
}
|
||
|
if (userType === '1' && currentRow['RightCtrlOrgCode'] !== userOrgId) {
|
||
|
Store.messager.warn(Store.MSG.FRS002_03); //此用户与当前登录用户不是同一个权限控制组织,不允修改角色信息。
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
return this.super('beforeEdit');
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.beforeDelete = function() {
|
||
|
var self = this;
|
||
|
self.setServerBiz('roleSavePlugin');
|
||
|
var currentRow = self.dsMaster.currentRow;
|
||
|
if (currentRow === null) return false;
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_04); //登录用户为普通用户,不允许删除用户。
|
||
|
return false;
|
||
|
}
|
||
|
if (userType === '1' && currentRow['RightCtrlOrgCode'] !== userOrgId) {
|
||
|
Store.messager.warn(Store.MSG.FRS002_05); //此用户与当前登录用户不是同一个权限控制组织,不允删除角色信息。
|
||
|
return false;
|
||
|
}
|
||
|
|
||
|
//删除角色时,同时删除角色功能表和删除角色操作权表对应数据
|
||
|
var roleID = currentRow['RoleID'];
|
||
|
var afterDeletePro = self.getDataSrc("sFrs_Role_AfterDelete");
|
||
|
afterDeletePro.getColumn('ps_KeyValue').paraValue = roleID; //入参
|
||
|
afterDeletePro.getColumn('ps_UserId').paraValue = '';
|
||
|
afterDeletePro.getColumn('ps_UserCode').paraValue = '';
|
||
|
afterDeletePro.getColumn('ps_UserName').paraValue = '';
|
||
|
afterDeletePro.getColumn('ps_OrgId').paraValue = '';
|
||
|
afterDeletePro.getColumn('ps_OrgCode').paraValue = '';
|
||
|
afterDeletePro.getColumn('ps_OrgName').paraValue = '';
|
||
|
self.dsMaster.afterDeleteProc = afterDeletePro;
|
||
|
|
||
|
return this.super('beforeDelete');
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.beforeSave = function() {
|
||
|
var self = this;
|
||
|
self.setServerBiz('roleSavePlugin');
|
||
|
var currentRow = self.dsMaster.currentRow;
|
||
|
if (currentRow === null) return false;
|
||
|
|
||
|
var curRoleID = currentRow["RoleID"];
|
||
|
var curRoleCode = currentRow["RoleCode"];
|
||
|
|
||
|
//循环为角色用户明细表赋值
|
||
|
for (var j = 0; j < self.dsDetail1.rows.length; j++) {
|
||
|
var _nwRow = self.dsDetail1.rows[j];
|
||
|
_nwRow.setColumnValue("RoleCode", curRoleCode);
|
||
|
}
|
||
|
|
||
|
//循环为角色组织明细表赋值
|
||
|
for (var j = 0; j < self.dsDetail2.rows.length; j++) {
|
||
|
var _nwRow = self.dsDetail2.rows[j];
|
||
|
_nwRow.setColumnValue("RoleCode", curRoleCode);
|
||
|
}
|
||
|
|
||
|
var afterSavePro = self.getDataSrc("sFrs_Role_AfterSave");
|
||
|
afterSavePro.getColumn('ps_KeyValue').paraValue = currentRow["RoleID"];
|
||
|
afterSavePro.getColumn('ps_UserId').paraValue = '';
|
||
|
afterSavePro.getColumn('ps_UserCode').paraValue = '';
|
||
|
afterSavePro.getColumn('ps_UserName').paraValue = '';
|
||
|
afterSavePro.getColumn('ps_OrgId').paraValue = '';
|
||
|
afterSavePro.getColumn('ps_OrgCode').paraValue = '';
|
||
|
afterSavePro.getColumn('ps_OrgName').paraValue = '';
|
||
|
self.dsMaster.afterSaveProc = afterSavePro;
|
||
|
|
||
|
return this.super('beforeSave');
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.afterAdd = function() {
|
||
|
this.super('afterAdd');
|
||
|
|
||
|
var self = this;
|
||
|
var currentRow = self.dsMaster.currentRow;
|
||
|
if (currentRow === null) return false;
|
||
|
|
||
|
var curRoleID = currentRow["RoleID"];
|
||
|
if (userType === '1') {
|
||
|
currentRow.setColumnText('RightCtrlOrgCode', Store.logOn.rightCtrlOrgCode);
|
||
|
this.view.setEditLimit(self.dsMaster, 'RightCtrlOrgCode', false);
|
||
|
}
|
||
|
|
||
|
if (self.getState() === 'add' && curRoleID === '*') {
|
||
|
currentRow.setColumnValue('RoleID', this.super('generateUUID'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.afterEdit = function() {
|
||
|
this.super('afterEdit');
|
||
|
var self = this;
|
||
|
if (userType === '1') {
|
||
|
this.view.setEditLimit(self.dsMaster, 'RightCtrlOrgCode', false);
|
||
|
}
|
||
|
|
||
|
this.view.setEditLimit(self.dsMaster, 'RoleCode', false);
|
||
|
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.getOpEnabled = function(opCode) {
|
||
|
var self = this;
|
||
|
if (self.dsMaster !== null) {
|
||
|
var currentRow = self.dsMaster.currentRow;
|
||
|
switch (opCode) {
|
||
|
case 'cus01':
|
||
|
if (currentRow === null || self.getState() === 'add' || self.getState() === 'edit' || currentRow.RoleType !== '0') {
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
case 'cus02':
|
||
|
if (currentRow === null || self.getState() === 'add' || self.getState() === 'edit') {
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
case 'cus03':
|
||
|
if (currentRow === null || self.getState() !== 'edit' && self.getState() !== 'add') {
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
case 'cus04':
|
||
|
if (currentRow === null || self.getState() !== 'edit' && self.getState() !== 'add') {
|
||
|
return false;
|
||
|
}
|
||
|
break;
|
||
|
}
|
||
|
}
|
||
|
return this.super('getOpEnabled', opCode);
|
||
|
}
|
||
|
|
||
|
ActRightBiz.prototype.doOp = function(opCode) {
|
||
|
this.super('doOp');
|
||
|
var actRightWin = null;
|
||
|
var copyActRight = null;
|
||
|
var self = this;
|
||
|
|
||
|
function addUser(data) {
|
||
|
var _nwRow = self.dsDetail1.addRow();
|
||
|
_nwRow.setColumnText("UserID", data.UserID);
|
||
|
_nwRow.setColumnText("UserCode", data.UserCode);
|
||
|
_nwRow.setColumnText("UserName", data.UserName);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
function addOrg(data) {
|
||
|
var _nwRow = self.dsDetail2.addRow();
|
||
|
_nwRow.setColumnText("OrgID", data.OrgId);
|
||
|
_nwRow.setColumnText("OrgCode", data.OrgCode);
|
||
|
_nwRow.setColumnText("OrgName", data.OrgName);
|
||
|
|
||
|
return true;
|
||
|
}
|
||
|
|
||
|
switch (opCode) {
|
||
|
//操作权按钮操作事件
|
||
|
case 'cus01':
|
||
|
var curRow = this.dsMaster.currentRow;
|
||
|
if (!curRow) {
|
||
|
Store.messager.warn(Store.MSG.FRS002_06); //请先选择一条数据后进行操作权的处理。
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_07); //登录用户为普通用户,不允许修改操作权。
|
||
|
return;
|
||
|
}
|
||
|
|
||
|
var roleCode = curRow["RoleCode"];
|
||
|
var roleID = curRow["RoleID"];
|
||
|
self.getDataSrc('dsRoleFun').search(function(isOk) {
|
||
|
if (isOk) {
|
||
|
self.getDataSrc('dsFuncMenu').defaultOrder = 'MenuCode';
|
||
|
self.getDataSrc('dsFuncMenu').search(function(isOk) {
|
||
|
if (isOk) {
|
||
|
self.getDataSrc('dsActRight').clear();
|
||
|
self.getDataSrc('dsRoleActRight').clear();
|
||
|
|
||
|
actRightWin = new ActRightWin(self.dsMaster, self.getDataSrc('dsActRight'), self.getDataSrc('dsRoleFun'),
|
||
|
self.getDataSrc('dsRoleActRight'), self.getDataSrc('dsFuncMenu').rows, self.getDataSrc('dsRoleFun').rows,
|
||
|
roleID, roleCode);
|
||
|
actRightWin.open();
|
||
|
}
|
||
|
|
||
|
});
|
||
|
}
|
||
|
});
|
||
|
break;
|
||
|
//复制权限按钮操作事件
|
||
|
case 'cus02':
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_08); //登录用户为普通用户,不允许复制权限。
|
||
|
return;
|
||
|
}
|
||
|
if (copyActRight) {
|
||
|
copyActRight.open();
|
||
|
} else {
|
||
|
copyActRight = new CopyActRight(self.dsMaster);
|
||
|
copyActRight.open();
|
||
|
}
|
||
|
break;
|
||
|
//批量增加用户
|
||
|
case 'cus03':
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_09); //登录用户为普通用户,不允许批量增加用户。
|
||
|
return false;
|
||
|
}
|
||
|
//tab页焦点设置在用户明细上
|
||
|
this.view.selectTab(self.dsMaster, 0);
|
||
|
var exists = new Array();
|
||
|
for (var j = 0; j < self.dsDetail1.rows.length; j++) {
|
||
|
exists.push({
|
||
|
'UserID': self.dsDetail1.rows[j].UserID
|
||
|
});
|
||
|
}
|
||
|
var param = {
|
||
|
exists: exists,
|
||
|
uiObjCode: 'tFrsUser_Mult',
|
||
|
biz: self,
|
||
|
fixQuery: {
|
||
|
'!UserID': '0'
|
||
|
},
|
||
|
itreator: function(data) {
|
||
|
return addUser(data);
|
||
|
}
|
||
|
};
|
||
|
var mywindow = new multiWindow(param);
|
||
|
mywindow.open();
|
||
|
break;
|
||
|
//批量增加组织
|
||
|
case 'cus04':
|
||
|
if (userType === '2') {
|
||
|
Store.messager.warn(Store.MSG.FRS002_10); //登录用户为普通用户,不允许批量增加组织。
|
||
|
return false;
|
||
|
}
|
||
|
//tab页焦点设置在组织明细上
|
||
|
this.view.selectTab(self.dsMaster, 1);
|
||
|
var exists = new Array();
|
||
|
for (var j = 0; j < self.dsDetail2.rows.length; j++) {
|
||
|
exists.push({
|
||
|
'OrgId': self.dsDetail2.rows[j].OrgID
|
||
|
});
|
||
|
}
|
||
|
var param = {
|
||
|
exists: exists,
|
||
|
uiObjCode: 'vFrsOrg',
|
||
|
biz: self,
|
||
|
fixQuery: {
|
||
|
'!OrgCode': '0'
|
||
|
},
|
||
|
itreator: function(data) {
|
||
|
return addOrg(data);
|
||
|
}
|
||
|
};
|
||
|
var mywindow = new multiWindow(param);
|
||
|
mywindow.open();
|
||
|
break;
|
||
|
}
|
||
|
|
||
|
return true;
|
||
|
};
|
||
|
|
||
|
return ActRightBiz;
|
||
|
})
|