workflow.ts 4.8 KB

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