index.vue 13 KB

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