Commit f049bd7530d9f9d9178e49462f9c9754e1a7cfe7

Authored by YunaiV
1 parent 93e02b36

流程发起界面,支持业务表单

yudao-admin-ui/src/api/bpm/processInstance.js
@@ -26,3 +26,10 @@ export function cancelProcessInstance(id, reason) { @@ -26,3 +26,10 @@ export function cancelProcessInstance(id, reason) {
26 } 26 }
27 }) 27 })
28 } 28 }
  29 +
  30 +export function getMyProcessInstance(id) {
  31 + return request({
  32 + url: '/bpm/process-instance/get?id=' + id,
  33 + method: 'get',
  34 + })
  35 +}
yudao-admin-ui/src/api/bpm/task.js
@@ -39,3 +39,4 @@ export function rejectTask(data) { @@ -39,3 +39,4 @@ export function rejectTask(data) {
39 data: data 39 data: data
40 }) 40 })
41 } 41 }
  42 +
yudao-admin-ui/src/views/bpm/processInstance/create.vue
@@ -32,7 +32,7 @@ @@ -32,7 +32,7 @@
32 <div v-else> 32 <div v-else>
33 <el-card class="box-card" > 33 <el-card class="box-card" >
34 <div slot="header" class="clearfix"> 34 <div slot="header" class="clearfix">
35 - <span class="el-icon-document">{{ selectProcessInstance.name }}</span> 35 + <span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
36 <el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button> 36 <el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button>
37 </div> 37 </div>
38 <el-col :span="16" :offset="6"> 38 <el-col :span="16" :offset="6">
@@ -58,10 +58,11 @@ import {DICT_TYPE, getDictDatas} from &quot;@/utils/dict&quot;; @@ -58,10 +58,11 @@ import {DICT_TYPE, getDictDatas} from &quot;@/utils/dict&quot;;
58 import {getForm} from "@/api/bpm/form"; 58 import {getForm} from "@/api/bpm/form";
59 import {decodeFields} from "@/utils/formGenerator"; 59 import {decodeFields} from "@/utils/formGenerator";
60 import Parser from '@/components/parser/Parser' 60 import Parser from '@/components/parser/Parser'
61 -import {createProcessInstance} from "@/api/bpm/processInstance"; 61 +import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance";
62 62
  63 +// 流程实例的发起
