From 22aa970420c00cea28097c79d0916094372bea87 Mon Sep 17 00:00:00 2001 From: han2015 <1019850453@qq.com> Date: Wed, 13 Aug 2025 15:59:25 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=8E=E4=BB=A3=E7=A0=81=E5=B9=B3=E5=8F=B0?= =?UTF-8?q?=E6=8E=A5=E5=85=A5AI=E5=8A=A9=E6=89=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/DesignForm/filterUnit.ts | 4 +- src/api/DesignForm/types.ts | 6 + src/api/DesignForm/utils.ts | 1 + src/api/doc/space.ts | 11 ++ .../DesignForm/formControlPropertiNew.vue | 64 ++++--- .../DesignForm/public/expand/digitpage.vue | 12 +- .../DesignForm/public/form/aiassist.vue | 177 ++++++++++++++++++ .../DesignForm/public/form/form.vue | 74 +++++++- .../DesignForm/public/form/formItem.vue | 15 +- 9 files changed, 333 insertions(+), 31 deletions(-) create mode 100644 src/components/DesignForm/public/form/aiassist.vue diff --git a/src/api/DesignForm/filterUnit.ts b/src/api/DesignForm/filterUnit.ts index 7ff71d3..f18f301 100644 --- a/src/api/DesignForm/filterUnit.ts +++ b/src/api/DesignForm/filterUnit.ts @@ -12,6 +12,8 @@ const analysisFromUnit = (unitInfo:formStruct) => { unitInfo.formData.list.forEach((item:any) => { // console.log("解析出表单可作为AI变量的元素------1---1--->",item.label?1:2) if(!layoutUnit.includes(item.type)){ + //by han2015: 暂时只支持普通类型字段 + if (item.type!='input' && item.type!='digitpage') return; let labelName = "" if(item.label){ labelName = item.label @@ -20,7 +22,7 @@ const analysisFromUnit = (unitInfo:formStruct) => { }else{ labelName = item.unitName } - console.log("解析出表单可作为AI变量的元素----2--1-1----->",item) + //console.log("解析出表单可作为AI变量的元素----2--1-1----->",item) optionsInfo.push({ label:labelName, value:item.name diff --git a/src/api/DesignForm/types.ts b/src/api/DesignForm/types.ts index 145f3cf..95669c7 100644 --- a/src/api/DesignForm/types.ts +++ b/src/api/DesignForm/types.ts @@ -57,6 +57,12 @@ export interface FormData { labelStyle:{}, inputStyle:{} } + aiConfig?:{ + library:string[]; + title:string[]; + trigger:number; + openShowType:number; + }[] } export interface TableData { diff --git a/src/api/DesignForm/utils.ts b/src/api/DesignForm/utils.ts index 7772d81..d0f5e32 100644 --- a/src/api/DesignForm/utils.ts +++ b/src/api/DesignForm/utils.ts @@ -106,3 +106,4 @@ export const constSetFormOptions = prefix + 'SetFormOptions' // 使用setOptions export const constGetControlByName = prefix + 'GetControlByName' // 根据name从formData.list查找数据 export const constFormBtnEvent = prefix + 'FormBtnEvent' // 按钮组件事件 export const constFormProps = prefix + 'FormProps' // 按钮组件事件 +export const constAiEffect = prefix + 'AiEffect' // 表单组件触发AI查询事件 diff --git a/src/api/doc/space.ts b/src/api/doc/space.ts index 3dd52b7..2a66158 100644 --- a/src/api/doc/space.ts +++ b/src/api/doc/space.ts @@ -178,4 +178,15 @@ export function setAiChat(data: any){ method: 'post', data: data }); +} + +/** + * 获取智能体 + */ +export function getAiagentList(data?: any){ + return request({ + url: '/aibot/agent/list', + method: 'post', + data: data + }); } \ No newline at end of file diff --git a/src/components/DesignForm/formControlPropertiNew.vue b/src/components/DesignForm/formControlPropertiNew.vue index abb916c..077341e 100644 --- a/src/components/DesignForm/formControlPropertiNew.vue +++ b/src/components/DesignForm/formControlPropertiNew.vue @@ -21,6 +21,10 @@ import { optionsInfo, } from "@/api/DesignForm/types"; +import { + getAiagentList +} from "@/api/doc/space"; + import { chineseToPinyin, customerFormGroupList, @@ -3534,6 +3538,14 @@ const gainFormGroupList = () => { } }); }; + +//by han2015 +const gainAiagentList=()=>{ + getAiagentList().then(resp=>{ + aiAgentList.value=resp.data + }) +}; + //liwenxuan 2025 移动端单选扫描输入功能 start const scanTypes = [ { @@ -3639,6 +3651,7 @@ watch( onMounted(() => { gainFormGroupList(); analysisFromUnit(props.state); + gainAiagentList() }); watch( @@ -4006,24 +4019,31 @@ const addPickTracn = () => { ]; } }; + +function delList(dex:number){ + if(props.formInfo.aiConfig){ + props.formInfo.aiConfig.splice(dex,1) + } +} + /** @ 作者: 秦东 @ 时间: 2025-04-10 08:12:21 @ 功能: 知识库 */ -const libraryList = ref([ - { - label: "法律法规", - value: 1, - }, - { - label: "安全环保", - value: 2, - }, - { - label: "员工守则", - value: 3, - }, +const aiAgentList = ref([ + // { + // label: "法律法规", + // value: 1, + // }, + // { + // label: "安全环保", + // value: 2, + // }, + // { + // label: "员工守则", + // value: 3, + // }, ]); diff --git a/src/components/DesignForm/public/form/formItem.vue b/src/components/DesignForm/public/form/formItem.vue index 1436830..459353e 100644 --- a/src/components/DesignForm/public/form/formItem.vue +++ b/src/components/DesignForm/public/form/formItem.vue @@ -16,6 +16,7 @@ import { constControlChange, constSetFormOptions, constFormProps, + constAiEffect, constGetControlByName, } from "@/api/DesignForm/utils"; import validate from "@/api/DesignForm/validate"; @@ -121,6 +122,17 @@ const updateModel = (val: any) => { attribute: controlAttribute, }); }; + +//----------by han2015: support AI event emitting---------------- +//区别与changeEvent,changeEvent是变动即派发,fieldChange是更改完成才派发事件 +const fieldChangeEnt = inject(constAiEffect, '') as any +function onValueChange(_type:string){ + if(_type=="password") return; + fieldChangeEnt && + fieldChangeEnt({key:props.data.name,value:props.modelValue, field:props.data.item.label}) +} +//-------------------------------------- + const value = computed({ get() { if (props.tProp) { @@ -1220,10 +1232,11 @@ const diGuiJilian = (val: any, options: any[]) => { :style="getFormItemInputStyle(configStyle, 2)" :input-style="getFormItemInputStyle(configStyle, 3)" v-if="['input', 'password'].includes(data.type)" + @change="onValueChange(data.type)" :placeholder=" data.control.placeholder ? data.control.placeholder - : '请输入' + getLabel(data.item) + : '请输入>>>' + getLabel(data.item) " >