新建任务
This commit is contained in:
1 parent
ae997fe850
commit
b3fa84e828
6 files changed
+417
-578
No files matched your search
+23
-514
@@ -6,529 +6,38 @@ const validateUtil = require('@jianghujs/jianghu/app/common/validateUtil');
|
||||
const idGenerateUtil = require("@jianghujs/jianghu/app/common/idGenerateUtil");
|
||||
const { BizError, errorInfoEnum } = require("../constant/error");
|
||||
|
||||
const appDataSchema = {};
|
||||
appDataSchema.submitNode = Object.freeze({
|
||||
type: 'object',
|
||||
required: ['id', 'taskFormInput', 'taskId', 'type'],
|
||||
properties: {
|
||||
id: {
|
||||
type: 'number'
|
||||
},
|
||||
taskFormInput: {
|
||||
type: 'string', minLength: 1, maxLength: 10000
|
||||
},
|
||||
taskId: {
|
||||
type: 'string', minLength: 1, maxLength: 200
|
||||
},
|
||||
type: {
|
||||
type: 'string', minLength: 1, maxLength: 200
|
||||
},
|
||||
taskComment: {
|
||||
type: 'string'
|
||||
}
|
||||
},
|
||||
additionalProperties: true
|
||||
});
|
||||
|
||||
class TaskService extends Service {
|
||||
async upcomingToUserId() {
|
||||
const { userId } = this.ctx.userInfo;
|
||||
this.ctx.request.body.appData.whereLike = { taskEditUserList: userId };
|
||||
}
|
||||
async whereToUserId() {
|
||||
const { where } = this.ctx.request.body.appData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
where.createByUser = userId;
|
||||
}
|
||||
async whereToViewUserId() {
|
||||
const { whereLike } = this.ctx.request.body.appData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
whereLike.taskViewUserList = userId;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建审批工作流
|
||||
* @returns void
|
||||
*/
|
||||
async createTask() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
async appendFileAfterHook() {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { workflowId, taskTitle, workflowForm, workflowFormData, workflowConfigCustom } = actionData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
const taskId = await idGenerateUtil.uuid();
|
||||
const workflow = await jianghuKnex('workflow', this.ctx).where({workflowId}).first();
|
||||
if (!workflow) {
|
||||
throw new BizError(errorInfoEnum.workflow_not_found)
|
||||
}
|
||||
|
||||
const workflowConfig = JSON.parse(workflow.workflowConfig || '{}');
|
||||
/*
|
||||
* workflowConfig = {
|
||||
* "nodeList": [...],
|
||||
* "lineList": [...],
|
||||
* "mode": "serial"
|
||||
* }
|
||||
* nodeList: 流程编辑器中的节点
|
||||
* lineList: 流程编辑器中节点间的连线
|
||||
* mode: serial | parallel
|
||||
* serial: 仅启动下一阶段的任务
|
||||
* parallel: 后续任务都启动
|
||||
*
|
||||
* workflowForm = [
|
||||
* {
|
||||
* "id": "input_kBIjNmho",
|
||||
* "type": "input",
|
||||
* // ...
|
||||
* },
|
||||
*
|
||||
* // ...
|
||||
* ]
|
||||
* type: input | short | single | multiple
|
||||
* input: 单行文本
|
||||
* short: 多行文本
|
||||
* single: 单选框
|
||||
* multiple: 多选框
|
||||
*/
|
||||
let {mode = 'serial', nodeList = [], lineList = []} = workflowConfig;
|
||||
const nodeListOfUserTaskNode = (JSON.parse(workflowConfigCustom || '{}')).nodeListOfUserTaskNode || []
|
||||
// 合并定制的审批人和workflow的审批人
|
||||
nodeList = _.merge(_.keyBy(nodeList, 'id'), _.keyBy(nodeListOfUserTaskNode, 'id'))
|
||||
for (let i = 0; i < nodeList.length; i++) {
|
||||
const node = nodeList[i];
|
||||
const tempNode = nodeListOfUserTaskNode.find(n => n.id === node.id);
|
||||
if (tempNode) {
|
||||
nodeList[i] = tempNode;
|
||||
}
|
||||
}
|
||||
nodeList = _.values(nodeList);
|
||||
workflowConfig.nodeList = nodeList
|
||||
|
||||
// start 节点进入历史
|
||||
const startNode = nodeList.find(e => e.id.includes('start-'));
|
||||
const startLine = lineList.filter(e => e.from === startNode.id);
|
||||
const userNode = nodeList.filter(e => e.id.includes('userTask') || e.id.includes('receiveTask') );
|
||||
const allUser = await this.getProcessUserList(userNode);
|
||||
const startData = {
|
||||
taskId,
|
||||
taskTitle,
|
||||
taskStatus: 'running',
|
||||
taskFormInput: JSON.stringify({
|
||||
input: workflowFormData,
|
||||
formList: workflowForm
|
||||
}),
|
||||
taskConfigId: startNode.id,
|
||||
taskNextConfigList: JSON.stringify(startLine),
|
||||
taskEditUserList: '',
|
||||
taskViewUserList: allUser,
|
||||
createByUser: userId,
|
||||
taskInitUser: userId,
|
||||
workflowConfig: JSON.stringify(workflowConfig)
|
||||
}
|
||||
await jianghuKnex.transaction(async trx => {
|
||||
const [id] = await trx('task', this.ctx).insert(startData);
|
||||
// 并行模式下,生成所有的userTask
|
||||
if (mode == 'parallel') {
|
||||
await this.generateAllUserTask(id, trx);
|
||||
}
|
||||
// 开始节点进入历史
|
||||
await this.buildNext({ type: '同意', id, taskTpl: {input: workflowFormData}, taskComment: ''}, trx);
|
||||
|
||||
const { taskFormInput, taskId } = this.ctx.request.body.appData.actionData;
|
||||
const fileInput = JSON.parse(taskFormInput).filter(item => item.type == 'file')
|
||||
|
||||
if (fileInput.length > 0) {
|
||||
const insertData = []
|
||||
const idSequence = await idGenerateUtil.idPlus({
|
||||
knex: jianghuKnex,
|
||||
startValue: 1000,
|
||||
tableName: 'jianghujs_workflow.file',
|
||||
columnName: 'idSequence',
|
||||
plusValue: 1
|
||||
});
|
||||
return startData;
|
||||
}
|
||||
/**
|
||||
* 获取组下的所有用户
|
||||
* @param {*} groupId
|
||||
* @returns
|
||||
*/
|
||||
async getGroupUserList(groupId) {
|
||||
const { jianghuKnex } = this.app;
|
||||
const userList = await jianghuKnex('_user_group_role').where({groupId}).select('userId');
|
||||
return userList.map(e => {
|
||||
return e.userId
|
||||
});
|
||||
}
|
||||
async getProcessUserList(nodeList) {
|
||||
let userIds = []
|
||||
for(const item of nodeList) {
|
||||
const {assignValue = [], assignType = ''} = item;
|
||||
if (assignType === 'person') {
|
||||
userIds = [...userIds, ...assignValue];
|
||||
} else if (assignType === 'group') {
|
||||
userIds = [...userIds, ...await this.getGroupUserList(assignValue)];
|
||||
}
|
||||
}
|
||||
return _.uniq(userIds).join(',');
|
||||
}
|
||||
async taskCareUser() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { jianghuKnex } = this.app;
|
||||
const { userId: careUser, taskId } = actionData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
const taskInfo = await jianghuKnex('task').where({taskId}).first();
|
||||
// 转交写入历史
|
||||
const history = {
|
||||
taskId: taskId,
|
||||
taskNode: '转交',
|
||||
historyForm: line.from,
|
||||
historyTo: line.to,
|
||||
historyChooseName: line.label,
|
||||
historyCostDuration: 0
|
||||
}
|
||||
await jianghuKnex('task_history').insert(history);
|
||||
// 修改task处理人
|
||||
const taskProcessorList = taskInfo.taskProcessorList.replace(userId, careUser);
|
||||
await jianghuKnex('task').where({taskId}).update({taskProcessorList});
|
||||
}
|
||||
/**
|
||||
* 工单历史信息
|
||||
* @returns
|
||||
*/
|
||||
async getTaskHistoryInfo() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { jianghuKnex } = this.app;
|
||||
const { id } = actionData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
const taskInfo = await jianghuKnex('task').where({id}).first();
|
||||
// 获取process 流程、根据节点线路组建步骤条
|
||||
if (!taskInfo) {
|
||||
throw new BizError(errorInfoEnum.task_not_found);
|
||||
}
|
||||
const taskHistoryList = await jianghuKnex('task_history').where({taskId: taskInfo.taskId}).orderBy('id', 'asc').select();
|
||||
const taskStepperList = this.makeStepper(taskInfo.workflowConfig, taskHistoryList, taskInfo);
|
||||
const userList = await jianghuKnex('_view01_user').whereIn('userId', taskInfo.taskViewUserList.split(',')).select();
|
||||
taskInfo.workflowConfig = JSON.parse(taskInfo.workflowConfig);
|
||||
const taskHistoryConfigList = this.getTaskHistoryConfigList(taskInfo.workflowConfig, taskHistoryList, userList);
|
||||
|
||||
// 查找task 任务历史列表 taskEditedUserList
|
||||
const isAccess = taskInfo.taskEditUserList.includes(userId) && (taskInfo.taskEditedUserList || '').indexOf(userId) === -1;
|
||||
const lineTypeList = taskInfo.taskLineTypeList;
|
||||
const nextLineList = taskInfo.taskStatus === 'running' ? JSON.parse(taskInfo.taskNextConfigList) : [];
|
||||
const taskTpl = JSON.parse(taskInfo.taskFormInput || '{"input": {}, "formList": []}');
|
||||
// const currentNode = taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId);
|
||||
return {
|
||||
taskStepperList,
|
||||
taskHistoryList,
|
||||
isAccess,
|
||||
lineTypeList,
|
||||
nextLineList,
|
||||
taskTpl,
|
||||
currentNode: taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId),
|
||||
taskHistoryConfigList
|
||||
};
|
||||
}
|
||||
/**
|
||||
* 获取所有节点,标示历史节点+当前节点
|
||||
* @returns
|
||||
*/
|
||||
getTaskHistoryConfigList(workflowConfig, taskHistory, userList) {
|
||||
const {nodeList = [], lineList = []} = workflowConfig;
|
||||
// 历史所有主节点和连线做标志
|
||||
nodeList.filter(node => taskHistory.some(history => history.taskConfigId === node.id || history.taskLineTo.includes(node.id))).forEach(node => {
|
||||
node.inPath = true
|
||||
fileInput.forEach(async element => {
|
||||
element.answer.forEach(async file => {
|
||||
const { filename, downloadPath, binarySize } = file
|
||||
insertData.push({
|
||||
fileId: "F" + (idSequence),
|
||||
idSequence: idSequence,
|
||||
fileBizId: taskId,
|
||||
filename,
|
||||
downloadPath,
|
||||
binarySize
|
||||
})
|
||||
// TODO: 将审批人 展示再 审批节点上
|
||||
nodeList.forEach(node => {
|
||||
if (node.type === 'userTask') {
|
||||
const userMap = _.keyBy(userList, 'userId');
|
||||
node.origin.properties.userList = node.assignValue.map(uId => userMap[uId] ? userMap[uId]['username'] : uId);
|
||||
}
|
||||
idSequence++
|
||||
});
|
||||
taskHistory.forEach((history, index) => {
|
||||
lineList.filter(line => history.taskConfigId === line.from && history.taskLineTo.includes(line.to)).forEach(line => {
|
||||
line.label = line.label + ` (${index + 1})`
|
||||
})
|
||||
})
|
||||
|
||||
return {nodeList, lineList};
|
||||
}
|
||||
/**
|
||||
* 制作节点步骤list
|
||||
* @param {*} processInfo
|
||||
* @returns
|
||||
*/
|
||||
makeStepper(workflowStructure, taskHistory, taskInfo) {
|
||||
const { jianghuKnex } = this.app;
|
||||
const {nodeList = [], lineList = []} = JSON.parse(workflowStructure || '{}');
|
||||
const nodeSortList = [];
|
||||
for (const item of taskHistory) {
|
||||
const taskNextConfigList = JSON.parse(item.taskNextConfigList);
|
||||
// 查找和当前节点相同的上个节点和下个节点来判断是否是并行处理
|
||||
const node = this.getNodeBrotherList(item.taskConfigId, nodeList, lineList);
|
||||
const nodeIdList = node.map(e => {return e.id});
|
||||
const exist = _.flatten(nodeSortList).some(e => nodeIdList.includes(e.id));
|
||||
if (!exist) {
|
||||
node.forEach(e => {
|
||||
e.type = 'history';
|
||||
})
|
||||
nodeSortList.push(node);
|
||||
}
|
||||
}
|
||||
const length = nodeList.length - nodeSortList.length;
|
||||
for(let i = 0; i < length; i++) {
|
||||
const nodeCache = this.getNextNodeSetup(nodeList, lineList, nodeSortList, taskInfo);
|
||||
if (!nodeCache || !nodeCache.length) {
|
||||
continue;
|
||||
}
|
||||
nodeSortList.push(nodeCache)
|
||||
if (nodeSortList.length >= nodeList.length) break;
|
||||
}
|
||||
const stepperList = []
|
||||
let i = 1;
|
||||
for (const item of nodeSortList) {
|
||||
const step = [];
|
||||
item.forEach(e => {
|
||||
step.push({value: i, text: e.label, id: e.id, type: e.type});
|
||||
})
|
||||
stepperList.push(step);
|
||||
i++;
|
||||
}
|
||||
return stepperList;
|
||||
}
|
||||
// 根据当前节点id 寻找共同并行节点
|
||||
getNodeBrotherList(currentNodeId, nodeList, lineList) {
|
||||
const prevLine = lineList.filter(e => e.to === currentNodeId);
|
||||
const nextLineList = lineList.filter(e => e.from === currentNodeId);
|
||||
const node = [nodeList.find(e => e.id === currentNodeId)];
|
||||
prevLine.forEach(line => {
|
||||
// 查找和当前节点相同的上个节点和下个节点来判断是否是并行处理
|
||||
let otherNodeIdList = lineList.filter(e =>
|
||||
// 来处节点相同
|
||||
e.from === line.from && e.to !== currentNodeId &&
|
||||
// 去处类型相同
|
||||
e.type === line.type).map(e => {return e.to});
|
||||
let otherNodeNextLine = lineList.filter(e => otherNodeIdList.includes(e.from));
|
||||
// 筛选其他兄弟和自己终点一样的节点
|
||||
otherNodeNextLine = otherNodeNextLine.filter(e => nextLineList.some(s => e.to === s.to && e.type === s.type));
|
||||
otherNodeNextLine.forEach(element => {
|
||||
node.push(nodeList.find(e => e.id === element.from))
|
||||
});
|
||||
|
||||
});
|
||||
return node;
|
||||
}
|
||||
/**
|
||||
* 获取下一个步骤节点
|
||||
* @param {*} nodeAllList
|
||||
* @param {*} lineAllList
|
||||
* @param {*} nodeSortList
|
||||
* @returns
|
||||
*/
|
||||
getNextNodeSetup(nodeAllList, lineAllList, nodeSortList, taskInfo) {
|
||||
const lastNodeIdList = nodeSortList[nodeSortList.length - 1].map(e => {return e.id});
|
||||
const lineList = lineAllList.filter(e => lastNodeIdList.includes(e.from));
|
||||
if (!lineList.length) {
|
||||
return null;
|
||||
// 线路不存在
|
||||
}
|
||||
if (lineList.some(e => e.to === taskInfo.taskConfigId)) {
|
||||
return this.getNodeBrotherList(taskInfo.taskConfigId, nodeAllList, lineAllList);
|
||||
}
|
||||
const existIdList = _.flatten(nodeSortList).map(e => {return e.id});
|
||||
return nodeAllList.filter(e => lineList.some(s => s.to === e.id) && !existIdList.includes(e.id));
|
||||
}
|
||||
async generateAllUserTask(id, trx) {
|
||||
const taskInfo = await trx('task', this.ctx).where({id}).first();
|
||||
delete taskInfo.id;
|
||||
const {nodeList = [], lineList = []} = JSON.parse(taskInfo.workflowConfig || '{}');
|
||||
const userNode = nodeList.filter(e => e.id.includes('userTask') || e.id.includes('receiveTask') );
|
||||
for (const node of userNode) {
|
||||
let taskEditUserList = await this.getProcessUserList([node]);
|
||||
const nextLineList = lineList.filter(e => e.from === node.id);
|
||||
await trx('task', this.ctx).insert({
|
||||
...taskInfo,
|
||||
taskNextConfigList: JSON.stringify(nextLineList),
|
||||
taskLineTypeList: node.lineTypeList,
|
||||
taskEditUserList,
|
||||
taskConfigId: node.id,
|
||||
taskStatus: 'running'
|
||||
});
|
||||
}
|
||||
}
|
||||
async submitNode() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
validateUtil.validate(appDataSchema.submitNode , actionData);
|
||||
const { jianghuKnex } = this.app;
|
||||
await jianghuKnex.transaction(async trx => {
|
||||
await this.buildNext(actionData, trx);
|
||||
});
|
||||
}
|
||||
|
||||
async saveCurrentNodeExecHistory(trx, taskInfo, currentNode, taskFormInput, taskComment, lines, lineType) {
|
||||
// 写入exec历史
|
||||
const taskHistory = await trx('task_history', this.ctx).where({taskId: taskInfo.taskId}).orderBy('operationAt', 'desc').select();
|
||||
const [prevHistory] = taskHistory;
|
||||
// let taskFormInput = JSON.parse(taskInfo.taskFormInput);
|
||||
// taskFormInput.input = taskTpl.input;
|
||||
// taskFormInput = JSON.stringify(taskFormInput);
|
||||
// const historyTaskFormInput = JSON.parse(taskInfo.taskFormInput)
|
||||
// historyTaskFormInput .input = taskTpl.input;
|
||||
const history = {
|
||||
...taskInfo,
|
||||
// taskFormInput: JSON.stringify(historyTaskFormInput),
|
||||
taskFormInput,
|
||||
taskExplain: currentNode.label,
|
||||
taskConfigId: currentNode.id,
|
||||
taskHandleDesc: currentNode.id.includes('start-') ? '流程开始' : lineType,
|
||||
taskLineFrom: (lines.map(e => {return e.form})).join(','),
|
||||
taskLineTo: (lines.map(e => {return e.to})).join(','),
|
||||
taskLineLabel: (lines.map(e => {return e.type + '-' + e.label})).join(','),
|
||||
taskCostDuration: prevHistory ? parseInt((new Date().getTime() - new Date(prevHistory.operationAt).getTime()) / 1000) : 0,
|
||||
taskComment
|
||||
}
|
||||
delete history.taskEditedUserList;
|
||||
await trx('task_history', this.ctx).insert(history);
|
||||
|
||||
return {taskHistory, history};
|
||||
}
|
||||
|
||||
async saveWorkFlowExecHistory(trx, taskInfo, currentNode, endNode, line, nextLineList, taskEditUserList, history) {
|
||||
taskEditUserList = await this.getProcessUserList([currentNode]);
|
||||
const endHistory = {
|
||||
...history,
|
||||
taskStatus: 'end',
|
||||
taskExplain: '结束',
|
||||
taskConfigId: endNode.id,
|
||||
taskHandleDesc: '流程结束',
|
||||
taskLineFrom: line.from,
|
||||
taskLineTo: line.to,
|
||||
taskLineLabel: line.type + '-' + line.label,
|
||||
taskCostDuration: 0
|
||||
}
|
||||
await trx('task_history', this.ctx).insert(endHistory);
|
||||
await trx('task', this.ctx).insert({
|
||||
...taskInfo,
|
||||
taskId: taskInfo.taskId,
|
||||
taskFormInput: taskInfo.taskFormInput,
|
||||
taskNextConfigList: JSON.stringify(nextLineList),
|
||||
taskLineTypeList: endNode.lineTypeList,
|
||||
taskEditUserList,
|
||||
taskConfigId: endNode.id,
|
||||
taskStatus: 'end'
|
||||
});
|
||||
}
|
||||
|
||||
// 保存历史任务,并生成下一阶段的任务
|
||||
async buildNext(actionData, trx) {
|
||||
let { type, id, taskComment, taskFormInput } = actionData;
|
||||
const { userId } = this.ctx.userInfo;
|
||||
|
||||
// 准备任务数据
|
||||
const taskInfo = await trx('task').where({id}).first();
|
||||
delete taskInfo.id;
|
||||
/*
|
||||
* mode: serial / parallel
|
||||
* serial: 仅启动下一阶段的任务
|
||||
* parallel: 后续任务都启动
|
||||
*/
|
||||
const {mode = 'serial', nodeList = [], lineList = []} = JSON.parse(taskInfo.workflowConfig || '{}');
|
||||
const userNode = nodeList.filter(e => e.id.includes('userTask') || e.id.includes('receiveTask') );
|
||||
const userTaskCount = userNode.reduce((acc, cur) => acc += cur.isNeedAllApproval? cur.assignValue.length: 1, 0);
|
||||
const endNode = nodeList.find(e => e.id.includes('end-'));
|
||||
const nLineList = JSON.parse(taskInfo.taskNextConfigList);
|
||||
// 取同意类型的连线
|
||||
const lines = nLineList.filter(e => e.type === type);
|
||||
const currentNode = nodeList.find(e => e.id === taskInfo.taskConfigId);
|
||||
taskFormInput = taskFormInput || taskInfo.taskFormInput;
|
||||
|
||||
const {taskHistory, history} = await this.saveCurrentNodeExecHistory(trx, taskInfo, currentNode, taskFormInput, taskComment, lines, type);
|
||||
|
||||
// 未配置连线时,默认添加拒绝连线到end节点
|
||||
if (endNode && !lines.length) {
|
||||
lines.push({
|
||||
"from": currentNode.id,
|
||||
"to": endNode.id,
|
||||
"type": "拒绝",
|
||||
"label": "结束",
|
||||
"toInterruptEnd": true
|
||||
});
|
||||
}
|
||||
|
||||
for (const line of lines) {
|
||||
const nextNode = nodeList.find(e => e.id === line.to);
|
||||
const nextLineList = lineList.filter(e => e.from === line.to);
|
||||
let taskEditUserList = await this.getProcessUserList([nextNode]);
|
||||
|
||||
// 当前节点如果需要所有人审批并且不是拒绝连线时,检查是否所有人都审批过了
|
||||
if (currentNode.isNeedAllApproval && !line.toInterruptEnd) {
|
||||
let taskEditedUserList = taskInfo.taskEditedUserList? `${taskInfo.taskEditedUserList},${userId}`: userId;
|
||||
await trx('task', this.ctx).where({id}).update({taskEditedUserList});
|
||||
if (_.xor(taskEditedUserList.split(','), taskInfo.taskEditUserList.split(',')).length != 0) {
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
await trx('task', this.ctx).where({id}).delete();
|
||||
|
||||
// 结束流程
|
||||
// 条件:
|
||||
// 1. 串行模式,连接end节点时
|
||||
// 2. 默认拒绝节点
|
||||
// 3. 并行模式,所有节点通过
|
||||
if (
|
||||
(mode == 'serial' && line.to.includes('end-')) ||
|
||||
line.toInterruptEnd === true ||
|
||||
(mode == 'parallel' && taskHistory.length == userTaskCount && line.type != '拒绝')
|
||||
) {
|
||||
await this.saveWorkFlowExecHistory(trx, taskInfo, currentNode, endNode, line, nextLineList, taskEditUserList, history);
|
||||
|
||||
// 默认拒绝节点,删除全部任务,执行interruptHook
|
||||
if (line.toInterruptEnd) {
|
||||
await trx('task', this.ctx).where({taskId: taskInfo.taskId, taskStatus: 'running'}).delete();
|
||||
await this.executeHook(endNode.interruptHook);
|
||||
} else {
|
||||
await this.executeHook(endNode.finishHook);
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
await this.executeHook(line.hook);
|
||||
|
||||
// 其他同级节点未结束,暂时不生成下一个节点
|
||||
let otherNodeList = this.getNodeBrotherList(taskInfo.taskConfigId, nodeList, lineList);
|
||||
otherNodeList = otherNodeList.filter(e => e.id !== taskInfo.taskConfigId);
|
||||
|
||||
if (otherNodeList.length && !otherNodeList.some(e => taskHistory.some(s => s.taskConfigId === e.id))) {
|
||||
console.log('其他并行未结束、暂停任务')
|
||||
return
|
||||
}
|
||||
|
||||
// 串行审核,生成下一个task
|
||||
if (mode == 'serial') {
|
||||
await trx('task', this.ctx).insert({
|
||||
...taskInfo,
|
||||
taskId: taskInfo.taskId,
|
||||
taskFormInput,
|
||||
taskNextConfigList: JSON.stringify(nextLineList),
|
||||
taskLineTypeList: nextNode.lineTypeList,
|
||||
taskEditUserList,
|
||||
taskConfigId: nextNode.id,
|
||||
taskStatus: type === 'deny' ? 'deny' : 'running'
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
async executeHook(hook) {
|
||||
try {
|
||||
const { service, serviceFunction } = JSON.parse(hook || '{}');
|
||||
if (service && serviceFunction) {
|
||||
await this.ctx.service[service][serviceFunction](this.ctx.request.body.appData.actionData, this.ctx)
|
||||
}
|
||||
} catch (error) {
|
||||
throw new BizError(errorInfoEnum.line_hook_error);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 操作历史查询 Hook,非 admin 账户只能查自己的操作历史
|
||||
*/
|
||||
async historyFilterHook() {
|
||||
const { where = {} } = this.ctx.request.body.appData;
|
||||
const { user, userGroupRoleList } = this.ctx.userInfo;
|
||||
// 如果用户不在 adminGroup 内,则只能查看自己的数据
|
||||
if (!userGroupRoleList.find(o => o.groupId === 'adminGroup')) {
|
||||
where.operationByUserId = user.userId;
|
||||
if (insertData.length > 0) await jianghuKnex('file', this.ctx).insert(insertData);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -68,7 +68,6 @@
|
||||
watch: {
|
||||
'inputFile':{
|
||||
handler(newVal,oldVal){
|
||||
console.log('inputFile', newVal);
|
||||
newVal.forEach(element => {
|
||||
this.uploadFn(element)
|
||||
});
|
||||
@@ -108,24 +107,12 @@
|
||||
}
|
||||
}
|
||||
})
|
||||
console.log('uploadFn', result);
|
||||
|
||||
const { filename, downloadPath, binarySize } = result.data.appData.resultData;
|
||||
this.$emit('input', [...this.value, {filename, downloadPath, binarySize}]);
|
||||
|
||||
const { status } = result.data;
|
||||
if (status === 'success') {
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'allPage',
|
||||
actionId: 'insertItem',
|
||||
actionData: { filename, downloadPath, binarySize }
|
||||
}
|
||||
}
|
||||
})
|
||||
} else {
|
||||
// this.uploadFail++
|
||||
if (status !== 'success') {
|
||||
await window.vtoast.fail(filename + "上传失败");
|
||||
}
|
||||
this.isTableLoading = false
|
||||
|
||||
@@ -3,25 +3,61 @@
|
||||
<v-navigation-drawer v-model="isDrawerShown" v-if="isDrawerShown" :permanent="isDrawerShown" fixed temporary right width="90%" class="elevation-24">
|
||||
<!-- 抽屉标题 -->
|
||||
<v-row no-gutters>
|
||||
<span class="text-h7 font-weight-bold pa-4">创建审批</span>
|
||||
<span class="text-h7 font-weight-bold pa-4">【{{taskData.workflowName}}】创建审批</span>
|
||||
</v-row>
|
||||
<!-- {{taskData.workflowForm}} -->
|
||||
<!-- 表单 -->
|
||||
<v-row class="px-4 mt-2">
|
||||
<v-col cols="12" v-for="(formItem, index) in taskData.workflowForm" :key="index" class="pa-2 ma-0">
|
||||
<v-row class="ma-4 mt-2">
|
||||
<v-col cols="12" v-for="(formItem, index) in taskData.workflowForm" :key="index" class="px-2 py-1 ma-0">
|
||||
<span class="jh-input-label">{{ index + 1 }}. {{ formItem.statement }}<span v-show="formItem.isRequire" class="red--text ml-1">*</span></span>
|
||||
<form-component-list :form-item="formItem" :disabled='false' @calc-workflow="getWorkflow"></form-component-list>
|
||||
<form-component-list v-if="isDrawerShown" :form-item="formItem" :disabled='false' @calc-workflow="getWorkflow" ></form-component-list>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-divider class="jh-divider"></v-divider>
|
||||
<!-- 审批流 -->
|
||||
<v-row class="px-4 mt-2">
|
||||
{{taskData.workflowConfig}}
|
||||
<v-row class="ma-4 mt-2">
|
||||
<v-col cols="12" class="font-weight-bold pa-0 mx-0 my-2">审批流程</v-col>
|
||||
<v-col cols="12" class="pa-0 ma-0">
|
||||
<div v-for="(node, nodeIndex) in curWorkflow">
|
||||
<div class="node-box">
|
||||
<div class="node-box-stepper" color="#cdcfd1">
|
||||
<v-icon v-if="node.properties.type == 'approvalTask'" color="#cdcfd1">mdi-account-circle</v-icon>
|
||||
<v-icon v-if="node.properties.type == 'noticeTask'" color="#cdcfd1">mdi-send-circle</v-icon>
|
||||
<div v-if="nodeIndex < curWorkflow.length - 1" class="vertical-line"></div>
|
||||
</div>
|
||||
<div class="node-box-item">
|
||||
<div class="item-label font-weight-bold ">
|
||||
{{node.properties.label}}
|
||||
<v-chip class="ml-1 px-1 py-2" x-small v-if="node.properties.approvalType" label outlined color="#4caf50">
|
||||
{{node.properties.approvalType}}
|
||||
</v-chip>
|
||||
</div>
|
||||
<div class="d-flex align-center">
|
||||
<template v-for="(userId, userIndex) in node.properties.userIdList">
|
||||
<div class="item-user-box d-flex justify-space-between px-2 mr-2">
|
||||
<span class="omit">{{ constantObj.userList.find(u => u.userId == userId)?.username || userId }}</span>
|
||||
<v-icon class="ml-1" color="#a4a7aa" @click="doUiAction('deleteNodeUser', {nodeIndex ,userIndex})">mdi-close</v-icon>
|
||||
</div>
|
||||
<v-icon v-if="userIndex != node.properties.userIdList.length && node.properties.approvalType == '依次审批'"
|
||||
class="mr-2" color="#afb1b4" small>
|
||||
mdi-arrow-right-thin
|
||||
</v-icon>
|
||||
</template>
|
||||
<template>
|
||||
<div class="abb-user d-flex justify-center align-center" @click="doUiAction('startAddNodeUser', nodeIndex)">
|
||||
<v-icon color="#4caf50">mdi-plus</v-icon>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</v-col>
|
||||
</v-row>
|
||||
<v-row class="justify-end mx-0 my-8 px-4">
|
||||
<!-- 抽屉操作按钮 -->
|
||||
<div class="d-flex justify-end pr-4">
|
||||
<v-btn color="success" @click="doUiAction()" small>保存</v-btn>
|
||||
<v-btn color="success" @click="doUiAction('createTask')" small>提交</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="isDrawerShown = false" small>取消</v-btn>
|
||||
</div>
|
||||
</v-row>
|
||||
@@ -31,6 +67,48 @@
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
<template>
|
||||
<v-row justify="center">
|
||||
<v-dialog
|
||||
v-model="isAddNodeUserDialogShown"
|
||||
persistent
|
||||
width="30%"
|
||||
>
|
||||
<v-card>
|
||||
<v-card-title class="text-h5">
|
||||
添加用户
|
||||
</v-card-title>
|
||||
<v-card-text>
|
||||
<v-autocomplete
|
||||
class="jh-v-input mr-2"
|
||||
dense filled single-line clearable
|
||||
:items="constantObj.userList"
|
||||
item-text="username"
|
||||
item-value="userId"
|
||||
v-model="addNodeUserId">
|
||||
</v-autocomplete>
|
||||
</v-card-text>
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="green darken-1"
|
||||
text
|
||||
@click="doUiAction('closeAddNodeUserDialog')"
|
||||
>
|
||||
取消
|
||||
</v-btn>
|
||||
<v-btn
|
||||
color="green darken-1"
|
||||
text
|
||||
@click="doUiAction('doAddNodeUser')"
|
||||
>
|
||||
保存
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</v-row>
|
||||
</template>
|
||||
</v-card>
|
||||
</template>
|
||||
|
||||
@@ -55,14 +133,22 @@ Vue.component("create-task-drawer", {
|
||||
},
|
||||
isHelpPageDrawerShown: false,
|
||||
|
||||
defaultWorkflow: {},
|
||||
taskData: {}
|
||||
defaultWorkflowConfig: {},
|
||||
defaultWorkflowForm: [],
|
||||
taskData: {},
|
||||
taskSubmitData: null,
|
||||
isAddNodeUserDialogShown: false,
|
||||
addNodeUserIndex: -1,
|
||||
addNodeUserId: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
isMobile() {
|
||||
return window.innerWidth < 600;
|
||||
},
|
||||
curWorkflow(){
|
||||
return this.taskData.workflowConfig.nodeList.filter(node => !['start', 'end', 'conditionTask'].includes(node.properties.type))
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
},
|
||||
@@ -88,6 +174,26 @@ Vue.component("create-task-drawer", {
|
||||
await this.getGroupList();
|
||||
await this.getLabelList();
|
||||
break;
|
||||
case 'deleteNodeUser':
|
||||
await this.deleteNodeUser(uiActionData);
|
||||
break;
|
||||
case 'startAddNodeUser':
|
||||
await this.startAddNodeUser(uiActionData);
|
||||
break;
|
||||
case 'doAddNodeUser':
|
||||
await this.addNodeUser();
|
||||
await this.closeAddNodeUserDialog();
|
||||
break;
|
||||
case 'closeAddNodeUserDialog':
|
||||
await this.closeAddNodeUserDialog();
|
||||
break;
|
||||
case 'createTask':
|
||||
await this.prepareCreateValidate();
|
||||
await this.confirmCreateWorkDialog();
|
||||
await this.prepareDoWorkItem();
|
||||
await this.doCreateWork();
|
||||
await this.doUiAction('close')
|
||||
break;
|
||||
default:
|
||||
console.error("[doUiAction] uiActionId not find", {uiActionId});
|
||||
break;
|
||||
@@ -104,7 +210,13 @@ Vue.component("create-task-drawer", {
|
||||
formObj.workflowConfig = formObj.workflowConfig ? JSON.parse(formObj.workflowConfig) : null;
|
||||
formObj.workflowForm = formObj.workflowForm ? (typeof formObj.workflowForm == 'string'? JSON.parse(formObj.workflowForm): formObj.workflowForm) : [];
|
||||
formObj.workflowForm.forEach(f => f.answer = []) // 兼容多选
|
||||
this.defaultWorkflow = _.cloneDeep(formObj.workflowConfig);
|
||||
this.defaultWorkflowConfig = _.cloneDeep(formObj.workflowConfig);
|
||||
this.defaultWorkflowForm = _.cloneDeep(formObj.workflowForm);
|
||||
this.defaultWorkflowConfig.nodeList.forEach(node =>{
|
||||
if(['approvalTask', 'noticeTask'].includes(node.properties.type)){
|
||||
node.properties.userIdList = this.getUserByType(node)
|
||||
}
|
||||
})
|
||||
this.taskData = _.cloneDeep(formObj);
|
||||
} else {
|
||||
window.vtoast.fail('[createTaskDrawer] 出错,请联系管理员!');
|
||||
@@ -117,52 +229,64 @@ Vue.component("create-task-drawer", {
|
||||
},
|
||||
|
||||
async closeDrawer() {
|
||||
this.defaultWorkflow = null;
|
||||
this.defaultWorkflowConfig = null;
|
||||
this.defaultWorkflowForm = null;
|
||||
this.taskData = null;
|
||||
this.isDrawerShown = false;
|
||||
},
|
||||
|
||||
// -- 获取数据 >>>>>>>>>>> ---------------
|
||||
/**
|
||||
* 获取user数据
|
||||
*/
|
||||
// 获取user数据
|
||||
async getUserList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
pageId: 'createTaskDrawer',
|
||||
actionId: 'selectUserList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
})).data.appData.resultData;
|
||||
this.constantObj.userList = rows.map(e => {
|
||||
return { username: e.username, userId: e.userId, userId: e.userId }
|
||||
})
|
||||
this.constantObj.userList = await this.handleMultiGroupUser(rows)
|
||||
},
|
||||
|
||||
/**
|
||||
* 获取group数据
|
||||
*/
|
||||
async handleMultiGroupUser(userList){
|
||||
let groupByUserId = _.groupBy(userList,'userId');
|
||||
_.forEach(groupByUserId,(val, key)=>{
|
||||
// 合并groupAllName,若只有一个值则转为数组
|
||||
const group = _.map(val, (u) => {
|
||||
return {
|
||||
groupId: u.groupId,
|
||||
groupPath: u.groupPath,
|
||||
groupAllName: u.groupAllName,
|
||||
isMainGroup: u.isMainGroup,
|
||||
roleId: u.roleId,
|
||||
roleName: u.roleName
|
||||
}
|
||||
}).filter(g => g.groupId)
|
||||
// 集成到第一个对象中
|
||||
val[0].group = group
|
||||
groupByUserId[key] = _.pick(val[0], ['userId', 'username', 'directSupervisor', 'group'])
|
||||
})
|
||||
return _.values(groupByUserId)
|
||||
},
|
||||
|
||||
// 获取group数据
|
||||
async getGroupList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
pageId: 'createTaskDrawer',
|
||||
actionId: 'selectGroupList',
|
||||
actionData: {},
|
||||
where: {},
|
||||
}
|
||||
}
|
||||
})).data.appData.resultData;
|
||||
this.constantObj.groupList = rows.map(e => {
|
||||
return {groupName: e.groupName, groupId: e.groupId}
|
||||
});
|
||||
this.constantObj.groupList = rows
|
||||
},
|
||||
/**
|
||||
* 获取label数据
|
||||
*/
|
||||
// 获取label数据
|
||||
async getLabelList() {
|
||||
const {rows} = (await window.jianghuAxios({
|
||||
data: {
|
||||
@@ -178,8 +302,84 @@ Vue.component("create-task-drawer", {
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 获取数据 --------------------
|
||||
|
||||
// -- 计算审批流 >>>>>>>>>>> ---------------
|
||||
getUserByType(node){
|
||||
var userList = []
|
||||
var type = node.properties.type == 'approvalTask' ?
|
||||
node.properties.approverType : node.properties.noticerType
|
||||
|
||||
switch (type) {
|
||||
case '指定上级':
|
||||
var num = 0
|
||||
node.properties.user.forEach(u =>{
|
||||
num = u == '直属上级' ? 1 : u[1]
|
||||
userList = userList.concat(this.getDirectSupervisor([`<$ ctx.userInfo.userId $>`], num))
|
||||
})
|
||||
break;
|
||||
case '指定部门负责人':
|
||||
var num = 0
|
||||
node.properties.user.forEach(u =>{
|
||||
num = u == '直接部门负责人' ? 1 : u[1]
|
||||
var groupId = this.constantObj.userList.find(u => u.userId == `<$ ctx.userInfo.userId $>`)?.group.find(g => g.isMainGroup == '是')?.groupId
|
||||
userList = userList.concat(this.getHeadId(groupId, num))
|
||||
})
|
||||
break;
|
||||
case '指定标签':
|
||||
node.properties.user.forEach(u =>{
|
||||
let userIdList = this.constantObj.labelList.find(l => l.labelId == u)?.user.split(',')
|
||||
if(userIdList && userIdList.length > 0) userList = userList.concat(userIdList)
|
||||
})
|
||||
break;
|
||||
case '指定人员':
|
||||
userList = node.properties.user
|
||||
break;
|
||||
case '申请人自选':
|
||||
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return userList
|
||||
},
|
||||
|
||||
// 获取第n级上级
|
||||
getDirectSupervisor(userIdList = [], num){
|
||||
var directSupervisorList = []
|
||||
if(num > 0 && userIdList.length > 0){
|
||||
while(num > 0){
|
||||
num--
|
||||
directSupervisorList = []
|
||||
userIdList.forEach(userId => {
|
||||
let user = this.constantObj.userList.find(u => u.userId == userId)
|
||||
if(user){
|
||||
directSupervisorList = directSupervisorList.concat(user.directSupervisor ? user.directSupervisor.split(',') : [])
|
||||
}
|
||||
})
|
||||
userIdList = directSupervisorList
|
||||
}
|
||||
}
|
||||
|
||||
return directSupervisorList
|
||||
},
|
||||
getHeadId(groupId, num){
|
||||
var headerId = []
|
||||
|
||||
while(num > 0){
|
||||
num--
|
||||
headerId = []
|
||||
if(!groupId) break
|
||||
var group = this.constantObj.groupList.find(g => g.groupId == groupId)
|
||||
if(group){
|
||||
headerId = group.headId?.split(',') || []
|
||||
}
|
||||
groupId = group.groupPath
|
||||
}
|
||||
|
||||
return headerId
|
||||
},
|
||||
async getWorkflow(){
|
||||
this.taskData.workflowConfig = await this.calcWorkflow(this.defaultWorkflow)
|
||||
this.taskData.workflowConfig = await this.calcWorkflow(this.defaultWorkflowConfig)
|
||||
},
|
||||
|
||||
// 计算审批流
|
||||
@@ -210,12 +410,12 @@ Vue.component("create-task-drawer", {
|
||||
|
||||
// 查找传入节点的下一个节点,直到找到结束节点
|
||||
calcNode(workflow, node){
|
||||
var lineList = workflow.lineList
|
||||
var nodeList = workflow.nodeList
|
||||
var lineList = workflow.lineList,
|
||||
nodeList = workflow.nodeList,
|
||||
nextNode = null,
|
||||
prevLine = null,
|
||||
nextNodeList = []
|
||||
|
||||
var nextNode = null
|
||||
var prevLine = null
|
||||
var nextNodeList = []
|
||||
nextNodeList = _.intersectionWith(nodeList, lineList.filter(line => line.sourceNodeId == node.id),
|
||||
(node, line) => line.targetNodeId == node.id);
|
||||
|
||||
@@ -284,15 +484,145 @@ Vue.component("create-task-drawer", {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
return isMatch
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 计算审批流 --------------------
|
||||
|
||||
// -- 操作审批流 >>>>>>>>>>> ---------------
|
||||
deleteNodeUser({nodeIndex ,userIndex}){
|
||||
this.curWorkflow[nodeIndex].properties.userIdList.splice(userIndex, 1)
|
||||
this.$forceUpdate()
|
||||
},
|
||||
|
||||
startAddNodeUser(nodeIndex){
|
||||
this.addNodeUserIndex = nodeIndex
|
||||
this.isAddNodeUserDialogShown = true
|
||||
},
|
||||
|
||||
addNodeUser(){
|
||||
if(!this.addNodeUserId) return window.vtoast.fail('保存用户失败!')
|
||||
this.curWorkflow[this.addNodeUserIndex].properties.userIdList.push(this.addNodeUserId)
|
||||
window.vtoast.success('保存用户成功!')
|
||||
},
|
||||
|
||||
closeAddNodeUserDialog(){
|
||||
this.isAddNodeUserDialogShown = false
|
||||
this.addNodeUserIndex = -1
|
||||
this.addNodeUserId = null
|
||||
},
|
||||
|
||||
// -- <<<<<<<<<<<<< 操作审批流 --------------------
|
||||
// -- 新建任务 >>>>>>>>>>> ---------------
|
||||
async prepareCreateValidate() {
|
||||
// 检查必填是否已填 TODO:注意文件
|
||||
this.taskData.workflowForm.forEach(f => {
|
||||
if(f.isRequire){
|
||||
if(!f.answer || f.answer && f.answer.length == 0){
|
||||
window.vtoast.fail("请完善表单信息")
|
||||
throw new Error("请完善表单信息")
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
},
|
||||
async confirmCreateWorkDialog() {
|
||||
if (await window.confirmDialog({ title: "新建任务", content: "确定新建任务吗?" }) === false) {
|
||||
throw new Error("[confirmCreateFormDialog] 否");
|
||||
}
|
||||
},
|
||||
prepareDoWorkItem() {
|
||||
const { workflowInfo, workflowForm, workflowConfig, } = this.taskData
|
||||
const { workflowName, taskTemplateGroup } = workflowInfo
|
||||
var curNode = this.curWorkflow[0]
|
||||
var taskLineType = this.taskData.workflowConfig.lineList.filter(line => line.sourceNodeId == curNode.id)[0]?.properties.type
|
||||
var taskViewUserList = this.curWorkflow.reduce((acc, cur) => acc.concat(cur.properties.userIdList), [] )
|
||||
this.taskSubmitData = {
|
||||
taskTitle: `<$ ctx.userInfo.username $>` + '的' + workflowName,
|
||||
taskStatus: 'running',
|
||||
taskFormInput: JSON.stringify(workflowForm),
|
||||
taskDefaultForm: JSON.stringify(this.defaultWorkflowForm),
|
||||
taskWorkflow: JSON.stringify(workflowConfig),
|
||||
taskDefaultWorkflow: JSON.stringify(this.defaultWorkflowConfig),
|
||||
taskConfigId: curNode.id,
|
||||
taskLineType: taskLineType,
|
||||
taskEditUserList: curNode.properties.userIdList.join(','),
|
||||
taskViewUserList: _.uniq(taskViewUserList).join(','),
|
||||
taskCreateAt: dayjs().format('YYYY-MM-DD HH:mm:ss'),
|
||||
taskInitUser: `<$ ctx.userInfo.userId $>`,
|
||||
taskTemplateGroup,
|
||||
}
|
||||
},
|
||||
|
||||
async doCreateWork() {
|
||||
await window.jhMask.show();
|
||||
await window.jianghuAxios({
|
||||
data: {
|
||||
appData: {
|
||||
pageId: 'workflowManagement',
|
||||
actionId: 'createTask',
|
||||
actionData: this.taskSubmitData,
|
||||
bizIdGenerate: {
|
||||
tableName: "task",
|
||||
prefix: "SP",
|
||||
type: "idSequence",
|
||||
bizId: "taskId",
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
await window.jhMask.hide();
|
||||
await window.vtoast.success("申请成功");
|
||||
},
|
||||
// -- <<<<<<<<<<<<< 新建任务 --------------------
|
||||
}
|
||||
})
|
||||
</script>
|
||||
|
||||
<style scoped>
|
||||
|
||||
.omit{
|
||||
white-space: nowrap;
|
||||
overflow-x: hidden;
|
||||
text-overflow: ellipsis;
|
||||
}
|
||||
|
||||
.node-box {
|
||||
display: flex;
|
||||
}
|
||||
|
||||
.node-box .node-box-stepper {
|
||||
padding: 12px 10px 0px 4px;
|
||||
}
|
||||
|
||||
.node-box .node-box-stepper .vertical-line {
|
||||
height: 80%;
|
||||
width: 0px;
|
||||
margin: 0 auto;
|
||||
border: #cdcfd1 solid 1px;
|
||||
}
|
||||
|
||||
.node-box .node-box-item .item-label {
|
||||
margin: 14px 0px 6px;
|
||||
}
|
||||
|
||||
.node-box .node-box-item .item-user-box {
|
||||
width: 84px;
|
||||
height: 40px;
|
||||
line-height: 40px;
|
||||
background-color: rgb(242 243 243);
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.node-box-item .abb-user {
|
||||
height: 40px;
|
||||
width: 40px;
|
||||
background-color: #d9f3da;
|
||||
border-radius: 2px;
|
||||
}
|
||||
|
||||
.node-box-item .abb-user:hover{
|
||||
background-color: #badebb;
|
||||
}
|
||||
</style>
|
||||
@@ -79,7 +79,6 @@
|
||||
<div :style="{'width': isMobile ? 'auto' : '350px'}">
|
||||
<!-- 右上 模式切换区 >>>>>>>>>>>>> -->
|
||||
<v-card class="mb-1 d-flex align-center" :class="{'ml-2': !isMobile}" >
|
||||
<!-- <div>{{constantObj.displayModes[displayModeIndex].text}}</div> -->
|
||||
<v-btn v-for="(displayMode, index) in constantObj.displayModes" v-if="index != displayModeIndex" class="ml-1 my-2" style="flex: 1;" color="primary"
|
||||
small outlined @click="doUiAction('changeDisplayMode', displayMode.value)">
|
||||
<span>切换展示模式</span>
|
||||
@@ -167,6 +166,10 @@ Vue.component("process-flow", {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
isDrawerShown: {
|
||||
type: Boolean,
|
||||
default: false
|
||||
},
|
||||
},
|
||||
data: () => {
|
||||
return {
|
||||
@@ -242,7 +245,6 @@ Vue.component("process-flow", {
|
||||
created(){
|
||||
},
|
||||
mounted() {
|
||||
|
||||
},
|
||||
methods: {
|
||||
async doUiAction(uiActionId, uiActionData) {
|
||||
@@ -266,7 +268,10 @@ Vue.component("process-flow", {
|
||||
break;
|
||||
}
|
||||
},
|
||||
|
||||
setDisplayMode(index){
|
||||
this.displayModeIndex = index
|
||||
this.displayMode = this.constantObj.displayModes[index].value
|
||||
},
|
||||
showMenuShown(event){
|
||||
this.activeMenuIndex = event?.target.dataset.menuIndex
|
||||
},
|
||||
@@ -378,7 +383,7 @@ Vue.component("process-flow", {
|
||||
|
||||
await this.$emit('reflesh-workflow-config', _this.workflowConfig)
|
||||
// 两种模式统一数据,待优化
|
||||
// this.initLogicFlowData()
|
||||
this.initLogicFlowData()
|
||||
},
|
||||
// 切换展示模式
|
||||
changeDisplayMode(displayMode){
|
||||
@@ -432,6 +437,7 @@ Vue.component("process-flow", {
|
||||
window.vtoast.fail("当前结构不能切换到简易模式:" + changeText + "!");
|
||||
}
|
||||
},
|
||||
|
||||
/**
|
||||
* 初始化logicFlow实例
|
||||
*/
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template id="form-component-list">
|
||||
<v-list-item>
|
||||
<!-- 单选 -->
|
||||
<v-list-item-content v-if="formItem.type === 'single'">
|
||||
<v-list-item-content v-if="formItem.type === 'single'" class="py-0">
|
||||
<template v-if="formItem.optionList.length > 0">
|
||||
<v-radio-group :disabled='disabled' v-model="formItem.answer" @change="calcWorkflow" >
|
||||
<v-radio hide-details v-for="(option, optionIndex) in formItem.optionList"
|
||||
@@ -12,7 +12,7 @@
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 多选 -->
|
||||
<v-list-item-content v-if="formItem.type === 'multiple'">
|
||||
<v-list-item-content v-if="formItem.type === 'multiple'" class="py-0">
|
||||
<template v-if="formItem.optionList.length > 0">
|
||||
<div v-for="(option, optionIndex) in formItem.optionList" :key="optionIndex">
|
||||
<v-checkbox class="mt-0" :disabled='disabled' :label="option" :value="option" hide-details v-model="formItem.answer" @click="calcWorkflow"></v-checkbox>
|
||||
@@ -22,27 +22,28 @@
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 多行文本 -->
|
||||
<v-list-item-content v-if="formItem.type === 'textarea'">
|
||||
<v-list-item-content v-if="formItem.type === 'textarea'" class="py-0">
|
||||
<v-textarea class="jh-v-input" dense outlined hide-details :disabled='disabled' :rows="4" placeholder='请输入' v-model="formItem.answer" />
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 单行文本 -->
|
||||
<v-list-item-content v-if="formItem.type === 'input'">
|
||||
<v-list-item-content v-if="formItem.type === 'input'" class="py-0">
|
||||
<v-text-field class="jh-v-input" dense outlined :disabled='disabled' placeholder='请输入' v-model="formItem.answer"></v-text-field>
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 文件 -->
|
||||
<v-list-item-content v-if="formItem.type === 'file'">
|
||||
<v-file-input chips multiple :disabled='disabled' ></v-file-input>
|
||||
<v-list-item-content v-if="formItem.type === 'file'" class="py-0">
|
||||
<v-file-input v-if="disabled" chips multiple :disabled='disabled' ></v-file-input>
|
||||
<file-upload v-else :file-biz-id="taskId" v-model="formItem.answer"></file-upload>
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 数字 -->
|
||||
<v-list-item-content v-if="formItem.type === 'number'">
|
||||
<v-list-item-content v-if="formItem.type === 'number'" class="py-0">
|
||||
<v-text-field class="jh-v-input" type="number" dense outlined :disabled='disabled' placeholder='请输入' v-model="formItem.answer" @input="calcWorkflow"></v-text-field>
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 日期选择器 -->
|
||||
<v-list-item-content v-if="formItem.type === 'date'">
|
||||
<v-list-item-content v-if="formItem.type === 'date'" class="py-0">
|
||||
<v-menu
|
||||
:close-on-content-click="false"
|
||||
:nudge-right="40"
|
||||
@@ -68,13 +69,14 @@
|
||||
</v-list-item-content>
|
||||
|
||||
<!-- 日期时间选择器 -->
|
||||
<v-list-item-content v-if="formItem.type === 'time'">
|
||||
<v-list-item-content v-if="formItem.type === 'time'" class="py-0">
|
||||
<date-time-picker :disabled='disabled' @save-date-time="setDateTime" v-model="formItem.answer"></date-time-picker>
|
||||
</v-list-item-content>
|
||||
</v-list-item>
|
||||
</template>
|
||||
|
||||
{% include 'component/common/dateTimePicker.html' %}
|
||||
{% include 'component/common/fileUpload.html' %}
|
||||
|
||||
<script type="module">
|
||||
Vue.component("form-component-list", {
|
||||
@@ -91,6 +93,10 @@ Vue.component("form-component-list", {
|
||||
type: Boolean,
|
||||
default: true,
|
||||
},
|
||||
taskId: {
|
||||
type: String,
|
||||
default: '',
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
<!-- 抽屉操作按钮 -->
|
||||
<div class="d-flex justify-end pr-4">
|
||||
<v-btn color="success" @click="doUiAction(submitUiActionId)" small>保存</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="isDrawerShown = false" small>取消</v-btn>
|
||||
<v-btn class="elevation-0 ml-2" @click="doUiAction('close')" small>取消</v-btn>
|
||||
</div>
|
||||
</v-row>
|
||||
<v-divider class="jh-divider"></v-divider>
|
||||
@@ -86,7 +86,7 @@
|
||||
</div>
|
||||
|
||||
<!-- 抽屉关闭按钮 -->
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="isDrawerShown = false">
|
||||
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn" @click="doUiAction('close')">
|
||||
<v-icon>mdi-close</v-icon>
|
||||
</v-btn>
|
||||
</v-navigation-drawer>
|
||||
@@ -201,6 +201,7 @@ Vue.component("workflow-editor-drawer", {
|
||||
},
|
||||
|
||||
async closeDrawer() {
|
||||
this.$refs.processFlow.setDisplayMode(1)
|
||||
this.isDrawerShown = false;
|
||||
},
|
||||
|
||||
|
||||
Reference in new issue
Block a user