index.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445
  1. <template>
  2. <div class="ele-body">
  3. <el-card shadow="never">
  4. <div class="filter-container">
  5. <modelSearch @search="reload" :processTypeList="processTypeList"></modelSearch>
  6. </div>
  7. <ele-pro-table
  8. ref="table"
  9. :columns="columns"
  10. :datasource="datasource"
  11. cache-key="systemRoleTable5"
  12. >
  13. <!-- 表头工具栏 -->
  14. <template v-slot:toolbar>
  15. <el-button
  16. icon="el-icon-plus"
  17. type="primary"
  18. @click="handleAdd"
  19. class="ele-btn-icon"
  20. >新建流程
  21. </el-button>
  22. </template>
  23. <template v-slot:suspensionState="{ row }">
  24. <el-switch v-if="row.processDefinition" v-model="row.processDefinition.suspensionState"
  25. :active-value="1" :inactive-value="2" @change="handleChangeState(row)"/>
  26. </template>
  27. <template v-slot:version="{ row }">
  28. <el-tag size="medium" v-if="row.processDefinition" v-model="row.processDefinition.version">
  29. v{{ row.processDefinition.version }}
  30. </el-tag>
  31. </template>
  32. <!-- 操作列 -->
  33. <template v-slot:action="{ row }">
  34. <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(row)">修改流程</el-button>
  35. <el-button size="mini" type="text" icon="el-icon-setting" @click="handleDesign(row)">设计流程</el-button>
  36. <el-button size="mini" type="text" icon="el-icon-s-custom" @click="handleAssignRule(row)">分配规则</el-button>
  37. <el-button size="mini" type="text" icon="el-icon-thumb" @click="handleDeploy(row)">发布流程</el-button>
  38. <el-button size="mini" type="text" icon="el-icon-ice-cream-round" @click="handleDefinitionList(row)">
  39. 流程定义
  40. </el-button>
  41. <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(row)">删除</el-button>
  42. </template>
  43. </ele-pro-table>
  44. </el-card>
  45. <!-- 对话框(添加 / 修改) -->
  46. <el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
  47. <el-form ref="form" :model="form" :rules="rules" label-width="110px">
  48. <el-form-item label="流程分类" prop="processTypeId">
  49. <el-select v-model="form.processTypeId" clearable style="width: 100%" @change="handleProcessType">
  50. <el-option v-for="item in processTypeList" :value="item.id" :label="item.name" :key="item.id"></el-option>
  51. </el-select>
  52. </el-form-item>
  53. <el-form-item label="流程标识" prop="key">
  54. <el-input v-model="form.key" placeholder="请输入流标标识" style="width: 330px;" :disabled="!!form.id"/>
  55. <el-tooltip v-if="!form.id" class="item" effect="light" content="新建后,流程标识不可修改!" placement="top">
  56. <i style="padding-left: 5px;" class="el-icon-question"/>
  57. </el-tooltip>
  58. <el-tooltip v-else class="item" effect="light" content="流程标识不可修改!" placement="top">
  59. <i style="padding-left: 5px;" class="el-icon-question"/>
  60. </el-tooltip>
  61. </el-form-item>
  62. <el-form-item label="流程名称" prop="name">
  63. <el-input v-model="form.name" placeholder="请输入流程名称" :disabled="!!form.id" clearable/>
  64. </el-form-item>
  65. <el-form-item label="流程描述" prop="description">
  66. <el-input type="textarea" v-model="form.description" clearable/>
  67. </el-form-item>
  68. <div v-if="form.id">
  69. <el-form-item label="表单路由" prop="formCustomCreatePath">
  70. <el-input v-model="form.formCustomCreatePath" placeholder="请按格式输入表单路由" style="width: 330px;"
  71. type="textarea" rows="3"/>
  72. <div style="line-height: 16px; color: red;">
  73. 提示:<br/>
  74. 1、表单路由中包含PC端和手机端的页面路由,路由分为处理路由和查看路由。<br/>
  75. 2、若整个流程的表单路由为同一个,则在此填写。若流程中的每个节点都有自己的个性化的处理页面,则此处留空。在流程设计器中设置节点的路由。<br/>
  76. 3、必须按照以下格式填入:{"pcHandle":"/xx/xx", "pcView":"/xx/xx", "miniHandle":"/xx/xx","miniView":"/xx/xx"}
  77. </div>
  78. </el-form-item>
  79. </div>
  80. </el-form>
  81. <div slot="footer" class="dialog-footer">
  82. <el-button type="primary" @click="submitForm">确 定</el-button>
  83. <el-button @click="cancel">取 消</el-button>
  84. </div>
  85. </el-dialog>
  86. <!-- ========== 流程任务分配规则 ========== -->
  87. <taskAssignRuleDialog ref="taskAssignRuleDialog"/>
  88. </div>
  89. </template>
  90. <script>
  91. import {
  92. deleteModel,
  93. deployModel,
  94. getModelPage,
  95. getModel,
  96. updateModelState,
  97. createModel,
  98. updateModel
  99. } from "@/api/bpm/model";
  100. import Pagination from '@/components/Pagination';
  101. import dictMixins from '@/mixins/dictMixins';
  102. import modelSearch from './components/modelSearch.vue';
  103. import taskAssignRuleDialog from '../taskAssignRule/taskAssignRuleDialog.vue';
  104. import {getProcessTypePageAPI} from "@/api/bpm/processClass";
  105. export default {
  106. mixins: [dictMixins],
  107. name: 'BpmModel',
  108. components: {
  109. modelSearch, Pagination, taskAssignRuleDialog,
  110. },
  111. data() {
  112. return {
  113. columns: [
  114. {
  115. type: 'index',
  116. label: '序号',
  117. width: 50,
  118. align: 'center',
  119. fixed: 'left'
  120. },
  121. {
  122. prop: 'processTypeName',
  123. label: '流程分类',
  124. align: 'center',
  125. width: 150,
  126. showOverflowTooltip: true
  127. },
  128. {
  129. prop: 'key',
  130. label: '流程标识',
  131. align: 'center',
  132. width: 150,
  133. showOverflowTooltip: true
  134. },
  135. {
  136. prop: 'name',
  137. label: '流程名称',
  138. align: 'center',
  139. width: 150,
  140. showOverflowTooltip: true
  141. },
  142. {
  143. prop: 'formCustomCreatePath',
  144. label: '表单信息',
  145. align: 'center',
  146. showOverflowTooltip: true
  147. },
  148. {
  149. prop: 'createTime',
  150. label: '创建时间',
  151. align: 'center',
  152. width: 160,
  153. showOverflowTooltip: true
  154. },
  155. {
  156. prop: 'version',
  157. label: '流程版本',
  158. align: 'center',
  159. width: 80,
  160. slot: "version",
  161. showOverflowTooltip: true
  162. },
  163. {
  164. prop: 'suspensionState',
  165. label: '激活状态',
  166. align: 'center',
  167. width: 80,
  168. slot: 'suspensionState',
  169. showOverflowTooltip: true
  170. },
  171. {
  172. prop: 'processDefinition.deploymentTime',
  173. label: '部署时间',
  174. align: 'center',
  175. width: 160,
  176. showOverflowTooltip: true
  177. },
  178. {
  179. columnKey: 'action',
  180. label: '操作',
  181. width: 450,
  182. align: 'center',
  183. resizable: false,
  184. slot: 'action',
  185. showOverflowTooltip: true
  186. }
  187. ],
  188. // 流程表单详情
  189. detailOpen: false,
  190. detailForm: {
  191. fields: []
  192. },
  193. // 流程表单
  194. title: "",
  195. open: false,
  196. form: {},
  197. // BPMN 数据
  198. showBpmnOpen: false,
  199. bpmnXML: null,
  200. processTypeList: [],
  201. bpmnControlForm: {
  202. prefix: "flowable"
  203. },
  204. // 表单校验
  205. rules: {
  206. key: [{required: true, message: "流程标识不能为空", trigger: "blur"}],
  207. name: [{required: true, message: "流程名称不能为空", trigger: "blur"}],
  208. processTypeId: [{required: true, message: "流程分类不能为空", trigger: "change"}],
  209. },
  210. };
  211. },
  212. created() {
  213. this.requestDict('工作流任务分配规则的类型');
  214. this.getProcessTypeList()
  215. },
  216. computed: {
  217. // 是否开启响应式布局
  218. styleResponsive() {
  219. return this.$store.state.theme.styleResponsive;
  220. }
  221. },
  222. watch: {
  223. open(nV) {
  224. if (!nV) {
  225. this.reset();
  226. }
  227. }
  228. },
  229. methods: {
  230. handleProcessType(val) {
  231. if (!val) return this.form.processTypeName = ''
  232. this.form.processTypeName = this.processTypeList.find(item => item.id == val)?.name
  233. },
  234. async getProcessTypeList() {
  235. this.processTypeList = await getProcessTypePageAPI({
  236. pageNum: 1,
  237. size: 9999,
  238. });
  239. },
  240. /* 表格数据源 */
  241. async datasource({page, where, limit}) {
  242. return await getModelPage({
  243. pageNo: page,
  244. pageSize: limit,
  245. ...where
  246. });
  247. },
  248. /* 刷新表格 */
  249. reload(params) {
  250. if (params && params.reset) {
  251. this.$refs.table.reload({page: 1, where: params});
  252. } else {
  253. this.$refs.table.reload({where: params});
  254. }
  255. },
  256. /** 取消按钮 */
  257. cancel() {
  258. this.open = false;
  259. },
  260. // 表单重置
  261. reset() {
  262. this.form = {
  263. id: undefined,
  264. key: undefined,
  265. name: undefined,
  266. description: undefined,
  267. category: undefined,
  268. formType: undefined,
  269. formId: undefined,
  270. formCustomCreatePath: undefined,
  271. formCustomViewPath: undefined
  272. };
  273. console.log(this.$refs.form);
  274. this.$refs.form.resetFields();
  275. },
  276. /** 新增按钮操作 */
  277. handleAdd() {
  278. this.title = "新建模型";
  279. this.open = true;
  280. },
  281. /** 修改按钮操作 */
  282. handleUpdate(row) {
  283. this.open = true;
  284. this.title = "修改模型";
  285. // 设置 form
  286. this.form = {
  287. ...row
  288. };
  289. },
  290. /** 设计按钮操作 */
  291. handleDesign(row) {
  292. this.$router.push({
  293. name: "设计流程",
  294. query: {
  295. modelId: row.id
  296. }
  297. });
  298. },
  299. /** 提交按钮 */
  300. submitForm() {
  301. this.$refs["form"].validate(valid => {
  302. const that = this;
  303. if (!valid) {
  304. return;
  305. }
  306. // 更新
  307. if (this.form.id) {
  308. updateModel({
  309. ...this.form,
  310. }).then(response => {
  311. this.$message.success('修改模型成功');
  312. that.reload();
  313. that.cancel();
  314. });
  315. return;
  316. }
  317. // 创建
  318. createModel(this.form).then(response => {
  319. this.open = false;
  320. this.reload();
  321. this.$alert('<strong>新建模型成功!</strong>后续需要执行如下 4 个步骤:' +
  322. '<div>1. 点击【修改流程】按钮,配置流程的分类、表单信息</div>' +
  323. '<div>2. 点击【设计流程】按钮,绘制流程图</div>' +
  324. '<div>3. 点击【分配规则】按钮,设置每个用户任务的审批人</div>' +
  325. '<div>4. 点击【发布流程】按钮,完成流程的最终发布</div>' +
  326. '另外,每次流程修改后,都需要点击【发布流程】按钮,才能正式生效!!!',
  327. '重要提示', {
  328. dangerouslyUseHTMLString: true,
  329. type: 'success'
  330. });
  331. });
  332. });
  333. },
  334. /** 删除按钮操作 */
  335. handleDelete(row) {
  336. const that = this;
  337. this.$confirm('是否删除该流程???', '删除', {
  338. type: 'warning'
  339. })
  340. .then(() => {
  341. deleteModel(row.id).then(response => {
  342. that.reload();
  343. this.$message.success('删除成功');
  344. })
  345. })
  346. .catch(() => {
  347. });
  348. },
  349. /** 部署按钮操作 */
  350. handleDeploy(row) {
  351. const that = this;
  352. this.$confirm('是否部署该流程???')
  353. .then(() => {
  354. deployModel(row.id).then(response => {
  355. that.reload();
  356. this.$message.success('部署成功');
  357. }).catch(() => {
  358. });
  359. })
  360. .catch(() => {
  361. });
  362. },
  363. /** 流程图的详情按钮操作 */
  364. handleBpmnDetail(row) {
  365. getModel(row.id).then(response => {
  366. this.bpmnXML = response.data.bpmnXml
  367. // 弹窗打开
  368. this.showBpmnOpen = true
  369. })
  370. },
  371. /** 跳转流程定义的列表 */
  372. handleDefinitionList(row) {
  373. this.$router.push({
  374. name: "流程定义",
  375. query: {
  376. key: row.key
  377. }
  378. });
  379. },
  380. /** 更新状态操作 */
  381. handleChangeState(row) {
  382. const that = this;
  383. const id = row.id;
  384. let state = row.processDefinition.suspensionState;
  385. let statusState = state === 1 ? '激活' : '挂起';
  386. this.$confirm('是否确认' + statusState + '流程名字为"' + row.name + '"的数据项?')
  387. .then(() => {
  388. return updateModelState(id, state);
  389. }).then(() => {
  390. that.reload();
  391. this.$message.success(statusState + "成功");
  392. })
  393. .catch(() => {
  394. // 取消后,进行恢复按钮
  395. row.processDefinition.suspensionState = (state === 1 ? 2 : 1);
  396. });
  397. },
  398. /** 处理任务分配规则列表的按钮操作 */
  399. handleAssignRule(row) {
  400. this.$refs['taskAssignRuleDialog'].initModel(row.id);
  401. },
  402. }
  403. };
  404. </script>
  405. <style scoped>
  406. .app-container {
  407. padding: 10px;
  408. }
  409. .filter-container .filter-item {
  410. display: inline-block;
  411. vertical-align: middle;
  412. margin-bottom: 5px;
  413. margin-right: 4px;
  414. }
  415. .filter-container {
  416. padding-bottom: 5px;
  417. }
  418. </style>