index.vue 7.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  1. <template>
  2. <div class="app-container">
  3. <!-- 搜索工作栏 -->
  4. <el-form :model="queryParams" ref="queryForm" :inline="true" v-show="showSearch" label-width="68px">
  5. <el-form-item label="流程标识" prop="key">
  6. <el-input v-model="queryParams.key" placeholder="请输入流程标识" clearable style="width: 240px;" size="small"
  7. @keyup.enter.native="handleQuery"/>
  8. </el-form-item>
  9. <el-form-item label="流程名称" prop="name">
  10. <el-input v-model="queryParams.name" placeholder="请输入流程名称" clearable style="width: 240px;" size="small"
  11. @keyup.enter.native="handleQuery"/>
  12. </el-form-item>
  13. <el-form-item label="流程分类" prop="category">
  14. <el-select v-model="queryParams.category" placeholder="流程分类" clearable size="small" style="width: 240px">
  15. <el-option v-for="dict in categoryDictDatas" :key="parseInt(dict.value)" :label="dict.label" :value="parseInt(dict.value)"/>
  16. </el-select>
  17. </el-form-item>
  18. <el-form-item>
  19. <el-button type="cyan" icon="el-icon-search" size="mini" @click="handleQuery">搜索</el-button>
  20. <el-button icon="el-icon-refresh" size="mini" @click="resetQuery">重置</el-button>
  21. </el-form-item>
  22. </el-form>
  23. <!-- 操作工具栏 -->
  24. <el-row :gutter="10" class="mb8">
  25. <el-col :span="1.5">
  26. <el-button type="primary" icon="el-icon-plus" size="mini" @click="handleAdd"
  27. v-hasPermi="['infra:config:create']">新建流程</el-button>
  28. </el-col>
  29. <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
  30. </el-row>
  31. <!-- 列表 -->
  32. <el-table v-loading="loading" :data="list">
  33. <el-table-column label="流程标识" align="center" prop="key" />
  34. <el-table-column label="流程名称" align="center" prop="name">
  35. <template slot-scope="scope">
  36. <el-button type="text" @click="handleBpmnDetail(scope.row)">
  37. <span>{{ scope.row.name }}</span>
  38. </el-button>
  39. </template>
  40. </el-table-column>
  41. <el-table-column label="流程分类" align="center" prop="category">
  42. <template slot-scope="scope">
  43. <span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
  44. </template>
  45. </el-table-column>
  46. <el-table-column label="表单信息" align="center" prop="formId">
  47. <template slot-scope="scope">
  48. <el-button v-if="scope.row.formId" type="text" @click="handleFormDetail(scope.row)">
  49. <span>{{ scope.row.formName }}</span>
  50. </el-button>
  51. <label v-else>暂无表单</label>
  52. </template>
  53. </el-table-column>
  54. <el-table-column label="流程版本" align="center" prop="processDefinition.version" />
  55. <el-table-column label="创建时间" align="center" prop="createTime" width="180">
  56. <template slot-scope="scope">
  57. <span>{{ parseTime(scope.row.createTime) }}</span>
  58. </template>
  59. </el-table-column>
  60. <el-table-column label="操作" align="center" width="240">
  61. <template slot-scope="scope">
  62. <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button>
  63. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
  64. <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布</el-button>
  65. <!-- TODO 芋艿:流程定义 -->
  66. </template>
  67. </el-table-column>
  68. </el-table>
  69. <!-- 分页组件 -->
  70. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  71. @pagination="getList"/>
  72. <!-- 流程表单配置详情 -->
  73. <el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body>
  74. <parser :key="new Date().getTime()" :form-conf="detailForm" />
  75. </el-dialog>
  76. <!-- 流程模型图的预览 -->
  77. <el-dialog title="流程图" :visible.sync="showBpmnOpen" width="80%" append-to-body>
  78. <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
  79. </el-dialog>
  80. </div>
  81. </template>
  82. <script>
  83. import {deleteModel, deployModel, getModelPage, getModel} from "@/api/bpm/model";
  84. import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  85. import {getForm} from "@/api/bpm/form";
  86. import {decodeFields} from "@/utils/formGenerator";
  87. import Parser from '@/components/parser/Parser'
  88. export default {
  89. name: "model",
  90. components: {
  91. Parser
  92. },
  93. data() {
  94. return {
  95. // 遮罩层
  96. loading: true,
  97. // 显示搜索条件
  98. showSearch: true,
  99. // 总条数
  100. total: 0,
  101. // 表格数据
  102. list: [],
  103. // 查询参数
  104. queryParams: {
  105. pageNo: 1,
  106. pageSize: 10
  107. },
  108. // BPMN 数据
  109. showBpmnOpen: false,
  110. bpmnXML: null,
  111. bpmnControlForm: {
  112. prefix: "activiti"
  113. },
  114. // 流程表单详情
  115. detailOpen: false,
  116. detailForm: {
  117. fields: []
  118. },
  119. // 数据字典
  120. categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
  121. };
  122. },
  123. created() {
  124. this.getList();
  125. },
  126. methods: {
  127. /** 查询流程模型列表 */
  128. getList() {
  129. this.loading = true;
  130. getModelPage(this.queryParams).then(response => {
  131. this.list = response.data.list;
  132. this.total = response.data.total;
  133. this.loading = false;
  134. }
  135. );
  136. },
  137. // 表单重置
  138. reset() {
  139. this.bpmnData = {}
  140. this.bpmnXML = ""
  141. },
  142. /** 搜索按钮操作 */
  143. handleQuery() {
  144. this.queryParams.pageNo = 1;
  145. this.getList();
  146. },
  147. /** 重置按钮操作 */
  148. resetQuery() {
  149. this.dateRange = [];
  150. this.resetForm("queryForm");
  151. this.handleQuery();
  152. },
  153. /** 新增按钮操作 */
  154. handleAdd() {
  155. this.$router.push({
  156. path:"/bpm/manager/model/edit"
  157. });
  158. },
  159. /** 修改按钮操作 */
  160. handleUpdate(row) {
  161. this.$router.push({
  162. path:"/bpm/manager/model/edit",
  163. query:{
  164. modelId: row.id
  165. }
  166. });
  167. },
  168. /** 删除按钮操作 */
  169. handleDelete(row) {
  170. const that = this;
  171. this.$confirm('是否删除该流程!!', "警告", {
  172. confirmButtonText: "确定",
  173. cancelButtonText: "取消",
  174. type: "warning"
  175. }).then(function() {
  176. deleteModel(row.id).then(response => {
  177. that.getList();
  178. that.msgSuccess("删除成功");
  179. })
  180. })
  181. },
  182. /** 部署按钮操作 */
  183. handleDeploy(row) {
  184. const that = this;
  185. this.$confirm('是否部署该流程!!', "提示", {
  186. confirmButtonText: "确定",
  187. cancelButtonText: "取消",
  188. type: "success"
  189. }).then(function() {
  190. deployModel(row.id).then(response => {
  191. that.getList();
  192. that.msgSuccess("部署成功");
  193. })
  194. })
  195. },
  196. /** 流程表单的详情按钮操作 */
  197. handleFormDetail(row) {
  198. getForm(row.formId).then(response => {
  199. // 设置值
  200. const data = response.data
  201. this.detailForm = {
  202. ...JSON.parse(data.conf),
  203. fields: decodeFields(data.fields)
  204. }
  205. // 弹窗打开
  206. this.detailOpen = true
  207. })
  208. },
  209. /** 流程图的详情按钮操作 */
  210. handleBpmnDetail(row) {
  211. getModel(row.id).then(response => {
  212. this.bpmnXML = response.data.bpmnXml
  213. // 弹窗打开
  214. this.showBpmnOpen = true
  215. })
  216. },
  217. }
  218. };
  219. </script>
  220. <style lang="scss">
  221. .my-process-designer {
  222. height: calc(100vh - 200px);
  223. }
  224. </style>