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.

146 lines
4.6 KiB

define(function(require, exports, module) {
var Window = require('system/views/pages/window');
var tpl = require('text!apps/edp/frs/frs001/CopyUserRight.tpl');
function CopyUserRight(dsUser) {
this.options = {
title: Store.MSG.FRS001_32,
content: tpl,
width: 400,
height: 300,
modal: true,
closed: true,
closable: true,
draggable: true,
maximizable: false,
resizable: false,
data: null
}
this.dsUser = dsUser;
Window.call(this, this.options);
}
inherits(CopyUserRight, Window);
CopyUserRight.prototype.init = function() {
}
CopyUserRight.prototype.open = function() {
Window.prototype.open.call(this);
}
//执行windows窗体上自定义按钮事件
CopyUserRight.prototype.customerize = function() {
var self = this;
var rows = null;
if (Store.logOn.userType === '0')
rows = this.dsUser.rows;
else
rows = _.where(self.dsUser.rows, {
'RightCtrlOrgCode': Store.logOn.rightCtrlOrgCode
});
var data = [];
var dataType = [];
//为源用户和复制到用户的用户combox增加下拉数据
for (var i = 0; i < rows.length; i++) {
var rowUserID = rows[i]['UserID'];
var rowUserCode = rows[i]['UserCode'];
var rowUserName = rows[i]["UserName"];
data.push({
userCode: rowUserCode,
userName: rowUserCode + '-' + rowUserName
});
dataType.push({
userID: rowUserID,
userCode: rowUserCode,
userName: rowUserName
});
}
var $sourceUser = this.getElement('.sourceUser');
$sourceUser.combobox('loadData', data);
if (this.dsUser.currentRow['RightCtrlOrgID'] === Store.logOn.rightCtrlOrgId || Store.logOn.userType === '0')
$sourceUser.combobox('setValue', this.dsUser.currentRow['UserCode']);
var $copyToUser = this.getElement('.copyToUser');
$copyToUser.combobox('loadData', data);
var $isCopyCheckbox = this.getElement('#frs-chk-delUser');
//确定按钮事件
this.getElement('.btnOK').on('click', function(event) {
var selectSourceUser = $sourceUser.combobox('getValue');
var selectCopyToUser = $copyToUser.combobox('getValue');
if (!selectSourceUser) {
Store.messager.warn(Store.MSG.FRS001_33);
return;
}
if (!selectCopyToUser) {
Store.messager.warn(Store.MSG.FRS001_34);
return;
}
if (selectSourceUser === selectCopyToUser) {
Store.messager.warn(Store.MSG.FRS001_35);
return;
}
var sourceUserID = null;
var copyToUserId = null;
_.each(dataType, function(item, index) {
var userCode = item['userCode'];
if (userCode === selectSourceUser) {
sourceUserID = item['userID'];
}
if (userCode === selectCopyToUser) {
copyToUserId = item['userID'];
}
});
if (sourceUserID === null) {
Store.messager.warn(Store.MSG.FRS001_36);
return;
}
if (copyToUserId === null) {
Store.messager.warn(Store.MSG.FRS001_37);
return;
}
var isCopyCheckbox = $isCopyCheckbox.prop('checked');
var params = {
plugin: 'proCopyUserRight',
pluginData: {
ps_SourceUserId: sourceUserID,
ps_DestUserId: copyToUserId,
ps_CopyType: isCopyCheckbox ? 0 : 1,
}
};
Store.services.executeplugin(params, function(isOk, result) {
if (isOk && result.data_Proc.pi_Result === 1) {
Store.messager.tip(Store.MSG.FRS001_38);
if (self.callback) {
self.callback();
}
self.close();
} else {
Store.messager.tip('用户权限复制失败!');
self.close();
}
});
});
//取消按钮事件
this.getElement('.btnCancel').on('click', function(event) {
self.close();
});
}
return CopyUserRight;
})