Skip to content

Commit

Permalink
fix: AI导出表格模板获取表格信息错误的bug
Browse files Browse the repository at this point in the history
  • Loading branch information
pixelmaxQm committed Oct 18, 2024
1 parent e918af0 commit 1753bf9
Showing 1 changed file with 38 additions and 2 deletions.
40 changes: 38 additions & 2 deletions web/src/view/systemTools/exportTemplate/exportTemplate.vue
Original file line number Diff line number Diff line change
Expand Up @@ -249,6 +249,25 @@
</el-select>
</el-form-item>

<el-form-item
label="AI用关联表"
prop="tables"
>
<el-select
multiple
v-model="tables"
clearable
placeholder="关联表使用AI关联的情况下请选择"
>
<el-option
v-for="item in tableOptions"
:key="item.tableName"
:label="item.tableName"
:value="item.tableName"
/>
</el-select>
</el-form-item>

<el-form-item
label="AI帮写:"
prop="ai"
Expand Down Expand Up @@ -488,6 +507,7 @@ const formData = ref({
})
const prompt = ref('')
const tables = ref([])
const typeSearchOptions = ref([
{
Expand Down Expand Up @@ -614,11 +634,26 @@ const dbList = ref([])
const tableOptions = ref([])
const aiLoading = ref(false)
const getTablesCloumn = async() => {
const tablesMap = {}
const promises = tables.value.map(async item => {
const res = await getColumn({
businessDB: formData.value.dbName,
tableName: item
})
if(res.code === 0) {
tablesMap[item] = res.data.columns
}
})
await Promise.all(promises)
return tablesMap
}
const autoExport = async () => {
aiLoading.value = true
const tables = tableOptions.value.map(item => item.tableName)
const aiRes = await butler({prompt:prompt.value,businessDB: formData.value.dbName||"",tables:tables,command:'autoExportTemplate'})
const tableMap = await getTablesCloumn()
const aiRes = await butler({prompt:prompt.value,businessDB: formData.value.dbName||"",tableMap:tableMap,command:'autoExportTemplate'})
aiLoading.value = false
if (aiRes.code === 0) {
const aiData = JSON.parse(aiRes.data)
Expand All @@ -643,6 +678,7 @@ getDbFunc()
const dbNameChange = () => {
formData.value.tableName = ''
formData.value.templateInfo = ''
tables.value = []
getTableFunc()
}
Expand Down

0 comments on commit 1753bf9

Please sign in to comment.