workflow.ts 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  1. import request from '@/utils/http'
  2. // ---------------------------------------------------------------------------
  3. // 流程定义
  4. // ---------------------------------------------------------------------------
  5. export function fetchProcessDefList(params?: {
  6. page?: number
  7. pageSize?: number
  8. keyword?: string
  9. status?: string
  10. }) {
  11. return request.get<{
  12. list: Api.Workflow.ProcessDefItem[]
  13. total: number
  14. page: number
  15. pageSize: number
  16. totalPages: number
  17. }>({
  18. url: '/web/admin/workflow/defs',
  19. params
  20. })
  21. }
  22. export function fetchExportProcessDefs(data: Record<string, any>) {
  23. return request.post({
  24. url: '/web/admin/workflow/defs/export',
  25. data,
  26. responseType: 'blob'
  27. })
  28. }
  29. export function fetchCreateProcessDef(data: {
  30. processCode: string
  31. processName: string
  32. status?: string
  33. orderNum?: number
  34. remark?: string
  35. }) {
  36. return request.post<Api.Workflow.ProcessDefItem>({
  37. url: '/web/admin/workflow/defs',
  38. data,
  39. showSuccessMessage: true
  40. })
  41. }
  42. export function fetchUpdateProcessDef(
  43. id: string,
  44. data: Partial<{
  45. processCode: string
  46. processName: string
  47. status: string
  48. orderNum: number
  49. remark: string
  50. }>
  51. ) {
  52. return request.put<Api.Workflow.ProcessDefItem>({
  53. url: `/web/admin/workflow/defs/${id}`,
  54. data,
  55. showSuccessMessage: true
  56. })
  57. }
  58. export function fetchDeleteProcessDef(id: string) {
  59. return request.del({
  60. url: `/web/admin/workflow/defs/${id}`,
  61. showSuccessMessage: true
  62. })
  63. }
  64. // ---------------------------------------------------------------------------
  65. // 发布版本
  66. // ---------------------------------------------------------------------------
  67. export function fetchPublishVersion(
  68. defId: string,
  69. data: {
  70. graphJson: string
  71. nodes: Array<{
  72. nodeKey: string
  73. nodeType: string
  74. nodeName?: string | null
  75. configJson?: string | null
  76. }>
  77. transitions: Array<{
  78. fromNodeKey: string
  79. toNodeKey: string
  80. conditionExpr?: string | null
  81. }>
  82. remark?: string
  83. }
  84. ) {
  85. return request.post({
  86. url: `/web/admin/workflow/defs/${defId}/publish`,
  87. data
  88. })
  89. }
  90. export function fetchVersionList(defId: string) {
  91. return request.get<Api.Workflow.VersionItem[]>({
  92. url: `/web/admin/workflow/defs/${defId}/versions`
  93. })
  94. }
  95. // ---------------------------------------------------------------------------
  96. // 设计器数据
  97. // ---------------------------------------------------------------------------
  98. export function fetchDesignerData(defId: string) {
  99. return request.get<Api.Workflow.DesignerData>({
  100. url: `/web/admin/workflow/defs/${defId}/designer`
  101. })
  102. }
  103. // ---------------------------------------------------------------------------
  104. // 流程实例
  105. // ---------------------------------------------------------------------------
  106. export function fetchStartInstance(data: {
  107. processCode: string
  108. businessType?: string
  109. businessId?: string
  110. variables?: Record<string, any>
  111. callbackUrl?: string
  112. }) {
  113. return request.post<{ instanceId: string }>({
  114. url: '/web/admin/workflow/instances',
  115. data
  116. })
  117. }
  118. export function fetchInstanceDetail(instanceId: string) {
  119. return request.get<Api.Workflow.InstanceDetail>({
  120. url: `/web/admin/workflow/instances/${instanceId}`
  121. })
  122. }
  123. // ---------------------------------------------------------------------------
  124. // 任务办理
  125. // ---------------------------------------------------------------------------
  126. export function fetchPendingTasks(params?: { page?: number; pageSize?: number; keyword?: string }) {
  127. return request.get<{
  128. list: Api.Workflow.TaskItem[]
  129. total: number
  130. page: number
  131. pageSize: number
  132. totalPages: number
  133. }>({
  134. url: '/web/admin/workflow/tasks/pending',
  135. params
  136. })
  137. }
  138. export function fetchExportPendingTasks(data: Record<string, any>) {
  139. return request.post({
  140. url: '/web/admin/workflow/tasks/pending/export',
  141. data,
  142. responseType: 'blob'
  143. })
  144. }
  145. export function fetchCompletedTasks(params?: {
  146. page?: number
  147. pageSize?: number
  148. keyword?: string
  149. }) {
  150. return request.get<{
  151. list: Api.Workflow.TaskItem[]
  152. total: number
  153. page: number
  154. pageSize: number
  155. totalPages: number
  156. }>({
  157. url: '/web/admin/workflow/tasks/completed',
  158. params
  159. })
  160. }
  161. export function fetchExportCompletedTasks(data: Record<string, any>) {
  162. return request.post({
  163. url: '/web/admin/workflow/tasks/completed/export',
  164. data,
  165. responseType: 'blob'
  166. })
  167. }
  168. export function fetchApproveTask(taskId: string, data?: { commentText?: string }) {
  169. return request.post({
  170. url: `/web/admin/workflow/tasks/${taskId}/approve`,
  171. data,
  172. showSuccessMessage: true
  173. })
  174. }
  175. export function fetchRejectTask(taskId: string, data?: { commentText?: string }) {
  176. return request.post({
  177. url: `/web/admin/workflow/tasks/${taskId}/reject`,
  178. data,
  179. showSuccessMessage: true
  180. })
  181. }
  182. export function fetchMyInstances(params?: {
  183. page?: number
  184. pageSize?: number
  185. keyword?: string
  186. status?: string
  187. }) {
  188. return request.get<{
  189. list: Api.Workflow.MyInstanceItem[]
  190. total: number
  191. page: number
  192. pageSize: number
  193. totalPages: number
  194. }>({
  195. url: '/web/admin/workflow/instances/my',
  196. params
  197. })
  198. }
  199. export function fetchExportMyInstances(data: Record<string, any>) {
  200. return request.post({
  201. url: '/web/admin/workflow/instances/my/export',
  202. data,
  203. responseType: 'blob'
  204. })
  205. }
  206. export function fetchBusinessAllTasks(businessType: string, businessId: string) {
  207. return request.get<Api.Workflow.BusinessAllTasks>({
  208. url: `/web/admin/workflow/instances/by-business/${businessType}/${businessId}`
  209. })
  210. }