249
249
</el-select >
250
250
</el-form-item >
251
251
252
+ <el-form-item
253
+ label =" AI用关联表"
254
+ prop =" tables"
255
+ >
256
+ <el-select
257
+ multiple
258
+ v-model =" tables"
259
+ clearable
260
+ placeholder =" 关联表使用AI关联的情况下请选择"
261
+ >
262
+ <el-option
263
+ v-for =" item in tableOptions"
264
+ :key =" item.tableName"
265
+ :label =" item.tableName"
266
+ :value =" item.tableName"
267
+ />
268
+ </el-select >
269
+ </el-form-item >
270
+
252
271
<el-form-item
253
272
label =" AI帮写:"
254
273
prop =" ai"
@@ -488,6 +507,7 @@ const formData = ref({
488
507
})
489
508
490
509
const prompt = ref (' ' )
510
+ const tables = ref ([])
491
511
492
512
const typeSearchOptions = ref ([
493
513
{
@@ -614,11 +634,26 @@ const dbList = ref([])
614
634
const tableOptions = ref ([])
615
635
const aiLoading = ref (false )
616
636
637
+ const getTablesCloumn = async () => {
638
+ const tablesMap = {}
639
+ const promises = tables .value .map (async item => {
640
+ const res = await getColumn ({
641
+ businessDB: formData .value .dbName ,
642
+ tableName: item
643
+ })
644
+ if (res .code === 0 ) {
645
+ tablesMap[item] = res .data .columns
646
+ }
647
+ })
648
+ await Promise .all (promises)
649
+ return tablesMap
650
+ }
651
+
617
652
618
653
const autoExport = async () => {
619
654
aiLoading .value = true
620
- const tables = tableOptions . value . map ( item => item . tableName )
621
- const aiRes = await butler ({prompt: prompt .value ,businessDB: formData .value .dbName || " " ,tables : tables ,command: ' autoExportTemplate' })
655
+ const tableMap = await getTablesCloumn ( )
656
+ const aiRes = await butler ({prompt: prompt .value ,businessDB: formData .value .dbName || " " ,tableMap : tableMap ,command: ' autoExportTemplate' })
622
657
aiLoading .value = false
623
658
if (aiRes .code === 0 ) {
624
659
const aiData = JSON .parse (aiRes .data )
@@ -643,6 +678,7 @@ getDbFunc()
643
678
const dbNameChange = () => {
644
679
formData .value .tableName = ' '
645
680
formData .value .templateInfo = ' '
681
+ tables .value = []
646
682
getTableFunc ()
647
683
}
648
684
0 commit comments