Skip to content

Commit 1753bf9

Browse files
committed
fix: AI导出表格模板获取表格信息错误的bug
1 parent e918af0 commit 1753bf9

File tree

1 file changed

+38
-2
lines changed

1 file changed

+38
-2
lines changed

web/src/view/systemTools/exportTemplate/exportTemplate.vue

Lines changed: 38 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,25 @@
249249
</el-select>
250250
</el-form-item>
251251

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+
252271
<el-form-item
253272
label="AI帮写:"
254273
prop="ai"
@@ -488,6 +507,7 @@ const formData = ref({
488507
})
489508
490509
const prompt = ref('')
510+
const tables = ref([])
491511
492512
const typeSearchOptions = ref([
493513
{
@@ -614,11 +634,26 @@ const dbList = ref([])
614634
const tableOptions = ref([])
615635
const aiLoading = ref(false)
616636
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+
617652
618653
const autoExport = async () => {
619654
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'})
622657
aiLoading.value = false
623658
if (aiRes.code === 0) {
624659
const aiData = JSON.parse(aiRes.data)
@@ -643,6 +678,7 @@ getDbFunc()
643678
const dbNameChange = () => {
644679
formData.value.tableName = ''
645680
formData.value.templateInfo = ''
681+
tables.value = []
646682
getTableFunc()
647683
}
648684

0 commit comments

Comments
 (0)