update: 发布dev2.7.6Beta版本 (#1908)
* feat: 优化菜单管理的路径选择框 * fixed: 修复错误的文件命名 * feat: 增加参数管理功能,调整菜单选择组件。 * feat: 恢复config.yaml * feat: 更新AI功能 * feat: 增加API自动填充功能 * feat: 增加AI自动填充表格导出模板 * feat: 增加AI自动填充表格导出模板和AI自动模板填充 * feat: 新增方法支持选择是否鉴权 --------- Co-authored-by: Azir <2075125282@qq.com>
This commit is contained in:
@@ -211,6 +211,8 @@
|
||||
label-position="right"
|
||||
:rules="rule"
|
||||
label-width="100px"
|
||||
v-loading="aiLoading"
|
||||
element-loading-text="小淼正在思考..."
|
||||
>
|
||||
|
||||
<el-form-item
|
||||
@@ -248,25 +250,30 @@
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="模板名称:"
|
||||
prop="name"
|
||||
label="AI帮写:"
|
||||
prop="ai"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
:clearable="true"
|
||||
placeholder="请输入模板名称"
|
||||
/>
|
||||
<div class="relative w-full">
|
||||
<el-input
|
||||
type="textarea"
|
||||
v-model="prompt"
|
||||
:clearable="true"
|
||||
:rows="5"
|
||||
placeholder="试试描述你要做的导出功能让AI帮你完成,在此之前请选择你需要导出的表所在的业务库,如不做选择,则默认使用gva库"
|
||||
/>
|
||||
<el-button
|
||||
class="absolute bottom-2 right-2"
|
||||
type="primary"
|
||||
@click="autoExport"
|
||||
><el-icon><ai-gva /></el-icon>帮写</el-button>
|
||||
</div>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="表名称:"
|
||||
clearable
|
||||
prop="tableName"
|
||||
label="表名称:"
|
||||
clearable
|
||||
prop="tableName"
|
||||
>
|
||||
<!-- <el-input
|
||||
v-model="formData.tableName"
|
||||
:clearable="true"
|
||||
placeholder="请输入要导出的表名称"
|
||||
/>-->
|
||||
<div
|
||||
class="w-full flex gap-4"
|
||||
>
|
||||
@@ -283,11 +290,22 @@
|
||||
:value="item.tableName"
|
||||
/>
|
||||
</el-select>
|
||||
|
||||
<el-button type="primary" @click="getColumnFunc">自动生成模板</el-button>
|
||||
<el-button :disabled="!formData.tableName" type="primary" @click="getColumnFunc(true)"><el-icon><ai-gva/></el-icon>自动补全</el-button>
|
||||
<el-button :disabled="!formData.tableName" type="primary" @click="getColumnFunc(false)">自动生成模板</el-button>
|
||||
</div>
|
||||
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="模板名称:"
|
||||
prop="name"
|
||||
>
|
||||
<el-input
|
||||
v-model="formData.name"
|
||||
:clearable="true"
|
||||
placeholder="请输入模板名称"
|
||||
/>
|
||||
</el-form-item>
|
||||
|
||||
<el-form-item
|
||||
label="模板标识:"
|
||||
prop="templateID"
|
||||
@@ -438,7 +456,7 @@ import { formatDate } from '@/utils/format'
|
||||
import { ElMessage, ElMessageBox } from 'element-plus'
|
||||
import { ref, reactive } from 'vue'
|
||||
import WarningBar from '@/components/warningBar/warningBar.vue'
|
||||
import {getDB, getTable, getColumn} from '@/api/autoCode'
|
||||
import {getDB, getTable, getColumn, butler} from '@/api/autoCode'
|
||||
|
||||
defineOptions({
|
||||
name: 'ExportTemplate'
|
||||
@@ -469,6 +487,8 @@ const formData = ref({
|
||||
joinTemplate: []
|
||||
})
|
||||
|
||||
const prompt = ref('')
|
||||
|
||||
const typeSearchOptions = ref([
|
||||
{
|
||||
label: '=',
|
||||
@@ -592,6 +612,24 @@ const searchInfo = ref({})
|
||||
|
||||
const dbList = ref([])
|
||||
const tableOptions = ref([])
|
||||
const aiLoading = ref(false)
|
||||
|
||||
|
||||
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'})
|
||||
aiLoading.value = false
|
||||
if (aiRes.code === 0) {
|
||||
const aiData = JSON.parse(aiRes.data)
|
||||
formData.value.name = aiData.name
|
||||
formData.value.tableName = aiData.tableName
|
||||
formData.value.templateID = aiData.templateID
|
||||
formData.value.templateInfo = JSON.stringify(aiData.templateInfo, null, 2)
|
||||
formData.value.joinTemplate = aiData.joinTemplate
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
const getDbFunc = async() => {
|
||||
const res = await getDB()
|
||||
@@ -616,8 +654,7 @@ const getTableFunc = async() => {
|
||||
formData.value.tableName = ''
|
||||
}
|
||||
getTableFunc()
|
||||
|
||||
const getColumnFunc = async () => {
|
||||
const getColumnFunc = async (aiFLag) => {
|
||||
if(!formData.value.tableName) {
|
||||
ElMessage({
|
||||
type: 'error',
|
||||
@@ -626,11 +663,26 @@ const getColumnFunc = async () => {
|
||||
return
|
||||
}
|
||||
formData.value.templateInfo = ""
|
||||
aiLoading.value = true
|
||||
const res = await getColumn({
|
||||
businessDB: formData.value.dbName,
|
||||
tableName: formData.value.tableName
|
||||
})
|
||||
if(res.code === 0) {
|
||||
if(aiFLag){
|
||||
const aiRes = await butler({data:res.data.columns,command:'exportCompletion'})
|
||||
if (aiRes.code === 0) {
|
||||
const aiData = JSON.parse(aiRes.data)
|
||||
aiLoading.value = false
|
||||
formData.value.templateInfo = JSON.stringify(aiData.templateInfo, null, 2)
|
||||
formData.value.name = aiData.name
|
||||
formData.value.templateID = aiData.templateID
|
||||
return
|
||||
}
|
||||
ElMessage.warning('AI自动补全失败,已调整为逻辑填写')
|
||||
}
|
||||
|
||||
|
||||
// 把返回值的data.columns做尊换,制作一组JSON数据,columnName做key,columnComment做value
|
||||
const templateInfo = {}
|
||||
res.data.columns.forEach(item => {
|
||||
@@ -638,6 +690,7 @@ const getColumnFunc = async () => {
|
||||
})
|
||||
formData.value.templateInfo = JSON.stringify(templateInfo, null, 2)
|
||||
}
|
||||
aiLoading.value = false
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user