workflow-api.js 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  1. import { request } from './request.js';
  2. // 工作流API配置
  3. export const workflowApi = {
  4. // 获取流程实例分页列表(我发起的)
  5. pageByCurrent: (params) =>
  6. request({
  7. url: '/workflow/instance/pageByCurrent',
  8. method: 'GET',
  9. data: params,
  10. }),
  11. // 删除流程实例
  12. deleteByInstanceIds: (instanceIds) =>
  13. request({
  14. url: `/workflow/instance/deleteByInstanceIds/${instanceIds}`,
  15. method: 'DELETE',
  16. // data: instanceIds,
  17. }),
  18. // 撤销流程申请
  19. cancelProcessApply: (data) =>
  20. request({
  21. url: '/workflow/instance/cancelProcessApply',
  22. method: 'PUT',
  23. data,
  24. }),
  25. // 获取流程分类树
  26. categoryTree: () =>
  27. request({
  28. url: '/workflow/category/categoryTree',
  29. method: 'GET',
  30. }),
  31. // 获取我的待办任务
  32. todoTasks: (params) =>
  33. request({
  34. url: '/workflow/task/todoTasks',
  35. method: 'GET',
  36. data: params,
  37. }),
  38. // 获取我的已办任务
  39. finishedTasks: (params) =>
  40. request({
  41. url: '/workflow/task/finishedTasks',
  42. method: 'GET',
  43. data: params,
  44. }),
  45. // 获取我的抄送任务
  46. copyTasks: (params) =>
  47. request({
  48. url: '/workflow/task/copyTasks',
  49. method: 'GET',
  50. data: params,
  51. }),
  52. // 获取全部待办任务(对应web端allTaskWaiting.vue)
  53. pageByAllTaskWait: (params) =>
  54. request({
  55. url: '/workflow/task/pageByAllTaskWait',
  56. method: 'GET',
  57. data: params,
  58. }),
  59. // 获取全部已办任务(对应web端allTaskWaiting.vue)
  60. pageByAllTaskFinish: (params) =>
  61. request({
  62. url: '/workflow/task/pageByAllTaskFinish',
  63. method: 'GET',
  64. data: params,
  65. }),
  66. // 获取我的已办任务(对应web端taskFinish.vue)
  67. pageByTaskFinish: (params) =>
  68. request({
  69. url: '/workflow/task/pageByTaskFinish',
  70. method: 'GET',
  71. data: params,
  72. }),
  73. // 获取我的抄送任务(对应web端taskCopyList.vue)
  74. pageByTaskCopy: (params) =>
  75. request({
  76. url: '/workflow/task/pageByTaskCopy',
  77. method: 'GET',
  78. data: params,
  79. }),
  80. // 修改办理人
  81. updateAssignee: (taskIds, assigneeId) =>
  82. request({
  83. url: '/workflow/task/updateAssignee',
  84. method: 'POST',
  85. data: { taskIds, assigneeId },
  86. }),
  87. // 启动流程实例
  88. startProcessInstance: (data) =>
  89. request({
  90. url: '/workflow/instance/start',
  91. method: 'POST',
  92. data,
  93. }),
  94. // 办理任务
  95. complete: (data) =>
  96. request({
  97. url: '/workflow/task/complete',
  98. method: 'POST',
  99. data,
  100. }),
  101. // 获取流程历史
  102. processHistory: (instanceId) =>
  103. request({
  104. url: `/workflow/instance/history/${instanceId}`,
  105. method: 'GET',
  106. }),
  107. // 获取流程实例详情(根据业务ID)
  108. processDetail: (businessId) =>
  109. request({
  110. url: `/workflow/instance/getInfo/${businessId}`,
  111. method: 'GET',
  112. }),
  113. };
  114. // 工作流状态映射
  115. export const workflowStatus = {
  116. draft: { label: '草稿', color: '#909399', icon: '📝' },
  117. waiting: { label: '待审批', color: '#e6a23c', icon: '⏰' },
  118. complete: { label: '已完成', color: '#67c23a', icon: '✅' },
  119. cancel: { label: '已取消', color: '#f56c6c', icon: '❌' },
  120. back: { label: '已退回', color: '#409eff', icon: '↩️' },
  121. suspend: { label: '挂起', color: '#909399', icon: '⏸️' },
  122. terminate: { label: '终止', color: '#f56c6c', icon: '🛑' },
  123. };
  124. // 工作流分类图标映射
  125. export const categoryIcons = {
  126. leave: '📅',
  127. repair: '🔧',
  128. purchase: '🛒',
  129. reimbursement: '💰',
  130. approval: '📋',
  131. default: '📄',
  132. };
  133. // 获取状态样式
  134. export const getStatusStyle = (status) => workflowStatus[status] || workflowStatus.draft;
  135. // 获取分类图标
  136. export const getCategoryIcon = (category) => categoryIcons[category] || categoryIcons.default;
  137. // 工作流路由跳转方法
  138. export const routerJump = (routerJumpVo) => {
  139. const { businessId, taskId, type, formCustom, formPath } = routerJumpVo;
  140. const params = { businessId, taskId, type, formCustom, formPath };
  141. const queryString = Object.keys(params)
  142. .filter((key) => params[key] !== undefined && params[key] !== null)
  143. .map((key) => `${key}=${encodeURIComponent(params[key])}`)
  144. .join('&');
  145. uni.navigateTo({
  146. url: `/pages/workflow/process?${queryString}`,
  147. fail: () => {
  148. uni.showToast({
  149. title: '页面跳转失败',
  150. icon: 'error',
  151. });
  152. },
  153. });
  154. };
  155. // 格式化时间显示
  156. export const formatTime = (timeStr) => {
  157. if (!timeStr) return '';
  158. const time = new Date(timeStr);
  159. const now = new Date();
  160. const diff = now.getTime() - time.getTime();
  161. if (diff < 60 * 1000) {
  162. return '刚刚';
  163. }
  164. if (diff < 60 * 60 * 1000) {
  165. return `${Math.floor(diff / (60 * 1000))}分钟前`;
  166. }
  167. if (diff < 24 * 60 * 60 * 1000) {
  168. return `${Math.floor(diff / (60 * 60 * 1000))}小时前`;
  169. }
  170. if (diff < 7 * 24 * 60 * 60 * 1000) {
  171. return `${Math.floor(diff / (24 * 60 * 60 * 1000))}天前`;
  172. }
  173. return time.toLocaleDateString();
  174. };