2022-04-04 01:48:50 +08:00
|
|
|
|
var OaNodeManageCtrl = [ '$scope' , '$modal', '$timeout', '$translate', function($scope, $modal, $timeout, $translate) {
|
|
|
|
|
var opts = {
|
|
|
|
|
template: 'editor-app/configuration/properties/oa-node-manage-popup.html?version=' + Date.now(),
|
|
|
|
|
backdrop: 'static',
|
|
|
|
|
keyboard: false,
|
|
|
|
|
scope: $scope
|
|
|
|
|
};
|
|
|
|
|
$modal(opts);
|
|
|
|
|
}];
|
|
|
|
|
|
|
|
|
|
var OaNodeManagePopupCtrl = ['$scope', '$timeout', '$http', function($scope, $timeout, $http) {
|
|
|
|
|
// console.log($scope.selectedItem);
|
|
|
|
|
// console.log($scope.editor);
|
|
|
|
|
// console.log($scope.editor.modelMetaData.model.childShapes);
|
|
|
|
|
// console.log($scope.stencilItemGroups)
|
|
|
|
|
// 获取流程中的配置
|
|
|
|
|
var model = $scope.editor.modelMetaData.model;
|
|
|
|
|
var childShapes = model.childShapes;
|
|
|
|
|
// 关联到的属性
|
|
|
|
|
var taskListenerProperty = $scope.selectedItem.properties[16];
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
var startNode;
|
|
|
|
|
$scope.oaNodeManage = {
|
|
|
|
|
assignee: {
|
|
|
|
|
nodeType: 'normal',
|
|
|
|
|
assigneeType: '',
|
|
|
|
|
assigneeCount: 0,
|
|
|
|
|
assignee: '',
|
2022-04-05 23:42:43 +08:00
|
|
|
|
assigneeName: '',
|
2022-04-04 01:48:50 +08:00
|
|
|
|
autoAssignType: '',
|
|
|
|
|
departmentType: '',
|
|
|
|
|
departments: '',
|
2022-04-05 23:42:43 +08:00
|
|
|
|
departmentNames: '',
|
2022-04-04 01:48:50 +08:00
|
|
|
|
roles: '',
|
2022-04-05 23:42:43 +08:00
|
|
|
|
roleNames: '',
|
2022-04-04 01:48:50 +08:00
|
|
|
|
positions: '',
|
2022-04-05 23:42:43 +08:00
|
|
|
|
positionNames: '',
|
2022-04-04 01:48:50 +08:00
|
|
|
|
quickAssignee: '',
|
|
|
|
|
signType: '',
|
|
|
|
|
signUsers: '',
|
|
|
|
|
completeCondition: '',
|
|
|
|
|
completeCount: 0
|
|
|
|
|
},
|
|
|
|
|
formId: '',
|
|
|
|
|
formFields: [],
|
|
|
|
|
oaUserTaskListeners: []
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 添加用户任务监听器
|
|
|
|
|
function addOaUserTaskListener(event, className, expression, delegateExpression) {
|
|
|
|
|
var implementation = '';
|
|
|
|
|
if (className) {
|
|
|
|
|
implementation = className;
|
|
|
|
|
} else if (expression) {
|
|
|
|
|
implementation = expression;
|
|
|
|
|
} else if (delegateExpression) {
|
|
|
|
|
implementation = delegateExpression;
|
|
|
|
|
}
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.push({
|
|
|
|
|
event: event,
|
|
|
|
|
implementation: implementation,
|
|
|
|
|
className: className ? className : '',
|
|
|
|
|
expression: expression ? expression : '',
|
|
|
|
|
delegateExpression: delegateExpression ? delegateExpression : ''
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
/**
|
|
|
|
|
* 判断监听器是否存在
|
|
|
|
|
* @param event
|
|
|
|
|
* @param className
|
|
|
|
|
*/
|
|
|
|
|
function isListenerExist(event, className) {
|
|
|
|
|
for (var i = 0, item; item = $scope.oaNodeManage.oaUserTaskListeners[i++];) {
|
|
|
|
|
if (item.event == event && item.className == className) {
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.addOaUserTaskCreateListener = function () {
|
|
|
|
|
var event = 'create',
|
|
|
|
|
className = '',
|
|
|
|
|
expression = '',
|
|
|
|
|
delegateExpression = '${oaUserTaskCreateListener}';
|
|
|
|
|
if (isListenerExist(event, className)) {
|
|
|
|
|
top.dialog.msg('监听器已经存在');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
addOaUserTaskListener(event, className, expression, delegateExpression);
|
|
|
|
|
}
|
|
|
|
|
$scope.addOaUserTaskAssignmentListener = function () {
|
|
|
|
|
var event = 'assignment',
|
|
|
|
|
className = '',
|
|
|
|
|
expression = '',
|
|
|
|
|
delegateExpression = '${oaUserTaskAssignmentListener}';
|
|
|
|
|
if (isListenerExist(event, className)) {
|
|
|
|
|
top.dialog.msg('监听器已经存在');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
addOaUserTaskListener(event, className, expression, delegateExpression);
|
|
|
|
|
}
|
|
|
|
|
$scope.addOaUserTaskDeleteListener = function () {
|
|
|
|
|
var event = 'delete',
|
|
|
|
|
className = '',
|
|
|
|
|
expression = '',
|
|
|
|
|
delegateExpression = '${oaUserTaskDeleteListener}';
|
|
|
|
|
if (isListenerExist(event, className)) {
|
|
|
|
|
top.dialog.msg('监听器已经存在');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
addOaUserTaskListener(event, className, expression, delegateExpression);
|
|
|
|
|
}
|
|
|
|
|
// 上移用户任务监听器
|
|
|
|
|
$scope.moveOaUserTaskListenerUp = function(index) {
|
|
|
|
|
var prevIndex = index - 1;
|
|
|
|
|
var temp = $scope.oaNodeManage.oaUserTaskListeners[index];
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.splice(index, 1);
|
|
|
|
|
$timeout(function () {
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.splice(prevIndex, 0, temp);
|
|
|
|
|
}, 10);
|
|
|
|
|
}
|
|
|
|
|
// 下移用户任务监听器
|
|
|
|
|
$scope.moveOaUserTaskListenerDown = function(index) {
|
|
|
|
|
var nextIndex = index + 1;
|
|
|
|
|
var temp = $scope.oaNodeManage.oaUserTaskListeners[index];
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.splice(index, 1);
|
|
|
|
|
$timeout(function () {
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.splice(nextIndex, 0, temp);
|
|
|
|
|
}, 10);
|
|
|
|
|
}
|
|
|
|
|
// 删除用户任务监听器
|
|
|
|
|
$scope.deleteOaUserTaskListener = function(index) {
|
|
|
|
|
$scope.oaNodeManage.oaUserTaskListeners.splice(index, 1);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 23:42:43 +08:00
|
|
|
|
// 选择用户
|
|
|
|
|
$scope.selectUser = function() {
|
|
|
|
|
var assignee = $scope.oaNodeManage.assignee;
|
|
|
|
|
top.dialog.dialogData.selectedUserIds = assignee.assignee;
|
|
|
|
|
top.dialog.open({
|
|
|
|
|
url: top.restAjax.path('route/department/user/select-user', []),
|
|
|
|
|
title: '选择用户',
|
|
|
|
|
width: '500px',
|
|
|
|
|
height: '500px',
|
|
|
|
|
closeBtn: 0,
|
|
|
|
|
onClose: function () {
|
|
|
|
|
var selectedUsers = top.dialog.dialogData.selectedDepartmentUsers;
|
|
|
|
|
// 这里写处理逻辑
|
|
|
|
|
if (selectedUsers && selectedUsers.length > 0) {
|
|
|
|
|
if(selectedUsers.length > 1) {
|
|
|
|
|
top.dialog.msg('只能选择一位代理人');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var userId = selectedUsers[0].userId;
|
|
|
|
|
var userName = selectedUsers[0].userName;
|
|
|
|
|
assignee.assignee = selectedUsers[0].userId;
|
|
|
|
|
assignee.assigneeName = selectedUsers[0].userName;
|
|
|
|
|
} else {
|
|
|
|
|
assignee.assignee = '';
|
|
|
|
|
assignee.assigneeName = '';
|
|
|
|
|
}
|
|
|
|
|
top.dialog.dialogData.selectedDepartmentUsers = [];
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$scope.selectDepartments = function() {
|
|
|
|
|
var assignee = $scope.oaNodeManage.assignee;
|
|
|
|
|
top.dialog.dialogData.checkedIds = !assignee.departments ? [] : assignee.departments.split(',');
|
|
|
|
|
top.dialog.open({
|
|
|
|
|
url: top.restAjax.path('route/department/list-tree-check', []),
|
|
|
|
|
title: '选择组织部门',
|
|
|
|
|
width: '400px',
|
|
|
|
|
height: '400px',
|
|
|
|
|
onClose: function() {
|
|
|
|
|
var checkedNodes = top.dialog.dialogData.checkedNodes;
|
|
|
|
|
if(checkedNodes && checkedNodes.length > 0) {
|
|
|
|
|
var departments = '';
|
|
|
|
|
var departmentNames = '';
|
|
|
|
|
for(var i = 0, item; item = checkedNodes[i++];) {
|
|
|
|
|
if(departments.length > 0) {
|
|
|
|
|
departments += ',';
|
|
|
|
|
departmentNames += ',';
|
|
|
|
|
}
|
|
|
|
|
departments += item.id;
|
|
|
|
|
departmentNames += item.name;
|
|
|
|
|
}
|
|
|
|
|
assignee.departments = departments;
|
|
|
|
|
assignee.departmentNames = departmentNames;
|
|
|
|
|
} else {
|
|
|
|
|
assignee.departments = '';
|
|
|
|
|
assignee.departmentNames = '';
|
|
|
|
|
}
|
|
|
|
|
top.dialog.dialogData.checkedNodes = [];
|
|
|
|
|
$scope.$apply();
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 01:48:50 +08:00
|
|
|
|
// Click handler for save button
|
|
|
|
|
$scope.save = function () {
|
|
|
|
|
|
|
|
|
|
$scope.property.value = {};
|
|
|
|
|
$scope.property.value = $scope.oaNodeManage;
|
|
|
|
|
$scope.updatePropertyInModel($scope.property);
|
|
|
|
|
|
|
|
|
|
// 更新任务监听器列表
|
|
|
|
|
taskListenerProperty.value = {}
|
|
|
|
|
taskListenerProperty.value.taskListeners = $scope.oaNodeManage.oaUserTaskListeners;
|
|
|
|
|
$scope.updatePropertyInModel(taskListenerProperty);
|
|
|
|
|
$scope.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
$scope.cancel = function () {
|
|
|
|
|
$scope.close();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
// Close button handler
|
|
|
|
|
$scope.close = function () {
|
|
|
|
|
taskListenerProperty.mode = 'read';
|
|
|
|
|
$scope.property.mode = 'read';
|
|
|
|
|
$scope.$hide();
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
function initOaNodeManage() {
|
|
|
|
|
if($scope.property.value) {
|
|
|
|
|
$scope.oaNodeManage = $scope.property.value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化开始节点
|
|
|
|
|
function initStartNode() {
|
|
|
|
|
for(var i = 0, node; node = childShapes[i++];) {
|
|
|
|
|
if(node.stencil.id == 'StartNoneEvent') {
|
|
|
|
|
startNode = node;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(!startNode) {
|
|
|
|
|
top.dialog.msg('未找到开始节点,无法设置OA节点');
|
|
|
|
|
$scope.close();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-05 23:42:43 +08:00
|
|
|
|
// 初始化oaUserTaskCompleteListener
|
|
|
|
|
function initOaUserTaskCompleteListener() {
|
|
|
|
|
if($scope.property.value) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
var event = 'complete',
|
|
|
|
|
className = '',
|
|
|
|
|
expression = '',
|
|
|
|
|
delegateExpression = '${oaUserTaskCompleteListener}';
|
|
|
|
|
if (isListenerExist(event, className)) {
|
|
|
|
|
top.dialog.msg('监听器已经存在');
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
addOaUserTaskListener(event, className, expression, delegateExpression);
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-04 01:48:50 +08:00
|
|
|
|
// 初始化form表单ID
|
2022-04-05 23:42:43 +08:00
|
|
|
|
function initFormId(callback) {
|
2022-04-04 01:48:50 +08:00
|
|
|
|
$scope.oaNodeManage.formId = startNode.properties.formkeydefinition;
|
|
|
|
|
if(!$scope.oaNodeManage.formId) {
|
|
|
|
|
top.dialog.msg('开始节点未绑定表单,无法设置OA节点');
|
2022-04-05 23:42:43 +08:00
|
|
|
|
$timeout(function() {
|
|
|
|
|
$scope.close();
|
|
|
|
|
}, 10)
|
2022-04-04 01:48:50 +08:00
|
|
|
|
return;
|
|
|
|
|
}
|
2022-04-05 23:42:43 +08:00
|
|
|
|
callback();
|
2022-04-04 01:48:50 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化form表单
|
|
|
|
|
function initFormField() {
|
|
|
|
|
$http.get('api/form-field/list/form-id/'+ $scope.oaNodeManage.formId).then(function(response) {
|
|
|
|
|
var formFields = [];
|
|
|
|
|
for(var i = 0, formField; formField = response.data[i++];) {
|
|
|
|
|
var isVisible = true;
|
|
|
|
|
var isEditable = true;
|
|
|
|
|
for(var j = 0, item; item = $scope.oaNodeManage.formFields[j++];) {
|
|
|
|
|
if(formField.fieldId === item.fieldId) {
|
|
|
|
|
isVisible = item.isVisible;
|
|
|
|
|
isEditable = item.isEditable;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
formFields.push({
|
|
|
|
|
fieldId: formField.fieldId,
|
|
|
|
|
fieldName: formField.fieldName,
|
|
|
|
|
fieldExplain: formField.fieldExplain,
|
|
|
|
|
fieldTag: formField.fieldTag,
|
|
|
|
|
fieldType: formField.fieldType,
|
|
|
|
|
isVisible: isVisible,
|
|
|
|
|
isEditable: isEditable
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
$scope.oaNodeManage.formFields = formFields;
|
|
|
|
|
}, function(response) {
|
|
|
|
|
top.dialog.msg(response.data.msg);
|
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化
|
|
|
|
|
(function() {
|
|
|
|
|
initOaNodeManage();
|
|
|
|
|
initStartNode();
|
|
|
|
|
initOaUserTaskCompleteListener();
|
2022-04-05 23:42:43 +08:00
|
|
|
|
initFormId(function() {
|
|
|
|
|
initFormField();
|
|
|
|
|
});
|
2022-04-04 01:48:50 +08:00
|
|
|
|
})();
|
|
|
|
|
|
|
|
|
|
}];
|