Skip to content

Commit d7891fe

Browse files
committed
Vue3 重构:流程实例的创建
1 parent ddd6bbb commit d7891fe

File tree

4 files changed

+66
-102
lines changed

4 files changed

+66
-102
lines changed

src/api/bpm/processInstance/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export type Task = {
44
id: string
55
name: string
66
}
7+
78
export type ProcessInstanceVO = {
89
id: number
910
name: string

src/router/modules/remaining.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,7 @@ const remainingRouter: AppRouteRecordRaw[] = [
272272
},
273273
{
274274
path: '/process-instance/create',
275-
component: () => import('@/views/bpm/processInstance/create.vue'),
275+
component: () => import('@/views/bpm/processInstance/create/index.vue'),
276276
name: 'BpmProcessInstanceCreate',
277277
meta: {
278278
noCache: true,
Lines changed: 64 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,53 @@
11
<template>
2-
<ContentWrap>
3-
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
4-
<div v-if="!selectProcessInstance">
5-
<XTable @register="registerTable">
6-
<!-- 流程分类 -->
7-
<template #category_default="{ row }">
8-
<DictTag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="Number(row?.category)" />
2+
<!-- 第一步,通过流程定义的列表,选择对应的流程 -->
3+
<ContentWrap v-if="!selectProcessInstance">
4+
<el-table v-loading="loading" :data="list">
5+
<el-table-column label="流程名称" align="center" prop="name" />
6+
<el-table-column label="流程分类" align="center" prop="category">
7+
<template #default="scope">
8+
<dict-tag :type="DICT_TYPE.BPM_MODEL_CATEGORY" :value="scope.row.category" />
99
</template>
10-
<template #version_default="{ row }">
11-
<el-tag v-if="row">v{{ row.version }}</el-tag>
10+
</el-table-column>
11+
<el-table-column label="流程版本" align="center" prop="version">
12+
<template #default="scope">
13+
<el-tag>v{{ scope.row.version }}</el-tag>
1214
</template>
13-
<template #actionbtns_default="{ row }">
14-
<XTextButton preIcon="ep:plus" title="选择" @click="handleSelect(row)" />
15+
</el-table-column>
16+
<el-table-column label="流程描述" align="center" prop="description" />
17+
<el-table-column label="操作" align="center">
18+
<template #default="scope">
19+
<el-button link type="primary" @click="handleSelect(scope.row)">
20+
<Icon icon="ep:plus" /> 选择
21+
</el-button>
1522
</template>
16-
</XTable>
17-
</div>
18-
<!-- 第二步,填写表单,进行流程的提交 -->
19-
<div v-else>
20-
<el-card class="box-card">
21-
<div class="clearfix">
22-
<span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
23-
<XButton
24-
style="float: right"
25-
type="primary"
26-
preIcon="ep:delete"
27-
title="选择其它流程"
28-
@click="selectProcessInstance = undefined"
29-
/>
30-
</div>
31-
<el-col :span="16" :offset="6" style="margin-top: 20px">
32-
<form-create
33-
:rule="detailForm.rule"
34-
v-model:api="fApi"
35-
:option="detailForm.option"
36-
@submit="submitForm"
37-
/>
38-
</el-col>
39-
</el-card>
40-
<!-- 流程图预览 -->
41-
<ProcessInstanceBpmnViewer :bpmn-xml="bpmnXML" />
42-
</div>
23+
</el-table-column>
24+
</el-table>
25+
</ContentWrap>
26+
27+
<!-- 第二步,填写表单,进行流程的提交 -->
28+
<ContentWrap v-else>
29+
<el-card class="box-card">
30+
<div class="clearfix">
31+
<span class="el-icon-document">申请信息【{{ selectProcessInstance.name }}】</span>
32+
<el-button style="float: right" type="primary" @click="selectProcessInstance = undefined">
33+
<Icon icon="ep:delete" /> 选择其它流程
34+
</el-button>
35+
</div>
36+
<el-col :span="16" :offset="6" style="margin-top: 20px">
37+
<form-create
38+
:rule="detailForm.rule"
39+
v-model:api="fApi"
40+
:option="detailForm.option"
41+
@submit="submitForm"
42+
/>
43+
</el-col>
44+
</el-card>
45+
<!-- 流程图预览 -->
46+
<ProcessInstanceBpmnViewer :bpmn-xml="bpmnXML" />
4347
</ContentWrap>
4448
</template>
4549
<script setup lang="ts">
4650
import { DICT_TYPE } from '@/utils/dict'
47-
// 业务相关的 import
48-
import { allSchemas } from './process.create'
4951
import * as DefinitionApi from '@/api/bpm/definition'
5052
import * as ProcessInstanceApi from '@/api/bpm/processInstance'
5153
import { setConfAndFields2 } from '@/utils/formCreate'
@@ -55,28 +57,32 @@ const router = useRouter() // 路由
5557
const message = useMessage() // 消息
5658
5759
// ========== 列表相关 ==========
58-
59-
const [registerTable] = useXTable({
60-
allSchemas: allSchemas,
61-
params: {
62-
suspensionState: 1
63-
},
64-
getListApi: DefinitionApi.getProcessDefinitionList,
65-
isList: true
60+
const loading = ref(true) // 列表的加载中
61+
const list = ref([]) // 列表的数据
62+
const queryParams = reactive({
63+
suspensionState: 1
6664
})
6765
68-
// ========== 表单相关 ==========
66+
/** 查询列表 */
67+
const getList = async () => {
68+
loading.value = true
69+
try {
70+
list.value = await DefinitionApi.getProcessDefinitionList(queryParams)
71+
} finally {
72+
loading.value = false
73+
}
74+
}
6975
76+
// ========== 表单相关 ==========
77+
const bpmnXML = ref(null) // BPMN 数据
7078
const fApi = ref<ApiAttrs>()
71-
72-
// 流程表单详情
7379
const detailForm = ref({
80+
// 流程表单详情
7481
rule: [],
7582
option: {}
7683
})
77-
78-
// 流程表单
7984
const selectProcessInstance = ref() // 选择的流程实例
85+
8086
/** 处理选择流程的按钮操作 **/
8187
const handleSelect = async (row) => {
8288
// 设置选择的流程
@@ -86,11 +92,8 @@ const handleSelect = async (row) => {
8692
if (row.formType == 10) {
8793
// 设置表单
8894
setConfAndFields2(detailForm, row.formConf, row.formFields)
89-
9095
// 加载流程图
91-
DefinitionApi.getProcessDefinitionBpmnXML(row.id).then((response) => {
92-
bpmnXML.value = response
93-
})
96+
bpmnXML.value = await DefinitionApi.getProcessDefinitionBpmnXML(row.id)
9497
// 情况二:业务表单
9598
} else if (row.formCustomCreatePath) {
9699
await router.push({
@@ -105,7 +108,6 @@ const submitForm = async (formData) => {
105108
if (!fApi.value || !selectProcessInstance.value) {
106109
return
107110
}
108-
109111
// 提交请求
110112
fApi.value.btn.loading(true)
111113
try {
@@ -121,8 +123,8 @@ const submitForm = async (formData) => {
121123
}
122124
}
123125
124-
// ========== 流程图相关 ==========
125-
126-
// // BPMN 数据
127-
const bpmnXML = ref(null)
126+
/** 初始化 */
127+
onMounted(() => {
128+
getList()
129+
})
128130
</script>

src/views/bpm/processInstance/create/process.create.ts

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)