From d1f33d5bd30145c748cbf24c5dc066fa43345349 Mon Sep 17 00:00:00 2001 From: CaptainB Date: Fri, 13 Sep 2024 15:53:54 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=BF=AB=E6=8D=B7=E8=BE=93=E5=85=A5?= =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ui/src/components/ai-chat/index.vue | 53 ++++++++++++++++++++++++++--- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/ui/src/components/ai-chat/index.vue b/ui/src/components/ai-chat/index.vue index f52244606..5d1755e1e 100644 --- a/ui/src/components/ai-chat/index.vue +++ b/ui/src/components/ai-chat/index.vue @@ -50,6 +50,14 @@ :render_data="inputFieldList" ref="dynamicsFormRef" /> + @@ -252,7 +260,7 @@ const inputValue = ref('') const chartOpenId = ref('') const chatList = ref([]) const inputFieldList = ref([]) -const apiInputFieldList = ref([]) +const apiInputFieldList = ref([]) const form_data = ref({}) const isDisabledChart = computed( @@ -353,10 +361,38 @@ function handleInputFieldList() { ? 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 + switch (v.type) { + case 'input': + return { + field: v.variable, + input_type: 'TextInput', + label: v.name, + required: v.is_required + } + case 'select': + return { + field: v.variable, + input_type: 'SingleSelect', + label: v.name, + required: v.is_required, + option_list: v.optionList.map((o: any) => { + return { key: o, value: o } + }) + } + case 'date': + return { + field: v.variable, + input_type: 'DatePicker', + label: v.name, + required: v.is_required, + attrs: { + format: 'YYYY-MM-DD HH:mm:ss', + 'value-format': 'YYYY-MM-DD HH:mm:ss', + type: 'datetime' + } + } + default: + break } }) : [] @@ -395,6 +431,13 @@ function showSource(row: any) { } function quickProblemHandle(val: string) { + // 检查inputFieldList是否有未填写的字段 + for (let i = 0; i < inputFieldList.value.length; i++) { + if (inputFieldList.value[i].required && !form_data.value[inputFieldList.value[i].field]) { + MsgWarning('请填写所有必填字段') + return + } + } if (!loading.value && props.data?.name) { handleDebounceClick(val) }