process-module.js 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. import { addDynamicRoute } from '@/router'
  2. export default {
  3. data () {
  4. return {
  5. processVisible: false
  6. }
  7. },
  8. methods: {
  9. // 初始化流程配置(集成发起流程和任务处理功能)
  10. initProcessMultiple (callbacks) {
  11. // showType 用于区分流程启动(start)、任务处理(taskHandle)以及查看详情(null)
  12. // 流程启动显示的是“流程启动”按钮,任务处理显示的是“通过、委托、回退、驳回、终止”按钮,查看详情都不显示
  13. var showType = this.$route.params.processShowType
  14. this.processVisible = true
  15. this.$nextTick(() => {
  16. if (this.$route.params.processDefinitionKey) {
  17. this.$refs.renProcessMultiple.dataForm.processDefinitionKey = this.$route.params.processDefinitionKey
  18. }
  19. if (this.$route.params.taskId) {
  20. this.$refs.renProcessMultiple.dataForm.taskId = this.$route.params.taskId
  21. }
  22. if (this.$route.params.processInstanceId) {
  23. this.$refs.renProcessMultiple.dataForm.processInstanceId = this.$route.params.processInstanceId
  24. }
  25. this.$refs.renProcessMultiple.dataForm.businessKey = this.$route.params.businessKey
  26. this.$refs.renProcessMultiple.showType = showType
  27. this.$refs.renProcessMultiple.parentObj = this
  28. this.$refs.renProcessMultiple.callbacks = callbacks
  29. })
  30. },
  31. // 关闭当前窗口
  32. closeCurrentTab (data) {
  33. var tabName = this.$store.state.contentTabsActiveName
  34. this.$store.state.contentTabs = this.$store.state.contentTabs.filter(item => item.name !== tabName)
  35. if (this.$store.state.contentTabs.length <= 0) {
  36. this.$store.state.sidebarMenuActiveName = this.$store.state.contentTabsActiveName = 'home'
  37. return false
  38. }
  39. if (tabName === this.$store.state.contentTabsActiveName) {
  40. this.$router.push({ name: this.$store.state.contentTabs[this.$store.state.contentTabs.length - 1].name })
  41. }
  42. },
  43. // 获取流程定义的表单路由配置信息
  44. getProcDefRouteSet (data, callback) {
  45. this.$http.get(`/act/process/getProcDefBizRoute/${data.processDefinitionId}`).then(({ data: res }) => {
  46. if (res.code !== 0) {
  47. return this.$message.error(res.msg)
  48. }
  49. if (!res.data || !res.data.bizRoute) {
  50. return this.$message.error(this.$t('process.routeError'))
  51. }
  52. var param = {
  53. ...data,
  54. ...res.data
  55. }
  56. callback(param)
  57. }).catch(() => {})
  58. },
  59. getProcDefBizRouteAndProcessInstance (params, callback) {
  60. this.$http.get(`/act/process/getProcDefBizRouteAndProcessInstance`, {
  61. params: params
  62. }).then(({ data: res }) => {
  63. if (res.code !== 0) {
  64. return this.$message.error(res.msg)
  65. }
  66. if (!res.data || !res.data.bizRoute) {
  67. return this.$message.error(this.$t('process.routeError'))
  68. }
  69. var param = {
  70. ...params,
  71. ...res.data
  72. }
  73. callback(param)
  74. }).catch(() => {})
  75. },
  76. // 根据流程定义KEY获取最新的表单路由配置信息
  77. getLatestProcDefRouteSet (procDefKey, callback) {
  78. this.$http.get(`/act/process/getLatestProcDefBizRoute`, {
  79. params: {
  80. procDefKey: procDefKey
  81. }
  82. }).then(({ data: res }) => {
  83. if (res.code !== 0) {
  84. return this.$message.error(res.msg)
  85. }
  86. if (!res.data || !res.data.bizRoute) {
  87. return this.$message.error(this.$t('process.routeError'))
  88. }
  89. var param = {
  90. procDefKey: procDefKey,
  91. ...res.data
  92. }
  93. callback(param)
  94. }).catch(() => {})
  95. },
  96. // 查看流程图
  97. forwardDetail (data) {
  98. var routeParams = {
  99. routeName: `${this.$route.name}__detail_${data.processInstanceId}`,
  100. menuId: `${this.$route.meta.menuId}`,
  101. title: `${this.$route.meta.title} - ${data.processDefinitionName}`,
  102. path: data.bizRoute,
  103. params: {
  104. processInstanceId: data.processInstanceId,
  105. businessKey: data.businessKey
  106. }
  107. }
  108. addDynamicRoute(routeParams, this.$router)
  109. },
  110. // 子级 查看流程图
  111. forwardTaskDetail (data) {
  112. var routeParams = {
  113. routeName: `${this.$route.name}__detail_${data.taskId}`,
  114. menuId: `${this.$route.meta.menuId}`,
  115. title: `${this.$route.meta.title} - ${data.taskName}`,
  116. path: data.bizRoute,
  117. params: {
  118. taskId: data.taskId,
  119. processInstanceId: data.processInstanceId,
  120. businessKey: data.businessKey
  121. }
  122. }
  123. addDynamicRoute(routeParams, this.$router)
  124. },
  125. forwardHandleUrl (data) {
  126. var routeParams = {
  127. routeName: `${this.$route.name}__handle_${data.taskId}`,
  128. menuId: `${this.$route.meta.menuId}`,
  129. title: `${this.$route.meta.title} - ${data.taskName}`,
  130. path: data.bizRoute,
  131. params: {
  132. taskId: data.taskId,
  133. processInstanceId: data.processInstanceId,
  134. processShowType: 'taskHandle',
  135. businessKey: data.businessKey
  136. }
  137. }
  138. addDynamicRoute(routeParams, this.$router)
  139. }
  140. }
  141. }