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.
233 lines
8.2 KiB
233 lines
8.2 KiB
define(function (require, exports, module) {
|
|
|
|
const Biz = require('system/base/biz');
|
|
const CopyUserRight = require('./copy-right');
|
|
const UserDepWin = require('./user-dep-win');
|
|
const UserFinanceWin = require('./user-finance-win');
|
|
const MultiWindow = require("system/views/pages/multiwindow/multiwindow");
|
|
const md5 = window.CryptoJS.md5;
|
|
|
|
function UserBiz(vm) {
|
|
Biz.call(this, vm);
|
|
}
|
|
|
|
inherits(UserBiz, Biz);
|
|
|
|
UserBiz.prototype.initialize = function () {
|
|
const self = this
|
|
self.setServerBiz('userBiz')
|
|
}
|
|
|
|
UserBiz.prototype.doOp = function (opCode) {
|
|
this.super('doOp');
|
|
const self = this;
|
|
const currentRow = self.dsMaster.currentRow
|
|
if (currentRow === null) {
|
|
Store.messager.tip('请先选择要处理的用户')
|
|
return
|
|
}
|
|
|
|
const userId = currentRow['UserID']
|
|
const userCode = currentRow['UserCode']
|
|
const userName = currentRow['UserName']
|
|
|
|
switch (opCode) {
|
|
case 'clear-pwd':
|
|
// 清空密码
|
|
Store.messager.confirm(`确定要清除用户${userCode}-${userName}的口令吗?注意:用户清除口令以后新口令为"0"`, function (cfmClear) {
|
|
if (cfmClear) {
|
|
const params = {
|
|
plugin: 'clearPasswordPlugin',
|
|
pluginData: {
|
|
userId: userId
|
|
}
|
|
}
|
|
|
|
Store.services.executeplugin(params, function (isOk, result) {
|
|
if (isOk) {
|
|
Store.messager.tip('密码清除成功。')
|
|
}
|
|
})
|
|
}
|
|
});
|
|
break;
|
|
case 'toggle-forbidden':
|
|
// 失效按钮操作事件
|
|
const isForbid = currentRow['IsForbid'];
|
|
if (isForbid === '0') {
|
|
Store.messager.confirm(`确定要禁用用户${userCode}-${userName}`, function (cfm) {
|
|
if (cfm) {
|
|
currentRow.setColumnText('IsForbid', '1')
|
|
self.dsMaster.save(function (isSuccess) {
|
|
if (! isSuccess) {
|
|
self.dsMaster.rejectChanges();
|
|
} else {
|
|
Store.messager.tip('禁用成功。');
|
|
self.dsMaster.updateRow()
|
|
// self.callView('updateOpEnable', true);
|
|
}
|
|
});
|
|
}
|
|
});
|
|
} else {
|
|
Store.messager.confirm(`确定要启用用户${userCode}-${userName}`, function (cfmFail) {
|
|
if (cfmFail) {
|
|
currentRow.setColumnText('IsForbid', '0')
|
|
self.dsMaster.save(function (isSuccess) {
|
|
if (! isSuccess) {
|
|
self.dsMaster.rejectChanges();
|
|
} else {
|
|
Store.messager.tip('启用成功。');
|
|
self.dsMaster.updateRow()
|
|
// self.callView('updateOpEnable', true);
|
|
|
|
}
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
break;
|
|
case 'copy-right':
|
|
// 复制权限按钮操作事件
|
|
const copyUserRight = new CopyUserRight(self.dsMaster.currentRow, self.dsMaster.funcCode);
|
|
copyUserRight.open();
|
|
break;
|
|
case 'batch-grp':
|
|
// 批量增加角色
|
|
// tab页焦点设置在角色明细上
|
|
handleBatchGrp(self)
|
|
break;
|
|
case 'dep-mng':
|
|
// 批量增加组织部门
|
|
handleDepMng(self)
|
|
break;
|
|
case 'fo': handleFinanceDep(self);
|
|
break;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
function handleBatchGrp(self) {
|
|
const exists = new Array();
|
|
for (let j = 0; j < self.dsUserRole.rows.length; j++) {
|
|
exists.push({'id': self.dsUserRole.rows[j].role_id});
|
|
}
|
|
|
|
const userId = self.dsMaster.currentRow['UserID']
|
|
const userCode = self.dsMaster.currentRow['UserCode']
|
|
|
|
const param = {
|
|
exists: exists,
|
|
uiObjCode: '2016',
|
|
biz: self,
|
|
itreator: function (data) {
|
|
const newRow = self.dsUserRole.addRow()
|
|
newRow.setColumnText("role_id", data.id)
|
|
newRow.setColumnText("RoleCode", data.code)
|
|
newRow.setColumnText("RoleName", data.name)
|
|
newRow.setColumnText("user_id", userId)
|
|
return true
|
|
}
|
|
};
|
|
const mywindow = new MultiWindow(param);
|
|
mywindow.open();
|
|
}
|
|
|
|
function handleDepMng(self) {
|
|
self.dsUserDep.fixQuery = {
|
|
UserID: self.dsMaster.currentRow['UserID'],
|
|
OrgStyle: '0'
|
|
}
|
|
self.dsUserDep.search(function () {
|
|
const mywindow = new UserDepWin(self.dsUserDep, self.dsMaster.currentRow['UserID']);
|
|
mywindow.open();
|
|
})
|
|
}
|
|
|
|
function handleFinanceDep(self) {
|
|
self.dsUserDep.fixQuery = {
|
|
UserID: self.dsMaster.currentRow['UserID'],
|
|
OrgStyle: '1'
|
|
}
|
|
self.dsUserDep.search(function () {
|
|
const mywindow = new UserFinanceWin(self.dsUserDep, self.dsMaster.currentRow['UserID']);
|
|
mywindow.open();
|
|
})
|
|
}
|
|
|
|
|
|
UserBiz.prototype.delete = function () {
|
|
const self = this
|
|
let content = Store.messager.confirm('用户删除后不可恢复,确定执行?', function (r) {
|
|
if (r) {
|
|
self.dsMaster.currentRow.setColumnText('IsActive', '0')
|
|
self.dsMaster.save(function (isOk, dataSrc) {
|
|
if (isOk) {
|
|
self.dsMaster.removeRow(self.dsMaster.currentRow)
|
|
}
|
|
});
|
|
}
|
|
});
|
|
content.parent().find('.messager-button a:eq(1)').focus();
|
|
}
|
|
|
|
UserBiz.prototype.fieldChanged = function (dataSrc, dr, dc) {}
|
|
|
|
UserBiz.prototype.afterNewRow = function (dataSrc, newRow) {
|
|
if (dataSrc === this.dsUserRole) {
|
|
newRow.setColumnText('user_id', this.dsMaster.currentRow['UserID'])
|
|
}
|
|
}
|
|
|
|
UserBiz.prototype.beforeEdit = function () {
|
|
const self = this;
|
|
const currentRow = self.dsMaster.currentRow;
|
|
if (currentRow === null) {
|
|
return false;
|
|
}
|
|
if (currentRow.UserCode === '0000') {
|
|
Store.messager.warn('内置用户不允许修改')
|
|
}
|
|
}
|
|
|
|
|
|
UserBiz.prototype.beforeDelete = function () {
|
|
const self = this;
|
|
const currentRow = self.dsMaster.currentRow;
|
|
if (currentRow === null) {
|
|
return false;
|
|
}
|
|
if (currentRow.UserCode === '0000') {
|
|
Store.messager.warn('内置用户不允许删除')
|
|
}
|
|
|
|
return this.super('beforeDelete');
|
|
}
|
|
|
|
|
|
UserBiz.prototype.getOpEnabled = function (opCode) {
|
|
const self = this;
|
|
const currentRow = self.dsMaster.currentRow;
|
|
|
|
switch (opCode) {
|
|
case 'toggle-forbidden': self.callView('setButtonText', 'toggle-forbidden', currentRow && currentRow['IsForbid'] === '1' ? '启用' : '禁用')
|
|
return currentRow && self.isBrowser()
|
|
case 'clear-pwd':
|
|
return currentRow && self.isBrowser()
|
|
case 'copy-right':
|
|
return currentRow && self.isBrowser()
|
|
case 'batch-grp':
|
|
return self.isEdit()
|
|
case 'dep-mng':
|
|
return currentRow && self.isBrowser()
|
|
case 'fo':
|
|
return currentRow && self.isBrowser()
|
|
}
|
|
return this.super('getOpEnabled', opCode);
|
|
};
|
|
|
|
return UserBiz;
|
|
})
|