调整页面,v4

This commit is contained in:
xueyuan committed 2023-02-09 23:38:35 +08:00
1 parent f3bed51eef
commit f695923685
16 files changed
+1854 -290

No files matched your search

+31 -32
View File
@@ -1,40 +1,39 @@
'use strict'; 'use strict';
module.exports = { module.exports.tableEnum = Object.freeze({
tableEnum: {
// ========================江湖表============================ // ========================江湖表============================
_cache: '_cache', _cache: "_cache",
_constant: '_constant', _constant: "_constant",
_file: '_file', _constant_ui: "_constant_ui",
_group: '_group', _file: "_file",
_log: '_log', _group: "_group",
_page: '_page', _page: "_page",
_resource: '_resource', _record_history: "_record_history",
_record_history: '_record_history', _resource: "_resource",
_resource_request_log: '_resource_request_log', _resource_request_log: "_resource_request_log",
_role: '_role', _role: "_role",
_test_case: '_test_case', _user: "_user",
_user: '_user', _user_group_role: "_user_group_role",
_user_group_role: '_user_group_role', _user_group_role_page: "_user_group_role_page",
_user_group_role_page: '_user_group_role_page', _user_group_role_resource: "_user_group_role_resource",
_user_group_role_resource: '_user_group_role_resource', _user_session: "_user_session",
_user_group_role_ui_level: '_user_group_role_ui_level', _constant_ui: "_constant_ui",
_user_session: '_user_session', // ========================基础表============================
// ========================应用表============================
app: 'student',
article: 'article',
assignment: 'assignment',
category: 'category',
workflow: 'workflow', workflow: 'workflow',
task: 'task', task: 'task',
task_history: 'task_history', task_history: 'task_history',
// ========================基础 View============================ // ========================基础View============================
_view01_resource: '_view01_resource', // ========================View============================
_view01_user: '_view01_user', _view01_user: "_view01_user",
// ========================高级 View============================ });
_view02_user_app: '_view02_user_app',
_view02_user_group_role: '_view02_user_group_role',
},
};
module.exports.genderEnum = Object.freeze({
male: 'male',
female: 'female'
})
module.exports.articleViewTypeEnum = Object.freeze({
content: 'content',
audio: 'audio',
video: 'video',
})
+2 -1
View File
@@ -16,7 +16,8 @@ const errorInfoEnum = {
task_not_found: { errorCode: 'task_not_found', errorReason: '任务不存在' }, task_not_found: { errorCode: 'task_not_found', errorReason: '任务不存在' },
node_not_found: { errorCode: 'node_not_found', errorReason: '节点不存在' }, node_not_found: { errorCode: 'node_not_found', errorReason: '节点不存在' },
line_not_found: { errorCode: 'line_not_found', errorReason: '线路不存在' }, line_not_found: { errorCode: 'line_not_found', errorReason: '线路不存在' },
line_hook_error: { errorCode: 'line_hook_error', errorReason: '线路Hook异常' } line_hook_error: { errorCode: 'line_hook_error', errorReason: '线路Hook异常' },
workflow_not_found: { errorCode: 'workflow_not_found', errorReason: '流程不存在' },
}; };
module.exports = { module.exports = {
-59
View File
@@ -1,59 +0,0 @@
'use strict';
// ========================================常用 require start===========================================
const Service = require('egg').Service;
const validateUtil = require("@jianghujs/jianghu/app/common/validateUtil");
const idGenerateUtil = require("@jianghujs/jianghu/app/common/idGenerateUtil");
const dayjs = require("dayjs");
const actionDataScheme = Object.freeze({
beforHookForGenerateStudentId: {
type: "object",
additionalProperties: true,
required: ["dateOfBirth"],
properties: {
dateOfBirth: { type: "string", format: "date" },
},
},
});
class StudentService extends Service {
async beforHookForGenerateStudentId() {
const { actionData } = this.ctx.request.body.appData;
validateUtil.validate(
actionDataScheme.beforHookForGenerateStudentId,
actionData
);
const { dateOfBirth } = actionData;
const dateOfBirthObj = dayjs(dateOfBirth);
const studentId = `S_${idGenerateUtil.uuid(
8
)}_${dateOfBirthObj.month()}_${dateOfBirthObj.day()}`;
this.ctx.request.body.appData.actionData.studentId = studentId;
}
async appendStudentInfoToUserInfo() {
const studentInfo = await this.app
.jianghuKnex("student")
.where({ studentId: this.ctx.userInfo.user.userId })
.first();
this.ctx.userInfo.studentInfo = studentInfo || { classId: null };
}
async selectStudentList() {
const studentInfo = await this.app
.jianghuKnex("student")
.where({ studentId: this.ctx.userInfo.user.userId })
.first();
const studentList = await this.app
.jianghuKnex("student")
.where({ classId: studentInfo.classId })
.select();
return {
rows: studentList,
};
}
}
module.exports = StudentService;
+192 -58
View File
@@ -45,25 +45,45 @@ class TaskService extends Service {
const { userId, username } = this.ctx.userInfo; const { userId, username } = this.ctx.userInfo;
where.createByUser = userId; where.createByUser = userId;
} }
async whereToViewUserId() {
const { whereLike } = this.ctx.request.body.appData;
const { userId } = this.ctx.userInfo;
whereLike.taskViewUserList = userId;
}
/**
* 创建审批工作流
* @returns void
*/
async createTask() { async createTask() {
const { actionData } = this.ctx.request.body.appData; const { actionData } = this.ctx.request.body.appData;
const { jianghuKnex, config } = this.app; const { jianghuKnex, config } = this.app;
// const { workflowId, taskTitle, taskFormStructure, taskFormData } = actionData; // const { workflowId, taskTitle, taskFormStructure, taskFormData } = actionData;
const { workflowId, taskTitle, workflowForm, workflowFormData } = actionData; const { workflowId, taskTitle, workflowForm, workflowFormData, workflowConfigCustom } = actionData;
const { userId, username } = this.ctx.userInfo; const { userId, username } = this.ctx.userInfo;
const taskId = await idGenerateUtil.idPlus({ const taskId = await idGenerateUtil.uuid();
knex: jianghuKnex, const workflow = await jianghuKnex(tableEnum.workflow, this.ctx).where({workflowId}).first();
startValue: 1000,
tableName: tableEnum.task,
columnName: "taskId"
});
const workflow = await jianghuKnex(tableEnum.workflow).where({workflowId}).first();
if (!workflow) { if (!workflow) {
throw new BizError(errorInfoEnum.workflow_not_found) throw new BizError(errorInfoEnum.workflow_not_found)
return return
} }
const { workflowConfig } = workflow;
const {nodeList = [], lineList = []} = JSON.parse(workflowConfig || '{}'); const workflowConfig = JSON.parse(workflow.workflowConfig || '{}');
let {mode = 'serial', nodeList = [], lineList = []} = workflowConfig;
const nodeListOfUserTaskNode = (JSON.parse(workflowConfigCustom || '{}')).nodeListOfUserTaskNode || []
// 合并定制的审批人和workflow的审批人
// nodeList = _.merge(_.keyBy(nodeList, 'id'), _.keyBy((JSON.parse(workflowConfigCustom || '{}')).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 节点进入历史 // start 节点进入历史
const startNode = nodeList.find(e => e.id.includes('start-')); const startNode = nodeList.find(e => e.id.includes('start-'));
const startLine = lineList.filter(e => e.from === startNode.id); const startLine = lineList.filter(e => e.from === startNode.id);
@@ -83,13 +103,26 @@ class TaskService extends Service {
taskViewUserList: allUser, taskViewUserList: allUser,
createByUser: userId, createByUser: userId,
taskInitUser: userId, taskInitUser: userId,
workflowConfig workflowConfig: JSON.stringify(workflowConfig)
} }
const [id] = await jianghuKnex(tableEnum.task, this.ctx).insert(startData); await jianghuKnex.transaction(async trx => {
await this.buildNext({ type: '同意', id, taskTpl: {input: workflowFormData}, taskComment: '' }) const [id] = await trx(tableEnum.task, this.ctx).insert(startData);
// 并行模式下,生成所有的userTask
if (mode == 'parallel') {
await this.generateAllUserTask(id, trx);
}
// 开始节点进入历史
await this.buildNext({ type: '同意', id, taskTpl: {input: workflowFormData}, taskComment: ''}, trx);
});
return startData; return startData;
} }
/**
* 获取组下的所有用户
* @param {*} groupId
* @returns
*/
async getGroupUserList(groupId) { async getGroupUserList(groupId) {
const { jianghuKnex, config } = this.app; const { jianghuKnex, config } = this.app;
const userList = await jianghuKnex(tableEnum._user_group_role).where({groupId}).select('userId'); const userList = await jianghuKnex(tableEnum._user_group_role).where({groupId}).select('userId');
@@ -145,11 +178,13 @@ class TaskService extends Service {
} }
const taskHistoryList = await jianghuKnex(tableEnum.task_history).where({taskId: taskInfo.taskId}).orderBy('id', 'asc').select(); const taskHistoryList = await jianghuKnex(tableEnum.task_history).where({taskId: taskInfo.taskId}).orderBy('id', 'asc').select();
const taskStepperList = this.makeStepper(taskInfo.workflowConfig, taskHistoryList, taskInfo); const taskStepperList = this.makeStepper(taskInfo.workflowConfig, taskHistoryList, taskInfo);
const userList = await jianghuKnex(tableEnum._view01_user).whereIn('userId', taskInfo.taskViewUserList.split(',')).select();
taskInfo.workflowConfig = JSON.parse(taskInfo.workflowConfig); taskInfo.workflowConfig = JSON.parse(taskInfo.workflowConfig);
const taskHistoryConfigList = this.getTaskHistoryConfigList(taskInfo.workflowConfig, taskHistoryList); const taskHistoryConfigList = this.getTaskHistoryConfigList(taskInfo.workflowConfig, taskHistoryList, userList);
// 查找task 任务历史列表
const isAccess = taskInfo.taskEditUserList.includes(userId);
// 查找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 nextLineList = taskInfo.taskStatus === 'running' ? JSON.parse(taskInfo.taskNextConfigList) : [];
const taskTpl = JSON.parse(taskInfo.taskFormInput || '{"input": {}, "formList": []}'); const taskTpl = JSON.parse(taskInfo.taskFormInput || '{"input": {}, "formList": []}');
// const currentNode = taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId); // const currentNode = taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId);
@@ -157,6 +192,7 @@ class TaskService extends Service {
taskStepperList, taskStepperList,
taskHistoryList, taskHistoryList,
isAccess, isAccess,
lineTypeList,
nextLineList, nextLineList,
taskTpl, taskTpl,
currentNode: taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId), currentNode: taskInfo.workflowConfig.nodeList.find(e => e.id === taskInfo.taskConfigId),
@@ -164,25 +200,29 @@ class TaskService extends Service {
}; };
} }
/** /**
* 获取历史节点+当前节点 * 获取所有节点,标示历史节点+当前节点
* @returns * @returns
*/ */
getTaskHistoryConfigList(workflowConfig, taskHistory) { getTaskHistoryConfigList(workflowConfig, taskHistory, userList) {
const {nodeList = [], lineList = []} = workflowConfig; const {nodeList = [], lineList = []} = workflowConfig;
// 历史所有主节点 // 历史所有主节点和连线做标志
const historyNodeList = nodeList.filter(node => taskHistory.some(history => history.taskConfigId === node.id || history.taskLineTo.includes(node.id))); nodeList.filter(node => taskHistory.some(history => history.taskConfigId === node.id || history.taskLineTo.includes(node.id))).forEach(node => {
let historyLineList = []; node.inPath = true
})
// 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);
}
});
taskHistory.forEach((history, index) => { taskHistory.forEach((history, index) => {
const filterLineList = lineList.filter(line => history.taskConfigId === line.from && history.taskLineTo.includes(line.to)); lineList.filter(line => history.taskConfigId === line.from && history.taskLineTo.includes(line.to)).forEach(line => {
if (filterLineList.length) {
filterLineList.forEach(line => {
line.label = line.label + ` (${index + 1})` line.label = line.label + ` (${index + 1})`
}) })
historyLineList = [...historyLineList, ...filterLineList];
}
}) })
return {nodeList: historyNodeList, lineList: historyLineList}; return {nodeList, lineList};
} }
/** /**
* 制作节点步骤list * 制作节点步骤list
@@ -269,32 +309,59 @@ class TaskService extends Service {
const existIdList = _.flatten(nodeSortList).map(e => {return e.id}); const existIdList = _.flatten(nodeSortList).map(e => {return e.id});
return nodeAllList.filter(e => lineList.some(s => s.to === e.id) && !existIdList.includes(e.id)); return nodeAllList.filter(e => lineList.some(s => s.to === e.id) && !existIdList.includes(e.id));
} }
async submitNode() { async generateAllUserTask(id, trx) {
const { actionData } = this.ctx.request.body.appData; const taskInfo = await trx(tableEnum.task).where({id}).first();
await this.buildNext(actionData);
}
async buildNext(actionData) {
const { jianghuKnex } = this.app;
const { type, id, taskTpl, taskComment } = actionData;
const taskInfo = await jianghuKnex(tableEnum.task).where({id}).first();
delete taskInfo.id; delete taskInfo.id;
const {nodeList = [], lineList = []} = JSON.parse(taskInfo.workflowConfig || '{}'); 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(tableEnum.task).insert({
...taskInfo,
taskNextConfigList: JSON.stringify(nextLineList),
taskLineTypeList: node.lineTypeList,
taskEditUserList,
taskConfigId: node.id,
taskStatus: 'running'
});
}
}
async submitNode() {
const { actionData } = this.ctx.request.body.appData;
const { jianghuKnex } = this.app;
await jianghuKnex.transaction(async trx => {
await this.buildNext(actionData, trx);
});
}
async buildNext(actionData, trx) {
const { type, id, taskComment } = actionData;
const { userId } = this.ctx.userInfo;
// 准备任务数据
const taskInfo = await trx(tableEnum.task).where({id}).first();
delete taskInfo.id;
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 nLineList = JSON.parse(taskInfo.taskNextConfigList);
const lines = nLineList.filter(e => e.type === type); const lines = nLineList.filter(e => e.type === type);
const currentNode = nodeList.find(e => e.id === taskInfo.taskConfigId); const currentNode = nodeList.find(e => e.id === taskInfo.taskConfigId);
// 写入exec历史 // 写入exec历史
const taskHistory = await jianghuKnex(tableEnum.task_history).where({taskId: taskInfo.taskId}).orderBy('operationAt', 'desc').select(); const taskHistory = await trx(tableEnum.task_history, this.ctx).where({taskId: taskInfo.taskId}).orderBy('operationAt', 'desc').select();
const [prevHistory] = taskHistory; const [prevHistory] = taskHistory;
let taskFormInput = JSON.parse(taskInfo.taskFormInput); // let taskFormInput = JSON.parse(taskInfo.taskFormInput);
taskFormInput.input = taskTpl.input; // taskFormInput.input = taskTpl.input;
taskFormInput = JSON.stringify(taskFormInput); // taskFormInput = JSON.stringify(taskFormInput);
const historyTaskFormInput = JSON.parse(taskInfo.taskFormInput) // const historyTaskFormInput = JSON.parse(taskInfo.taskFormInput)
historyTaskFormInput .input = taskTpl.input; // historyTaskFormInput .input = taskTpl.input;
const taskFormInput = taskInfo.taskFormInput;
const history = { const history = {
...taskInfo, ...taskInfo,
taskFormInput: JSON.stringify(historyTaskFormInput), // taskFormInput: JSON.stringify(historyTaskFormInput),
taskFormInput,
taskExplain: currentNode.label, taskExplain: currentNode.label,
taskConfigId: currentNode.id, taskConfigId: currentNode.id,
taskHandleDesc: type, taskHandleDesc: type,
@@ -304,53 +371,108 @@ class TaskService extends Service {
taskCostDuration: prevHistory ? parseInt((new Date().getTime() - new Date(prevHistory.operationAt).getTime()) / 1000) : 0, taskCostDuration: prevHistory ? parseInt((new Date().getTime() - new Date(prevHistory.operationAt).getTime()) / 1000) : 0,
taskComment taskComment
} }
delete history.taskEditedUserList;
await trx(tableEnum.task_history, this.ctx).insert(history);
await jianghuKnex(tableEnum.task_history, this.ctx).insert(history); // 未配置连线时,默认添加拒绝连线到end节点
if (endNode && !lines.length) {
lines.push({
"from": currentNode.id,
"to": endNode.id,
"type": "拒绝",
"label": "结束",
"toInterruptEnd": true
});
}
for (const line of lines) { for (const line of lines) {
const nextNode = nodeList.find(e => e.id === line.to); const nextNode = nodeList.find(e => e.id === line.to);
let taskEditUserList = await this.getProcessUserList([nextNode]);
// 修改任务步骤node 处理人\
const nextLineList = lineList.filter(e => e.from === line.to); const nextLineList = lineList.filter(e => e.from === line.to);
if (line.to.includes('end-')) { let taskEditUserList = await this.getProcessUserList([nextNode]);
// 当前节点如果需要所有人审批并且不是拒绝连线时,检查是否所有人都审批过了
if (currentNode.isNeedAllApproval && !line.toInterruptEnd) {
let taskEditedUserList = taskInfo.taskEditedUserList? `${taskInfo.taskEditedUserList},${userId}`: userId;
await trx(tableEnum.task, this.ctx).where({id}).update({taskEditedUserList});
if (_.xor(taskEditedUserList.split(','), taskInfo.taskEditUserList.split(',')).length != 0) {
return
}
}
await trx(tableEnum.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 != '拒绝')
) {
taskEditUserList = await this.getProcessUserList([currentNode]); taskEditUserList = await this.getProcessUserList([currentNode]);
const endHistory = { const endHistory = {
...history, ...history,
taskStatus: 'end',
taskExplain: '结束', taskExplain: '结束',
taskConfigId: nextNode.id, taskConfigId: endNode.id,
taskHandleDesc: '流程结束', taskHandleDesc: '流程结束',
taskLineFrom: line.from, taskLineFrom: line.from,
taskLineTo: line.to, taskLineTo: line.to,
taskLineLabel: line.type + '-' + line.label, taskLineLabel: line.type + '-' + line.label,
taskCostDuration: 0 taskCostDuration: 0
} }
await jianghuKnex(tableEnum.task_history, this.ctx).insert(endHistory); await trx(tableEnum.task_history, this.ctx).insert(endHistory);
await trx(tableEnum.task).insert({
...taskInfo,
taskId: taskInfo.taskId,
taskFormInput: taskInfo.taskFormInput,
taskNextConfigList: JSON.stringify(nextLineList),
taskLineTypeList: endNode.lineTypeList,
taskEditUserList,
taskConfigId: endNode.id,
taskStatus: 'end'
});
// 默认拒绝节点,删除全部任务,执行interruptHook
if (line.toInterruptEnd) {
await trx(tableEnum.task, this.ctx).where({taskId: taskInfo.taskId, taskStatus: 'running'}).delete();
await this.executeHook(endNode.interruptHook);
} else {
await this.executeHook(endNode.finishHook);
}
return
} }
await jianghuKnex(tableEnum.task).where({id}).delete();
await this.executeHook(line.hook);
// 其他同级节点未结束,暂时不生成下一个节点
let otherNodeList = this.getNodeBrotherList(taskInfo.taskConfigId, nodeList, lineList); let otherNodeList = this.getNodeBrotherList(taskInfo.taskConfigId, nodeList, lineList);
otherNodeList = otherNodeList.filter(e => e.id !== taskInfo.taskConfigId); otherNodeList = otherNodeList.filter(e => e.id !== taskInfo.taskConfigId);
if (otherNodeList.length && !otherNodeList.some(e => taskHistory.some(s => s.taskConfigId === e.id))) { if (otherNodeList.length && !otherNodeList.some(e => taskHistory.some(s => s.taskConfigId === e.id))) {
console.log('其他并行未结束、暂停任务') console.log('其他并行未结束、暂停任务')
return return
} }
await jianghuKnex(tableEnum.task).insert({
// 串行审核,生成下一个task
if (mode == 'serial') {
await trx(tableEnum.task, this.ctx).insert({
...taskInfo, ...taskInfo,
taskId: taskInfo.taskId, taskId: taskInfo.taskId,
taskFormInput, taskFormInput,
taskNextConfigList: JSON.stringify(nextLineList), taskNextConfigList: JSON.stringify(nextLineList),
taskLineTypeList: nextNode.lineTypeList,
taskEditUserList, taskEditUserList,
taskConfigId: nextNode.id, taskConfigId: nextNode.id,
taskStatus: (nextLineList.length === 0 || currentNode.id.includes('end-')) ? 'end' : type === 'deny' ? 'deny' : 'running' taskStatus: type === 'deny' ? 'deny' : 'running'
}); });
await this.executeLineHook(line);
} }
} }
async executeLineHook(line) { }
async executeHook(hook) {
try { try {
const { service, serviceFunction } = JSON.parse(line.hook || '{}'); const { service, serviceFunction } = JSON.parse(hook || '{}');
if (service && serviceFunction) { if (service && serviceFunction) {
await this.ctx.service[service][serviceFunction](this.ctx.request.body.appData.actionData, this.ctx) await this.ctx.service[service][serviceFunction](this.ctx.request.body.appData.actionData, this.ctx)
} }
@@ -358,6 +480,18 @@ class TaskService extends Service {
throw new BizError(errorInfoEnum.line_hook_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;
}
}
} }
module.exports = TaskService; module.exports = TaskService;
+41
View File
@@ -80,6 +80,47 @@ class WorkflowService extends Service {
console.log(actionData); console.log(actionData);
} }
/**
* 创建流程审批
*/
async createWorkflowTask() {
const { actionData } = this.ctx.request.body.appData;
const { jianghuKnex } = this.app;
const { group, formItemList, taskUserList, workflowConfigCustom, workflowId } = actionData;
const { userId, username } = this.ctx.userInfo;
let workflow = await jianghuKnex(tableEnum.workflow, this.ctx).where({workflowId}).first();
if(!workflow) {
throw new BizError(errorInfoEnum.workflow_not_found);
}
actionData.workflowConfigCustom = JSON.stringify(workflowConfigCustom);
actionData.workflowId = workflow.workflowId;
actionData.taskTitle = `[${group}]${username}`;
actionData.workflowForm = formItemList;
const formData = {};
formItemList.forEach(item => {
formData[item.statement] = item.answer;
})
actionData.workflowFormData = formData;
await this.ctx.service.task.createTask()
}
/**
* 获取节点审批历史
* @returns
*/
async getTaskHistory() {
const { taskId } = this.ctx.request.body.appData.actionData;
const { jianghuKnex } = this.app;
const taskInfo = await jianghuKnex(tableEnum.task, this.ctx).where({taskId}).first();
const taskHistoryList = await jianghuKnex(tableEnum.task_history).where({taskId: taskInfo.taskId}).orderBy('id', 'asc').select();
// const userList = await jianghuKnex(tableEnum._view01_user).whereIn('userId', taskInfo.taskViewUserList.split(',')).select();
// taskInfo.workflowConfig = JSON.parse(taskInfo.workflowConfig);
// return this.ctx.service.task.getTaskHistoryConfigList(taskInfo.workflowConfig, taskHistoryList, userList);
const lineTypeList = taskInfo.taskLineTypeList;
return {taskHistoryList, lineTypeList};
}
} }
module.exports = WorkflowService; module.exports = WorkflowService;
+5 -2
View File
@@ -35,7 +35,7 @@
<span class="inputLabel">名称</span> <span class="inputLabel">名称</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="名称" v-model="line.label"></v-text-field> <v-text-field class="cus-v-input mr-2" dense filled single-line label="名称" v-model="line.label"></v-text-field>
</v-col> </v-col>
<v-col cols="12" class=" pb-3"> <v-col cols="12" class=" pb-3" v-if="mode == 'serial'">
<span class="inputLabel">操作类型</span> <span class="inputLabel">操作类型</span>
<v-select <v-select
:items="lineTypeList" :items="lineTypeList"
@@ -68,6 +68,10 @@
lf: { lf: {
type: Object, type: Object,
default: null default: null
},
mode: {
type: String,
default: 'serial'
} }
}, },
data() { data() {
@@ -83,7 +87,6 @@
handler: function (line) { handler: function (line) {
this.lf.updateText(line.id, `${line.type}-${line.label}`); this.lf.updateText(line.id, `${line.type}-${line.label}`);
this.lf.setProperties(line.id, line); this.lf.setProperties(line.id, line);
console.log(this.lf.getEdgeModelById(line.id));
}, },
deep: true deep: true
} }
+23 -10
View File
@@ -49,23 +49,22 @@
v-model="node.assignType" v-model="node.assignType"
></v-select> ></v-select>
</v-col> </v-col>
-->
<v-col cols="12" class=" pb-3"> <v-col cols="12" class=" pb-3">
<span class="inputLabel">指派</span> <span class="inputLabel">指派</span>
<v-select <v-autocomplete
class="cus-v-input mr-2"
dense filled single-line clearable
:items="optionList" :items="optionList"
color="success"
item-color="success"
dense filled single-line
item-text="text" item-text="text"
item-value="value" item-value="value"
class="cus-v-input"
:label="assignType" :label="assignType"
:multiple="node.assignType === 'person'" :multiple="node.assignType === 'person'"
v-model="node.assignValue" v-model="node.assignValue"
:disabled="!node.assignType" :disabled="!node.assignType">
></v-select> </v-autocomplete>
</v-col> --> </v-col>
<v-col cols="12" class=" pb-3" > <v-col cols="12" class=" pb-3" v-if="mode == 'serial'">
<span class="inputLabel">允许的操作(英文逗号分隔)</span> <span class="inputLabel">允许的操作(英文逗号分隔)</span>
<!-- <v-textarea <!-- <v-textarea
filled single-line filled single-line
@@ -77,7 +76,7 @@
></v-textarea> --> ></v-textarea> -->
<v-text-field class="cus-v-input" dense filled single-line label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field> <v-text-field class="cus-v-input" dense filled single-line label="允许的操作(英文逗号分隔)" v-model="node.lineTypeList"></v-text-field>
</v-col> </v-col>
<v-col cols="12" class=" pb-3" > <!-- <v-col cols="12" class=" pb-3" >
<span class="inputLabel">可写模板</span> <span class="inputLabel">可写模板</span>
<v-select <v-select
:items="tpl" :items="tpl"
@@ -106,6 +105,16 @@
multiple multiple
v-model="node.formIdHidden" v-model="node.formIdHidden"
></v-select> ></v-select>
</v-col> -->
</template>
<template v-if="node.id.includes('end-')">
<v-col cols="12" class=" pb-3">
<span class="inputLabel">流程完成Hook</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="流程完成Hook" v-model="node.finishHook"></v-text-field>
</v-col>
<v-col cols="12" class=" pb-3">
<span class="inputLabel">流程中断Hook</span>
<v-text-field class="cus-v-input mr-2" dense filled single-line label="流程中断Hook" v-model="node.interruptHook"></v-text-field>
</v-col> </v-col>
</template> </template>
</v-row> </v-row>
@@ -139,6 +148,10 @@
return [] return []
} }
}, },
mode: {
type: String,
default: 'serial'
}
}, },
data() { data() {
return { return {
+77 -5
View File
@@ -16,8 +16,8 @@
<span style="transform: translateY(2px); display: inline-block; ">{{editType == 'node' ? '节点' : '连线'}}属性</span> <span style="transform: translateY(2px); display: inline-block; ">{{editType == 'node' ? '节点' : '连线'}}属性</span>
</div> </div>
<div class="flow-edit-content"> <div class="flow-edit-content">
<edit-node ref="nodeForm" v-if="editType == 'node'" :lf="lf" :user="user" :group="group" :tpl="tpl"></edit-node> <edit-node ref="nodeForm" v-if="editType == 'node'" :lf="lf" :user="user" :group="group" :tpl="tpl" :mode="mode"></edit-node>
<edit-line ref="lineForm" v-if="editType == 'line'" :lf="lf"></edit-line> <edit-line ref="lineForm" v-if="editType == 'line'" :lf="lf" :mode="mode"></edit-line>
</div> </div>
</template> </template>
<template v-else> <template v-else>
@@ -40,6 +40,8 @@
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/MiniMap.js"></script> <script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/MiniMap.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Menu.js"></script> <script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Menu.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/SelectionSelect.js"></script> <script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/SelectionSelect.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Control.js"></script>
<script src="/<$ ctx.app.config.appId $>/public/logicflow/extension/lib/Popup.js"></script>
<script type="module"> <script type="module">
Vue.component("process-flow", { Vue.component("process-flow", {
@@ -82,6 +84,10 @@
type: Boolean, type: Boolean,
default: false default: false
}, },
mode: {
type: String,
default: 'serial'
}
}, },
data: () => { data: () => {
return { return {
@@ -102,6 +108,11 @@
] ]
}; };
}, },
watch: {
mode() {
this.lf.clearData();
}
},
mounted() { mounted() {
this.init(); this.init();
}, },
@@ -109,6 +120,7 @@
init() { init() {
this.initLFInstance(); this.initLFInstance();
this.initLFCustomType(); this.initLFCustomType();
this.initLFControl();
this.initLFMenu(); this.initLFMenu();
this.initLFEvent(); this.initLFEvent();
this.initLFData(); this.initLFData();
@@ -143,7 +155,7 @@
// edgeTextDraggable: true, // edgeTextDraggable: true,
stopScrollGraph: true, stopScrollGraph: true,
edgeType: 'polyline', edgeType: 'polyline',
plugins: [MiniMap, Menu, SelectionSelect], plugins: [MiniMap, Menu, SelectionSelect, Control, Popup],
isSilentMode: this.readonly isSilentMode: this.readonly
}); });
@@ -167,6 +179,11 @@
const properties = this.properties; const properties = this.properties;
if (_this.currentNodeId === this.id) { if (_this.currentNodeId === this.id) {
style.fill = "#4caf50"; style.fill = "#4caf50";
} else {
const rawNode = _this.data.nodeList.find(o => o.id === this.id)
if (rawNode && rawNode.inPath) {
style.fill = "#d4ffd6";
}
} }
return style; return style;
} }
@@ -187,6 +204,17 @@
this.lf.register(CustomNode); this.lf.register(CustomNode);
}, },
/**
* 初始化LogicFlow控制台
*/
initLFControl() {
let lf = this.lf;
// 删除上一步
lf.extension.control.removeItem('undo');
// 删除下一步
lf.extension.control.removeItem('redo');
},
/** /**
* 初始化LogicFlow菜单 * 初始化LogicFlow菜单
*/ */
@@ -243,6 +271,21 @@
lf.on("edge:add", (e) => { lf.on("edge:add", (e) => {
const { data } = e; const { data } = e;
const { id, sourceNodeId, targetNodeId, properties } = data; const { id, sourceNodeId, targetNodeId, properties } = data;
// 并行模式不允许多条流程线
if(this.mode == 'parallel') {
const sourceNodeEdges = lf.getNodeEdges(sourceNodeId);
const targetNodeEdges = lf.getNodeEdges(targetNodeId);
if (
sourceNodeEdges.filter(edge => edge.sourceNodeId == sourceNodeId).length > 1 ||
sourceNodeEdges.filter(edge => edge.targetNodeId == sourceNodeId).length > 1 ||
targetNodeEdges.filter(edge => edge.sourceNodeId == targetNodeId).length > 1 ||
targetNodeEdges.filter(edge => edge.targetNodeId == targetNodeId).length > 1
) {
window.vtoast.fail("并行模式不允许多条流程线");
lf.deleteEdge(id);
return;
}
}
let line = { let line = {
from: sourceNodeId, from: sourceNodeId,
to: targetNodeId, to: targetNodeId,
@@ -302,7 +345,6 @@
// this.lf.render({"nodes":[{"id":"3","type":"CustomNode","x":380,"y":140,"properties":{},"text":{"x":380,"y":140,"value":"开始"}},{"id":"1","type":"CustomNode","x":380,"y":280,"properties":{},"text":{"x":380,"y":280,"value":"经理"}},{"id":"2","type":"CustomNode","x":380,"y":420,"properties":{},"text":{"x":380,"y":420,"value":"结束"}}],"edges":[{"id":"a2ed12a0-7548-4725-a8e6-290d565d66da","type":"polyline","sourceNodeId":"3","targetNodeId":"1","startPoint":{"x":380,"y":160},"endPoint":{"x":380,"y":260},"properties":{},"text":{"x":380,"y":190,"value":"开始"},"pointsList":[{"x":380,"y":160},{"x":380,"y":260}]},{"id":"135f3e3a-d8c5-4329-83d6-833512175ea4","type":"polyline","sourceNodeId":"2","targetNodeId":"1","startPoint":{"x":330,"y":420},"endPoint":{"x":330,"y":280},"properties":{},"text":{"x":265,"y":350,"value":"经理审核拒绝"},"pointsList":[{"x":330,"y":420},{"x":265,"y":420},{"x":265,"y":280},{"x":330,"y":280}]},{"id":"c4dbefa6-1ce0-4cef-babe-444329affea7","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":430,"y":280},"endPoint":{"x":430,"y":420},"properties":{},"text":{"x":495,"y":350,"value":"经理审核通过"},"pointsList":[{"x":430,"y":280},{"x":495,"y":280},{"x":495,"y":420},{"x":430,"y":420}]},{"id":"6fb6a3b1-a8fc-4d22-b9f0-5692208118d5","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":348,"y":300},"endPoint":{"x":348,"y":400},"properties":{},"text":{"x":348,"y":350,"value":"同意-连线文本"},"pointsList":[{"x":348,"y":300},{"x":348,"y":400}]}]}) // this.lf.render({"nodes":[{"id":"3","type":"CustomNode","x":380,"y":140,"properties":{},"text":{"x":380,"y":140,"value":"开始"}},{"id":"1","type":"CustomNode","x":380,"y":280,"properties":{},"text":{"x":380,"y":280,"value":"经理"}},{"id":"2","type":"CustomNode","x":380,"y":420,"properties":{},"text":{"x":380,"y":420,"value":"结束"}}],"edges":[{"id":"a2ed12a0-7548-4725-a8e6-290d565d66da","type":"polyline","sourceNodeId":"3","targetNodeId":"1","startPoint":{"x":380,"y":160},"endPoint":{"x":380,"y":260},"properties":{},"text":{"x":380,"y":190,"value":"开始"},"pointsList":[{"x":380,"y":160},{"x":380,"y":260}]},{"id":"135f3e3a-d8c5-4329-83d6-833512175ea4","type":"polyline","sourceNodeId":"2","targetNodeId":"1","startPoint":{"x":330,"y":420},"endPoint":{"x":330,"y":280},"properties":{},"text":{"x":265,"y":350,"value":"经理审核拒绝"},"pointsList":[{"x":330,"y":420},{"x":265,"y":420},{"x":265,"y":280},{"x":330,"y":280}]},{"id":"c4dbefa6-1ce0-4cef-babe-444329affea7","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":430,"y":280},"endPoint":{"x":430,"y":420},"properties":{},"text":{"x":495,"y":350,"value":"经理审核通过"},"pointsList":[{"x":430,"y":280},{"x":495,"y":280},{"x":495,"y":420},{"x":430,"y":420}]},{"id":"6fb6a3b1-a8fc-4d22-b9f0-5692208118d5","type":"polyline","sourceNodeId":"1","targetNodeId":"2","startPoint":{"x":348,"y":300},"endPoint":{"x":348,"y":400},"properties":{},"text":{"x":348,"y":350,"value":"同意-连线文本"},"pointsList":[{"x":348,"y":300},{"x":348,"y":400}]}]})
// this.lf.render({"nodes":[{"id":"start-c31f75a55c48","type":"CustomNode","x":100,"y":80,"properties":{"id":"start-c31f75a55c48","label":"起点","type":"start","assignType":"person","assignValue":["admin"],"lineTypeList":"同意"},"text":{"x":100,"y":80,"value":"起点"}},{"id":"end-72e945407d48","type":"CustomNode","x":540,"y":80,"properties":{"id":"end-72e945407d48","label":"终点","type":"end","assignType":"person","assignValue":["admin"],"lineTypeList":""},"text":{"x":540,"y":80,"value":"终点"}},{"id":"userTask-fa96d9f1f548","type":"CustomNode","x":320,"y":80,"properties":{"id":"userTask-fa96d9f1f548","label":"审批节点","type":"userTask","assignType":"person","assignValue":["admin"],"lineTypeList":"同意,拒绝"},"text":{"x":320,"y":80,"value":"审批节点"}}],"edges":[{"id":"line-8c746156fb48","type":"polyline","sourceNodeId":"start-c31f75a55c48","targetNodeId":"userTask-fa96d9f1f548","startPoint":{"x":150,"y":80},"endPoint":{"x":270,"y":80},"properties":{"from":"start-c31f75a55c48","to":"userTask-fa96d9f1f548","label":"同意-连线文本3","type":"同意","id":"line-8c746156fb48","Remark":"","endpoint":"Dot"},"text":{"x":210,"y":80,"value":"同意-连线文本3"},"pointsList":[{"x":150,"y":80},{"x":270,"y":80}]},{"id":"line-088a246e9248","type":"polyline","sourceNodeId":"userTask-fa96d9f1f548","targetNodeId":"end-72e945407d48","startPoint":{"x":370,"y":80},"endPoint":{"x":490,"y":80},"properties":{"from":"userTask-fa96d9f1f548","to":"end-72e945407d48","label":"同意-连线文本","type":"同意","id":"line-088a246e9248","Remark":"","endpoint":"Dot"},"text":{"x":430,"y":80,"value":"同意-连线文本"},"pointsList":[{"x":370,"y":80},{"x":490,"y":80}]}]}); // this.lf.render({"nodes":[{"id":"start-c31f75a55c48","type":"CustomNode","x":100,"y":80,"properties":{"id":"start-c31f75a55c48","label":"起点","type":"start","assignType":"person","assignValue":["admin"],"lineTypeList":"同意"},"text":{"x":100,"y":80,"value":"起点"}},{"id":"end-72e945407d48","type":"CustomNode","x":540,"y":80,"properties":{"id":"end-72e945407d48","label":"终点","type":"end","assignType":"person","assignValue":["admin"],"lineTypeList":""},"text":{"x":540,"y":80,"value":"终点"}},{"id":"userTask-fa96d9f1f548","type":"CustomNode","x":320,"y":80,"properties":{"id":"userTask-fa96d9f1f548","label":"审批节点","type":"userTask","assignType":"person","assignValue":["admin"],"lineTypeList":"同意,拒绝"},"text":{"x":320,"y":80,"value":"审批节点"}}],"edges":[{"id":"line-8c746156fb48","type":"polyline","sourceNodeId":"start-c31f75a55c48","targetNodeId":"userTask-fa96d9f1f548","startPoint":{"x":150,"y":80},"endPoint":{"x":270,"y":80},"properties":{"from":"start-c31f75a55c48","to":"userTask-fa96d9f1f548","label":"同意-连线文本3","type":"同意","id":"line-8c746156fb48","Remark":"","endpoint":"Dot"},"text":{"x":210,"y":80,"value":"同意-连线文本3"},"pointsList":[{"x":150,"y":80},{"x":270,"y":80}]},{"id":"line-088a246e9248","type":"polyline","sourceNodeId":"userTask-fa96d9f1f548","targetNodeId":"end-72e945407d48","startPoint":{"x":370,"y":80},"endPoint":{"x":490,"y":80},"properties":{"from":"userTask-fa96d9f1f548","to":"end-72e945407d48","label":"同意-连线文本","type":"同意","id":"line-088a246e9248","Remark":"","endpoint":"Dot"},"text":{"x":430,"y":80,"value":"同意-连线文本"},"pointsList":[{"x":370,"y":80},{"x":490,"y":80}]}]});
this.lf.render(this.parseBusinessDataToLfData(this.data)); this.lf.render(this.parseBusinessDataToLfData(this.data));
}, },
/** /**
@@ -396,7 +438,7 @@
* 将流程设计器数据转换为业务数据 * 将流程设计器数据转换为业务数据
*/ */
parseLFDataToBusinessData() { parseLFDataToBusinessData() {
const lfData = this.lf.getGraphData(); const lfData = this.getOrderedGraphData();
return { return {
nodeList: lfData.nodes.map(node => ({ nodeList: lfData.nodes.map(node => ({
...node.properties, ...node.properties,
@@ -409,6 +451,31 @@
} }
}, },
/**
* 获取排序后的GraphData
* @param nodeList
*/
getOrderedGraphData() {
const lfData = this.lf.getGraphData();
const orderedNodes = lfData.edges.reduce((acc, edge) => {
const sourceNode = lfData.nodes.find(node => node.id === edge.sourceNodeId);
const targetNode = lfData.nodes.find(node => node.id === edge.targetNodeId);
if (sourceNode && targetNode) {
const sourceIndex = acc.findIndex(node => node.id === sourceNode.id);
const targetIndex = acc.findIndex(node => node.id === targetNode.id);
if (sourceIndex > targetIndex) {
acc.splice(targetIndex, 0, sourceNode);
acc.splice(sourceIndex + 1, 1);
}
}
return acc;
}, lfData.nodes);
return {
nodes: orderedNodes,
edges: lfData.edges
}
},
/** /**
* 将业务数据转换为流程设计器数据 * 将业务数据转换为流程设计器数据
*/ */
@@ -508,4 +575,9 @@
border-radius: 4px; border-radius: 4px;
} }
.lf-control-item i{
width: 10px;
height: 10px;
}
</style> </style>
+79
View File
@@ -0,0 +1,79 @@
<!-- formItem.html >>>>>>>>>>>>> -->
<script type="text/html" id="form-item">
<div>
<span class="jh-input-label">{{ formItem.statement }}</span>
<!-- 文本 -->
<v-text-field v-if="formItem.type === 'input'" :rules="validationRules.requireRules" class="jh-v-input" dense single-line filled label="班级ID" v-model="formItem.answer"></v-text-field>
<!-- 单选 -->
<v-select
v-if="formItem.type === 'single'"
v-model="formItem.answer"
:items="formItem.optionList"
dense single-line filled
:rules="validationRules.requireRules"
></v-select>
<!-- 多选 -->
<v-select
v-if="formItem.type === 'multiple'"
v-model="formItem.answer"
:items="formItem.optionList"
multiple
dense single-line filled
:rules="validationRules.requireRules"
></v-select>
<!-- 文本框 -->
<v-textarea v-if="formItem.type === 'short'" :rules="validationRules.requireRules" class="jh-v-input" no-resize dense single-line filled label="备注"
v-model="formItem.answer"></v-textarea>
<!-- 时间选择 -->
<v-text-field v-if="formItem.type === 'date'" class="jh-v-input" dense single-line filled readonly @click="openDataPicker" label="出生日期" v-model="formItem.answer" :rules="validationRules.requireRules"></v-text-field>
<v-menu v-if="formItem.type === 'date'" class="jh-v-input" :close-on-content-click="false" v-model="isDataPickerShown" :position-x="dataPickerPosition.x" :position-y="dataPickerPosition.y" transition="scale-transition" offset-y min-width="auto">
<v-date-picker color="green lighten-1" elevation="20" @input="isDataPickerShown = false" v-model="formItem.answer"></v-date-picker>
</v-menu>
</div>
</script>
<script>
Vue.component('form-item', {
template: "#form-item",
vueComponent: 'form-item',
vuetify: new Vuetify(),
props: {
formItem: {
type: Boolean,
default: false,
},
},
data() {
return {
isDataPickerShown: false,
dataPickerPosition: {x: null, y: null},
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
};
},
created() {
console.log(this.formItem)
},
methods: {
// ---------- 日期选择 >>>>>>>>>> --------
async openDataPicker(funObj) {
this.dataPickerPosition.x = funObj.x - funObj.offsetX;
this.dataPickerPosition.y = funObj.y - funObj.offsetY + 40;
this.isDataPickerShown = !this.isDataPickerShown;
},
// ---------- <<<<<<<<<< 日期选择 --------
},
});
</script>
<style>
</style>
<!-- <<<<<<<<<<<<< formItem.html -->
+104
View File
@@ -0,0 +1,104 @@
<!-- formItem.html >>>>>>>>>>>>> -->
<script type="text/html" id="task-history">
<div>
<v-data-table
:headers="headers"
:items="tableData"
:items-per-page="-1"
mobile-breakpoint="0"
:loading="isTableLoading"
checkbox-color="success"
fixed-header
hide-default-footer
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
<template v-slot:item.taskHandleDesc="{ item }">
<span v-if="item.taskConfigId.includes('userTask-')">
<v-icon
large
>
mdi-arrow-right-thin
</v-icon>
<v-chip
v-if="item.taskHandleDesc === '拒绝'"
color="red"
small outlined label
>
{{item.taskHandleDesc}}
</v-chip>
<v-chip
v-else
color="green"
small outlined label
>
{{item.taskHandleDesc}}
</v-chip>
</span>
<span v-else>{{item.taskHandleDesc}}</span>
</template>
</v-data-table>
</div>
</script>
<script>
Vue.component('task-history', {
template: "#task-history",
vueComponent: 'task-history',
vuetify: new Vuetify(),
props: {
taskId: {
type: String,
default: '',
},
},
data() {
return {
isTableLoading: false,
headers: [
{text: "名称", value: "taskTitle", width: 230, class: 'fixed', cellClass: 'fixed'},
{text: "节点说明", value: "taskExplain", width: 200},
{text: "操作人", value: "operationByUser", width: 80},
{text: "操作描述", value: "taskHandleDesc", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
],
tableData: [],
};
},
watch: {
taskId: {
handler(val, oldVal) {
if (!val) return;
this.getTableData();
},
immediate: true,
},
},
methods: {
// ---------- 获取列表 >>>>>>>>>> --------
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'getTaskHistory',
actionData: {taskId: this.taskId},
}
}
})
const {taskHistoryList, lineTypeList} = result.data.appData.resultData;
taskHistoryList.forEach(task => {
task.operationAt = task.taskStatus != 'end' ? dayjs(task.operationAt).format('YYYY-MM-DD HH:mm:ss') : ''
})
this.tableData = taskHistoryList;
this.$emit('line-type-list', lineTypeList);
this.isTableLoading = false;
},
// ---------- <<<<<<<<<< 获取列表 --------
},
});
</script>
<style>
</style>
<!-- <<<<<<<<<<<<< formItem.html -->
+283
View File
@@ -0,0 +1,283 @@
{% extends 'template/jhTemplateV4.html'%}
{% block vueTemplate %}
<script type="text/html" id="app-template">
<div>
<v-app mobile-breakpoint="sm">
<jh-menu />
<v-main class="mt-15">
<!-- 头部内容 >>>>>>>>>>>>> -->
<div class="jh-page-second-bar px-8">
<div class="pt-3 text-h7 font-weight-bold">审批列表
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg">
<v-row class="ma-0 py-0 px-4">
<v-spacer></v-spacer>
<!--搜索-->
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-0">
<v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled hide-details
single-line></v-text-field>
</v-col>
</v-row>
<!--表格-->
<v-data-table
:headers="headers"
:items="tableData"
:search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页行数', itemsPerPageAllText: '所有'}"
:items-per-page="-1"
mobile-breakpoint="0"
:loading="isTableLoading"
:class="{'zebraLine': isTableZebraLineShown }"
checkbox-color="success"
fixed-header
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
<template v-slot:item.taskTitle="{ item }">
<span>{{item.taskTitle}}</span>
</template>
<template v-slot:item.taskStatus="{ item }">
<v-chip
v-if="item.taskStatus === '已结束'" label outlined
color="red"
small
>
{{item.taskStatus}}
</v-chip>
<v-chip
v-else label outlined
color="green"
small
>
{{item.taskStatus}}
</v-chip>
</template>
<!--表格行操作按钮-->
<template v-slot:item.action="{ item }">
<span role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
查看
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</template>
<!--表格底部右侧分页-->
<template v-slot:footer.page-text="pagination">
<span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
<span class="ml-1">共{{pagination.itemsLength}}条</span>
</template>
</v-data-table>
</v-card>
<!-- <<<<<<<<<<<<< 页面内容 -->
<!--编辑抽屉-->
<v-navigation-drawer v-model="isViewDrawerShown" :permanent="isViewDrawerShown" fixed temporary right hide-overlay width="80%"
class="elevation-24">
<v-form v-if="isViewDrawerShown" ref="updateForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">历史审核记录</span>
</v-row>
<!--抽屉表单-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核申请信息</span>
<task-history :task-id="updateItem.taskId"></task-history>
</v-col>
</v-row>
</v-form>
<!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isViewDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
</div>
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
class="elevation-24">
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#taskHistory.md`" width="100%"
height="100%"></iframe>
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isHelpPageDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
</v-main>
</v-app>
<jh-toast />
<jh-mask />
<jh-confirm-dialog />
</div>
</script>
<div id="app">
</div>
{% endblock %}
{% block vueScript %}
<!-- 加载页面组件 >>>>>>>>>>>>> -->
{% include 'common/fixedTableHeightV4.html' %}
{% include 'component/taskHistory.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: {
// 面包屑
breadcrumbs: [
{
text: '首页',
disabled: true,
},
{
text: '所有审批',
disabled: true,
}
],
isHelpPageDrawerShown: false,
// 表格相关数据
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isTableZebraLineShown: true,
// 生日日期选择
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
searchInput: null,
isTableLoading: true,
tableData: [],
historyData: [],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: "审批项", value: "taskTitle" },
{ text: "审核状态", value: "taskStatus" },
{ text: "操作者", value: "operationByUser", width: 120 },
{ text: "操作时间", value: "operationAt", width: 250 }
],
isViewDrawerShown: false,
updateItem: {},
workflowType: 'todo', // todo, history
lineTypeList: [],
userId: '<$ ctx.userInfo.userId $>'
},
// 计算
computed: {
},
watch: {
},
mounted() {
this.doUiAction('getTableData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'getTableData':
await this.getTableData();
break;
case 'openDataPicker':
await this.openDataPicker(uiActionData);
break;
case 'openTableZebraLineMenu':
await this.openTableZebraLineMenu(uiActionData);
break;
case 'startUpdateItem':
await this.prepareUpdateFormData(uiActionData);
await this.openUpdateDrawer();
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'taskHistory',
actionId: 'selectItemList',
actionData: {},
orderBy: [{ column: 'operationAt', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
const statusMap = {
'running': '审核中',
'end': '已结束',
};
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
row.taskStatus = statusMap[row.taskStatus];
});
this.tableData = rows;
this.isTableLoading = false;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
async openTableZebraLineMenu(funObj) {
this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
async prepareUpdateFormData(funObj) {
this.updateItem = _.cloneDeep(funObj);
},
async closeSubmitDrawer() {
this.isViewDrawerShown = false;
},
async openUpdateDrawer() {
this.isViewDrawerShown = true;
},
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
}
})
</script>
<style scoped>
</style>
{% endblock %}
s
+412
View File
@@ -0,0 +1,412 @@
{% extends 'template/jhTemplateV4.html'%}
{% block vueTemplate %}
<script type="text/html" id="app-template">
<div>
<v-app mobile-breakpoint="sm">
<jh-menu />
<v-main class="mt-15">
<!-- 头部内容 >>>>>>>>>>>>> -->
<div class="jh-page-second-bar px-8">
<div class="pt-3 text-h7 font-weight-bold">待办审批
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg">
<v-row class="ma-0 py-0 px-4">
<v-spacer></v-spacer>
<!--切换状态-->
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0 d-flex justify-end">
<v-btn-toggle
v-model="workflowType"
borderless
color="success"
>
<v-btn value="todo" small>
<v-badge
v-if="tableData.length"
inline
:content="tableData.length"
color="warning"
>
<span class="">待处理</span>
</v-badge>
<span v-else class="">待处理</span>
</v-btn>
<v-btn value="history" small>
<v-badge
v-if="historyData.length"
inline
:content="historyData.length"
color="grey darken-3"
>
<span class="">已处理</span>
</v-badge>
<span v-else class="">已处理</span>
</v-btn>
</v-btn-toggle>
</v-col>
<!--搜索-->
<v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-0">
<v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled hide-details
single-line></v-text-field>
</v-col>
</v-row>
<!--表格-->
<v-data-table
:headers="headers"
:items="tableDataList"
:search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页行数', itemsPerPageAllText: '所有'}"
:items-per-page="-1"
mobile-breakpoint="0"
:loading="isTableLoading"
:class="{'zebraLine': isTableZebraLineShown }"
checkbox-color="success"
fixed-header
class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
<template v-slot:item.taskTitle="{ item }">
<span>{{item.taskTitle}}</span>
<span v-if="workflowType != 'todo'">
<v-chip
v-if="item.taskHandleDesc === '拒绝'" label outlined
color="red"
small
>
已{{item.taskHandleDesc}}
</v-chip>
<v-chip
v-else label outlined
color="green"
small
>
已{{item.taskHandleDesc}}
</v-chip>
</span>
</template>
<!--表格行操作按钮-->
<template v-slot:item.action="{ item }">
<span v-if="workflowType === 'todo'" role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
<v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>
审核
</span>
<span v-else role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction('startUpdateItem', item)">
查看
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</template>
<!--表格底部右侧分页-->
<template v-slot:footer.page-text="pagination">
<span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
<span class="ml-1">共{{pagination.itemsLength}}条</span>
</template>
</v-data-table>
</v-card>
<!-- <<<<<<<<<<<<< 页面内容 -->
<!--编辑抽屉-->
<v-navigation-drawer v-model="isSubmitDrawerShown" :permanent="isSubmitDrawerShown" fixed temporary right hide-overlay width="80%"
class="elevation-24">
<v-form v-if="isSubmitDrawerShown" ref="updateForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">审核信息</span>
</v-row>
<!--抽屉表单-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核申请信息</span>
<v-card class="rounded-lg px-4" outlined>
<v-row class="my-0">
<v-col cols="12" sm="12" md="6" v-for="(item, key, index) in updateItem.taskFormInput.input">
<span class="jh-input-label" style="color: gray">{{key}}:</span>
<span>{{item}}</span>
</v-col>
</v-row>
</v-card>
</v-col>
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">备注</span>
<v-textarea class="jh-v-input" no-resize dense single-line filled label="备注"
v-model="updateItem.taskComment" :readonly="workflowType != 'todo'"></v-textarea>
</v-col>
</v-row>
<!--抽屉操作按钮-->
<v-row class="justify-end mx-0 mt-8 px-6">
<v-btn color="success" class="mx-4" v-for="item in lineTypeList" v-if="item.type" @click="doUiAction('submitNode', item.type)">
{{ item.type }}
</v-btn>
</v-row>
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审核历史</span>
<task-history :task-id="updateItem.taskId" @line-type-list="setLineTypeList"></task-history>
</v-col>
</v-row>
</v-form>
<!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isSubmitDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
</div>
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
class="elevation-24">
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#todo.md`" width="100%"
height="100%"></iframe>
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isHelpPageDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
</v-main>
</v-app>
<jh-toast />
<jh-mask />
<jh-confirm-dialog />
</div>
</script>
<div id="app">
</div>
{% endblock %}
{% block vueScript %}
<!-- 加载页面组件 >>>>>>>>>>>>> -->
{% include 'common/fixedTableHeightV4.html' %}
{% include 'component/taskHistory.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(),
data: {
// 面包屑
breadcrumbs: [
{
text: '首页',
disabled: true,
},
{
text: '我的相关、待办',
disabled: true,
}
],
isHelpPageDrawerShown: false,
// 表格相关数据
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isTableZebraLineShown: true,
// 生日日期选择
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
searchInput: null,
isTableLoading: true,
tableData: [],
historyData: [],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: "审批项", value: "taskTitle" },
{ text: "操作者", value: "operationByUser", width: 120 },
{ text: "操作时间", value: "operationAt", width: 250 }
],
isSubmitDrawerShown: false,
updateItem: {},
workflowType: 'todo', // todo, history
lineTypeList: [],
userId: '<$ ctx.userInfo.userId $>'
},
// 计算
computed: {
tableDataList() {
return this.workflowType === 'todo' ? this.tableData : this.historyData;
},
},
watch: {
},
mounted() {
this.doUiAction('getTableData');
this.doUiAction('getHistoryData');
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'getTableData':
await this.getTableData();
break;
case 'getHistoryData':
await this.getHistoryData();
break;
case 'openDataPicker':
await this.openDataPicker(uiActionData);
break;
case 'openTableZebraLineMenu':
await this.openTableZebraLineMenu(uiActionData);
break;
case 'startUpdateItem':
await this.prepareUpdateFormData(uiActionData);
await this.openUpdateDrawer();
break;
case 'submitNode':
await this.confirmSumitDialog();
await this.submitForReview(uiActionData);
await this.closeSubmitDrawer();
await this.clearSubmitData();
this.getTableData();
this.getHistoryData();
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
async getTableData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'selectItemList',
actionData: {},
where: {taskStatus: 'running'},
whereLike: {taskEditUserList: this.userId},
orderBy: [{ column: 'operationAt', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
});
this.tableData = rows.filter(item => !item.taskEditedUserList || !item.taskEditedUserList.includes(this.userId));
this.isTableLoading = false;
},
async getHistoryData() {
this.isTableLoading = true;
const result = await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'selectHistoryList',
actionData: {},
where: {taskStatus: 'running'},
whereLike: {taskEditUserList: '<$ ctx.userInfo.userId $>', taskConfigId: 'userTask-'},
orderBy: [{ column: 'id', order: 'desc' }]
}
}
});
const rows = result.data.appData.resultData.rows;
rows.forEach(row => {
row.taskFormInput = JSON.parse(row.taskFormInput);
row.operationAt = dayjs(row.operationAt).format('YYYY-MM-DD HH:mm:ss');
});
this.historyData = rows;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
async openTableZebraLineMenu(funObj) {
this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
// ---------- 审核、查看 uiAction >>>>>>>>>>>> --------
async prepareUpdateFormData(funObj) {
this.updateItem = _.cloneDeep(funObj);
this.updateItem.taskHistoryList = []; // 审核历史
this.updateItem.taskComment = ''; // 备注
this.lineTypeList = []; // 所有操作按钮
},
async closeSubmitDrawer() {
this.isSubmitDrawerShown = false;
},
async openUpdateDrawer() {
this.isSubmitDrawerShown = true;
},
async confirmSumitDialog() {
if (await window.confirmDialog({title: "审核", content: "确定提交审核吗?"}) === false) {
throw new Error("[confirmSumitDialog] 否");
}
},
async clearSubmitData() {
this.updateItem = {};
},
async submitForReview(type) {
await window.vtoast.loading("提交审核");
await window.jianghuAxios({
data: {
appData: {
pageId: 'todo',
actionId: 'submitNode',
actionData: {type, id: this.updateItem.id, taskId: this.updateItem.taskId, taskComment: this.updateItem.taskComment}
}
}
})
await window.vtoast.success("提交审核成功");
setTimeout(()=> {
this.$emit('close-detail-drawer')
// if (document.referrer) {
// location.href = document.referrer;
// } else {
// history.back();
// }
}, 1000);
},
setLineTypeList(lineTypeList) {
this.lineTypeList = _.uniqBy((lineTypeList||'').split(",").map(lineType => ({type: lineType, label: lineType})), 'type');
},
// ---------- <<<<<<<<<<< 审核、查看 uiAction --------
}
})
</script>
<style scoped>
</style>
{% endblock %}
+40 -13
View File
@@ -12,31 +12,36 @@
</template> </template>
<template slot-scope="props"> <template slot-scope="props">
<v-card class="mt-3 mb-12" :class="{'pa-8': !props.ismobile, 'pa-4': props.ismobile}"> <v-card class="mt-3 mb-3" :class="{'pa-8': !props.ismobile, 'pa-4': props.ismobile}">
<v-row> <v-row>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3"> <v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="流程名:" v-model="editItem['workflowName']" :rules="requireRules"> <v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="流程名:" v-model="editItem['workflowName']" :rules="requireRules">
</v-text-field> </v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3"> <!-- <v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="分类:" v-model="editItem['workflowCategory']" :rules="requireRules"> <v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="分类:" v-model="editItem['workflowCategory']" :rules="requireRules">
</v-text-field> </v-text-field>
</v-col> </v-col> -->
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3"> <v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="备注:" <v-text-field class="cus-v-input mr-2" dense filled single-line color="success" prefix="备注:"
v-model="editItem['workflowRemark']"> v-model="editItem['workflowRemark']">
</v-text-field> </v-text-field>
</v-col> </v-col>
<v-col cols="12" sm="12" md="3" xl="3" class=" pb-3">
<v-select class="cus-v-input mr-2" dense filled single-line color="success" prefix="审批模式:"
v-model="editItem['mode']" :items="constantCollection.modeList" />
</v-col>
</v-row> </v-row>
</v-card> </v-card>
<div class=" pb-4" style="font-size: 18px; font-weight: bold">模板设置</div> <!-- <div class=" pb-4" style="font-size: 18px; font-weight: bold">模板设置</div>
<tpl-form-design :form="editItem.workflowForm" v-if="!loading"> <tpl-form-design :form="editItem.workflowForm" v-if="!loading">
</tpl-form-design> </tpl-form-design> -->
<div class="pt-8 pb-4" style="font-size: 18px; font-weight: bold">流程设置</div> <div class="pt-8 pb-4" style="font-size: 18px; font-weight: bold">流程设置</div>
<process-flow v-if="!loading" ref="processFlow" :data="editItem.workflowConfig" :user="constantCollection.userList" <process-flow v-if="!loading" ref="processFlow" :data="editItem.workflowConfig" :user="constantCollection.userList"
:group="constantCollection.groupList" :tpl="constantCollection.workflowFormList"> :group="constantCollection.groupList" :tpl="constantCollection.workflowFormList"
:mode="editItem.mode">
</process-flow> </process-flow>
<v-overlay :value="loading" absolute> <v-overlay :value="loading" absolute>
@@ -66,12 +71,16 @@ new Vue({
vuetify: new Vuetify(), vuetify: new Vuetify(),
data: () => ({ data: () => ({
requireRules: [ requireRules: [
v => !!v || 'This is required', v => !!v || '必填',
], ],
constantCollection: { constantCollection: {
userList: [], userList: [],
groupList: [], groupList: [],
workflowFormList: [] workflowFormList: [],
modeList: [
{ text: '串行', value: 'serial'},
{ text: '并行', value: 'parallel'},
]
}, },
editItem: {}, editItem: {},
dialogSaveInfoAction: 'createItem', dialogSaveInfoAction: 'createItem',
@@ -123,8 +132,17 @@ new Vue({
}, },
buildEditItem() { buildEditItem() {
const { id, workflowId, workflowName, workflowRemark, workflowCategory, workflowForm } = this.editItem; const { id, workflowId, workflowName, workflowRemark, workflowCategory, mode, workflowForm } = this.editItem;
const workflowConfig = this.$refs.processFlow.getData(); const workflowConfig = this.$refs.processFlow.getData();
workflowConfig.mode = mode
// TODO: 清除不存在的用户
workflowConfig.nodeList.forEach(node => {
if (node.type === 'userTask') {
node.assignValue = node.assignValue || [];
node.assignValue = node.assignValue.filter(userId => this.constantCollection.userList.findIndex(u => u.userId === userId) > -1);
node.origin.properties.assignValue = node.assignValue;
}
});
let item = { let item = {
workflowName, workflowName,
workflowRemark, workflowRemark,
@@ -159,7 +177,6 @@ new Vue({
} }
} }
config.formId = formId config.formId = formId
console.log(config.outline, config.formId)
} }
}, },
@@ -178,7 +195,7 @@ new Vue({
} }
})).data.appData.resultData; })).data.appData.resultData;
this.constantCollection.userList = rows.map(e => { this.constantCollection.userList = rows.map(e => {
return {text: e.username, value: e.userId} return {text: e.username, value: e.userId, userId: e.userId }
}) })
}, },
/** /**
@@ -202,7 +219,7 @@ new Vue({
async clearItemData() { async clearItemData() {
this.dialogSaveInfoAction = 'createItem'; this.dialogSaveInfoAction = 'createItem';
this.editItem = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}}; this.editItem = {workflowForm: [], workflowConfig: {lineList: [], nodeList: []}, mode: 'serial'};
}, },
async syncEditItem() { async syncEditItem() {
@@ -223,6 +240,7 @@ new Vue({
const item = rows[0]; const item = rows[0];
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null; item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : []; item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
item.mode = item.workflowConfig.mode || 'serial';
this.editItem = item; this.editItem = item;
} }
setTimeout(() => { setTimeout(() => {
@@ -285,7 +303,16 @@ new Vue({
}) })
</script> </script>
<style scoped> <style>
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr > td:not(.v-data-table__mobile-row) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 500px;
}
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr {
cursor: pointer;
}
</style> </style>
{% endblock %} {% endblock %}
+187
View File
@@ -0,0 +1,187 @@
{% extends 'template/jhTemplateV3.html'%}
{% block vue_template %}
<jh-layout-v3>
<!-- 页面主要内容 -->
<v-card :class="{'px-2': isMobile}">
<v-row class="ma-0 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}">
<v-col cols="12" xs="12" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" dark class="elevation-0 mr-2" @click="doUiAction('createItem')">新增</v-btn>
<span class="body-2">共{{ tableDataFromBackend.length }}条记录</span>
</v-col>
<v-spacer></v-spacer>
<v-col cols="12" xs="12" sm="4" md="3" xl="3" class="px-0">
<v-text-field v-model="searchInput" prefix="表格过滤:" color="success" class="cus-v-input" dense filled
single-line></v-text-field>
</v-col>
</v-row>
<v-data-table
fixed-header
:headers="headers"
:items="tableDataFromBackend"
:search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }"
height="600"
:items-per-page="100"
mobile-breakpoint="0"
:loading="isTableLoading"
checkbox-color="success"
:class="{'mx-2': isMobile}"
color="success"
class="elevation-0 mt-0 flex-fill d-flex flex-column">
<template v-slot:item.action="{ item }">
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList"
@click="doUiAction(tableButton.action, {item})">
{{ tableButton.text }}
</v-btn>
</template>
<template v-slot:item.operationAt="{ item }">
{{ item.operationAt && dayjs(item.operationAt).format('YYYY-MM-DD HH:mm:ss') }}
</template>
</v-data-table>
</v-card>
</jh-layout-v3>
{% endblock %}
{% block vue_body %}
<script type="module">
new Vue({
el: '#app',
template: '#app-template',
vuetify: new Vuetify(),
data: () => ({
isMobile: window.innerWidth < 600,
searchInput: null,
isTableLoading: true,
tableDataFromBackend: [],
headers: [
// {text: "ID", value: "id", width: 120, class: 'fixed', cellClass: 'fixed'},
{text: "流程名", value: "workflowName", width: 200, class: 'fixed', cellClass: 'fixed'},
{text: "流程ID", value: "workflowId", width: 120},
// {text: "分类ID", value: "workflowCategory", width: 120},
{text: "备注", value: "workFlowRemark", width: 120},
{text: "操作者", value: "operationByUser", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
{text: '操作', value: 'action', align: 'center', sortable: false, width: 160, class: 'fixed', cellClass: 'fixed'},
],
tableButtonList: [
{text: '编辑', buttonType: 'edit', color: 'success', action: 'updateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
]
}),
async created() {
await this.doUiAction('refreshTableData');
},
mounted() {
},
methods: {
async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) {
case 'refreshTableData':
await this.refreshTableData(uiActionData);
break;
case 'createItem':
await this.prepareValidate(uiActionData);
await this.doCreateItem(uiActionData);
break;
case 'updateItem':
await this.prepareValidate(uiActionData);
await this.doUpdateItem(uiActionData);
break;
case 'deleteItem':
await this.confirmDeleteItemDialog(uiActionData);
await this.doDeleteItem(uiActionData);
await this.refreshTableData(uiActionData);
break;
default:
console.error("[doUiAction] uiActionId not find", { uiActionId });
break;
}
},
/**
* 获取表格数据
*/
async refreshTableData() {
this.isTableLoading = true;
const {rows} = (await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'selectItemList',
orderBy: [{column: 'id', order: 'asc'}]
}
}
})).data.appData.resultData;
for (const item of rows) {
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : [];
item.operationAt = dayjs(item.operationAt).format();
}
this.tableDataFromBackend = rows;
this.isTableLoading = false;
},
async prepareValidate() {
if(this.isMobile) {
window.vtoast.fail({message: '该功能只能在电脑使用'})
return false;
}
},
// CreateItem
async doCreateItem() {
window.location.href = `/${window.appInfo.appId}/page/workflowEditor`;
},
// UpdateItem
async doUpdateItem({item}) {
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?id=${item.id}`;
},
async confirmDeleteItemDialog() {
if (await window.confirmDialog({title: "删除", content: "确定删除吗?"}) === false) {
throw new Error("[confirmDeleteItemDialog] 否");
}
},
/**
* 删除数据
*/
async doDeleteItem({item}) {
const {id} = item;
await window.vtoast.loading("删除数据");
await window.jianghuAxios({
data: {
appData: {
pageId: 'workflowManagement',
actionId: 'deleteItem',
actionData: {},
where: {id: id}
}
}
});
await window.vtoast.success("删除数据成功");
},
}
})
</script>
<style>
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr > td:not(.v-data-table__mobile-row) {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 500px;
}
.theme--light.v-data-table > .v-data-table__wrapper > table > tbody > tr {
cursor: pointer;
}
</style>
{% endblock %}
+377 -106
View File
@@ -1,173 +1,444 @@
{% extends 'template/jhTemplateV3.html'%} {% extends 'template/jhTemplateV4.html'%}
{% block vue_template %} {% block vueTemplate %}
<jh-layout-v3> <script type="text/html" id="app-template">
<!-- 页面主要内容 --> <div>
<v-card :class="{'px-2': isMobile}"> <v-app mobile-breakpoint="sm">
<v-row class="ma-0 align-center flex-none pt-0 " :class="{'pa-4': !isMobile, 'pb-0': !isMobile, 'pa-2': isMobile}"> <jh-menu />
<v-col cols="12" xs="12" sm="4" md="4" xl="4" class="pl-0"> <v-main class="mt-15">
<v-btn color="success" dark class="elevation-0 mr-2" @click="doUiAction('createItem')">新增</v-btn> <!-- 头部内容 >>>>>>>>>>>>> -->
<span class="body-2">共{{ tableDataFromBackend.length }}条记录</span> <div class="jh-page-second-bar px-8">
<div class="pt-3 text-h7 font-weight-bold">新申请审批
<!-- 帮助页按钮 -->
<v-icon @click="isHelpPageDrawerShown = true" color="success" small>mdi-help-circle-outline</v-icon>
</div>
<v-breadcrumbs class="pb-3 pt-0 px-0" :items="breadcrumbs" divider="-"></v-breadcrumbs>
</div>
<!-- <<<<<<<<<<<<< 头部内容 -->
<div class="jh-page-body-container px-8">
<!-- 页面内容 >>>>>>>>>>>>> -->
<v-card class="rounded-lg mb-4">
<v-row class="ma-0 py-0 px-4">
<!--新增按钮-->
<v-col cols="12" xs="4" sm="4" md="4" xl="4" class="pl-0">
<v-btn color="success" small class="elevation-0 mr-2"
@click="doUiAction('jumpToCreateWorkflow')">新增</v-btn>
</v-col> </v-col>
<v-spacer></v-spacer> <v-spacer></v-spacer>
<v-col cols="12" xs="12" sm="4" md="3" xl="3" class="px-0"> <!--搜索-->
<v-text-field v-model="searchInput" prefix="表格过滤:" color="success" class="cus-v-input" dense filled <v-col cols="12" xs="8" sm="4" md="3" xl="2" class="px-0">
single-line></v-text-field> <v-text-field v-model="searchInput" color="success" prefix="搜索:" class="jh-v-input" dense filled single-line hide-details></v-text-field>
</v-col> </v-col>
</v-row> </v-row>
<!--表格-->
<v-data-table <v-data-table
fixed-header
:headers="headers" :headers="headers"
:items="tableDataFromBackend" :items="tableData"
:search="searchInput" :search="searchInput"
:footer-props="{ itemsPerPageOptions: [20, 40, 60, 100, -1] }" :footer-props="{ itemsPerPageOptions: [20, 50, -1], itemsPerPageText: '每页行数', itemsPerPageAllText: '所有'}"
:items-per-page="20" :items-per-page="-1"
mobile-breakpoint="0" mobile-breakpoint="0"
:loading="isTableLoading" :loading="isTableLoading"
:class="{'zebraLine': isTableZebraLineShown }"
checkbox-color="success" checkbox-color="success"
:class="{'mx-2': isMobile}" fixed-header
color="success" class="jh-fixed-table-height elevation-0 mt-0 mb-xs-4">
class="elevation-0 mt-0 flex-fill d-flex flex-column"> <!--表格行操作按钮-->
<template v-slot:item.action="{ item }"> <template v-slot:item.action="{ item }">
<v-btn small class="mr-2" :class="tableButton.color" v-for="tableButton of tableButtonList" <span role="button" class="success--text jh-font-size-3 pr-2"
@click="doUiAction(tableButton.action, {item})"> @click="doUiAction('startCreateWorkflow', {formItemList: item.formItemList, group: item.name})">
{{ tableButton.text }} <v-icon size="14" class="success--text">mdi-note-edit-outline</v-icon>申请
</span>
</template>
<!--表格底部右侧功能按钮-->
<template v-slot:footer.prepend>
<v-btn icon @click="doUiAction('openTableZebraLineMenu', $event)">
<v-icon>mdi-menu</v-icon>
</v-btn> </v-btn>
<v-menu top offset-y :close-on-content-click="false" v-model="isTableZebraLineMenuShown" :position-x="tableZebraLineMenuPosition.x" :position-y="tableZebraLineMenuPosition.y">
<v-list>
<v-list-item>
<v-switch v-model="isTableZebraLineShown" hide-details class="ma-0" label="显示斑马纹" dense flat></v-switch>
</v-list-item>
</v-list>
</v-menu>
</template>
<!--表格底部右侧分页-->
<template v-slot:footer.page-text="pagination">
<span>{{pagination.pageStart}}-{{pagination.pageStop}}</span>
<span class="ml-1">共{{pagination.itemsLength}}条</span>
</template> </template>
</v-data-table> </v-data-table>
</v-card> </v-card>
</jh-layout-v3> <!-- <<<<<<<<<<<<< 页面内容 -->
</div>
<!-- <<<<<<<<<<<<< 创建审批抽屉 -->
<v-navigation-drawer v-model="isCreateDrawerShown" :permanent="isCreateDrawerShown" fixed temporary right width="80%"
class="elevation-24">
<v-form v-if="isCreateDrawerShown" ref="createForm" lazy-validation>
<!--抽屉标题-->
<v-row>
<span class="title pa-6 pl-8">创建审批</span>
</v-row>
<!--抽屉表单主体-->
<v-row class="mt-0 px-6">
<v-col cols="12" sm="12" md="4" v-for="(item, index) in createFormList" :key="index">
<form-item :form-item="item"></form-item>
</v-col>
<v-col cols="12" sm="12" md="4">
<span class="jh-input-label">附件</span>
xxx
</v-col>
<v-col cols="12" sm="12" md="12">
<span class="jh-input-label">审批流程 - 添加审批人</span>
<v-row v-for="item in workflowPersonList">
<v-col cols="2">
<v-text-field class="cus-v-input " dense filled single-line v-model="item.label" disabled></v-text-field>
</v-col>
<v-col cols="4">
<v-autocomplete
class="cus-v-input mr-2"
dense filled single-line clearable
:items="userList"
item-text="username"
item-value="userId"
multiple
:rules="validationRules.requireRules"
v-model="item.assignValue">
</v-autocomplete>
</v-col>
<v-col cols="4">
<v-checkbox dense filled v-model="item.isNeedAllApproval" label="是否需要所有人审批" hide-details ></v-checkbox>
</v-col>
</v-row>
</v-col>
</v-row>
<!--抽屉操作按钮-->
<v-row class="justify-end mx-0 mt-8 px-6">
<v-btn color="success" @click="doUiAction('createWorkflow')" small>保存</v-btn>
<v-btn class="ml-2" @click="isCreateDrawerShown = false" small>取消</v-btn>
</v-row>
</v-form>
<!--抽屉关闭按钮-->
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isCreateDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
<!-- 创建审批抽屉 >>>>>>>>>>>>> -->
<!-- 帮助页抽屉 >>>>>>>>>>>>> -->
<v-navigation-drawer v-model="isHelpPageDrawerShown" fixed temporary right width="80%" hide-overlay
class="elevation-24">
<iframe style="border: 0" :src="`/${appInfo.appId}/pageDoc#workflowManagement.md`" width="100%"
height="100%"></iframe>
<v-btn elevation="0" color="success" fab absolute top left small tile class="drawer-close-float-btn"
@click="isHelpPageDrawerShown = false">
<v-icon>mdi-close</v-icon>
</v-btn>
</v-navigation-drawer>
<!-- <<<<<<<<<<<<< 帮助页抽屉 -->
</v-main>
</v-app>
<jh-toast />
<jh-mask />
<jh-confirm-dialog />
</div>
</script>
<div id="app">
</div>
{% endblock %} {% endblock %}
{% block vue_body %} {% block vueScript %}
<!-- 加载页面组件 >>>>>>>>>>>>> -->
{% include 'component/formItem.html' %}
<!-- <<<<<<<<<<<<< 加载页面组件 -->
<script type="module"> <script type="module">
new Vue({ new Vue({
el: '#app', el: '#app',
template: '#app-template', template: '#app-template',
vueComponent: 'page',
vuetify: new Vuetify(), vuetify: new Vuetify(),
data: () => ({ data: {
isMobile: window.innerWidth < 600, // 面包屑
searchInput: null, breadcrumbs: [
isTableLoading: true, {
tableDataFromBackend: [], text: '首页',
headers: [ disabled: true,
{text: "ID", value: "id", width: 120, class: 'fixed', cellClass: 'fixed'},
{text: "流程ID", value: "workflowId", width: 120},
{text: "流程名", value: "workflowName", width: 200},
{text: "分类ID", value: "workflowCategory", width: 120},
{text: "备注", value: "workFlowRemark", width: 120},
{text: "操作者", value: "operationByUser", width: 120},
{text: "操作时间", value: "operationAt", width: 250},
{text: '操作', value: 'action', align: 'center', sortable: false, width: 160, class: 'fixed', cellClass: 'fixed'},
],
tableButtonList: [
{text: '编辑', buttonType: 'edit', color: 'success', action: 'updateItem'},
{text: '删除', buttonType: 'delete', color: 'error', action: 'deleteItem'},
]
}),
async created() {
await this.doUiAction('refreshTableData');
}, },
mounted() { {
text: '申请模板',
disabled: true,
}
],
validationRules: {
requireRules: [
v => !!v || 'This is required',
],
},
isTableLoading: false,
userList: [],
tableData: [
{ name: '请假', desc: '正常工作日请假', id: 'leave', icon: 'mdi-calendar-range', color: 'orange darken-2', formItemList: [
{
type: 'single',
typeName: '单选',
statement: '请假类型',
answer: '',
optionList: ['年假', '事假', '病假', '婚假', '产假', '其他']
},
{
type: 'date',
typeName: '时间',
statement: '开始时间',
answer: '',
},
{
type: 'date',
typeName: '时间',
statement: '结束时间',
answer: '',
},
{
type: 'input',
typeName: '文本',
statement: '请假时长',
answer: '',
},
{
type: 'short',
typeName: '文本框',
statement: '请假事由',
answer: '',
},
] },
{ name: '加班', desc: '工作日早晚加班', id: 'overtime', icon: 'mdi-account-clock', color: 'blue darken-2', formItemList: [
{
type: 'date',
typeName: '时间',
statement: '开始时间',
answer: '',
},
{
type: 'date',
typeName: '时间',
statement: '结束时间',
answer: '',
},
{
type: 'input',
typeName: '文本',
statement: '加班时长',
answer: '',
},
{
type: 'short',
typeName: '文本框',
statement: '加班事由',
answer: '',
},
] },
{ name: '出差', desc: '外地往返公干', desc: '外出公干', id: 'businessTrip', icon: 'mdi-airplane-takeoff', color: 'blue darken-2' },
{ name: '补卡', desc: '工作日忘记打卡', id: 'makeUpCard', icon: 'mdi-account-clock', color: 'blue darken-2' },
{ name: '调休', desc: '某节假日紧急工作后调换休息日期', id: 'adjustRest', icon: 'mdi-account-clock', color: 'teal darken-2' },
{ name: '调班', desc: '因个人事务和同事调换工作时间', id: 'adjustClass', icon: 'mdi-account-clock', color: 'blue darken-2' },
],
headers: [
{ text: '操作', value: 'action', align: 'center', sortable: false, width: 120, class: 'fixed', cellClass: 'fixed' },
{ text: '审批名称', value: 'name' },
{ text: '审批名称', value: 'desc' },
],
searchInput: '',
isHelpPageDrawerShown: false,
isTableZebraLineShown: true,
isTableZebraLineMenuShown: false,
tableZebraLineMenuPosition: {x: null, y: null},
isCreateDrawerShown: false,
createFormList: [],
createItem: {
group: '',
},
workflowPersonList: [],
workflowId: '6D7HV6Twfer_xtmbqUsDO'
},
watch: {},
created() {
this.getUserList();
this.getWorkflow();
}, },
methods: { methods: {
async doUiAction(uiActionId, uiActionData) { async doUiAction(uiActionId, uiActionData) {
switch (uiActionId) { switch (uiActionId) {
case 'refreshTableData': case 'getTableData':
await this.refreshTableData(uiActionData); await this.getTableData();
break; break;
case 'createItem': case 'openTableZebraLineMenu':
await this.prepareValidate(uiActionData); await this.openTableZebraLineMenu(uiActionData);
await this.doCreateItem(uiActionData);
break; break;
case 'updateItem': case 'startCreateWorkflow':
await this.prepareValidate(uiActionData); await this.prepareCreateFormData(uiActionData);
await this.doUpdateItem(uiActionData); await this.openCreateDrawer();
break; break;
case 'deleteItem': case 'createWorkflow':
await this.confirmDeleteItemDialog(uiActionData); await this.prepareCreateValidate();
await this.doDeleteItem(uiActionData); await this.confirmCreateWorkDialog();
await this.refreshTableData(uiActionData); await this.prepareDoWorkItem();
await this.doCreateWork();
await this.closeCreateDrawer();
break;
case 'jumpToCreateWorkflow':
await this.jumpToCreateWorkflow();
break; break;
default: default:
console.error("[doUiAction] uiActionId not find", { uiActionId }); console.error("[doUiAction] uiActionId not find", { uiActionId });
break; break;
} }
}, },
/**
* 获取表格数据 async getUserList() {
*/ const result = await window.jianghuAxios({
async refreshTableData() { data: {
this.isTableLoading = true; appData: {
const {rows} = (await window.jianghuAxios({ pageId: 'workflowManagement',
actionId: 'selectUserList',
actionData: {},
orderBy: [{ column: 'userId', order: 'asc' }]
}
}
});
const userList = result.data.appData.resultData.rows;
this.userList = userList;
},
async getWorkflow() {
const result = await window.jianghuAxios({
data: { data: {
appData: { appData: {
pageId: 'workflowManagement', pageId: 'workflowManagement',
actionId: 'selectItemList', actionId: 'selectItemList',
orderBy: [{column: 'operationAt', order: 'desc'}] where: {workflowId: this.workflowId}
} }
} }
})).data.appData.resultData; });
for (const item of rows) {
item.workflowConfig = item.workflowConfig ? JSON.parse(item.workflowConfig) : null; const workflowList = result.data.appData.resultData.rows;
item.workflowForm = item.workflowForm ? JSON.parse(item.workflowForm) : []; if (!workflowList.length) {
item.operationAt = dayjs(item.operationAt).format('YYYY-MM-DD HH:mm:ss'); throw new Error('缺少默认流程');
} }
this.tableDataFromBackend = rows; const workflowNodeList = JSON.parse(workflowList[0].workflowConfig).nodeList;
this.isTableLoading = false; workflowNodeList.forEach(node => {
node.isNeedAllApproval = true;
});
this.workflowPersonList = workflowNodeList.filter(node => node.id.includes('userTask-'));
}, },
async prepareValidate() { // ---------- <<<<<<<<<< 斑马纹开关 uiAction --------
if(this.isMobile) { async openTableZebraLineMenu(funObj) {
window.vtoast.fail({message: '该功能只能在电脑使用'}) this.tableZebraLineMenuPosition.x = funObj.x -funObj.offsetX + 10;
return false; this.tableZebraLineMenuPosition.y = window.innerHeight - 50;
this.isTableZebraLineMenuShown = !this.isTableZebraLineMenuShown;
},
// ---------- 斑马纹开关 uiAction >>>>>>>>>> --------
// ---------- <<<<<<<<<< 申请项目审核 --------
async prepareCreateFormData({formItemList, group}) {
if (!formItemList) {
await window.confirmDialog({title: "温馨提示", content: "该项目尚未开放"});
throw new Error("formItemList is null");
}
this.createFormList = formItemList;
this.createItem.group = group;
},
async openCreateDrawer() {
this.isCreateDrawerShown = true;
},
async prepareCreateValidate() {
if(!await this.$refs.createForm.validate()) {
throw new Error("请完善表单信息")
}
this.workflowPersonList.forEach(workflowPerson => {
workflowPerson.assignValue = workflowPerson.assignValue || [];
workflowPerson.assignValue = workflowPerson.assignValue.filter(userId => this.userList.find(u => u.userId === userId));
workflowPerson.origin.properties.assignValue = workflowPerson.assignValue;
if (workflowPerson.assignValue.length === 0) {
window.vtoast.fail({ message: `${workflowPerson.label}必填!` });
throw new Error("[prepareValidate] 审批人 false");
}
});
},
async confirmCreateWorkDialog() {
if (await window.confirmDialog({title: "新增", content: "确定新增吗?"}) === false) {
throw new Error("[confirmCreateFormDialog] 否");
} }
}, },
prepareDoWorkItem() {
// CreateItem console.log('create', this.createFormList);
async doCreateItem() {
window.location.href = `/${window.appInfo.appId}/page/workflowEditor`;
}, },
// UpdateItem async doCreateWork() {
async doUpdateItem({item}) { await window.jhMask.show();
sessionStorage.setItem('workflowEditItem', JSON.stringify(item))
window.location.href = `/${window.appInfo.appId}/page/workflowEditor?id=${item.id}`;
},
async confirmDeleteItemDialog() {
if (await window.confirmDialog({title: "删除", content: "确定删除吗?"}) === false) {
throw new Error("[confirmDeleteItemDialog] 否");
}
},
/**
* 删除数据
*/
async doDeleteItem({item}) {
const {id} = item;
await window.vtoast.loading("删除数据");
await window.jianghuAxios({ await window.jianghuAxios({
data: { data: {
appData: { appData: {
pageId: 'workflowManagement', pageId: 'workflowManagement',
actionId: 'deleteItem', actionId: 'insertItem',
actionData: {}, actionData: {
where: {id: id} formItemList: this.createFormList,
group: this.createItem.group,
workflowId: this.workflowId,
workflowConfigCustom: JSON.stringify({ nodeListOfUserTaskNode: this.workflowPersonList })
} }
} }
}); }
await window.vtoast.success("删除数据成功"); })
await window.jhMask.hide();
await window.vtoast.success("申请成功");
}, },
async closeCreateDrawer() {
this.isCreateDrawerShown = false;
},
// ---------- 申请项目审核 >>>>>>>>>> --------
jumpToCreateWorkflow() {
window.location.href = '/<$ ctx.app.config.appId $>/page/workflowEditor';
} }
}) }
})
</script> </script>
<style scoped> <style scoped>
.work-item-box {
padding: 50% 0;
position: relative;
}
.work-item-content {
position: absolute;
left: 0;
top: 0;
width: 100%;
height: 100%;
}
@media (max-width: 500px) {
body [xs='4'] {
flex: auto;
}
}
</style> </style>
{% endblock %} {% endblock %}
+1 -4
View File
@@ -8,14 +8,11 @@
"framework": "@jianghujs/jianghu" "framework": "@jianghujs/jianghu"
}, },
"dependencies": { "dependencies": {
"@jianghujs/jianghu": "3.0.81", "@jianghujs/jianghu": "4.0.5",
"dayjs": "^1.11.4",
"egg": "^2.15.1", "egg": "^2.15.1",
"egg-scripts": "^2.11.0" "egg-scripts": "^2.11.0"
}, },
"devDependencies": { "devDependencies": {
"autod": "^3.0.1",
"autod-egg": "^1.1.0",
"egg-bin": "^4.11.0", "egg-bin": "^4.11.0",
"egg-mock": "^3.21.0", "egg-mock": "^3.21.0",
"eslint": "^7.32.0", "eslint": "^7.32.0",