自动审批
This commit is contained in:
1 parent
8f918fcdaa
commit
cf99cb74e1
3 files changed
+620
-64
No files matched your search
+495
-49
@@ -38,28 +38,402 @@ class TaskService extends Service {
|
||||
idSequence++
|
||||
});
|
||||
});
|
||||
if (insertData.length > 0) await jianghuKnex('file', this.ctx).insert(insertData);
|
||||
if (insertData.length > 0) await jianghuKnex('file', this.ctx).jhInsert(insertData);
|
||||
}
|
||||
}
|
||||
|
||||
async submitNode() {
|
||||
async createTask() {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { taskConfigId, taskInfo, taskWorkflow, taskFormInput } = actionData
|
||||
|
||||
await jianghuKnex('task', this.ctx).jhInsert(actionData);
|
||||
|
||||
if (taskConfigId.startsWith('noticeTask-')) {
|
||||
var data = {
|
||||
...actionData,
|
||||
taskInfo: JSON.parse(taskInfo),
|
||||
taskWorkflow: JSON.parse(taskWorkflow),
|
||||
taskFormInput: JSON.parse(taskFormInput),
|
||||
}
|
||||
// 往下走
|
||||
await this.submitNode(data, '同意', 1)
|
||||
}
|
||||
}
|
||||
|
||||
async submitApproval() {
|
||||
const { actionData } = this.ctx.request.body.appData;
|
||||
const { updateItem, type } = actionData;
|
||||
|
||||
const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext({ taskData: updateItem, type })
|
||||
await this.submitNode(updateItem, type, 0)
|
||||
}
|
||||
|
||||
async submitNode(taskData, type, times) {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { updateTaskData, historyInsertData, noticeInsertData } = await this.buildNext1({ taskData: taskData, type: type, times: times })
|
||||
|
||||
console.log('updateTaskData------', updateTaskData);
|
||||
console.log('historyInsertData------', historyInsertData);
|
||||
console.log('noticeInsertData------', noticeInsertData);
|
||||
await jianghuKnex.transaction(async trx => {
|
||||
if (updateTaskData) await trx("task", this.ctx).where({ taskId: updateItem.taskId }).jhUpdate(updateTaskData);
|
||||
if (updateTaskData) await trx("task", this.ctx).where({ taskId: taskData.taskId }).jhUpdate(updateTaskData);
|
||||
if (noticeInsertData.length > 0) await trx("notice_push", this.ctx).jhInsert(noticeInsertData);
|
||||
if (historyInsertData.length > 0) await trx("task_history", this.ctx).jhInsert(historyInsertData);
|
||||
})
|
||||
}
|
||||
|
||||
async buildNext1({ taskData, type, times }) {
|
||||
const { jianghuKnex } = this.app;
|
||||
const { userId, username } = this.ctx.userInfo;
|
||||
const { taskId, taskInfo, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData;
|
||||
|
||||
const taskHistory = await jianghuKnex('task_history').where({ taskId }).where('taskConfigId', 'like', 'approvalTask-%').select();
|
||||
|
||||
var updateTaskData = null,
|
||||
historyInsertData = [],
|
||||
noticeInsertData = [],
|
||||
curNode = taskWorkflow.nodeList.find(node => node.id == taskConfigId),
|
||||
curNodeType = curNode?.properties.type,
|
||||
taskStatus = "running",
|
||||
taskHistoryUser = [userId, ...taskHistory.map(h => h.createHistoryBy)];
|
||||
|
||||
// 插入上一次节点历史
|
||||
if (!taskData?.createHistoryBy) taskData.createHistoryBy = [userId]
|
||||
taskStatus = curNodeType == 'end' ? 'end' : 'running'
|
||||
console.log("taskData----", taskStatus, taskData);
|
||||
|
||||
// 判断是不是抄送节点,taskLineTypeList,taskExplain,taskHandleDesc,createHistoryBy
|
||||
if (curNodeType == 'noticeTask') {
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskLineTypeList: '抄送',
|
||||
taskExplain: '抄送节点',
|
||||
taskHandleDesc: '抄送',
|
||||
createHistoryBy: taskEditUserList && taskEditUserList.split(',') || []
|
||||
}
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
} else if (curNodeType == 'end') {
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskLineTypeList: '结束',
|
||||
taskExplain: '结束节点',
|
||||
taskHandleDesc: '结束',
|
||||
createHistoryBy: [userId]
|
||||
}
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
}
|
||||
|
||||
|
||||
// 判断是否同意
|
||||
if (type == '同意') {
|
||||
switch (curNodeType) {
|
||||
case 'approvalTask':
|
||||
var curApprovalType = curNode?.properties.approvalType,
|
||||
autoApprovel = taskInfo.autoApprovel,
|
||||
editUserList = taskEditUserList && taskEditUserList.split(',') || [],
|
||||
editedUserList = taskEditedUserList && taskEditedUserList.split(',') || [];
|
||||
|
||||
if (times == 0) {
|
||||
editUserList = editUserList.filter(u => u != userId)
|
||||
editedUserList.splice(-1, 0, userId)
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
}
|
||||
|
||||
if (['会签'].includes(curApprovalType)) {
|
||||
// 把可以自动审批的人给审批了
|
||||
if (autoApprovel == 1 && times == 1) {
|
||||
var autoApprovelUser = _.intersection(taskHistoryUser, editUserList)
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskComment: null,
|
||||
taskExplain: "自动审批",
|
||||
taskHandleDesc: "同意",
|
||||
taskLineTypeList: "同意",
|
||||
createHistoryBy: autoApprovelUser,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
|
||||
editUserList = editUserList.filter(u => !autoApprovelUser.includes(u))
|
||||
editedUserList = editedUserList.concat(autoApprovelUser)
|
||||
}
|
||||
|
||||
// 判断是否全部审批完成
|
||||
if (_.differenceWith(curNode.properties.userIdList, editedUserList, _.isEqual).length == 0) {
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
|
||||
editUserList = nextNode.properties.userIdList;
|
||||
editedUserList = null;
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: editUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
} else {
|
||||
updateTaskData = {
|
||||
taskConfigId: curNode.id,
|
||||
taskEditUserList: editUserList.join(','),
|
||||
taskEditedUserList: editedUserList.join(','),
|
||||
}
|
||||
}
|
||||
} else if (['或签'].includes(curApprovalType)) {
|
||||
if (times == 0) {
|
||||
// 手动审批直接进入下一节点
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
|
||||
editUserList = nextNode.properties.userIdList;
|
||||
editedUserList = null;
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: editUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
} else {
|
||||
// 自动流转,识别是否需要自动审批
|
||||
if (autoApprovel == 1) {
|
||||
var autoApprovelUser = _.intersection(taskHistoryUser, editUserList)
|
||||
|
||||
if (autoApprovelUser.length > 0) {
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskComment: null,
|
||||
taskExplain: "自动审批",
|
||||
taskHandleDesc: "同意",
|
||||
taskLineTypeList: "同意",
|
||||
createHistoryBy: [autoApprovelUser[0]],
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
|
||||
editUserList = nextNode.properties.userIdList;
|
||||
editedUserList = null;
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: editUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
} else {
|
||||
updateTaskData = {
|
||||
taskConfigId: curNode.id,
|
||||
taskEditUserList: editUserList.join(','),
|
||||
taskEditedUserList: editedUserList.join(','),
|
||||
}
|
||||
}
|
||||
} else {
|
||||
updateTaskData = {
|
||||
taskConfigId: curNode.id,
|
||||
taskEditUserList: editUserList.join(','),
|
||||
taskEditedUserList: editedUserList.join(','),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} else if (['依次审批'].includes(curApprovalType)) {
|
||||
|
||||
// 判断是否全部审批完成
|
||||
if (_.differenceWith(curNode.properties.userIdList, editedUserList, _.isEqual).length == 0) {
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
editUserList = nextNode.properties.userIdList;
|
||||
editedUserList = null;
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: editUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
} else {
|
||||
// 判断下一个是否可以自动审批
|
||||
if (autoApprovel == 1) {
|
||||
while (editUserList.length > 0 && taskHistoryUser.includes(editUserList[0])) {
|
||||
// 插入历史
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskEditUserList: editedUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
createHistoryBy: [editUserList[0]],
|
||||
taskComment: null,
|
||||
taskExplain: "自动审批",
|
||||
taskHandleDesc: "同意",
|
||||
taskLineTypeList: "同意",
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
historyInsertData.push(...await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
editedUserList.push(editUserList[0])
|
||||
editUserList.splice(0, 1)
|
||||
}
|
||||
|
||||
if (editUserList.length == 0) {
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
editUserList = nextNode.properties.userIdList;
|
||||
editedUserList = null;
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: editUserList?.join(','),
|
||||
taskEditedUserList: editedUserList?.join(','),
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
} else {
|
||||
updateTaskData = {
|
||||
taskConfigId: curNode.id,
|
||||
taskEditUserList: editUserList.join(','),
|
||||
taskEditedUserList: editedUserList.join(','),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
} else {
|
||||
updateTaskData = {
|
||||
taskConfigId: curNode.id,
|
||||
taskEditUserList: editUserList.join(','),
|
||||
taskEditedUserList: editedUserList.join(','),
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
case 'noticeTask':
|
||||
noticeInsertData.push({
|
||||
noticeId: await idGenerateUtil.uuid(),
|
||||
noticeName: "通知-审批-" + taskId,
|
||||
noticeContent: taskData.taskEditUserList,
|
||||
pushContent: '{}',
|
||||
pushStatus: "success",
|
||||
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
})
|
||||
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: nextNode.properties.userIdList?.join(','),
|
||||
taskEditedUserList: null,
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
createHistoryBy: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
const result = await this.buildNext1({ taskData, type: '同意', times: 1 })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
|
||||
break;
|
||||
case 'end':
|
||||
taskStatus = "end"
|
||||
updateTaskData = {
|
||||
taskStatus: taskStatus,
|
||||
taskConfigId: null,
|
||||
taskLineType: null,
|
||||
taskEditUserList: null,
|
||||
taskEditedUserList: null,
|
||||
taskFinishAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
} else {
|
||||
// 直接结束任务
|
||||
taskStatus = "end"
|
||||
updateTaskData = {
|
||||
taskStatus: taskStatus,
|
||||
taskConfigId: null,
|
||||
taskLineType: null,
|
||||
taskEditUserList: null,
|
||||
taskEditedUserList: null,
|
||||
taskFinishAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
// historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type: '拒绝' }))
|
||||
}
|
||||
|
||||
|
||||
return {
|
||||
updateTaskData,
|
||||
noticeInsertData,
|
||||
historyInsertData
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// TODO:逻辑待优化
|
||||
async buildNext({ taskData, type }) {
|
||||
const { userId, username } = this.ctx.userInfo;
|
||||
const { taskId, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData;
|
||||
const { taskId, taskInfo, taskWorkflow, taskConfigId, taskEditUserList, taskEditedUserList } = taskData;
|
||||
|
||||
var updateTaskData = null
|
||||
var historyInsertData = []
|
||||
@@ -87,12 +461,25 @@ class TaskService extends Service {
|
||||
|
||||
} else {// 流转搭配下一节点
|
||||
|
||||
if (curNode.properties.type.startsWith('noticeTask-')) {
|
||||
var noticeUser = nextNode.properties.userIdList
|
||||
for (let index = 0; index < noticeUser.length; index++) {
|
||||
const element = noticeUser[index];
|
||||
taskData.createHistoryBy = element
|
||||
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
}
|
||||
} else {
|
||||
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
}
|
||||
|
||||
// 找下一个节点
|
||||
var nextNode = await this.getNextNode(taskWorkflow, curNode)
|
||||
var nextLine = taskWorkflow.lineList.find(line => line.sourceNodeId == nextNode.id)
|
||||
|
||||
console.log('nextNode-=-', nextNode);
|
||||
// 下一个节点是审批节点
|
||||
if (nextNode.properties.type === "approvalTask") {
|
||||
|
||||
updateTaskData = {
|
||||
taskConfigId: nextNode.id,
|
||||
taskLineType: nextLine?.properties.type,
|
||||
@@ -100,11 +487,40 @@ class TaskService extends Service {
|
||||
taskEditedUserList: null
|
||||
}
|
||||
|
||||
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
// 如果autoApprovel == 1, 就自动再迭代
|
||||
if (taskInfo.autoApprovel == 1) {
|
||||
// 判断是不是只需要该人审批就能够继续流转: 一个人,多人或签
|
||||
if (nextNode.properties.userIdList.length == 1 || nextNode.properties.approvalType == '或签' && nextNode.properties.userIdList.includes(userId)) {
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskConfigId: nextNode.id,
|
||||
taskEditUserList: userId,
|
||||
taskEditedUserList: null,
|
||||
taskLineTypeList: type,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: type,
|
||||
taskComment: '系统自动流转',
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
const result = await this.buildNext({ taskData, type: '同意' })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// 下一个节点是抄送节点
|
||||
if (nextNode.properties.type === "noticeTask") {
|
||||
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
|
||||
noticeInsertData.push({
|
||||
noticeId: await idGenerateUtil.uuid(),
|
||||
noticeName: "通知-审批-" + taskId,
|
||||
noticeContent: taskData.taskEditUserList,
|
||||
pushContent: '{}',
|
||||
pushStatus: "success",
|
||||
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
})
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
@@ -118,34 +534,57 @@ class TaskService extends Service {
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
|
||||
noticeInsertData.push({
|
||||
noticeId: await idGenerateUtil.uuid(),
|
||||
noticeName: "通知-审批-" + taskId,
|
||||
noticeContent: nextNode.properties.userIdList.join(','),
|
||||
pushContent: '{}',
|
||||
pushStatus: "success",
|
||||
pushAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
})
|
||||
// var noticeUser = nextNode.properties.userIdList
|
||||
// for (let index = 0; index < noticeUser.length; index++) {
|
||||
// const element = noticeUser[index];
|
||||
// taskData.createHistoryBy = element
|
||||
// historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
// }
|
||||
|
||||
var noticeUser = nextNode.properties.userIdList
|
||||
for (let index = 0; index < noticeUser.length; index++) {
|
||||
const element = noticeUser[index];
|
||||
taskData.createHistoryBy = element
|
||||
historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
}
|
||||
// historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
|
||||
taskData = {
|
||||
...taskData,
|
||||
taskEditUserList: null,
|
||||
taskEditedUserList: null,
|
||||
taskComment: null,
|
||||
taskExplain: null,
|
||||
taskHandleDesc: null,
|
||||
taskLineTypeList: null,
|
||||
operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
}
|
||||
// taskData = {
|
||||
// ...taskData,
|
||||
// taskConfigId: nextNode.id,
|
||||
// taskEditUserList: nextNode.properties.userIdList.join(','),
|
||||
// taskEditedUserList: null,
|
||||
// taskComment: null,
|
||||
// taskExplain: '抄送节点',
|
||||
// taskHandleDesc: '抄送',
|
||||
// taskLineTypeList: '抄送',
|
||||
// operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
// }
|
||||
|
||||
const result = await this.buildNext({ taskData, type: 'end' })
|
||||
// var noticeUser = nextNode.properties.userIdList
|
||||
// for (let index = 0; index < noticeUser.length; index++) {
|
||||
// const element = noticeUser[index];
|
||||
// taskData.createHistoryBy = element
|
||||
// historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
// }
|
||||
|
||||
|
||||
|
||||
// var noticeUser = nextNode.properties.userIdList
|
||||
// for (let index = 0; index < noticeUser.length; index++) {
|
||||
// const element = noticeUser[index];
|
||||
// taskData.createHistoryBy = element
|
||||
// historyInsertData.push(await this.createTaskHistory({ taskData, taskStatus, type }))
|
||||
// }
|
||||
|
||||
nextNode = await this.getNextNode(taskWorkflow, nextNode)
|
||||
|
||||
// taskData = {
|
||||
// ...taskData,
|
||||
// taskConfigId: nextNode.id,
|
||||
// taskEditUserList: nextNode.properties.userIdList?.join(','),
|
||||
// taskEditUserList: null,
|
||||
// taskExplain: null,
|
||||
// taskHandleDesc: null,
|
||||
// taskLineTypeList: null,
|
||||
// operationAt: dayjs().format("YYYY-MM-DD HH:mm:ss")
|
||||
// }
|
||||
|
||||
const result = await this.buildNext({ taskData, type: '同意' })
|
||||
updateTaskData = result.updateTaskData
|
||||
historyInsertData.push(...result.historyInsertData)
|
||||
noticeInsertData.push(...result.noticeInsertData)
|
||||
@@ -207,27 +646,34 @@ class TaskService extends Service {
|
||||
taskLineType, taskEditUserList, taskViewUserList,
|
||||
taskComment, taskWorkflow, operationAt, createHistoryBy,
|
||||
taskHandleDesc, taskExplain, taskLineTypeList } = taskData;
|
||||
const history = []
|
||||
|
||||
// 计算任务持续时间
|
||||
const taskCostDuration = Math.round(dayjs().diff(dayjs(operationAt)) / 1000);
|
||||
|
||||
return {
|
||||
taskId,
|
||||
taskStatus,
|
||||
taskFormInput: JSON.stringify(taskFormInput),
|
||||
taskConfigId,
|
||||
taskNextConfigList,
|
||||
taskLineTypeList: taskLineTypeList || type,
|
||||
taskEditUserList,
|
||||
taskViewUserList,
|
||||
taskComment,
|
||||
taskWorkflow: JSON.stringify(taskWorkflow),
|
||||
taskExplain: taskExplain || type,
|
||||
taskHandleDesc: taskHandleDesc || type,
|
||||
taskCostDuration,
|
||||
createHistoryBy: createHistoryBy,
|
||||
createHistoryAt: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
createHistoryBy.forEach(userId => {
|
||||
history.push(
|
||||
{
|
||||
taskId,
|
||||
taskStatus,
|
||||
taskFormInput: JSON.stringify(taskFormInput),
|
||||
taskConfigId,
|
||||
taskNextConfigList,
|
||||
taskLineTypeList: taskLineTypeList || type,
|
||||
taskEditUserList,
|
||||
taskViewUserList,
|
||||
taskComment,
|
||||
taskWorkflow: JSON.stringify(taskWorkflow),
|
||||
taskExplain: taskExplain || type,
|
||||
taskHandleDesc: taskHandleDesc || type,
|
||||
taskCostDuration,
|
||||
createHistoryBy: userId,
|
||||
createHistoryAt: dayjs().format('YYYY-MM-DD HH:mm:ss')
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
return history
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
<div class="workflow-basic-info-container">
|
||||
<v-form ref="basicInfoForm" lazy-validation>
|
||||
<v-row>
|
||||
<v-col cols="12" sm="12" md="12" xl="12">
|
||||
<span class="jh-input-label">流程名<span class="red--text text--accent-2 ml-1">*必填</span></span>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="jh-input-label title-label">流程名<span class="red--text text--accent-2 ml-1 require-label">*必填</span></span>
|
||||
<v-text-field
|
||||
class="jh-v-input mr-2" dense filled single-line color="success"
|
||||
class="jh-v-input" dense filled single-line color="success"
|
||||
v-model="workflowInfo['workflowName']" :rules="validationRules.requireRules">
|
||||
</v-text-field>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="12" xl="12">
|
||||
<span class="jh-input-label">模板图标</span>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="title-label jh-input-label">模板图标</span>
|
||||
<v-menu
|
||||
:nudge-right="40"
|
||||
transition="scale-transition"
|
||||
@@ -45,7 +45,7 @@
|
||||
<v-card>
|
||||
<div class="d-flex flex-wrap">
|
||||
<div
|
||||
v-for="icon in materialDesignIcons"
|
||||
v-for="icon in constantObj.materialDesignIcons"
|
||||
:class="`item-icon pa-1 ${workflowInfo.taskTemplateIcon == icon && 'grey lighten-2'}`"
|
||||
@click="workflowInfo.taskTemplateIcon = icon"
|
||||
>
|
||||
@@ -60,12 +60,92 @@
|
||||
</v-menu>
|
||||
</v-col>
|
||||
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-1">
|
||||
<span class="jh-input-label">模板分组(支持输入自定义分组)</span>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="jh-input-label title-label">模板分组(支持输入自定义分组)</span>
|
||||
<v-combobox v-model="workflowInfo['taskTemplateGroup']" :items="constantObj.taskTemplateGroup" class="jh-v-input" dense
|
||||
filled small hide-actions hide-controls hide-details>
|
||||
</v-combobox>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="jh-input-label title-label">申请时,设置审批人/抄送人权限</span>
|
||||
<v-checkbox
|
||||
v-model="workflowInfo['modifyAuthority']"
|
||||
label="申请人不可修改预设审批/抄送人"
|
||||
hide-details
|
||||
dense
|
||||
></v-checkbox>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="jh-input-label title-label">审批过程时,当审批人账号被禁用</span>
|
||||
<!-- 自动同意、自动交接给指定人员 -->
|
||||
<v-radio-group v-model="workflowInfo['abnormalType']" dense>
|
||||
<v-radio
|
||||
label="自动同意"
|
||||
value="-1"
|
||||
dense
|
||||
></v-radio>
|
||||
<v-radio
|
||||
label="自动交接给指定人员"
|
||||
value="1"
|
||||
dense
|
||||
>
|
||||
<template v-slot:label>
|
||||
<div class="d-flex align-center" style="width: 450px;">
|
||||
<span>自动交接给指定人员</span>
|
||||
<div v-if="workflowInfo['abnormalType'] == 1" style="width: 45%;" class="d-flex align-center ml-2" >
|
||||
<v-autocomplete
|
||||
|
||||
class="jh-v-input mr-2"
|
||||
dense filled single-line clearable
|
||||
:items="user"
|
||||
item-text="username"
|
||||
item-value="userId"
|
||||
v-model="workflowInfo['abnormalUser']">
|
||||
</v-autocomplete>
|
||||
<v-tooltip bottom>
|
||||
<template v-slot:activator="{ on, attrs }">
|
||||
<v-icon
|
||||
color="grey"
|
||||
dark
|
||||
v-bind="attrs"
|
||||
v-on="on"
|
||||
small
|
||||
>
|
||||
mdi-alert-circle-outline
|
||||
</v-icon>
|
||||
</template>
|
||||
<span>若指定成员也异常,将自动通过</span>
|
||||
</v-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
</v-radio>
|
||||
</v-radio-group>
|
||||
</v-col>
|
||||
<v-col cols="12" sm="12" md="12" xl="12" class="pb-0">
|
||||
<span class="jh-input-label title-label">审批过程时,一人多节点自动审批配置</span>
|
||||
<!-- 仅首个节点需要审批,其余自动同意 -->
|
||||
<!-- 仅连续审批时自动同意 -->
|
||||
<!-- 每个节点都需要审批 -->
|
||||
<v-radio-group v-model="workflowInfo['autoApprovel']" dense>
|
||||
<v-radio
|
||||
label="仅首个节点需要审批,其余自动同意"
|
||||
value="1"
|
||||
dense
|
||||
></v-radio>
|
||||
<!-- <v-radio
|
||||
label="仅连续审批时自动同意"
|
||||
value="2"
|
||||
dense
|
||||
></v-radio> -->
|
||||
<v-radio
|
||||
label="每个节点都需要审批"
|
||||
value="2"
|
||||
dense
|
||||
></v-radio>
|
||||
</v-radio>
|
||||
|
||||
</v-col>
|
||||
<!-- <v-col cols="12" sm="12" md="12" xl="12">
|
||||
<span class="jh-input-label">备注</span>
|
||||
<v-text-field
|
||||
@@ -89,10 +169,20 @@ Vue.component("workflow-basic-info", {
|
||||
type: Object,
|
||||
default: () => {
|
||||
return {
|
||||
taskTemplateIcon: 'account'
|
||||
taskTemplateIcon: '/images/task-template-icon/10001.png',
|
||||
addAuthority: false,
|
||||
modifyAuthority: false,
|
||||
abnormalType: '-1',
|
||||
autoApprovel: '1',
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
user: {
|
||||
type: Array,
|
||||
default: () => {
|
||||
return []
|
||||
}
|
||||
},
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
@@ -102,9 +192,9 @@ Vue.component("workflow-basic-info", {
|
||||
],
|
||||
},
|
||||
constantObj: {
|
||||
taskTemplateGroup: ['行政', '人事', '其他']
|
||||
taskTemplateGroup: window.constantObj.taskTemplateGroup,
|
||||
materialDesignIcons: window.constantObj.materialDesignIcons,
|
||||
},
|
||||
materialDesignIcons
|
||||
}
|
||||
},
|
||||
watch: {
|
||||
@@ -125,8 +215,8 @@ Vue.component("workflow-basic-info", {
|
||||
if (await this.$refs.basicInfoForm.validate()) {
|
||||
return true;
|
||||
}
|
||||
await window.vtoast.fail("请完善基础信息!");
|
||||
throw new Error("请完善基础信息!")
|
||||
await window.vtoast.fail("基础信息:请完善基础信息!");
|
||||
throw new Error("基础信息:请完善基础信息!")
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -135,7 +225,26 @@ Vue.component("workflow-basic-info", {
|
||||
<style scoped>
|
||||
.workflow-basic-info-container {
|
||||
height: 650px;
|
||||
max-height: 700px;
|
||||
max-height: 850px;
|
||||
overflow-y: auto;
|
||||
overflow-x: hidden;
|
||||
}
|
||||
|
||||
.theme--light.v-messages{
|
||||
display: none;
|
||||
}
|
||||
.v-input--selection-controls{
|
||||
margin-top: 0px;
|
||||
padding-top: 0px;
|
||||
}
|
||||
|
||||
.title-label{
|
||||
/* font-weight: 600 !important; */
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
.title-label .require-label{
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
}
|
||||
</style>
|
||||
@@ -324,6 +324,7 @@
|
||||
|
||||
this.updateItem = _.cloneDeep(funObj);
|
||||
this.updateItemId = this.updateItem.taskId
|
||||
this.updateItem.taskInfo = JSON.parse(funObj.taskInfo);
|
||||
this.updateItem.taskWorkflow = JSON.parse(funObj.taskWorkflow);
|
||||
this.updateItem.taskFormInput = JSON.parse(funObj.taskFormInput);
|
||||
this.updateItem.taskComment = ''; // 备注
|
||||
|
||||
Reference in new issue
Block a user