2023-02-11 00:44:00 +08:00
|
|
|
<template>
|
2023-03-27 14:06:30 +08:00
|
|
|
<content-wrap v-loading="loading">
|
|
|
|
<el-tabs v-model="activeName">
|
|
|
|
<el-tab-pane label="基本信息" name="basicInfo">
|
|
|
|
<basic-info-form ref="basicInfoRef" :table="formData.table" />
|
|
|
|
</el-tab-pane>
|
|
|
|
<el-tab-pane label="字段信息" name="colum">
|
|
|
|
<colum-info-form ref="columInfoRef" :columns="formData.columns" />
|
|
|
|
</el-tab-pane>
|
|
|
|
<el-tab-pane label="生成信息" name="generateInfo">
|
|
|
|
<generate-info-form ref="generateInfoRef" :table="formData.table" />
|
|
|
|
</el-tab-pane>
|
|
|
|
</el-tabs>
|
|
|
|
<el-form label-width="100px">
|
|
|
|
<el-form-item style="text-align: center; margin-left: -100px; margin-top: 10px">
|
|
|
|
<el-button type="primary" @click="submitForm" :loading="submitLoading">
|
|
|
|
{{ t('action.save') }}
|
|
|
|
</el-button>
|
2023-03-29 09:09:34 +08:00
|
|
|
<el-button @click="close">返回</el-button>
|
2023-03-27 14:06:30 +08:00
|
|
|
</el-form-item>
|
|
|
|
</el-form>
|
|
|
|
</content-wrap>
|
2023-02-11 00:44:00 +08:00
|
|
|
</template>
|
|
|
|
<script setup lang="ts">
|
2023-03-27 14:06:30 +08:00
|
|
|
import { BasicInfoForm, ColumInfoForm, GenerateInfoForm } from './components'
|
|
|
|
import * as CodegenApi from '@/api/infra/codegen'
|
|
|
|
import ContentWrap from '@/components/ContentWrap/src/ContentWrap.vue'
|
|
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
|
import { CodegenUpdateReqVO } from '@/api/infra/codegen/types'
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
const message = useMessage() // 消息弹窗
|
2023-03-27 14:06:30 +08:00
|
|
|
const { push, currentRoute } = useRouter()
|
2023-02-11 00:44:00 +08:00
|
|
|
const { query } = useRoute()
|
2023-03-27 14:06:30 +08:00
|
|
|
const { delView } = useTagsViewStore()
|
2023-02-11 00:44:00 +08:00
|
|
|
const loading = ref(false)
|
2023-03-27 14:06:30 +08:00
|
|
|
const submitLoading = ref(false)
|
2023-02-11 00:44:00 +08:00
|
|
|
const activeName = ref('basicInfo')
|
|
|
|
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
|
2023-03-27 14:06:30 +08:00
|
|
|
const columInfoRef = ref<ComponentRef<typeof ColumInfoForm>>()
|
|
|
|
const generateInfoRef = ref<ComponentRef<typeof GenerateInfoForm>>()
|
|
|
|
const formData = ref<CodegenUpdateReqVO>({
|
|
|
|
table: {},
|
|
|
|
columns: []
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
2023-03-27 14:06:30 +08:00
|
|
|
const getDetail = async () => {
|
2023-02-11 00:44:00 +08:00
|
|
|
const id = query.id as unknown as number
|
|
|
|
if (id) {
|
2023-03-27 14:06:30 +08:00
|
|
|
loading.value = true
|
2023-02-11 00:44:00 +08:00
|
|
|
// 获取表详细信息
|
2023-03-27 14:06:30 +08:00
|
|
|
formData.value = await CodegenApi.getCodegenTable(id)
|
|
|
|
loading.value = false
|
2023-02-11 00:44:00 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
const submitForm = async () => {
|
2023-03-27 14:06:30 +08:00
|
|
|
if (!unref(formData)) return
|
|
|
|
try {
|
|
|
|
await unref(basicInfoRef)?.validate()
|
|
|
|
await unref(generateInfoRef)?.validate()
|
|
|
|
await CodegenApi.updateCodegenTable(unref(formData))
|
2023-02-11 00:44:00 +08:00
|
|
|
message.success(t('common.updateSuccess'))
|
|
|
|
push('/infra/codegen')
|
2023-03-27 14:06:30 +08:00
|
|
|
} catch {}
|
|
|
|
}
|
|
|
|
/** 关闭按钮 */
|
|
|
|
const close = () => {
|
|
|
|
delView(unref(currentRoute))
|
|
|
|
push('/infra/codegen')
|
2023-02-11 00:44:00 +08:00
|
|
|
}
|
|
|
|
onMounted(() => {
|
2023-03-27 14:06:30 +08:00
|
|
|
getDetail()
|
2023-02-11 00:44:00 +08:00
|
|
|
})
|
|
|
|
</script>
|