Skip to content

Commit 98afdfc

Browse files
committed
REVIEW 代码生成
1 parent e6dac1e commit 98afdfc

File tree

5 files changed

+29
-47
lines changed

5 files changed

+29
-47
lines changed

src/api/system/dict/dict.type.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ export type DictTypeVO = {
1010
}
1111

1212
// 查询字典(精简)列表
13-
export const listSimpleDictType = () => {
13+
export const getSimpleDictTypeList = () => {
1414
return request.get({ url: '/system/dict-type/list-all-simple' })
1515
}
1616

src/views/infra/codegen/components/BasicInfoForm.vue

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
<el-input placeholder="请输入" v-model="formData.tableComment" />
1212
</el-form-item>
1313
</el-col>
14-
1514
<el-col :span="12">
1615
<el-form-item prop="className">
1716
<template #label>
@@ -25,7 +24,6 @@
2524
</el-tooltip>
2625
</span>
2726
</template>
28-
2927
<el-input placeholder="请输入" v-model="formData.className" />
3028
</el-form-item>
3129
</el-col>
@@ -43,13 +41,12 @@
4341
</el-form>
4442
</template>
4543
<script setup lang="ts">
46-
import { CodegenTableVO } from '@/api/infra/codegen/types'
44+
import * as CodegenApi from '@/api/infra/codegen'
4745
import { PropType } from 'vue'
4846
49-
const emits = defineEmits(['update:basicInfo'])
5047
const props = defineProps({
5148
table: {
52-
type: Object as PropType<Nullable<CodegenTableVO>>,
49+
type: Object as PropType<Nullable<CodegenApi.CodegenTableVO>>,
5350
default: () => null
5451
}
5552
})
@@ -62,14 +59,14 @@ const formData = ref({
6259
author: '',
6360
remark: ''
6461
})
65-
6662
const rules = reactive({
6763
tableName: [required],
6864
tableComment: [required],
6965
className: [required],
7066
author: [required]
7167
})
7268
69+
/** 监听 table 属性,复制给 formData 属性 */
7370
watch(
7471
() => props.table,
7572
(table) => {
@@ -81,12 +78,7 @@ watch(
8178
immediate: true
8279
}
8380
)
84-
watch(
85-
() => formData.value,
86-
(val) => {
87-
emits('update:basicInfo', val)
88-
}
89-
)
81+
9082
defineExpose({
9183
validate: async () => unref(formRef)?.validate()
9284
})

src/views/infra/codegen/components/ColumInfoForm.vue

Lines changed: 10 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,28 +114,24 @@
114114
</template>
115115
<script setup lang="ts">
116116
import { PropType } from 'vue'
117-
import { CodegenColumnVO } from '@/api/infra/codegen/types'
118-
import { DictTypeVO, listSimpleDictType } from '@/api/system/dict/dict.type'
117+
import * as CodegenApi from '@/api/infra/codegen'
118+
import * as DictDataApi from '@/api/system/dict/dict.type'
119119
120-
const emits = defineEmits(['update:columns'])
121120
const props = defineProps({
122121
columns: {
123-
type: Array as unknown as PropType<CodegenColumnVO[]>,
122+
type: Array as unknown as PropType<CodegenApi.CodegenColumnVO[]>,
124123
default: () => null
125124
}
126125
})
127126
128-
const formData = ref<CodegenColumnVO[]>([])
127+
const formData = ref<CodegenApi.CodegenColumnVO[]>([])
129128
const tableHeight = document.documentElement.scrollHeight - 350 + 'px'
130129
131130
/** 查询字典下拉列表 */
132-
const dictOptions = ref<DictTypeVO[]>()
131+
const dictOptions = ref<DictDataApi.DictTypeVO[]>()
133132
const getDictOptions = async () => {
134-
dictOptions.value = await listSimpleDictType()
133+
dictOptions.value = await DictDataApi.getSimpleDictTypeList()
135134
}
136-
onMounted(async () => {
137-
await getDictOptions()
138-
})
139135
140136
watch(
141137
() => props.columns,
@@ -148,10 +144,8 @@ watch(
148144
immediate: true
149145
}
150146
)
151-
watch(
152-
() => formData.value,
153-
(val) => {
154-
emits('update:columns', val)
155-
}
156-
)
147+
148+
onMounted(async () => {
149+
await getDictOptions()
150+
})
157151
</script>

src/views/infra/codegen/components/GenerateInfoForm.vue

Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
<el-form-item prop="templateType" label="生成模板">
66
<el-select v-model="formData.templateType" @change="tplSelectChange">
77
<el-option
8-
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)"
9-
:key="parseInt(dict.value)"
8+
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)"
9+
:key="dict.value"
1010
:label="dict.label"
11-
:value="parseInt(dict.value)"
11+
:value="dict.value"
1212
/>
1313
</el-select>
1414
</el-form-item>
@@ -17,10 +17,10 @@
1717
<el-form-item prop="scene" label="生成场景">
1818
<el-select v-model="formData.scene">
1919
<el-option
20-
v-for="dict in getDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE)"
21-
:key="parseInt(dict.value)"
20+
v-for="dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_SCENE)"
21+
:key="dict.value"
2222
:label="dict.label"
23-
:value="parseInt(dict.value)"
23+
:value="dict.value"
2424
/>
2525
</el-select>
2626
</el-form-item>
@@ -280,17 +280,16 @@
280280
</el-form>
281281
</template>
282282
<script setup lang="ts">
283-
import { CodegenTableVO } from '@/api/infra/codegen/types'
283+
import { getIntDictOptions, DICT_TYPE } from '@/utils/dict'
284+
import { handleTree } from '@/utils/tree'
285+
import * as CodegenApi from '@/api/infra/codegen'
284286
import * as MenuApi from '@/api/system/menu'
285287
import { PropType } from 'vue'
286-
import { getDictOptions, DICT_TYPE } from '@/utils/dict'
287-
import { handleTree } from '@/utils/tree'
288288
289289
const message = useMessage() // 消息弹窗
290-
const emits = defineEmits(['update:basicInfo'])
291290
const props = defineProps({
292291
table: {
293-
type: Object as PropType<Nullable<CodegenTableVO>>,
292+
type: Object as PropType<Nullable<CodegenApi.CodegenTableVO>>,
294293
default: () => null
295294
}
296295
})
@@ -335,6 +334,7 @@ const menuTreeProps = {
335334
const subSelectChange = () => {
336335
formData.value.subTableFkName = ''
337336
}
337+
338338
/** 选择生成模板触发 */
339339
const tplSelectChange = (value) => {
340340
if (value !== 1) {
@@ -361,18 +361,14 @@ watch(
361361
immediate: true
362362
}
363363
)
364-
watch(
365-
() => formData.value,
366-
(val) => {
367-
emits('update:basicInfo', val)
368-
}
369-
)
364+
370365
onMounted(async () => {
371366
try {
372367
const resp = await MenuApi.getSimpleMenusList()
373368
menus.value = handleTree(resp)
374369
} catch {}
375370
})
371+
376372
defineExpose({
377373
validate: async () => unref(formRef)?.validate()
378374
})

src/views/system/dict/data.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ const handleExport = async () => {
190190
191191
/** 查询字典(精简)列表 */
192192
const getDictList = async () => {
193-
dicts.value = await DictTypeApi.listSimpleDictType()
193+
dicts.value = await DictTypeApi.getSimpleDictTypeList()
194194
}
195195
196196
/** 初始化 **/

0 commit comments

Comments
 (0)