detail.vue 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. <template>
  2. <div class="app-container">
  3. <!-- 第一步,通过流程定义的列表,选择对应的流程 -->
  4. <div v-if="!selectProcessInstance">
  5. <el-table v-loading="loading" :data="list">
  6. <el-table-column label="流程名称" align="center" prop="name" width="200">
  7. <template slot-scope="scope">
  8. <el-button type="text" @click="handleBpmnDetail(scope.row)">
  9. <span>{{ scope.row.name }}</span>
  10. </el-button>
  11. </template>
  12. </el-table-column>
  13. <el-table-column label="流程分类" align="center" prop="category" width="100">
  14. <template slot-scope="scope">
  15. <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  16. </template>
  17. </el-table-column>
  18. <el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
  19. <template slot-scope="scope">
  20. <el-tag size="medium" v-if="scope.row">v{{ scope.row.version }}</el-tag>
  21. </template>
  22. </el-table-column>
  23. <el-table-column label="流程描述" align="center" prop="description" width="300" show-overflow-tooltip />
  24. <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
  25. <template slot-scope="scope">
  26. <el-button type="text" size="small" icon="el-icon-plus" @click="handleSelect(scope.row)">选择</el-button>
  27. </template>
  28. </el-table-column>
  29. </el-table>
  30. </div>
  31. <!-- 第二步,填写表单,进行流程的提交 -->
  32. <div v-else>
  33. <el-card class="box-card" >
  34. <div slot="header" class="clearfix">
  35. <span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
  36. <el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button>
  37. </div>
  38. <el-col :span="16" :offset="6">
  39. <div>
  40. <parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" />
  41. </div>
  42. </el-col>
  43. </el-card>
  44. <el-card class="box-card">
  45. <div slot="header" class="clearfix">
  46. <span class="el-icon-picture-outline">流程图</span>
  47. </div>
  48. <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
  49. </el-card>
  50. </div>
  51. </div>
  52. </template>
  53. <script>
  54. import {getProcessDefinitionBpmnXML, getProcessDefinitionList} from "@/api/bpm/definition";
  55. import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  56. import {getForm} from "@/api/bpm/form";
  57. import {decodeFields} from "@/utils/formGenerator";
  58. import Parser from '@/components/parser/Parser'
  59. import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance";
  60. // 流程实例的详情页,可用于审批
  61. export default {
  62. name: "ProcessInstanceDetail",
  63. components: {
  64. Parser
  65. },
  66. data() {
  67. return {
  68. // 遮罩层
  69. loading: true,
  70. // 总条数
  71. total: 0,
  72. // 表格数据
  73. list: [],
  74. // 流程表单详情
  75. detailForm: {
  76. fields: []
  77. },
  78. // BPMN 数据
  79. bpmnXML: null,
  80. bpmnControlForm: {
  81. prefix: "activiti"
  82. },
  83. // 流程表单
  84. selectProcessInstance: undefined, // 选择的流程实例
  85. // 数据字典
  86. categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
  87. };
  88. },
  89. created() {
  90. this.getList();
  91. },
  92. methods: {
  93. /** 查询流程定义列表 */
  94. getList() {
  95. this.loading = true;
  96. getProcessDefinitionList({
  97. suspensionState: 1
  98. }).then(response => {
  99. this.list = response.data
  100. this.loading = false
  101. }
  102. );
  103. },
  104. /** 处理选择流程的按钮操作 **/
  105. handleSelect(row) {
  106. // 设置选择的流程
  107. this.selectProcessInstance = row;
  108. // 流程表单
  109. if (row.formId) {
  110. // 设置对应的表单
  111. this.detailForm = {
  112. ...JSON.parse(row.formConf),
  113. fields: decodeFields(row.formFields)
  114. }
  115. // 加载流程图
  116. getProcessDefinitionBpmnXML(row.id).then(response => {
  117. this.bpmnXML = response.data
  118. })
  119. } else if (row.formCustomCreatePath) {
  120. this.$router.push({ path: row.formCustomCreatePath});
  121. // 这里暂时无需加载流程图,因为跳出到另外个 Tab;
  122. }
  123. },
  124. /** 提交按钮 */
  125. submitForm(params) {
  126. if (!params) {
  127. return;
  128. }
  129. // 设置表单禁用
  130. const conf = params.conf;
  131. conf.disabled = true; // 表单禁用
  132. conf.formBtns = false; // 按钮隐藏
  133. // 提交表单,创建流程
  134. const variables = params.values;
  135. createProcessInstance({
  136. processDefinitionId: this.selectProcessInstance.id,
  137. variables: variables
  138. }).then(response => {
  139. this.msgSuccess("发起流程成功");
  140. // 关闭当前窗口
  141. this.$store.dispatch("tagsView/delView", this.$route);
  142. this.$router.go(-1);
  143. }).catch(() => {
  144. conf.disabled = false; // 表单开启
  145. conf.formBtns = true; // 按钮展示
  146. })
  147. },
  148. }
  149. };
  150. </script>
  151. <style lang="scss">
  152. .my-process-designer {
  153. height: calc(100vh - 200px);
  154. }
  155. .box-card {
  156. width: 100%;
  157. margin-bottom: 20px;
  158. }
  159. </style>