refactor: 处理接口传入和手动输入的参数
Some checks are pending
sync2gitee / repo-sync (push) Waiting to run
Typos Check / Spell Check with Typos (push) Waiting to run

This commit is contained in:
CaptainB 2024-09-13 13:40:43 +08:00 committed by 刘瑞斌
parent 7096075fff
commit 22d08252c8

View File

@ -259,6 +259,7 @@ const inputValue = ref('')
const chartOpenId = ref('')
const chatList = ref<any[]>([])
const inputFieldList = ref<FormField[]>([])
const apiInputFieldList = ref<any[]>([])
const form_data = ref<any>({})
const isDisabledChart = computed(
@ -317,7 +318,7 @@ function handleInputFieldList() {
?.filter((v: any) => v.id === 'base-node')
.map((v: any) => {
inputFieldList.value = v.properties.input_field_list
? v.properties.input_field_list.map((v: any) => {
? v.properties.input_field_list.filter((v: any) => v.assignment_method === 'user_input').map((v: any) => {
switch (v.type) {
case 'input':
return {
@ -353,6 +354,15 @@ function handleInputFieldList() {
}
})
: []
apiInputFieldList.value = v.properties.input_field_list
? v.properties.input_field_list.filter((v: any) => v.assignment_method === 'api_input').map((v: any) => {
return {
field: v.variable,
label: v.name,
required: v.is_required
}
})
: []
})
}
@ -566,6 +576,14 @@ const errorWrite = (chat: any, message?: string) => {
}
function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
// query
for (let f of apiInputFieldList.value) {
if (f.required && !route.query[f.field]) {
MsgWarning(`请在接入的URL补全必填参数${f.field}`)
return
}
form_data.value[f.field] = route.query[f.field]
}
loading.value = true
if (!chat) {
chat = reactive({