63 export default { 64 export default {
64 - name: "processDefinition", 65 + name: "ProcessInstanceCreate",
65 components: { 66 components: {
66 Parser 67 Parser
67 }, 68 },
@@ -109,28 +110,25 @@ export default { @@ -109,28 +110,25 @@ export default {
109 }, 110 },
110 /** 处理选择流程的按钮操作 **/ 111 /** 处理选择流程的按钮操作 **/
111 handleSelect(row) { 112 handleSelect(row) {
112 - // 如果无表单,则无法发起流程  
113 - if (!row.formId) {  
114 - this.$message.error('该流程未绑定表单,无法发起流程!请重新选择你要发起的流程');  
115 - return;  
116 - }  
117 // 设置选择的流程 113 // 设置选择的流程
118 this.selectProcessInstance = row; 114 this.selectProcessInstance = row;
119 115
120 - // 加载对应的表单  
121 - getForm(row.formId).then(response => {  
122 - // 设置值  
123 - const data = response.data 116 + // 流程表单
  117 + if (row.formId) {
  118 + // 设置对应的表单
124 this.detailForm = { 119 this.detailForm = {
125 - ...JSON.parse(data.conf),  
126 - fields: decodeFields(data.fields) 120 + ...JSON.parse(row.formConf),
  121 + fields: decodeFields(row.formFields)
127 } 122 }
128 - });  
129 123
130 - // 加载流程图  
131 - getProcessDefinitionBpmnXML(row.id).then(response => {  
132 - this.bpmnXML = response.data  
133 - }) 124 + // 加载流程图
  125 + getProcessDefinitionBpmnXML(row.id).then(response => {
  126 + this.bpmnXML = response.data
  127 + })
  128 + } else if (row.formCustomCreatePath) {
  129 + this.$router.push({ path: row.formCustomCreatePath});
  130 + // 这里暂时无需加载流程图,因为跳出到另外个 Tab;
  131 + }
134 }, 132 },
135 /** 提交按钮 */ 133 /** 提交按钮 */
136 submitForm(params) { 134 submitForm(params) {
yudao-admin-ui/src/views/bpm/processInstance/detail.vue 0 → 100644
  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 +
  52 + </div>
  53 +</template>
  54 +
  55 +<script>
  56 +import {getProcessDefinitionBpmnXML, getProcessDefinitionList} from "@/api/bpm/definition";
  57 +import {DICT_TYPE, getDictDatas} from "@/utils/dict";
  58 +import {getForm} from "@/api/bpm/form";
  59 +import {decodeFields} from "@/utils/formGenerator";
  60 +import Parser from '@/components/parser/Parser'
  61 +import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance";
  62 +
  63 +// 流程实例的详情页,可用于审批
  64 +export default {
  65 + name: "ProcessInstanceDetail",
  66 + components: {
  67 + Parser
  68 + },
  69 + data() {
  70 + return {
  71 + // 遮罩层
  72 + loading: true,
  73 + // 总条数
  74 + total: 0,
  75 + // 表格数据
  76 + list: [],
  77 +
  78 + // 流程表单详情
  79 + detailForm: {
  80 + fields: []
  81 + },
  82 +
  83 + // BPMN 数据
  84 + bpmnXML: null,
  85 + bpmnControlForm: {
  86 + prefix: "activiti"
  87 + },
  88 +
  89 + // 流程表单
  90 + selectProcessInstance: undefined, // 选择的流程实例
  91 +
  92 + // 数据字典
  93 + categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
  94 + };
  95 + },
  96 + created() {
  97 + this.getList();
  98 + },
  99 + methods: {
  100 + /** 查询流程定义列表 */
  101 + getList() {
  102 + this.loading = true;
  103 + getProcessDefinitionList({
  104 + suspensionState: 1
  105 + }).then(response => {
  106 + this.list = response.data
  107 + this.loading = false
  108 + }
  109 + );
  110 + },
  111 + /** 处理选择流程的按钮操作 **/
  112 + handleSelect(row) {
  113 + // 设置选择的流程
  114 + this.selectProcessInstance = row;
  115 +
  116 + // 流程表单
  117 + if (row.formId) {
  118 + // 设置对应的表单
  119 + this.detailForm = {
  120 + ...JSON.parse(row.formConf),
  121 + fields: decodeFields(row.formFields)
  122 + }
  123 +
  124 + // 加载流程图
  125 + getProcessDefinitionBpmnXML(row.id).then(response => {
  126 + this.bpmnXML = response.data
  127 + })
  128 + } else if (row.formCustomCreatePath) {
  129 + this.$router.push({ path: row.formCustomCreatePath});
  130 + // 这里暂时无需加载流程图,因为跳出到另外个 Tab;
  131 + }
  132 + },
  133 + /** 提交按钮 */
  134 + submitForm(params) {
  135 + if (!params) {
  136 + return;
  137 + }
  138 + // 设置表单禁用
  139 + const conf = params.conf;
  140 + conf.disabled = true; // 表单禁用
  141 + conf.formBtns = false; // 按钮隐藏
  142 +
  143 + // 提交表单,创建流程
  144 + const variables = params.values;
  145 + createProcessInstance({
  146 + processDefinitionId: this.selectProcessInstance.id,
  147 + variables: variables
  148 + }).then(response => {
  149 + this.msgSuccess("发起流程成功");
  150 + // 关闭当前窗口
  151 + this.$store.dispatch("tagsView/delView", this.$route);
  152 + this.$router.go(-1);
  153 + }).catch(() => {
  154 + conf.disabled = false; // 表单开启
  155 + conf.formBtns = true; // 按钮展示
  156 + })
  157 + },
  158 + }
  159 +};
  160 +</script>
  161 +
  162 +<style lang="scss">
  163 +.my-process-designer {
  164 + height: calc(100vh - 200px);
  165 +}
  166 +
  167 +.box-card {
  168 + width: 100%;
  169 + margin-bottom: 20px;
  170 +}
  171 +</style>
yudao-admin-ui/src/views/bpm/processInstance/index.vue
@@ -129,7 +129,7 @@ import { @@ -129,7 +129,7 @@ import {
129 import {deleteErrorCode} from "@/api/system/errorCode"; 129 import {deleteErrorCode} from "@/api/system/errorCode";
130 130
131 export default { 131 export default {
132 - name: "ProcessInstanceExt", 132 + name: "ProcessInstance",
133 components: { 133 components: {
134 }, 134 },
135 data() { 135 data() {