feat: 流程新增/修改页面中-第二步骤中表单预览功能增加
parent
6e6754e44a
commit
a6461da0f8
|
@ -144,7 +144,6 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getBoolDictOptions, getIntDictOptions } from '@/utils/dict'
|
||||||
import { BpmModelType } from '@/utils/constants'
|
|
||||||
import { UserVO } from '@/api/system/user'
|
import { UserVO } from '@/api/system/user'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
|
|
|
@ -1,11 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<el-form
|
<el-form ref="formRef" :model="modelData" :rules="rules" label-width="120px" class="mt-20px">
|
||||||
ref="formRef"
|
|
||||||
:model="modelData"
|
|
||||||
:rules="rules"
|
|
||||||
label-width="120px"
|
|
||||||
class="mt-20px"
|
|
||||||
>
|
|
||||||
<el-form-item label="表单类型" prop="formType" class="mb-20px">
|
<el-form-item label="表单类型" prop="formType" class="mb-20px">
|
||||||
<el-radio-group v-model="modelData.formType">
|
<el-radio-group v-model="modelData.formType">
|
||||||
<el-radio
|
<el-radio
|
||||||
|
@ -19,19 +13,10 @@
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item v-if="modelData.formType === 10" label="流程表单" prop="formId">
|
<el-form-item v-if="modelData.formType === 10" label="流程表单" prop="formId">
|
||||||
<el-select v-model="modelData.formId" clearable style="width: 100%">
|
<el-select v-model="modelData.formId" clearable style="width: 100%">
|
||||||
<el-option
|
<el-option v-for="form in formList" :key="form.id" :label="form.name" :value="form.id" />
|
||||||
v-for="form in formList"
|
|
||||||
:key="form.id"
|
|
||||||
:label="form.name"
|
|
||||||
:value="form.id"
|
|
||||||
/>
|
|
||||||
</el-select>
|
</el-select>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item v-if="modelData.formType === 20" label="表单提交路由" prop="formCustomCreatePath">
|
||||||
v-if="modelData.formType === 20"
|
|
||||||
label="表单提交路由"
|
|
||||||
prop="formCustomCreatePath"
|
|
||||||
>
|
|
||||||
<el-input
|
<el-input
|
||||||
v-model="modelData.formCustomCreatePath"
|
v-model="modelData.formCustomCreatePath"
|
||||||
placeholder="请输入表单提交路由"
|
placeholder="请输入表单提交路由"
|
||||||
|
@ -46,11 +31,7 @@
|
||||||
<Icon icon="ep:question" class="ml-5px" />
|
<Icon icon="ep:question" class="ml-5px" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
<el-form-item
|
<el-form-item v-if="modelData.formType === 20" label="表单查看地址" prop="formCustomViewPath">
|
||||||
v-if="modelData.formType === 20"
|
|
||||||
label="表单查看地址"
|
|
||||||
prop="formCustomViewPath"
|
|
||||||
>
|
|
||||||
<el-input
|
<el-input
|
||||||
v-model="modelData.formCustomViewPath"
|
v-model="modelData.formCustomViewPath"
|
||||||
placeholder="请输入表单查看的组件地址"
|
placeholder="请输入表单查看的组件地址"
|
||||||
|
@ -65,12 +46,28 @@
|
||||||
<Icon icon="ep:question" class="ml-5px" />
|
<Icon icon="ep:question" class="ml-5px" />
|
||||||
</el-tooltip>
|
</el-tooltip>
|
||||||
</el-form-item>
|
</el-form-item>
|
||||||
|
<!-- 表单预览 -->
|
||||||
|
<div
|
||||||
|
v-if="modelData.formType === 10 && modelData.formId && formPreview.rule.length > 0"
|
||||||
|
class="mt-20px"
|
||||||
|
>
|
||||||
|
<div class="flex items-center mb-15px">
|
||||||
|
<div class="h-15px w-4px bg-[#1890ff] mr-10px"></div>
|
||||||
|
<span class="text-15px font-bold">表单预览</span>
|
||||||
|
</div>
|
||||||
|
<form-create
|
||||||
|
v-model="formPreview.formData"
|
||||||
|
:rule="formPreview.rule"
|
||||||
|
:option="formPreview.option"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
</el-form>
|
</el-form>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
import { DICT_TYPE, getIntDictOptions } from '@/utils/dict'
|
||||||
import { BpmModelFormType } from '@/utils/constants'
|
import * as FormApi from '@/api/bpm/form'
|
||||||
|
import { setConfAndFields2 } from '@/utils/formCreate'
|
||||||
|
|
||||||
const props = defineProps({
|
const props = defineProps({
|
||||||
modelValue: {
|
modelValue: {
|
||||||
|
@ -93,6 +90,35 @@ const modelData = computed({
|
||||||
set: (val) => emit('update:modelValue', val)
|
set: (val) => emit('update:modelValue', val)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 表单预览数据
|
||||||
|
const formPreview = ref({
|
||||||
|
formData: {},
|
||||||
|
rule: [],
|
||||||
|
option: {
|
||||||
|
submitBtn: false,
|
||||||
|
resetBtn: false,
|
||||||
|
formData: {}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
// 监听表单ID变化,加载表单数据
|
||||||
|
watch(
|
||||||
|
() => modelData.value.formId,
|
||||||
|
async (newFormId) => {
|
||||||
|
if (newFormId && modelData.value.formType === 10) {
|
||||||
|
const data = await FormApi.getForm(newFormId)
|
||||||
|
setConfAndFields2(formPreview.value, data.conf, data.fields)
|
||||||
|
// 设置只读
|
||||||
|
formPreview.value.rule.forEach((item: any) => {
|
||||||
|
item.props = { ...item.props, disabled: true }
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
formPreview.value.rule = []
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{ immediate: true }
|
||||||
|
)
|
||||||
|
|
||||||
const rules = {
|
const rules = {
|
||||||
formType: [{ required: true, message: '表单类型不能为空', trigger: 'blur' }],
|
formType: [{ required: true, message: '表单类型不能为空', trigger: 'blur' }],
|
||||||
formId: [{ required: true, message: '流程表单不能为空', trigger: 'blur' }],
|
formId: [{ required: true, message: '流程表单不能为空', trigger: 'blur' }],
|
||||||
|
|
|
@ -1,8 +1,10 @@
|
||||||
<template>
|
<template>
|
||||||
<ContentWrap>
|
<ContentWrap>
|
||||||
<div class="max-w-1024px mx-auto">
|
<div class="mx-auto">
|
||||||
<!-- 头部导航栏 -->
|
<!-- 头部导航栏 -->
|
||||||
<div class="absolute top-0 left-0 right-0 h-50px bg-white border-bottom z-10 flex items-center px-20px">
|
<div
|
||||||
|
class="absolute top-0 left-0 right-0 h-50px bg-white border-bottom z-10 flex items-center px-20px"
|
||||||
|
>
|
||||||
<!-- 左侧标题 -->
|
<!-- 左侧标题 -->
|
||||||
<div class="w-200px flex items-center overflow-hidden">
|
<div class="w-200px flex items-center overflow-hidden">
|
||||||
<Icon icon="ep:arrow-left" class="cursor-pointer flex-shrink-0" @click="router.back()" />
|
<Icon icon="ep:arrow-left" class="cursor-pointer flex-shrink-0" @click="router.back()" />
|
||||||
|
@ -14,12 +16,25 @@
|
||||||
<!-- 步骤条 -->
|
<!-- 步骤条 -->
|
||||||
<div class="flex-1 flex items-center justify-center h-full">
|
<div class="flex-1 flex items-center justify-center h-full">
|
||||||
<div class="w-400px flex items-center justify-between h-full">
|
<div class="w-400px flex items-center justify-between h-full">
|
||||||
<div v-for="(step, index) in steps" :key="index"
|
<div
|
||||||
|
v-for="(step, index) in steps"
|
||||||
|
:key="index"
|
||||||
class="flex items-center cursor-pointer mx-15px relative h-full"
|
class="flex items-center cursor-pointer mx-15px relative h-full"
|
||||||
:class="[currentStep === index ? 'text-[#3473ff] border-[#3473ff] border-b-2 border-b-solid' : 'text-gray-500']"
|
:class="[
|
||||||
@click="handleStepClick(index)">
|
currentStep === index
|
||||||
<div class="w-28px h-28px rounded-full flex items-center justify-center mr-8px border-2 border-solid text-15px"
|
? 'text-[#3473ff] border-[#3473ff] border-b-2 border-b-solid'
|
||||||
:class="[currentStep === index ? 'bg-[#3473ff] text-white border-[#3473ff]' : 'border-gray-300 bg-white text-gray-500']">
|
: 'text-gray-500'
|
||||||
|
]"
|
||||||
|
@click="handleStepClick(index)"
|
||||||
|
>
|
||||||
|
<div
|
||||||
|
class="w-28px h-28px rounded-full flex items-center justify-center mr-8px border-2 border-solid text-15px"
|
||||||
|
:class="[
|
||||||
|
currentStep === index
|
||||||
|
? 'bg-[#3473ff] text-white border-[#3473ff]'
|
||||||
|
: 'border-gray-300 bg-white text-gray-500'
|
||||||
|
]"
|
||||||
|
>
|
||||||
{{ index + 1 }}
|
{{ index + 1 }}
|
||||||
</div>
|
</div>
|
||||||
<span class="text-16px font-bold whitespace-nowrap">{{ step.title }}</span>
|
<span class="text-16px font-bold whitespace-nowrap">{{ step.title }}</span>
|
||||||
|
@ -37,23 +52,31 @@
|
||||||
<!-- 主体内容 -->
|
<!-- 主体内容 -->
|
||||||
<div class="mt-50px">
|
<div class="mt-50px">
|
||||||
<!-- 第一步:基本信息 -->
|
<!-- 第一步:基本信息 -->
|
||||||
<BasicInfo v-if="currentStep === 0"
|
<div v-if="currentStep === 0" class="mx-auto" style="max-width: 1024px">
|
||||||
|
<BasicInfo
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
:categoryList="categoryList"
|
:categoryList="categoryList"
|
||||||
:userList="userList"
|
:userList="userList"
|
||||||
ref="basicInfoRef" />
|
ref="basicInfoRef"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 第二步:表单设计 -->
|
<!-- 第二步:表单设计 -->
|
||||||
<FormDesign v-if="currentStep === 1"
|
<div v-if="currentStep === 1" class="mx-auto" style="max-width: 1024px">
|
||||||
|
<FormDesign
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
:formList="formList"
|
:formList="formList"
|
||||||
ref="formDesignRef" />
|
ref="formDesignRef"
|
||||||
|
/>
|
||||||
|
</div>
|
||||||
|
|
||||||
<!-- 第三步:流程设计 -->
|
<!-- 第三步:流程设计 -->
|
||||||
<ProcessDesign v-if="currentStep === 2"
|
<ProcessDesign
|
||||||
|
v-if="currentStep === 2"
|
||||||
v-model="formData"
|
v-model="formData"
|
||||||
ref="processDesignRef"
|
ref="processDesignRef"
|
||||||
@success="handleDesignSuccess" />
|
@success="handleDesignSuccess"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</ContentWrap>
|
</ContentWrap>
|
||||||
|
@ -61,7 +84,6 @@
|
||||||
|
|
||||||
<script lang="ts" setup>
|
<script lang="ts" setup>
|
||||||
import { useRouter, useRoute } from 'vue-router'
|
import { useRouter, useRoute } from 'vue-router'
|
||||||
import { useI18n } from 'vue-i18n'
|
|
||||||
import { useMessage } from '@/hooks/web/useMessage'
|
import { useMessage } from '@/hooks/web/useMessage'
|
||||||
import * as ModelApi from '@/api/bpm/model'
|
import * as ModelApi from '@/api/bpm/model'
|
||||||
import * as FormApi from '@/api/bpm/form'
|
import * as FormApi from '@/api/bpm/form'
|
||||||
|
@ -75,7 +97,6 @@ import ProcessDesign from './ProcessDesign.vue'
|
||||||
|
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
const route = useRoute()
|
const route = useRoute()
|
||||||
const { t } = useI18n()
|
|
||||||
const message = useMessage()
|
const message = useMessage()
|
||||||
const userStore = useUserStoreWithOut()
|
const userStore = useUserStoreWithOut()
|
||||||
|
|
||||||
|
@ -106,7 +127,7 @@ const steps = [
|
||||||
]
|
]
|
||||||
|
|
||||||
// 表单数据
|
// 表单数据
|
||||||
const formData = ref({
|
const formData: any = ref({
|
||||||
id: undefined,
|
id: undefined,
|
||||||
name: '',
|
name: '',
|
||||||
key: '',
|
key: '',
|
||||||
|
@ -128,11 +149,11 @@ const formData = ref({
|
||||||
// 数据列表
|
// 数据列表
|
||||||
const formList = ref([])
|
const formList = ref([])
|
||||||
const categoryList = ref([])
|
const categoryList = ref([])
|
||||||
const userList = ref([])
|
const userList = ref<UserApi.UserVO[]>([])
|
||||||
|
|
||||||
/** 初始化数据 */
|
/** 初始化数据 */
|
||||||
const initData = async () => {
|
const initData = async () => {
|
||||||
const modelId = route.params.id
|
const modelId = route.params.id as string
|
||||||
if (modelId) {
|
if (modelId) {
|
||||||
// 修改场景
|
// 修改场景
|
||||||
formData.value = await ModelApi.getModel(modelId)
|
formData.value = await ModelApi.getModel(modelId)
|
||||||
|
@ -209,7 +230,7 @@ const handleStepClick = async (index: number) => {
|
||||||
}
|
}
|
||||||
// 校验当前步骤
|
// 校验当前步骤
|
||||||
try {
|
try {
|
||||||
if (steps[currentStep.value].validator) {
|
if (typeof steps[currentStep.value].validator === 'function') {
|
||||||
await steps[currentStep.value].validator()
|
await steps[currentStep.value].validator()
|
||||||
}
|
}
|
||||||
currentStep.value = index
|
currentStep.value = index
|
||||||
|
|
Loading…
Reference in New Issue