Skip to content

Commit d5f3f0a

Browse files
committed
REVIEW 代码生成
1 parent 76c5c7c commit d5f3f0a

File tree

2 files changed

+31
-115
lines changed

2 files changed

+31
-115
lines changed

src/views/infra/codegen/EditTable.vue

Lines changed: 31 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<template>
2-
<content-wrap v-loading="loading">
2+
<content-wrap v-loading="formLoading">
33
<el-tabs v-model="activeName">
44
<el-tab-pane label="基本信息" name="basicInfo">
55
<basic-info-form ref="basicInfoRef" :table="formData.table" />
@@ -11,63 +11,69 @@
1111
<generate-info-form ref="generateInfoRef" :table="formData.table" />
1212
</el-tab-pane>
1313
</el-tabs>
14-
<el-form label-width="100px">
15-
<el-form-item style="text-align: center; margin-left: -100px; margin-top: 10px">
16-
<el-button type="primary" @click="submitForm" :loading="submitLoading">
17-
{{ t('action.save') }}
18-
</el-button>
14+
<el-form>
15+
<el-form-item style="float: right">
16+
<el-button type="primary" @click="submitForm" :loading="formLoading">保存</el-button>
1917
<el-button @click="close">返回</el-button>
2018
</el-form-item>
2119
</el-form>
2220
</content-wrap>
2321
</template>
2422
<script setup lang="ts">
23+
import { useTagsViewStore } from '@/store/modules/tagsView'
2524
import { BasicInfoForm, ColumInfoForm, GenerateInfoForm } from './components'
2625
import * as CodegenApi from '@/api/infra/codegen'
27-
import ContentWrap from '@/components/ContentWrap/src/ContentWrap.vue'
28-
import { useTagsViewStore } from '@/store/modules/tagsView'
29-
import { CodegenUpdateReqVO } from '@/api/infra/codegen/types'
30-
3126
const { t } = useI18n() // 国际化
3227
const message = useMessage() // 消息弹窗
33-
const { push, currentRoute } = useRouter()
34-
const { query } = useRoute()
35-
const { delView } = useTagsViewStore()
36-
const loading = ref(false)
37-
const submitLoading = ref(false)
38-
const activeName = ref('basicInfo')
28+
const { push, currentRoute } = useRouter() // 路由
29+
const { query } = useRoute() // 查询参数
30+
const { delView } = useTagsViewStore() // 视图操作
31+
32+
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
33+
const activeName = ref('basicInfo') // Tag 激活的窗口
3934
const basicInfoRef = ref<ComponentRef<typeof BasicInfoForm>>()
4035
const columInfoRef = ref<ComponentRef<typeof ColumInfoForm>>()
4136
const generateInfoRef = ref<ComponentRef<typeof GenerateInfoForm>>()
42-
const formData = ref<CodegenUpdateReqVO>({
37+
const formData = ref<CodegenApi.CodegenUpdateReqVO>({
4338
table: {},
4439
columns: []
4540
})
4641
42+
/** 获得详情 */
4743
const getDetail = async () => {
4844
const id = query.id as unknown as number
49-
if (id) {
50-
loading.value = true
51-
// 获取表详细信息
45+
if (!id) {
46+
return
47+
}
48+
formLoading.value = true
49+
try {
5250
formData.value = await CodegenApi.getCodegenTable(id)
53-
loading.value = false
51+
} finally {
52+
formLoading.value = false
5453
}
5554
}
55+
56+
/** 提交按钮 */
5657
const submitForm = async () => {
58+
// 参数校验
5759
if (!unref(formData)) return
60+
await unref(basicInfoRef)?.validate()
61+
await unref(generateInfoRef)?.validate()
5862
try {
59-
await unref(basicInfoRef)?.validate()
60-
await unref(generateInfoRef)?.validate()
61-
await CodegenApi.updateCodegenTable(unref(formData))
63+
// 提交请求
64+
await CodegenApi.updateCodegenTable(formData.value)
6265
message.success(t('common.updateSuccess'))
63-
push('/infra/codegen')
66+
close()
6467
} catch {}
6568
}
69+
6670
/** 关闭按钮 */
6771
const close = () => {
6872
delView(unref(currentRoute))
6973
push('/infra/codegen')
7074
}
75+
76+
/** 初始化 */
7177
onMounted(() => {
7278
getDetail()
7379
})

src/views/infra/config/config.data.ts

Lines changed: 0 additions & 90 deletions
This file was deleted.

0 commit comments

Comments
 (0)