bpm:完成流程实例的发起功能

This commit is contained in:
YunaiV 2023-01-23 23:11:25 +08:00
parent 2d6fe27b43
commit 6c6050a320
5 changed files with 105 additions and 92 deletions

View File

@ -1,11 +1,10 @@
import request from '@/config/axios'
import { ProcessInstanceVO } from './types'
export const getMyProcessInstancePageApi = async (params) => {
return await request.get({ url: '/bpm/process-instance/my-page', params })
}
export const createProcessInstanceApi = async (data: ProcessInstanceVO) => {
export const createProcessInstanceApi = async (data) => {
return await request.post({ url: '/bpm/process-instance/create', data: data })
}

View File

@ -363,7 +363,7 @@ const handleFormDetail = async (row) => {
//
formDetailVisible.value = true
} else {
router.push({
await router.push({
path: row.formCustomCreatePath
})
}

View File

@ -1,5 +1,5 @@
<template>
<div class="app-container">
<ContentWrap>
<!-- 第一步通过流程定义的列表选择对应的流程 -->
<div v-if="!selectProcessInstance">
<XTable @register="registerTable">
@ -7,9 +7,7 @@
<el-tag v-if="row">v{{ row.version }}</el-tag>
</template>
<template #actionbtns_default="{ row }">
<el-button type="text" size="small" icon="el-icon-plus" @click="handleSelect(row)"
>选择</el-button
>
<XTextButton preIcon="ep:plus" title="选择" @click="handleSelect(row)" />
</template>
</XTable>
</div>
@ -18,107 +16,119 @@
<el-card class="box-card">
<div class="clearfix">
<span class="el-icon-document">申请信息{{ selectProcessInstance.name }}</span>
<el-button style="float: right" type="primary" @click="selectProcessInstance = undefined"
>选择其它流程</el-button
>
<XButton
style="float: right"
type="primary"
preIcon="ep:delete"
title="选择其它流程"
@click="selectProcessInstance = undefined"
/>
</div>
<el-col :span="16" :offset="6">
<div>
<!-- <parser :key="new Date().getTime()" :form-conf="detailForm" @submit="submitForm" /> -->
</div>
<el-col :span="16" :offset="6" style="margin-top: 20px">
<form-create
:rule="detailForm.rule"
v-model:api="fApi"
:option="detailForm.option"
@submit="submitForm"
/>
</el-col>
</el-card>
<el-card class="box-card">
<div class="clearfix">
<span class="el-icon-picture-outline">流程图</span>
</div>
<!-- TODO 芋艿待完成 -->
<!-- <my-process-viewer key="designer" v-model="bpmnXML" v-bind="bpmnControlForm" /> -->
</el-card>
</div>
</div>
</ContentWrap>
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { useXTable } from '@/hooks/web/useXTable'
import * as definitionApi from '@/api/bpm/definition'
// import {DICT_TYPE, getDictDatas} from "@/utils/dict";
import { decodeFields } from '@/utils/formGenerator'
// import Parser from '@/components/parser/Parser'
// import * as processInstanceApi from "@/api/bpm/processInstance";
// import
import { allSchemas } from './process.create'
import { useRouter } from 'vue-router'
const router = useRouter()
import * as DefinitionApi from '@/api/bpm/definition'
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
const router = useRouter() //
const message = useMessage() //
// ========== ==========
const queryParams = reactive({
suspensionState: 1
})
const [registerTable] = useXTable({
allSchemas: allSchemas,
params: queryParams,
getListApi: definitionApi.getProcessDefinitionListApi
params: {
suspensionState: 1
},
getListApi: DefinitionApi.getProcessDefinitionListApi,
isList: true
})
// ========== ==========
import { setConfAndFields2 } from '@/utils/formCreate'
import { ApiAttrs } from '@form-create/element-ui/types/config'
const fApi = ref<ApiAttrs>()
//
const detailForm = ref({
fields: []
rule: [],
option: {}
})
//
const selectProcessInstance = ref(undefined) //
/** 处理选择流程的按钮操作 **/
const handleSelect = async (row) => {
//
selectProcessInstance.value = row
//
if (row.formType == 10) {
//
setConfAndFields2(detailForm, row.formConf, row.formFields)
//
DefinitionApi.getProcessDefinitionBpmnXMLApi(row.id).then((response) => {
bpmnXML.value = response.data
})
//
} else if (row.formCustomCreatePath) {
await router.push({
path: row.formCustomCreatePath
})
// Tab
}
}
/** 提交按钮 */
const submitForm = async (formData) => {
if (!fApi.value || !selectProcessInstance.value) {
return
}
//
fApi.value.btn.loading(true)
try {
await ProcessInstanceApi.createProcessInstanceApi({
processDefinitionId: selectProcessInstance.value.id,
variables: formData
})
//
message.success('发起流程成功')
// this.$tab.closeOpenPage();
router.go(-1)
} finally {
fApi.value.btn.loading(false)
}
}
// ========== ==========
// // BPMN
const bpmnXML = ref(null)
// const bpmnControlForm=ref( {
// prefix: "flowable"
// })
//
const selectProcessInstance = ref(undefined) //
/** 处理选择流程的按钮操作 **/
const handleSelect = (row) => {
//
selectProcessInstance.value = row
//
if (row.formId) {
//
detailForm.value = {
...JSON.parse(row.formConf),
fields: decodeFields([], row.formFields)
}
//
definitionApi.getProcessDefinitionBpmnXMLApi(row.id).then((response) => {
bpmnXML.value = response.data
})
} else if (row.formCustomCreatePath) {
router.push({ path: row.formCustomCreatePath })
// Tab
}
}
/** 提交按钮 */
// const submitForm=(params)=> {
// if (!params) {
// return;
// }
// //
// const conf = params.conf;
// conf.disabled = true; //
// conf.formBtns = false; //
// //
// const variables = params.values;
// await processInstanceApi.createProcessInstanceApi({
// processDefinitionId: this.selectProcessInstance.id,
// variables: variables
// }).then(response => {
// this.$modal.msgSuccess("");
// //
// this.$tab.closeOpenPage();
// this.$router.go(-1);
// }).catch(() => {
// conf.disabled = false; //
// conf.formBtns = true; //
// })
// }
</script>
<style lang="scss">

View File

@ -20,11 +20,17 @@
</template>
<!-- 操作 -->
<template #actionbtns_default="{ row }">
<XButton preIcon="ep:view" :title="t('action.detail')" @click="handleDetail(row)" />
<XButton
<XTextButton
preIcon="ep:view"
:title="t('action.detail')"
v-hasPermi="['bpm:process-instance:cancel']"
@click="handleDetail(row)"
/>
<XTextButton
preIcon="ep:delete"
title="取消"
v-if="row.result === 1"
v-hasPermi="['bpm:process-instance:query']"
@click="handleCancel(row)"
/>
</template>

View File

@ -1,17 +1,15 @@
import { reactive } from 'vue'
// import { useI18n } from '@/hooks/web/useI18n'
import { VxeCrudSchema, useVxeCrudSchemas } from '@/hooks/web/useVxeCrudSchemas'
import { DICT_TYPE } from '@/utils/dict'
// const { t } = useI18n() // 国际化
// CrudSchema
// crudSchemas
const crudSchemas = reactive<VxeCrudSchema>({
primaryKey: 'id',
primaryType: 'id',
primaryTitle: '流程名称',
primaryType: null,
action: true,
actionWidth: '200px',
columns: [
{
title: '流程名称',
field: 'name'
},
{
title: '流程分类',
field: 'category',
@ -20,7 +18,7 @@ const crudSchemas = reactive<VxeCrudSchema>({
},
{
title: '流程版本',
field: 'processDefinition.version',
field: 'version',
table: {
slots: {
default: 'version_default'