2023-02-11 00:44:00 +08:00
|
|
|
|
<template>
|
2023-04-05 20:13:35 +08:00
|
|
|
|
<ContentWrap v-loading="formLoading">
|
2023-03-27 14:06:30 +08:00
|
|
|
|
<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>
|
2023-03-29 13:57:16 +08:00
|
|
|
|
<el-form>
|
|
|
|
|
<el-form-item style="float: right">
|
2023-04-14 21:32:11 +08:00
|
|
|
|
<el-button :loading="formLoading" type="primary" @click="submitForm">保存</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>
|
2023-04-05 20:13:35 +08:00
|
|
|
|
</ContentWrap>
|
2023-02-11 00:44:00 +08:00
|
|
|
|
</template>
|
2023-06-21 19:14:34 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-03-29 13:57:16 +08:00
|
|
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
2023-03-27 14:06:30 +08:00
|
|
|
|
import { BasicInfoForm, ColumInfoForm, GenerateInfoForm } from './components'
|
|
|
|
|
import * as CodegenApi from '@/api/infra/codegen'
|
2023-04-14 21:32:11 +08:00
|
|
|
|
|
2023-06-21 19:14:34 +08:00
|
|
|
|
defineOptions({ name: 'InfraCodegenEditTable' })
|
|
|
|
|
|
2023-02-11 00:44:00 +08:00
|
|
|
|
const { t } = useI18n() // 国际化
|
|
|
|
|
const message = useMessage() // 消息弹窗
|
2023-03-29 13:57:16 +08:00
|
|
|
|
const { push, currentRoute } = useRouter() // 路由
|
|
|
|
|
const { query } = useRoute() // 查询参数
|
|
|
|
|
const { delView } = useTagsViewStore() // 视图操作
|
|
|
|
|
|
|
|
|
|
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
|
2023-04-13 07:54:37 +08:00
|
|
|
|
const activeName = ref('colum') // Tag 激活的窗口
|
2023-02-11 00:44:00 +08:00
|
|
|
|
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>>()
|
2023-03-29 13:57:16 +08:00
|
|
|
|
const formData = ref<CodegenApi.CodegenUpdateReqVO>({
|
2023-03-27 14:06:30 +08:00
|
|
|
|
table: {},
|
|
|
|
|
columns: []
|
|
|
|
|
})
|
2023-02-11 00:44:00 +08:00
|
|
|
|
|
2023-03-29 13:57:16 +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
|
2023-03-29 13:57:16 +08:00
|
|
|
|
if (!id) {
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
formLoading.value = true
|
|
|
|
|
try {
|
2023-03-27 14:06:30 +08:00
|
|
|
|
formData.value = await CodegenApi.getCodegenTable(id)
|
2023-03-29 13:57:16 +08:00
|
|
|
|
} finally {
|
|
|
|
|
formLoading.value = false
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-03-29 13:57:16 +08:00
|
|
|
|
|
|
|
|
|
/** 提交按钮 */
|
2023-02-11 00:44:00 +08:00
|
|
|
|
const submitForm = async () => {
|
2023-03-29 13:57:16 +08:00
|
|
|
|
// 参数校验
|
2023-03-27 14:06:30 +08:00
|
|
|
|
if (!unref(formData)) return
|
2023-03-29 13:57:16 +08:00
|
|
|
|
await unref(basicInfoRef)?.validate()
|
|
|
|
|
await unref(generateInfoRef)?.validate()
|
2023-03-27 14:06:30 +08:00
|
|
|
|
try {
|
2023-03-29 13:57:16 +08:00
|
|
|
|
// 提交请求
|
|
|
|
|
await CodegenApi.updateCodegenTable(formData.value)
|
2023-02-11 00:44:00 +08:00
|
|
|
|
message.success(t('common.updateSuccess'))
|
2023-03-29 13:57:16 +08:00
|
|
|
|
close()
|
2023-03-27 14:06:30 +08:00
|
|
|
|
} catch {}
|
|
|
|
|
}
|
2023-03-29 13:57:16 +08:00
|
|
|
|
|
2023-03-27 14:06:30 +08:00
|
|
|
|
/** 关闭按钮 */
|
|
|
|
|
const close = () => {
|
|
|
|
|
delView(unref(currentRoute))
|
|
|
|
|
push('/infra/codegen')
|
2023-02-11 00:44:00 +08:00
|
|
|
|
}
|
2023-03-29 13:57:16 +08:00
|
|
|
|
|
|
|
|
|
/** 初始化 */
|
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>
|