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

This commit is contained in:
YunaiV 2022-01-16 17:55:29 +08:00
parent 93e02b36dd
commit f049bd7530
5 changed files with 197 additions and 20 deletions

View File

@ -26,3 +26,10 @@ export function cancelProcessInstance(id, reason) {
} }
}) })
} }
export function getMyProcessInstance(id) {
return request({
url: '/bpm/process-instance/get?id=' + id,
method: 'get',
})
}

View File

@ -39,3 +39,4 @@ export function rejectTask(data) {
data: data data: data
}) })
} }

View File

@ -32,7 +32,7 @@
<div v-else> <div v-else>
<el-card class="box-card" > <el-card class="box-card" >
<div slot="header" class="clearfix"> <div slot="header" class="clearfix">
<span class="el-icon-document">{{ selectProcessInstance.name }}</span> <span class="el-icon-document">申请信息{{ selectProcessInstance.name }}</span>
<el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button> <el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button>
</div> </div>
<el-col :span="16" :offset="6"> <el-col :span="16" :offset="6">
@ -58,10 +58,11 @@ import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {getForm} from "@/api/bpm/form"; import {getForm} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator"; import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser' import Parser from '@/components/parser/Parser'
import {createProcessInstance} from "@/api/bpm/processInstance"; import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance";
//
export default { export default {
name: "processDefinition", name: "ProcessInstanceCreate",
components: { components: {
Parser Parser
}, },
@ -109,28 +110,25 @@ export default {
}, },
/** 处理选择流程的按钮操作 **/ /** 处理选择流程的按钮操作 **/
handleSelect(row) { handleSelect(row) {
//
if (!row.formId) {
this.$message.error('该流程未绑定表单,无法发起流程!请重新选择你要发起的流程');
return;
}
// //
this.selectProcessInstance = row; this.selectProcessInstance = row;
// //
getForm(row.formId).then(response => { if (row.formId) {
// //
const data = response.data
this.detailForm = { this.detailForm = {
...JSON.parse(data.conf), ...JSON.parse(row.formConf),
fields: decodeFields(data.fields) fields: decodeFields(row.formFields)
} }
});
// //
getProcessDefinitionBpmnXML(row.id).then(response => { getProcessDefinitionBpmnXML(row.id).then(response => {
this.bpmnXML = response.data this.bpmnXML = response.data
}) })
} else if (row.formCustomCreatePath) {
this.$router.push({ path: row.formCustomCreatePath});
// Tab
}
}, },
/** 提交按钮 */ /** 提交按钮 */
submitForm(params) { submitForm(params) {

View File

@ -0,0 +1,171 @@
<template>
<div class="app-container">
<!-- 第一步通过流程定义的列表选择对应的流程 -->
<div v-if="!selectProcessInstance">
<el-table v-loading="loading" :data="list">
<el-table-column label="流程名称" align="center" prop="name" width="200">
<template slot-scope="scope">
<el-button type="text" @click="handleBpmnDetail(scope.row)">
<span>{{ scope.row.name }}</span>
</el-button>
</template>
</el-table-column>
<el-table-column label="流程分类" align="center" prop="category" width="100">
<template slot-scope="scope">
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
</template>
</el-table-column>
<el-table-column label="流程版本" align="center" prop="processDefinition.version" width="80">
<template slot-scope="scope">
<el-tag size="medium" v-if="scope.row">v{{ scope.row.version }}</el-tag>
</template>
</el-table-column>
<el-table-column label="流程描述" align="center" prop="description" width="300" show-overflow-tooltip />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template slot-scope="scope">
<el-button type="text" size="small" icon="el-icon-plus" @click="handleSelect(scope.row)">选择</el-button>
</template>
</el-table-column>
</el-table>
</div>
<!-- 第二步填写表单进行流程的提交 -->
<div v-else>
<el-card class="box-card" >
<div slot="header" class="clearfix">
<span class="el-icon-document">申请信息{{ selectProcessInstance.name }}</span>
<el-button style="float: right;" type="primary" @click="selectProcessInstance = undefined">选择其它流程</el-button>
</div>
<el-col :span="16" :offset="6">
<div>
<parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" />
</div>
</el-col>
</el-card>
<el-card class="box-card">
<div slot="header" class="clearfix">
<span class="el-icon-picture-outline">流程图</span>
</div>
<my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" />
</el-card>
</div>
</div>
</template>
<script>
import {getProcessDefinitionBpmnXML, getProcessDefinitionList} from "@/api/bpm/definition";
import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import {getForm} from "@/api/bpm/form";
import {decodeFields} from "@/utils/formGenerator";
import Parser from '@/components/parser/Parser'
import {createProcessInstance, getMyProcessInstancePage} from "@/api/bpm/processInstance";
//
export default {
name: "ProcessInstanceDetail",
components: {
Parser
},
data() {
return {
//
loading: true,
//
total: 0,
//
list: [],
//
detailForm: {
fields: []
},
// BPMN
bpmnXML: null,
bpmnControlForm: {
prefix: "activiti"
},
//
selectProcessInstance: undefined, //
//
categoryDictDatas: getDictDatas(DICT_TYPE.BPM_MODEL_CATEGORY),
};
},
created() {
this.getList();
},
methods: {
/** 查询流程定义列表 */
getList() {
this.loading = true;
getProcessDefinitionList({
suspensionState: 1
}).then(response => {
this.list = response.data
this.loading = false
}
);
},
/** 处理选择流程的按钮操作 **/
handleSelect(row) {
//
this.selectProcessInstance = row;
//
if (row.formId) {
//
this.detailForm = {
...JSON.parse(row.formConf),
fields: decodeFields(row.formFields)
}
//
getProcessDefinitionBpmnXML(row.id).then(response => {
this.bpmnXML = response.data
})
} else if (row.formCustomCreatePath) {
this.$router.push({ path: row.formCustomCreatePath});
// Tab
}
},
/** 提交按钮 */
submitForm(params) {
if (!params) {
return;
}
//
const conf = params.conf;
conf.disabled = true; //
conf.formBtns = false; //
//
const variables = params.values;
createProcessInstance({
processDefinitionId: this.selectProcessInstance.id,
variables: variables
}).then(response => {
this.msgSuccess("发起流程成功");
//
this.$store.dispatch("tagsView/delView", this.$route);
this.$router.go(-1);
}).catch(() => {
conf.disabled = false; //
conf.formBtns = true; //
})
},
}
};
</script>
<style lang="scss">
.my-process-designer {
height: calc(100vh - 200px);
}
.box-card {
width: 100%;
margin-bottom: 20px;
}
</style>

View File

@ -129,7 +129,7 @@ import {
import {deleteErrorCode} from "@/api/system/errorCode"; import {deleteErrorCode} from "@/api/system/errorCode";
export default { export default {
name: "ProcessInstanceExt", name: "ProcessInstance",
components: { components: {
}, },
data() { data() {