Vue3 重构:流程实例的创建
This commit is contained in:
parent
ddd6bbbee1
commit
d7891fe759
@ -4,6 +4,7 @@ export type Task = {
|
|||||||
id: string
|
id: string
|
||||||
name: string
|
name: string
|
||||||
}
|
}
|
||||||
|
|
||||||
export type ProcessInstanceVO = {
|
export type ProcessInstanceVO = {
|
||||||
id: number
|
id: number
|
||||||
name: string
|
name: string
|
||||||
|
@ -272,7 +272,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: '/process-instance/create',
|
path: '/process-instance/create',
|
||||||
component: () => import('@/views/bpm/processInstance/create.vue'),
|
component: () => import('@/views/bpm/processInstance/create/index.vue'),
|
||||||
name: 'BpmProcessInstanceCreate',
|
name: 'BpmProcessInstanceCreate',
|
||||||
meta: {
|
meta: {
|
||||||
noCache: true,
|
noCache: true,
|
||||||
|
@ -1,51 +1,53 @@
|
|||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
|
||||||
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
|
<ContentWrap v-if="!selectProcessInstance">
|
||||||
<div v-if="!selectProcessInstance">
|
<el-table v-loading="loading" :data="list">
|
||||||
<XTable @register="registerTable">
|
<el-table-column label="流程名称" align="center" prop="name" />
|
||||||
<!-- 流程分类 -->
|
<el-table-column label="流程分类" align="center" prop="category">
|
||||||
<template #category_default="{ row }">
|
<template #default="scope">
|
||||||
<DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" />
|
<dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
|
||||||
</template>
|
</template>
|
||||||
<template #version_default="{ row }">
|
</el-table-column>
|
||||||
<el-tag v-if="row">v{{ row.version }}</el-tag>
|
<el-table-column label="流程版本" align="center" prop="version">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-tag>v{{ scope.row.version }}</el-tag>
|
||||||
</template>
|
</template>
|
||||||
<template #actionbtns_default="{ row }">
|
</el-table-column>
|
||||||
<XTextButton preIcon="ep:plus" title="选择" @click="handleSelect(row)" />
|
<el-table-column label="流程描述" align="center" prop="description" />
|
||||||
|
<el-table-column label="操作" align="center">
|
||||||
|
<template #default="scope">
|
||||||
|
<el-button link type="primary" @click="handleSelect(scope.row)">
|
||||||
|
<Icon icon="ep:plus" /> 选择
|
||||||
|
</el-button>
|
||||||
</template>
|
</template>
|
||||||
</XTable>
|
</el-table-column>
|
||||||
</div>
|
</el-table>
|
||||||
<!-- 第二步,填写表单,进行流程的提交 -->
|
</ContentWrap>
|
||||||
<div v-else>
|
|
||||||
<el-card class="box-card">
|
<!-- 第二步,填写表单,进行流程的提交 -->
|
||||||
<div class="clearfix">
|
<ContentWrap v-else>
|
||||||
<span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
|
<el-card class="box-card">
|
||||||
<XButton
|
<div class="clearfix">
|
||||||
style="float: right"
|
<span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
|
||||||
type="primary"
|
<el-button style="float: right" type="primary" @click="selectProcessInstance = undefined">
|
||||||
preIcon="ep:delete"
|
<Icon icon="ep:delete" /> 选择其它流程
|
||||||
title="选择其它流程"
|
</el-button>
|
||||||
@click="selectProcessInstance = undefined"
|
</div>
|
||||||
/>
|
<el-col :span="16" :offset="6" style="margin-top: 20px">
|
||||||
</div>
|
<form-create
|
||||||
<el-col :span="16" :offset="6" style="margin-top: 20px">
|
:rule="detailForm.rule"
|
||||||
<form-create
|
v-model:api="fApi"
|
||||||
:rule="detailForm.rule"
|
:option="detailForm.option"
|
||||||
v-model:api="fApi"
|
@submit="submitForm"
|
||||||
:option="detailForm.option"
|
/>
|
||||||
@submit="submitForm"
|
</el-col>
|
||||||
/>
|
</el-card>
|
||||||
</el-col>
|
<!-- 流程图预览 -->
|
||||||
</el-card>
|
<ProcessInstanceBpmnViewer :bpmn-xml="bpmnXML" />
|
||||||
<!-- 流程图预览 -->
|
|
||||||
<ProcessInstanceBpmnViewer :bpmn-xml="bpmnXML" />
|
|
||||||
</div>
|
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { DICT_TYPE } from '@/utils/dict'
|
import { DICT_TYPE } from '@/utils/dict'
|
||||||
// 业务相关的 import
|
|
||||||
import { allSchemas } from './process.create'
|
|
||||||
import * as DefinitionApi from '@/api/bpm/definition'
|
import * as DefinitionApi from '@/api/bpm/definition'
|
||||||
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
|
||||||
import { setConfAndFields2 } from '@/utils/formCreate'
|
import { setConfAndFields2 } from '@/utils/formCreate'
|
||||||
@ -55,28 +57,32 @@ const router = useRouter() // 路由
|
|||||||
const message = useMessage() // 消息
|
const message = useMessage() // 消息
|
||||||
|
|
||||||
// ========== 列表相关 ==========
|
// ========== 列表相关 ==========
|
||||||
|
const loading = ref(true) // 列表的加载中
|
||||||
const [registerTable] = useXTable({
|
const list = ref([]) // 列表的数据
|
||||||
allSchemas: allSchemas,
|
const queryParams = reactive({
|
||||||
params: {
|
suspensionState: 1
|
||||||
suspensionState: 1
|
|
||||||
},
|
|
||||||
getListApi: DefinitionApi.getProcessDefinitionList,
|
|
||||||
isList: true
|
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/** 查询列表 */
|
||||||
|
const getList = async () => {
|
||||||
|
loading.value = true
|
||||||
|
try {
|
||||||
|
list.value = await DefinitionApi.getProcessDefinitionList(queryParams)
|
||||||
|
} finally {
|
||||||
|
loading.value = false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// ========== 表单相关 ==========
|
// ========== 表单相关 ==========
|
||||||
|
const bpmnXML = ref(null) // BPMN 数据
|
||||||
const fApi = ref<ApiAttrs>()
|
const fApi = ref<ApiAttrs>()
|
||||||
|
|
||||||
// 流程表单详情
|
|
||||||
const detailForm = ref({
|
const detailForm = ref({
|
||||||
|
// 流程表单详情
|
||||||
rule: [],
|
rule: [],
|
||||||
option: {}
|
option: {}
|
||||||
})
|
})
|
||||||
|
|
||||||
// 流程表单
|
|
||||||
const selectProcessInstance = ref() // 选择的流程实例
|
const selectProcessInstance = ref() // 选择的流程实例
|
||||||
|
|
||||||
/** 处理选择流程的按钮操作 **/
|
/** 处理选择流程的按钮操作 **/
|
||||||
const handleSelect = async (row) => {
|
const handleSelect = async (row) => {
|
||||||
// 设置选择的流程
|
// 设置选择的流程
|
||||||
@ -86,11 +92,8 @@ const handleSelect = async (row) => {
|
|||||||
if (row.formType == 10) {
|
if (row.formType == 10) {
|
||||||
// 设置表单
|
// 设置表单
|
||||||
setConfAndFields2(detailForm, row.formConf, row.formFields)
|
setConfAndFields2(detailForm, row.formConf, row.formFields)
|
||||||
|
|
||||||
// 加载流程图
|
// 加载流程图
|
||||||
DefinitionApi.getProcessDefinitionBpmnXML(row.id).then((response) => {
|
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
|
||||||
bpmnXML.value = response
|
|
||||||
})
|
|
||||||
// 情况二:业务表单
|
// 情况二:业务表单
|
||||||
} else if (row.formCustomCreatePath) {
|
} else if (row.formCustomCreatePath) {
|
||||||
await router.push({
|
await router.push({
|
||||||
@ -105,7 +108,6 @@ const submitForm = async (formData) => {
|
|||||||
if (!fApi.value || !selectProcessInstance.value) {
|
if (!fApi.value || !selectProcessInstance.value) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// 提交请求
|
// 提交请求
|
||||||
fApi.value.btn.loading(true)
|
fApi.value.btn.loading(true)
|
||||||
try {
|
try {
|
||||||
@ -121,8 +123,8 @@ const submitForm = async (formData) => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========== 流程图相关 ==========
|
/** 初始化 */
|
||||||
|
onMounted(() => {
|
||||||
// // BPMN 数据
|
getList()
|
||||||
const bpmnXML = ref(null)
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -1,39 +0,0 @@
|
|||||||
import type { VxeCrudSchema } from '@/hooks/web/useVxeCrudSchemas'
|
|
||||||
|
|
||||||
// crudSchemas
|
|
||||||
const crudSchemas = reactive<VxeCrudSchema>({
|
|
||||||
primaryKey: 'id',
|
|
||||||
primaryType: null,
|
|
||||||
action: true,
|
|
||||||
columns: [
|
|
||||||
{
|
|
||||||
title: '流程名称',
|
|
||||||
field: 'name'
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '流程分类',
|
|
||||||
field: 'category',
|
|
||||||
dictType: DICT_TYPE.BPM_MODEL_CATEGORY,
|
|
||||||
dictClass: 'number',
|
|
||||||
table: {
|
|
||||||
slots: {
|
|
||||||
default: 'category_default'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '流程版本',
|
|
||||||
field: 'version',
|
|
||||||
table: {
|
|
||||||
slots: {
|
|
||||||
default: 'version_default'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
title: '流程描述',
|
|
||||||
field: 'description'
|
|
||||||
}
|
|
||||||
]
|
|
||||||
})
|
|
||||||
export const { allSchemas } = useVxeCrudSchemas(crudSchemas)
|
|
Loading…
Reference in New Issue
Block a user