refactor: codegen

This commit is contained in:
xingyu4j
2022-11-23 13:59:13 +08:00
parent b1a2dfb09b
commit 7ff6db9ac7
8 changed files with 227 additions and 281 deletions

View File

@@ -1,13 +1,34 @@
<template>
<ContentDetailWrap title="代码生成" @back="push('/infra/codegen')">
<el-tabs v-model="activeName">
<el-tab-pane label="基本信息" name="basicInfo">
<BasicInfoForm ref="basicInfoRef" :basicInfo="tableCurrentRow" />
</el-tab-pane>
<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 type="primary" :title="t('action.save')" :loading="loading" @click="submitForm()" />
</template>
</ContentDetailWrap>
</template>
<script setup lang="ts">
import { ref, unref, onMounted } from 'vue'
import { useRouter, useRoute } from 'vue-router'
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 { ElTabs, ElTabPane, ElMessage } from 'element-plus'
import { getCodegenTableApi, updateCodegenTableApi } from '@/api/infra/codegen'
import { useRouter, useRoute } from 'vue-router'
import { useI18n } from '@/hooks/web/useI18n'
import { CodegenTableVO, CodegenColumnVO, CodegenUpdateReqVO } from '@/api/infra/codegen/types'
const { t } = useI18n()
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const { push } = useRouter()
const { query } = useRoute()
const tableCurrentRow = ref<CodegenTableVO>()
@@ -26,10 +47,6 @@ const activeName = ref('cloum')
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
const genInfoRef = ref<ComponentRef<typeof GenInfoForm>>()
const cloumInfoRef = ref(null)
const parentMenuId = ref<number>()
const menu = (id: number) => {
parentMenuId.value = id
}
const submitForm = async () => {
const basicInfo = unref(basicInfoRef)
const genInfo = unref(genInfoRef)
@@ -38,17 +55,12 @@ const submitForm = async () => {
if (basicForm && genForm) {
const basicInfoData = (await basicInfo?.getFormData()) as CodegenTableVO
const genInfoData = (await genInfo?.getFormData()) as CodegenTableVO
if (parentMenuId.value) {
genInfoData.parentMenuId = parentMenuId.value
} else {
genInfoData.parentMenuId = 0
}
const genTable: CodegenUpdateReqVO = {
table: Object.assign({}, basicInfoData, genInfoData),
columns: cloumCurrentRow.value
}
await updateCodegenTableApi(genTable)
ElMessage.success(t('common.updateSuccess'))
message.success(t('common.updateSuccess'))
push('/infra/codegen')
}
}
@@ -56,21 +68,3 @@ onMounted(() => {
getList()
})
</script>
<template>
<ContentDetailWrap title="代码生成" @back="push('/infra/codegen')">
<el-tabs v-model="activeName">
<el-tab-pane label="基本信息" name="basicInfo">
<BasicInfoForm ref="basicInfoRef" :basicInfo="tableCurrentRow" />
</el-tab-pane>
<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" @menu="menu" />
</el-tab-pane>
</el-tabs>
<template #right>
<XButton type="primary" :title="t('action.save')" :loading="loading" @click="submitForm()" />
</template>
</ContentDetailWrap>
</template>