refactor: 调试时展示所有的参数,嵌入后仅展示用户输入,接口输入需要写在url上
This commit is contained in:
parent
d1f33d5bd3
commit
398d8b3f19
@ -35,7 +35,7 @@
|
|||||||
</el-card>
|
</el-card>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div v-if="inputFieldList.length > 0">
|
<div v-if="inputFieldList.length > 0 || apiInputFieldList.length > 0">
|
||||||
<div class="avatar">
|
<div class="avatar">
|
||||||
<img v-if="data.avatar" :src="data.avatar" height="30px" />
|
<img v-if="data.avatar" :src="data.avatar" height="30px" />
|
||||||
<LogoIcon v-else height="30px" />
|
<LogoIcon v-else height="30px" />
|
||||||
@ -51,8 +51,9 @@
|
|||||||
ref="dynamicsFormRef"
|
ref="dynamicsFormRef"
|
||||||
/>
|
/>
|
||||||
<DynamicsForm
|
<DynamicsForm
|
||||||
v-model="form_data"
|
v-if="debug"
|
||||||
:model="form_data"
|
v-model="api_form_data"
|
||||||
|
:model="api_form_data"
|
||||||
label-position="left"
|
label-position="left"
|
||||||
require-asterisk-position="right"
|
require-asterisk-position="right"
|
||||||
:render_data="apiInputFieldList"
|
:render_data="apiInputFieldList"
|
||||||
@ -240,7 +241,11 @@ const props = defineProps({
|
|||||||
chatId: {
|
chatId: {
|
||||||
type: String,
|
type: String,
|
||||||
default: ''
|
default: ''
|
||||||
} // 历史记录Id
|
}, // 历史记录Id
|
||||||
|
debug: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false
|
||||||
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
const emit = defineEmits(['refresh', 'scroll'])
|
const emit = defineEmits(['refresh', 'scroll'])
|
||||||
@ -262,6 +267,7 @@ const chatList = ref<any[]>([])
|
|||||||
const inputFieldList = ref<FormField[]>([])
|
const inputFieldList = ref<FormField[]>([])
|
||||||
const apiInputFieldList = ref<FormField[]>([])
|
const apiInputFieldList = ref<FormField[]>([])
|
||||||
const form_data = ref<any>({})
|
const form_data = ref<any>({})
|
||||||
|
const api_form_data = ref<any>({})
|
||||||
|
|
||||||
const isDisabledChart = computed(
|
const isDisabledChart = computed(
|
||||||
() => !(inputValue.value.trim() && (props.appId || props.data?.name))
|
() => !(inputValue.value.trim() && (props.appId || props.data?.name))
|
||||||
@ -431,13 +437,9 @@ function showSource(row: any) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function quickProblemHandle(val: string) {
|
function quickProblemHandle(val: string) {
|
||||||
// 检查inputFieldList是否有未填写的字段
|
if (!checkInputParam()) {
|
||||||
for (let i = 0; i < inputFieldList.value.length; i++) {
|
|
||||||
if (inputFieldList.value[i].required && !form_data.value[inputFieldList.value[i].field]) {
|
|
||||||
MsgWarning('请填写所有必填字段')
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
|
||||||
if (!loading.value && props.data?.name) {
|
if (!loading.value && props.data?.name) {
|
||||||
handleDebounceClick(val)
|
handleDebounceClick(val)
|
||||||
}
|
}
|
||||||
@ -447,14 +449,40 @@ const handleDebounceClick = debounce((val) => {
|
|||||||
chatMessage(null, val)
|
chatMessage(null, val)
|
||||||
}, 200)
|
}, 200)
|
||||||
|
|
||||||
function sendChatHandle(event: any) {
|
function checkInputParam() {
|
||||||
// 检查inputFieldList是否有未填写的字段
|
// 检查inputFieldList是否有未填写的字段
|
||||||
for (let i = 0; i < inputFieldList.value.length; i++) {
|
for (let i = 0; i < inputFieldList.value.length; i++) {
|
||||||
if (inputFieldList.value[i].required && !form_data.value[inputFieldList.value[i].field]) {
|
if (inputFieldList.value[i].required && !form_data.value[inputFieldList.value[i].field]) {
|
||||||
MsgWarning('请填写所有必填字段')
|
MsgWarning('请填写所有必填字段')
|
||||||
return
|
return false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 浏览器query参数找到接口传参
|
||||||
|
let msg = []
|
||||||
|
for (let f of apiInputFieldList.value) {
|
||||||
|
if (!props.debug) {
|
||||||
|
if (f.required && !route.query[f.field]) {
|
||||||
|
msg.push(f.field)
|
||||||
|
}
|
||||||
|
api_form_data.value[f.field] = route.query[f.field]
|
||||||
|
} else {
|
||||||
|
if (f.required && !api_form_data.value[f.field]) {
|
||||||
|
MsgWarning('请填写所有必填字段')
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (msg.length > 0) {
|
||||||
|
MsgWarning(`请在URL中填写参数 ${msg.join('、')}的值`)
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
function sendChatHandle(event: any) {
|
||||||
|
if (!checkInputParam()) {
|
||||||
|
return
|
||||||
|
}
|
||||||
if (!event.ctrlKey) {
|
if (!event.ctrlKey) {
|
||||||
// 如果没有按下组合键ctrl,则会阻止默认事件
|
// 如果没有按下组合键ctrl,则会阻止默认事件
|
||||||
event.preventDefault()
|
event.preventDefault()
|
||||||
@ -616,18 +644,6 @@ const errorWrite = (chat: any, message?: string) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
|
function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
|
||||||
// 浏览器query参数找到接口传参
|
|
||||||
let msg = []
|
|
||||||
for (let f of apiInputFieldList.value) {
|
|
||||||
if (f.required && !route.query[f.field]) {
|
|
||||||
msg.push(f.field)
|
|
||||||
}
|
|
||||||
form_data.value[f.field] = route.query[f.field]
|
|
||||||
}
|
|
||||||
if (msg.length > 0) {
|
|
||||||
MsgWarning(`请在URL中填写参数 ${msg.join('、')}的值`)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
loading.value = true
|
loading.value = true
|
||||||
if (!chat) {
|
if (!chat) {
|
||||||
chat = reactive({
|
chat = reactive({
|
||||||
@ -658,7 +674,7 @@ function chatMessage(chat?: any, problem?: string, re_chat?: boolean) {
|
|||||||
const obj = {
|
const obj = {
|
||||||
message: chat.problem_text,
|
message: chat.problem_text,
|
||||||
re_chat: re_chat || false,
|
re_chat: re_chat || false,
|
||||||
form_data: form_data.value
|
form_data: {...form_data.value, ...api_form_data.value}
|
||||||
}
|
}
|
||||||
// 对话
|
// 对话
|
||||||
applicationApi
|
applicationApi
|
||||||
|
|||||||
@ -138,7 +138,7 @@
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="scrollbar-height">
|
<div class="scrollbar-height">
|
||||||
<AiChat :data="detail"></AiChat>
|
<AiChat :data="detail" :debug="true"></AiChat>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</el-collapse-transition>
|
</el-collapse-transition>
|
||||||
|
|||||||
@ -108,6 +108,7 @@
|
|||||||
:appId="applicationDetail?.id"
|
:appId="applicationDetail?.id"
|
||||||
:record="currentRecordList"
|
:record="currentRecordList"
|
||||||
:chatId="currentChatId"
|
:chatId="currentChatId"
|
||||||
|
:debug="true"
|
||||||
@refresh="refresh"
|
@refresh="refresh"
|
||||||
@scroll="handleScroll"
|
@scroll="handleScroll"
|
||||||
>
|
>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user