Skip to content

Commit a6461da

Browse files
committed
feat: 流程新增/修改页面中-第二步骤中表单预览功能增加
1 parent 6e6754e commit a6461da

File tree

3 files changed

+96
-50
lines changed

3 files changed

+96
-50
lines changed

src/views/bpm/model/form/BasicInfo.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,6 @@
144144

145145
<script lang="ts" setup>
146146
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
147-
import { BpmModelType } from '@/utils/constants'
148147
import { UserVO } from '@/api/system/user'
149148
150149
const props = defineProps({

src/views/bpm/model/form/FormDesign.vue

Lines changed: 51 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,5 @@
11
<template>
2-
<el-form
3-
ref="formRef"
4-
:model="modelData"
5-
:rules="rules"
6-
label-width="120px"
7-
class="mt-20px"
8-
>
2+
<el-form ref="formRef" :model="modelData" :rules="rules" label-width="120px" class="mt-20px">
93
<el-form-item label="表单类型" prop="formType" class="mb-20px">
104
<el-radio-group v-model="modelData.formType">
115
<el-radio
@@ -19,19 +13,10 @@
1913
</el-form-item>
2014
<el-form-item v-if="modelData.formType === 10" label="流程表单" prop="formId">
2115
<el-select v-model="modelData.formId" clearable style="width: 100%">
22-
<el-option
23-
v-for="form in formList"
24-
:key="form.id"
25-
:label="form.name"
26-
:value="form.id"
27-
/>
16+
<el-option v-for="form in formList" :key="form.id" :label="form.name" :value="form.id" />
2817
</el-select>
2918
</el-form-item>
30-
<el-form-item
31-
v-if="modelData.formType === 20"
32-
label="表单提交路由"
33-
prop="formCustomCreatePath"
34-
>
19+
<el-form-item v-if="modelData.formType === 20" label="表单提交路由" prop="formCustomCreatePath">
3520
<el-input
3621
v-model="modelData.formCustomCreatePath"
3722
placeholder="请输入表单提交路由"
@@ -46,11 +31,7 @@
4631
<Icon icon="ep:question" class="ml-5px" />
4732
</el-tooltip>
4833
</el-form-item>
49-
<el-form-item
50-
v-if="modelData.formType === 20"
51-
label="表单查看地址"
52-
prop="formCustomViewPath"
53-
>
34+
<el-form-item v-if="modelData.formType === 20" label="表单查看地址" prop="formCustomViewPath">
5435
<el-input
5536
v-model="modelData.formCustomViewPath"
5637
placeholder="请输入表单查看的组件地址"
@@ -65,12 +46,28 @@
6546
<Icon icon="ep:question" class="ml-5px" />
6647
</el-tooltip>
6748
</el-form-item>
49+
<!-- 表单预览 -->
50+
<div
51+
v-if="modelData.formType === 10 && modelData.formId && formPreview.rule.length > 0"
52+
class="mt-20px"
53+
>
54+
<div class="flex items-center mb-15px">
55+
<div class="h-15px w-4px bg-[#1890ff] mr-10px"></div>
56+
<span class="text-15px font-bold">表单预览</span>
57+
</div>
58+
<form-create
59+
v-model="formPreview.formData"
60+
:rule="formPreview.rule"
61+
:option="formPreview.option"
62+
/>
63+
</div>
6864
</el-form>
6965
</template>
7066

7167
<script lang="ts" setup>
7268
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
73-
import { BpmModelFormType } from '@/utils/constants'
69+
import * as FormApi from '@/api/bpm/form'
70+
import { setConfAndFields2 } from '@/utils/formCreate'
7471
7572
const props = defineProps({
7673
modelValue: {
@@ -93,6 +90,35 @@ const modelData = computed({
9390
set: (val) => emit('update:modelValue', val)
9491
})
9592
93+
// 表单预览数据
94+
const formPreview = ref({
95+
formData: {},
96+
rule: [],
97+
option: {
98+
submitBtn: false,
99+
resetBtn: false,
100+
formData: {}
101+
}
102+
})
103+
104+
// 监听表单ID变化,加载表单数据
105+
watch(
106+
() => modelData.value.formId,
107+
async (newFormId) => {
108+
if (newFormId && modelData.value.formType === 10) {
109+
const data = await FormApi.getForm(newFormId)
110+
setConfAndFields2(formPreview.value, data.conf, data.fields)
111+
// 设置只读
112+
formPreview.value.rule.forEach((item: any) => {
113+
item.props = { ...item.props, disabled: true }
114+
})
115+
} else {
116+
formPreview.value.rule = []
117+
}
118+
},
119+
{ immediate: true }
120+
)
121+
96122
const rules = {
97123
formType: [{ required: true, message: '表单类型不能为空', trigger: 'blur' }],
98124
formId: [{ required: true, message: '流程表单不能为空', trigger: 'blur' }],
@@ -108,4 +134,4 @@ const validate = async () => {
108134
defineExpose({
109135
validate
110136
})
111-
</script>
137+
</script>

src/views/bpm/model/form/index.vue

Lines changed: 45 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
<template>
22
<ContentWrap>
3-
<div class="max-w-1024px mx-auto">
3+
<div class="mx-auto">
44
<!-- 头部导航栏 -->
5-
<div class="absolute top-0 left-0 right-0 h-50px bg-white border-bottom z-10 flex items-center px-20px">
5+
<div
6+
class="absolute top-0 left-0 right-0 h-50px bg-white border-bottom z-10 flex items-center px-20px"
7+
>
68
<!-- 左侧标题 -->
79
<div class="w-200px flex items-center overflow-hidden">
810
<Icon icon="ep:arrow-left" class="cursor-pointer flex-shrink-0" @click="router.back()" />
@@ -14,12 +16,25 @@
1416
<!-- 步骤条 -->
1517
<div class="flex-1 flex items-center justify-center h-full">
1618
<div class="w-400px flex items-center justify-between h-full">
17-
<div v-for="(step, index) in steps" :key="index"
19+
<div
20+
v-for="(step, index) in steps"
21+
:key="index"
1822
class="flex items-center cursor-pointer mx-15px relative h-full"
19-
:class="[currentStep === index ? 'text-[#3473ff] border-[#3473ff] border-b-2 border-b-solid' : 'text-gray-500']"
20-
@click="handleStepClick(index)">
21-
<div class="w-28px h-28px rounded-full flex items-center justify-center mr-8px border-2 border-solid text-15px"
22-
:class="[currentStep === index ? 'bg-[#3473ff] text-white border-[#3473ff]' : 'border-gray-300 bg-white text-gray-500']">
23+
:class="[
24+
currentStep === index
25+
? 'text-[#3473ff] border-[#3473ff] border-b-2 border-b-solid'
26+
: 'text-gray-500'
27+
]"
28+
@click="handleStepClick(index)"
29+
>
30+
<div
31+
class="w-28px h-28px rounded-full flex items-center justify-center mr-8px border-2 border-solid text-15px"
32+
:class="[
33+
currentStep === index
34+
? 'bg-[#3473ff] text-white border-[#3473ff]'
35+
: 'border-gray-300 bg-white text-gray-500'
36+
]"
37+
>
2338
{{ index + 1 }}
2439
</div>
2540
<span class="text-16px font-bold whitespace-nowrap">{{ step.title }}</span>
@@ -37,31 +52,38 @@
3752
<!-- 主体内容 -->
3853
<div class="mt-50px">
3954
<!-- 第一步:基本信息 -->
40-
<BasicInfo v-if="currentStep === 0"
41-
v-model="formData"
42-
:categoryList="categoryList"
43-
:userList="userList"
44-
ref="basicInfoRef" />
55+
<div v-if="currentStep === 0" class="mx-auto" style="max-width: 1024px">
56+
<BasicInfo
57+
v-model="formData"
58+
:categoryList="categoryList"
59+
:userList="userList"
60+
ref="basicInfoRef"
61+
/>
62+
</div>
4563

4664
<!-- 第二步:表单设计 -->
47-
<FormDesign v-if="currentStep === 1"
48-
v-model="formData"
49-
:formList="formList"
50-
ref="formDesignRef" />
65+
<div v-if="currentStep === 1" class="mx-auto" style="max-width: 1024px">
66+
<FormDesign
67+
v-model="formData"
68+
:formList="formList"
69+
ref="formDesignRef"
70+
/>
71+
</div>
5172

5273
<!-- 第三步:流程设计 -->
53-
<ProcessDesign v-if="currentStep === 2"
74+
<ProcessDesign
75+
v-if="currentStep === 2"
5476
v-model="formData"
5577
ref="processDesignRef"
56-
@success="handleDesignSuccess" />
78+
@success="handleDesignSuccess"
79+
/>
5780
</div>
5881
</div>
5982
</ContentWrap>
6083
</template>
6184

6285
<script lang="ts" setup>
6386
import { useRouter, useRoute } from 'vue-router'
64-
import { useI18n } from 'vue-i18n'
6587
import { useMessage } from '@/hooks/web/useMessage'
6688
import * as ModelApi from '@/api/bpm/model'
6789
import * as FormApi from '@/api/bpm/form'
@@ -75,7 +97,6 @@ import ProcessDesign from './ProcessDesign.vue'
7597
7698
const router = useRouter()
7799
const route = useRoute()
78-
const { t } = useI18n()
79100
const message = useMessage()
80101
const userStore = useUserStoreWithOut()
81102
@@ -106,7 +127,7 @@ const steps = [
106127
]
107128
108129
// 表单数据
109-
const formData = ref({
130+
const formData: any = ref({
110131
id: undefined,
111132
name: '',
112133
key: '',
@@ -128,11 +149,11 @@ const formData = ref({
128149
// 数据列表
129150
const formList = ref([])
130151
const categoryList = ref([])
131-
const userList = ref([])
152+
const userList = ref<UserApi.UserVO[]>([])
132153
133154
/** 初始化数据 */
134155
const initData = async () => {
135-
const modelId = route.params.id
156+
const modelId = route.params.id as string
136157
if (modelId) {
137158
// 修改场景
138159
formData.value = await ModelApi.getModel(modelId)
@@ -209,7 +230,7 @@ const handleStepClick = async (index: number) => {
209230
}
210231
// 校验当前步骤
211232
try {
212-
if (steps[currentStep.value].validator) {
233+
if (typeof steps[currentStep.value].validator === 'function') {
213234
await steps[currentStep.value].validator()
214235
}
215236
currentStep.value = index

0 commit comments

Comments
 (0)