diff --git a/src/utils/routerHelper.ts b/src/utils/routerHelper.ts index af6a9c3c..a6825653 100644 --- a/src/utils/routerHelper.ts +++ b/src/utils/routerHelper.ts @@ -1,10 +1,22 @@ +import type { RouteLocationNormalized, Router, RouteRecordNormalized } from 'vue-router' import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router' -import type { Router, RouteLocationNormalized, RouteRecordNormalized } from 'vue-router' import { isUrl } from '@/utils/is' -import { omit, cloneDeep } from 'lodash-es' +import { cloneDeep, omit } from 'lodash-es' const modules = import.meta.glob('../views/**/*.{vue,tsx}') - +/** + * 注册一个异步组件 + * @param componentPath 例:/bpm/oa/leave/detail + */ +export const registerComponent = (componentPath: string) => { + for (const item in modules) { + if (item.includes(componentPath)) { + // 使用异步组件的方式来动态加载组件 + // @ts-ignore + return defineAsyncComponent(modules[item]) + } + } +} /* Layout */ export const Layout = () => import('@/layout/Layout.vue') diff --git a/src/views/bpm/form/editor/index.vue b/src/views/bpm/form/editor/index.vue index c56a7747..f11c1228 100644 --- a/src/views/bpm/form/editor/index.vue +++ b/src/views/bpm/form/editor/index.vue @@ -44,10 +44,13 @@ import { CommonStatusEnum } from '@/utils/constants' import * as FormApi from '@/api/bpm/form' import FcDesigner from '@form-create/designer' import { encodeConf, encodeFields, setConfAndFields } from '@/utils/formCreate' +import { useTagsViewStore } from '@/store/modules/tagsView' const { t } = useI18n() // 国际化 const message = useMessage() // 消息 -const { query } = useRoute() // 路由 +const { push, currentRoute } = useRouter() // 路由 +const { query } = useRoute() // 路由信息 +const { delView } = useTagsViewStore() // 视图操作 const designer = ref() // 表单设计器 const dialogVisible = ref(false) // 弹窗是否展示 @@ -88,10 +91,16 @@ const submitForm = async () => { message.success(t('common.updateSuccess')) } dialogVisible.value = false + close() } finally { formLoading.value = false } } +/** 关闭按钮 */ +const close = () => { + delView(unref(currentRoute)) + push('/bpm/manager/form') +} /** 初始化 **/ onMounted(async () => { diff --git a/src/views/bpm/form/index.vue b/src/views/bpm/form/index.vue index 915bd0bd..48bb3698 100644 --- a/src/views/bpm/form/index.vue +++ b/src/views/bpm/form/index.vue @@ -2,26 +2,33 @@ - 搜索 - 重置 - - 新增 + + + 搜索 + + + + 重置 + + + + 新增 @@ -30,38 +37,38 @@ - - - + + + - + - + -