3
3
<el-row >
4
4
<el-col :span =" 12" >
5
5
<el-form-item label =" 生成模板" prop =" templateType" >
6
- <el-select v-model =" formData.templateType" @change = " tplSelectChange " >
6
+ <el-select v-model =" formData.templateType" >
7
7
<el-option
8
8
v-for =" dict in getIntDictOptions(DICT_TYPE.INFRA_CODEGEN_TEMPLATE_TYPE)"
9
9
:key =" dict.value"
246
246
</el-form-item >
247
247
</el-col >
248
248
</el-row >
249
- <el-row v-show =" formData.tplCategory === 'sub'" >
250
- <h4 class =" form-header" >关联信息</h4 >
249
+
250
+ <!-- 主表信息 -->
251
+ <el-row v-if =" formData.templateType === 15" >
252
+ <el-col :span =" 24" >
253
+ <h4 class =" form-header" >主表信息</h4 >
254
+ </el-col >
251
255
<el-col :span =" 12" >
252
- <el-form-item >
256
+ <el-form-item prop = " masterTableId " >
253
257
<template #label >
254
258
<span >
255
- 关联子表的表名
256
- <el-tooltip content =" 关联子表的表名 , 如:sys_user " placement =" top" >
259
+ 关联的主表
260
+ <el-tooltip content =" 关联主表(父表)的表名 , 如:system_user " placement =" top" >
257
261
<Icon icon =" ep:question-filled" />
258
262
</el-tooltip >
259
263
</span >
260
264
</template >
261
- <el-select v-model =" formData.subTableName " placeholder =" 请选择" @change = " subSelectChange " >
265
+ <el-select v-model =" formData.masterTableId " placeholder =" 请选择" >
262
266
<el-option
263
267
v-for =" (table0, index) in tables"
264
268
:key =" index"
265
269
:label =" table0.tableName + ':' + table0.tableComment"
266
- :value =" table0.tableName "
270
+ :value =" table0.id "
267
271
/>
268
272
</el-select >
269
273
</el-form-item >
270
274
</el-col >
271
275
<el-col :span =" 12" >
272
- <el-form-item >
276
+ <el-form-item prop = " subJoinColumnId " >
273
277
<template #label >
274
278
<span >
275
- 子表关联的外键名
276
- <el-tooltip content =" 子表关联的外键名 , 如:user_id" placement =" top" >
279
+ 子表关联的字段
280
+ <el-tooltip content =" 子表关联的字段 , 如:user_id" placement =" top" >
277
281
<Icon icon =" ep:question-filled" />
278
282
</el-tooltip >
279
283
</span >
280
284
</template >
281
- <el-select v-model =" formData.subTableFkName " placeholder =" 请选择" >
285
+ <el-select v-model =" formData.subJoinColumnId " placeholder =" 请选择" >
282
286
<el-option
283
- v-for =" (column, index) in subColumns "
287
+ v-for =" (column, index) in props.columns "
284
288
:key =" index"
285
289
:label =" column.columnName + ':' + column.columnComment"
286
- :value =" column.columnName "
290
+ :value =" column.id "
287
291
/>
288
292
</el-select >
289
293
</el-form-item >
290
294
</el-col >
295
+ <el-col :span =" 12" >
296
+ <el-form-item prop =" subJoinMany" >
297
+ <template #label >
298
+ <span >
299
+ 关联关系
300
+ <el-tooltip content =" 主表与子表的关联关系" placement =" top" >
301
+ <Icon icon =" ep:question-filled" />
302
+ </el-tooltip >
303
+ </span >
304
+ </template >
305
+ <el-radio-group v-model =" formData.subJoinMany" placeholder =" 请选择" >
306
+ <el-radio :label =" true" >一对多</el-radio >
307
+ <el-radio :label =" false" >一对一</el-radio >
308
+ </el-radio-group >
309
+ </el-form-item >
310
+ </el-col >
291
311
</el-row >
292
312
</el-form >
293
313
</template >
@@ -305,6 +325,10 @@ const props = defineProps({
305
325
table: {
306
326
type: Object as PropType <Nullable <CodegenApi .CodegenTableVO >>,
307
327
default : () => null
328
+ },
329
+ columns: {
330
+ type: Array as unknown as PropType <CodegenApi .CodegenColumnVO []>,
331
+ default : () => null
308
332
}
309
333
})
310
334
@@ -323,9 +347,10 @@ const formData = ref({
323
347
treeParentCode: ' ' ,
324
348
treeName: ' ' ,
325
349
tplCategory: ' ' ,
326
- subTableName: ' ' ,
327
- subTableFkName: ' ' ,
328
- genType: ' '
350
+ genType: ' ' ,
351
+ masterTableId: undefined ,
352
+ subJoinColumnId: undefined ,
353
+ subJoinMany: undefined
329
354
})
330
355
331
356
const rules = reactive ({
@@ -336,41 +361,27 @@ const rules = reactive({
336
361
businessName: [required ],
337
362
businessPackage: [required ],
338
363
className: [required ],
339
- classComment: [required ]
364
+ classComment: [required ],
365
+ masterTableId: [required ],
366
+ subJoinColumnId: [required ],
367
+ subJoinMany: [required ]
340
368
})
341
369
342
- const tables = ref ([])
343
- const subColumns = ref ([])
370
+ const tables = ref ([]) // 表定义列表
344
371
const menus = ref <any []>([])
345
372
const menuTreeProps = {
346
373
label: ' name'
347
374
}
348
375
349
- /** 选择子表名触发 */
350
- const subSelectChange = () => {
351
- formData .value .subTableFkName = ' '
352
- }
353
-
354
- /** 选择生成模板触发 */
355
- const tplSelectChange = (value ) => {
356
- if (value !== 1 ) {
357
- // TODO 芋艿:暂时不考虑支持树形结构
358
- message .error (
359
- ' 暂时不考虑支持【树形】和【主子表】的代码生成。原因是:导致 vm 模板过于复杂,不利于胖友二次开发'
360
- )
361
- return false
362
- }
363
- if (value !== ' sub' ) {
364
- formData .value .subTableName = ' '
365
- formData .value .subTableFkName = ' '
366
- }
367
- }
368
-
369
376
watch (
370
377
() => props .table ,
371
- (table ) => {
378
+ async (table ) => {
372
379
if (! table ) return
373
380
formData .value = table as any
381
+ // 加载表列表
382
+ if (table .dataSourceConfigId >= 0 ) {
383
+ tables .value = await CodegenApi .getCodegenTableList (formData .value .dataSourceConfigId )
384
+ }
374
385
},
375
386
{
376
387
deep: true ,
@@ -380,6 +391,7 @@ watch(
380
391
381
392
onMounted (async () => {
382
393
try {
394
+ // 加载菜单
383
395
const resp = await MenuApi .getSimpleMenusList ()
384
396
menus .value = handleTree (resp )
385
397
} catch {}
0 commit comments