detail2.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="app-container">
  3. <el-button
  4. icon="el-icon-circle-close"
  5. type="danger"
  6. size="mini"
  7. @click="handleAudit(item, false)"
  8. >不通过</el-button
  9. >
  10. <el-button
  11. icon="el-icon-edit-outline"
  12. type="primary"
  13. size="mini"
  14. @click="handleUpdateAssignee(item)"
  15. >转办</el-button
  16. >
  17. <el-button
  18. icon="el-icon-edit-outline"
  19. type="primary"
  20. size="mini"
  21. @click="handleDelegate(item)"
  22. >委派</el-button
  23. >
  24. <el-button
  25. icon="el-icon-refresh-left"
  26. type="warning"
  27. size="mini"
  28. @click="handleBack(item)"
  29. >退回</el-button
  30. >
  31. <!-- 高亮流程图 -->
  32. <el-card class="box-card" v-loading="processInstanceLoading">
  33. <div slot="header" class="clearfix">
  34. <span class="el-icon-picture-outline">流程图</span>
  35. </div>
  36. <my-process-viewer
  37. key="designer"
  38. v-model="bpmnXML"
  39. v-bind="bpmnControlForm"
  40. :activityData="activityList"
  41. :processInstanceData="processInstance"
  42. :taskData="tasks"
  43. />
  44. </el-card>
  45. <!-- 对话框(转派审批人) -->
  46. <el-dialog title="转派审批人" :visible.sync="updateAssignee.open" width="500px" append-to-body>
  47. <el-form
  48. ref="updateAssigneeForm"
  49. :model="updateAssignee.form"
  50. :rules="updateAssignee.rules"
  51. label-width="110px"
  52. >
  53. <el-form-item label="新审批人" prop="assigneeUserId">
  54. <el-select v-model="updateAssignee.form.assigneeUserId" clearable style="width: 100%">
  55. <el-option
  56. v-for="item in userOptions"
  57. :key="parseInt(item.id)"
  58. :label="item.nickname"
  59. :value="parseInt(item.id)"
  60. />
  61. </el-select>
  62. </el-form-item>
  63. </el-form>
  64. <div slot="footer" class="dialog-footer">
  65. <el-button type="primary" @click="submitUpdateAssigneeForm">确 定</el-button>
  66. <el-button @click="cancelUpdateAssigneeForm">取 消</el-button>
  67. </div>
  68. </el-dialog>
  69. </div>
  70. </template>
  71. <script>
  72. import { getProcessDefinitionBpmnXML } from "@/api/bpm/definition"
  73. import { DICT_TYPE, getDictOptions } from "@/utils/dict"
  74. import store from "@/store"
  75. import { decodeFields } from "@/utils/formGenerator"
  76. import Parser from '@/components/parser/Parser'
  77. import { getProcessInstanceApi } from "@/api/bpm/processInstance"
  78. import { approveTask, getTaskListByProcessInstanceId, rejectTask, updateTaskAssignee } from "@/api/bpm/task"
  79. import { getListSimpleUsersApi } from "@/api/system/user"
  80. import { getActivityList } from "@/api/bpm/activity"
  81. // 流程实例的详情页,可用于审批
  82. export default {
  83. name: "ProcessInstanceDetail",
  84. data () {
  85. return {
  86. // BPMN 数据
  87. bpmnXML: null,
  88. bpmnControlForm: {
  89. prefix: "flowable"
  90. },
  91. activityList: [],
  92. // 转派审批人
  93. userOptions: [],
  94. updateAssignee: {
  95. open: false,
  96. form: {
  97. assigneeUserId: undefined,
  98. },
  99. rules: {
  100. assigneeUserId: [{ required: true, message: "新审批人不能为空", trigger: "change" }],
  101. }
  102. },
  103. // 数据字典
  104. categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
  105. }
  106. },
  107. created () {
  108. this.id = this.$route.query.id
  109. if (!this.id) {
  110. this.$message.error('未传递 id 参数,无法查看流程信息')
  111. return
  112. }
  113. this.getDetail()
  114. // 获得用户列表
  115. this.userOptions = []
  116. getListSimpleUsersApi().then(response => {
  117. this.userOptions.push(...response.data)
  118. })
  119. },
  120. methods: {
  121. /** 获得流程实例 */
  122. getDetail () {
  123. // 获得流程实例相关
  124. this.processInstanceLoading = true
  125. getProcessInstanceApi(this.id).then(response => {
  126. // 加载流程图
  127. getProcessDefinitionBpmnXML(this.processInstance.processDefinition.id).then(response => {
  128. this.bpmnXML = response.data
  129. })
  130. // 加载活动列表
  131. getActivityList({
  132. processInstanceId: this.processInstance.id
  133. }).then(response => {
  134. this.activityList = response.data
  135. })
  136. })
  137. },
  138. /** 处理审批通过和不通过的操作 */
  139. handleAudit (task, pass) {
  140. const index = this.runningTasks.indexOf(task)
  141. this.$refs['form' + index][0].validate(valid => {
  142. if (!valid) {
  143. return
  144. }
  145. const data = {
  146. id: task.id,
  147. reason: this.auditForms[index].reason
  148. }
  149. if (pass) {
  150. approveTask(data).then(response => {
  151. this.$modal.msgSuccess("审批通过成功!")
  152. this.getDetail() // 获得最新详情
  153. })
  154. } else {
  155. rejectTask(data).then(response => {
  156. this.$modal.msgSuccess("审批不通过成功!")
  157. this.getDetail() // 获得最新详情
  158. })
  159. }
  160. })
  161. },
  162. /** 处理转派审批人 */
  163. handleUpdateAssignee (task) {
  164. // 设置表单
  165. this.resetUpdateAssigneeForm()
  166. this.updateAssignee.form.id = task.id
  167. // 设置为打开
  168. this.updateAssignee.open = true
  169. },
  170. /** 提交转派审批人 */
  171. submitUpdateAssigneeForm () {
  172. this.$refs['updateAssigneeForm'].validate(valid => {
  173. if (!valid) {
  174. return
  175. }
  176. updateTaskAssignee(this.updateAssignee.form).then(response => {
  177. this.$modal.msgSuccess("转派任务成功!")
  178. this.updateAssignee.open = false
  179. this.getDetail() // 获得最新详情
  180. })
  181. })
  182. },
  183. /** 取消转派审批人 */
  184. cancelUpdateAssigneeForm () {
  185. this.updateAssignee.open = false
  186. this.resetUpdateAssigneeForm()
  187. },
  188. /** 重置转派审批人 */
  189. resetUpdateAssigneeForm () {
  190. this.updateAssignee.form = {
  191. id: undefined,
  192. assigneeUserId: undefined,
  193. }
  194. this.resetForm("updateAssigneeForm")
  195. },
  196. /** 处理审批退回的操作 */
  197. handleDelegate (task) {
  198. this.$modal.msgError("暂不支持【委派】功能,可以使用【转派】替代!")
  199. },
  200. /** 处理审批退回的操作 */
  201. handleBack (task) {
  202. this.$modal.msgError("暂不支持【退回】功能!")
  203. // 可参考 http://blog.wya1.com/article/636697030/details/7296
  204. // const data = {
  205. // id: task.id,
  206. // assigneeUserId: 1
  207. // }
  208. // backTask(data).then(response => {
  209. // this.$modal.msgSuccess("回退成功!");
  210. // this.getDetail(); // 获得最新详情
  211. // });
  212. }
  213. }
  214. };
  215. </script>
  216. <style lang="scss">
  217. .my-process-designer {
  218. height: calc(100vh - 200px);
  219. }
  220. .box-card {
  221. width: 100%;
  222. margin-bottom: 20px;
  223. }
  224. </style>