index.vue 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  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" width="200">
  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" width="100">
  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="createTime" width="180">
  55. <template slot-scope="scope">
  56. <span>{{ parseTime(scope.row.createTime) }}</span>
  57. </template>
  58. </el-table-column>
  59. <el-table-column label="最新部署的流程定义" align="center">
  60. <el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
  61. <template slot-scope="scope">
  62. <el-tag size="medium" v-if="scope.row.processDefinition">v{{ scope.row.processDefinition.version }}</el-tag>
  63. <el-tag size="medium" type="warning" v-else>未部署</el-tag>
  64. </template>
  65. </el-table-column>
  66. <el-table-column label="激活状态" align="center" prop="processDefinition.version" width="80">
  67. <template slot-scope="scope">
  68. <el-switch v-if="scope.row.processDefinition" v-model="scope.row.processDefinition.suspensionState"
  69. :active-value="1" :inactive-value="2" @change="handleChangeState(scope.row)" />
  70. </template>
  71. </el-table-column>
  72. <el-table-column label="部署时间" align="center" prop="deploymentTime" width="180">
  73. <template slot-scope="scope">
  74. <span v-if="scope.row.processDefinition">{{ parseTime(scope.row.processDefinition.deploymentTime) }}</span>
  75. </template>
  76. </el-table-column>
  77. </el-table-column>
  78. <el-table-column label="操作" align="center" width="300">
  79. <template slot-scope="scope">
  80. <el-button size="mini" type="text" icon="el-icon-setting" @click="handleUpdate(scope.row)">设计流程</el-button>
  81. <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(scope.row)">发布流程</el-button>
  82. <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(scope.row)">流程定义</el-button>
  83. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)">删除</el-button>
  84. </template>
  85. </el-table-column>
  86. </el-table>
  87. <!-- 分页组件 -->
  88. <pagination v-show="total>0" :total="total" :page.sync="queryParams.pageNo" :limit.sync="queryParams.pageSize"
  89. @pagination="getList"/>
  90. <!-- 流程表单配置详情 -->
  91. <el-dialog title="表单详情" :visible.sync="detailOpen" width="50%" append-to-body>
  92. <parser :key="new Date().getTime()" :form-conf="detailForm" />
  93. </el-dialog>
  94. <!-- 流程模型图的预览 -->
  95. <el-dialog title="流程图" :visible.sync="showBpmnOpen" width="80%" append-to-body>
  96. <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
  97. </el-dialog>
  98. </div>
  99. </template>
  100. <script>
  101. import {deleteModel, deployModel, getModelPage, getModel, updateModelState} from "@/api/bpm/model";
  102. import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  103. import {getForm} from "@/api/bpm/form";
  104. import {decodeFields} from "@/utils/formGenerator";
  105. import Parser from '@/components/parser/Parser'
  106. export default {
  107. name: "model",
  108. components: {
  109. Parser
  110. },
  111. data() {
  112. return {
  113. // 遮罩层
  114. loading: true,
  115. // 显示搜索条件
  116. showSearch: true,
  117. // 总条数
  118. total: 0,
  119. // 表格数据
  120. list: [],
  121. // 查询参数
  122. queryParams: {
  123. pageNo: 1,
  124. pageSize: 10
  125. },
  126. // BPMN 数据
  127. showBpmnOpen: false,
  128. bpmnXML: null,
  129. bpmnControlForm: {
  130. prefix: "activiti"
  131. },
  132. // 流程表单详情
  133. detailOpen: false,
  134. detailForm: {
  135. fields: []
  136. },
  137. // 数据字典
  138. categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
  139. };
  140. },
  141. created() {
  142. this.getList();
  143. },
  144. methods: {
  145. /** 查询流程模型列表 */
  146. getList() {
  147. this.loading = true;
  148. getModelPage(this.queryParams).then(response => {
  149. this.list = response.data.list;
  150. this.total = response.data.total;
  151. this.loading = false;
  152. }
  153. );
  154. },
  155. // 表单重置
  156. reset() {
  157. this.bpmnData = {}
  158. this.bpmnXML = ""
  159. },
  160. /** 搜索按钮操作 */
  161. handleQuery() {
  162. this.queryParams.pageNo = 1;
  163. this.getList();
  164. },
  165. /** 重置按钮操作 */
  166. resetQuery() {
  167. this.dateRange = [];
  168. this.resetForm("queryForm");
  169. this.handleQuery();
  170. },
  171. /** 新增按钮操作 */
  172. handleAdd() {
  173. this.$router.push({
  174. path:"/bpm/manager/model/edit"
  175. });
  176. },
  177. /** 修改按钮操作 */
  178. handleUpdate(row) {
  179. this.$router.push({
  180. path:"/bpm/manager/model/edit",
  181. query:{
  182. modelId: row.id
  183. }
  184. });
  185. },
  186. /** 删除按钮操作 */
  187. handleDelete(row) {
  188. const that = this;
  189. this.$confirm('是否删除该流程!!', "警告", {
  190. confirmButtonText: "确定",
  191. cancelButtonText: "取消",
  192. type: "warning"
  193. }).then(function() {
  194. deleteModel(row.id).then(response => {
  195. that.getList();
  196. that.msgSuccess("删除成功");
  197. })
  198. })
  199. },
  200. /** 部署按钮操作 */
  201. handleDeploy(row) {
  202. const that = this;
  203. this.$confirm('是否部署该流程!!', "提示", {
  204. confirmButtonText: "确定",
  205. cancelButtonText: "取消",
  206. type: "success"
  207. }).then(function() {
  208. deployModel(row.id).then(response => {
  209. that.getList();
  210. that.msgSuccess("部署成功");
  211. })
  212. })
  213. },
  214. /** 流程表单的详情按钮操作 */
  215. handleFormDetail(row) {
  216. getForm(row.formId).then(response => {
  217. // 设置值
  218. const data = response.data
  219. this.detailForm = {
  220. ...JSON.parse(data.conf),
  221. fields: decodeFields(data.fields)
  222. }
  223. // 弹窗打开
  224. this.detailOpen = true
  225. })
  226. },
  227. /** 流程图的详情按钮操作 */
  228. handleBpmnDetail(row) {
  229. getModel(row.id).then(response => {
  230. this.bpmnXML = response.data.bpmnXml
  231. // 弹窗打开
  232. this.showBpmnOpen = true
  233. })
  234. },
  235. /** 跳转流程定义的列表 */
  236. handleDefinitionList(row) {
  237. this.$router.push({
  238. path:"/bpm/manager/definition",
  239. query:{
  240. key: row.key
  241. }
  242. });
  243. },
  244. /** 更新状态操作 */
  245. handleChangeState(row) {
  246. const id = row.id;
  247. let state = row.processDefinition.suspensionState;
  248. let statusState = state === 1 ? '激活' : '挂起';
  249. this.$confirm('是否确认' + statusState + '流程名字为"' + row.name + '"的数据项?', "警告", {
  250. confirmButtonText: "确定",
  251. cancelButtonText: "取消",
  252. type: "warning"
  253. }).then(function() {
  254. return updateModelState(id, state);
  255. }).then(() => {
  256. this.getList();
  257. this.msgSuccess(statusState + "成功");
  258. })
  259. },
  260. }
  261. };
  262. </script>
  263. <style lang="scss">
  264. .my-process-designer {
  265. height: calc(100vh - 200px);
  266. }
  267. </style>