182 lines
5.5 KiB
JavaScript
182 lines
5.5 KiB
JavaScript
import { request } from './request.js';
|
||
|
||
// 工作流API配置
|
||
export const workflowApi = {
|
||
// 获取流程实例分页列表(我发起的)
|
||
pageByCurrent: (params) =>
|
||
request({
|
||
url: '/workflow/instance/pageByCurrent',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 删除流程实例
|
||
deleteByInstanceIds: (instanceIds) =>
|
||
request({
|
||
url: `/workflow/instance/deleteByInstanceIds/${instanceIds}`,
|
||
method: 'DELETE',
|
||
// data: instanceIds,
|
||
}),
|
||
// 撤销流程申请
|
||
cancelProcessApply: (data) =>
|
||
request({
|
||
url: '/workflow/instance/cancelProcessApply',
|
||
method: 'PUT',
|
||
data,
|
||
}),
|
||
// 获取流程分类树
|
||
categoryTree: () =>
|
||
request({
|
||
url: '/workflow/category/categoryTree',
|
||
method: 'GET',
|
||
}),
|
||
// 获取我的待办任务
|
||
todoTasks: (params) =>
|
||
request({
|
||
url: '/workflow/task/todoTasks',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取我的已办任务
|
||
finishedTasks: (params) =>
|
||
request({
|
||
url: '/workflow/task/finishedTasks',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取我的抄送任务
|
||
copyTasks: (params) =>
|
||
request({
|
||
url: '/workflow/task/copyTasks',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取全部待办任务(对应web端allTaskWaiting.vue)
|
||
pageByAllTaskWait: (params) =>
|
||
request({
|
||
url: '/workflow/task/pageByAllTaskWait',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取全部已办任务(对应web端allTaskWaiting.vue)
|
||
pageByAllTaskFinish: (params) =>
|
||
request({
|
||
url: '/workflow/task/pageByAllTaskFinish',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取我的已办任务(对应web端taskFinish.vue)
|
||
pageByTaskFinish: (params) =>
|
||
request({
|
||
url: '/workflow/task/pageByTaskFinish',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 获取我的抄送任务(对应web端taskCopyList.vue)
|
||
pageByTaskCopy: (params) =>
|
||
request({
|
||
url: '/workflow/task/pageByTaskCopy',
|
||
method: 'GET',
|
||
data: params,
|
||
}),
|
||
// 修改办理人
|
||
updateAssignee: (taskIds, assigneeId) =>
|
||
request({
|
||
url: '/workflow/task/updateAssignee',
|
||
method: 'POST',
|
||
data: { taskIds, assigneeId },
|
||
}),
|
||
// 启动流程实例
|
||
startProcessInstance: (data) =>
|
||
request({
|
||
url: '/workflow/instance/start',
|
||
method: 'POST',
|
||
data,
|
||
}),
|
||
// 办理任务
|
||
complete: (data) =>
|
||
request({
|
||
url: '/workflow/task/complete',
|
||
method: 'POST',
|
||
data,
|
||
}),
|
||
// 获取流程历史
|
||
processHistory: (instanceId) =>
|
||
request({
|
||
url: `/workflow/instance/history/${instanceId}`,
|
||
method: 'GET',
|
||
}),
|
||
// 获取流程实例详情(根据业务ID)
|
||
processDetail: (businessId) =>
|
||
request({
|
||
url: `/workflow/instance/getInfo/${businessId}`,
|
||
method: 'GET',
|
||
}),
|
||
};
|
||
|
||
// 工作流状态映射
|
||
export const workflowStatus = {
|
||
draft: { label: '草稿', color: '#909399', icon: '📝' },
|
||
waiting: { label: '待审批', color: '#e6a23c', icon: '⏰' },
|
||
complete: { label: '已完成', color: '#67c23a', icon: '✅' },
|
||
cancel: { label: '已取消', color: '#f56c6c', icon: '❌' },
|
||
back: { label: '已退回', color: '#409eff', icon: '↩️' },
|
||
suspend: { label: '挂起', color: '#909399', icon: '⏸️' },
|
||
terminate: { label: '终止', color: '#f56c6c', icon: '🛑' },
|
||
};
|
||
|
||
// 工作流分类图标映射
|
||
export const categoryIcons = {
|
||
leave: '📅',
|
||
repair: '🔧',
|
||
purchase: '🛒',
|
||
reimbursement: '💰',
|
||
approval: '📋',
|
||
default: '📄',
|
||
};
|
||
|
||
// 获取状态样式
|
||
export const getStatusStyle = (status) => workflowStatus[status] || workflowStatus.draft;
|
||
|
||
// 获取分类图标
|
||
export const getCategoryIcon = (category) => categoryIcons[category] || categoryIcons.default;
|
||
|
||
// 工作流路由跳转方法
|
||
export const routerJump = (routerJumpVo) => {
|
||
const { businessId, taskId, type, formCustom, formPath } = routerJumpVo;
|
||
const params = { businessId, taskId, type, formCustom, formPath };
|
||
const queryString = Object.keys(params)
|
||
.filter((key) => params[key] !== undefined && params[key] !== null)
|
||
.map((key) => `${key}=${encodeURIComponent(params[key])}`)
|
||
.join('&');
|
||
uni.navigateTo({
|
||
url: `/pages/workflow/process?${queryString}`,
|
||
fail: () => {
|
||
uni.showToast({
|
||
title: '页面跳转失败',
|
||
icon: 'error',
|
||
});
|
||
},
|
||
});
|
||
};
|
||
|
||
// 格式化时间显示
|
||
export const formatTime = (timeStr) => {
|
||
if (!timeStr) return '';
|
||
const time = new Date(timeStr);
|
||
const now = new Date();
|
||
const diff = now.getTime() - time.getTime();
|
||
if (diff < 60 * 1000) {
|
||
return '刚刚';
|
||
}
|
||
if (diff < 60 * 60 * 1000) {
|
||
return `${Math.floor(diff / (60 * 1000))}分钟前`;
|
||
}
|
||
if (diff < 24 * 60 * 60 * 1000) {
|
||
return `${Math.floor(diff / (60 * 60 * 1000))}小时前`;
|
||
}
|
||
if (diff < 7 * 24 * 60 * 60 * 1000) {
|
||
return `${Math.floor(diff / (24 * 60 * 60 * 1000))}天前`;
|
||
}
|
||
return time.toLocaleDateString();
|
||
};
|