perf: 重构代码生成 优化性能

This commit is contained in:
xingyu
2023-01-13 23:58:14 +08:00
parent 258577e86a
commit 4941a43e08
5 changed files with 187 additions and 230 deletions

View File

@@ -8,9 +8,6 @@
<el-tab-pane label="字段信息" name="cloum">
<CloumInfoForm ref="cloumInfoRef" :info="cloumCurrentRow" />
</el-tab-pane>
<el-tab-pane label="生成信息" name="genInfo">
<GenInfoForm ref="genInfoRef" :genInfo="tableCurrentRow" />
</el-tab-pane>
</el-tabs>
<template #right>
<XButton
@@ -30,7 +27,7 @@ import { ElTabs, ElTabPane } from 'element-plus'
import { useI18n } from '@/hooks/web/useI18n'
import { useMessage } from '@/hooks/web/useMessage'
import { ContentDetailWrap } from '@/components/ContentDetailWrap'
import { BasicInfoForm, CloumInfoForm, GenInfoForm } from './components'
import { BasicInfoForm, CloumInfoForm } from './components'
import { getCodegenTableApi, updateCodegenTableApi } from '@/api/infra/codegen'
import { CodegenTableVO, CodegenColumnVO, CodegenUpdateReqVO } from '@/api/infra/codegen/types'
@@ -40,12 +37,11 @@ const { push } = useRouter()
const { query } = useRoute()
const loading = ref(false)
const title = ref('代码生成')
const activeName = ref('cloum')
const activeName = ref('basicInfo')
const cloumInfoRef = ref(null)
const tableCurrentRow = ref<CodegenTableVO>()
const cloumCurrentRow = ref<CodegenColumnVO[]>([])
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
const genInfoRef = ref<ComponentRef<typeof GenInfoForm>>()
const getList = async () => {
const id = query.id as unknown as number
@@ -59,14 +55,11 @@ const getList = async () => {
}
const submitForm = async () => {
const basicInfo = unref(basicInfoRef)
const genInfo = unref(genInfoRef)
const basicForm = await basicInfo?.elFormRef?.validate()?.catch(() => {})
const genForm = await genInfo?.elFormRef?.validate()?.catch(() => {})
if (basicForm && genForm) {
if (basicForm) {
const basicInfoData = (await basicInfo?.getFormData()) as CodegenTableVO
const genInfoData = (await genInfo?.getFormData()) as CodegenTableVO
const genTable: CodegenUpdateReqVO = {
table: Object.assign({}, basicInfoData, genInfoData),
table: basicInfoData,
columns: cloumCurrentRow.value
}
await updateCodegenTableApi(genTable)