Browse Source

Merge branch 'han_v3'

space2
han2015 3 months ago
parent
commit
177f3d5ef0
  1. 1
      .env.development
  2. 1
      .env.production
  3. 3
      src/api/DesignForm/fieldUnit.ts
  4. 22
      src/api/DesignForm/filterUnit.ts
  5. 17
      src/api/doc/space.ts
  6. 3
      src/components/DesignForm/public/expand/digitpage.vue
  7. 52
      src/components/DesignForm/public/form/aiassist.vue
  8. 44
      src/components/DesignForm/public/form/form.vue
  9. 45
      src/components/DesignForm/public/form/formItem.vue
  10. 3
      src/views/doc/space.vue

1
.env.development

@ -11,3 +11,4 @@ VITE_APP_TOKEN_KEY = 'offlineAccessSystemAppToken'
VITE_APP_SJZT_URL = 'http://172.20.5.86/prod-api' VITE_APP_SJZT_URL = 'http://172.20.5.86/prod-api'
VITE_OFFICE_HOST='http://myvuetest.net/kkapi' VITE_OFFICE_HOST='http://myvuetest.net/kkapi'
VITE_ONLYOFFICE_HOST = 'http://myvuetest.net/onlyoffice' VITE_ONLYOFFICE_HOST = 'http://myvuetest.net/onlyoffice'
VITE_DEFAULT_AI_AGENT = '5bd9b0e9-d3f4-4089-670a-880009e925a8'

1
.env.production

@ -7,3 +7,4 @@ VITE_APP_TOKEN_KEY = 'onlineAccessSystemAppToken'
VITE_APP_SJZT_URL = 'http://120.224.6.6:29911/prod-api' VITE_APP_SJZT_URL = 'http://120.224.6.6:29911/prod-api'
VITE_OFFICE_HOST='https://gyhlw.hxgk.group/kkapi' VITE_OFFICE_HOST='https://gyhlw.hxgk.group/kkapi'
VITE_ONLYOFFICE_HOST = 'https://gyhlw.hxgk.group/onlyoffice' VITE_ONLYOFFICE_HOST = 'https://gyhlw.hxgk.group/onlyoffice'
VITE_DEFAULT_AI_AGENT = '23a3c2c5-2de1-40df-59fa-a9206b11861d'

3
src/api/DesignForm/fieldUnit.ts

@ -5,4 +5,5 @@ export const choiceUnit = ["radio"]
export const switchUnit = ["switch"] export const switchUnit = ["switch"]
export const checkboxUnit = ["checkbox"] export const checkboxUnit = ["checkbox"]
export const orgDeptUnit = ["deptOrg"] export const orgDeptUnit = ["deptOrg"]
export const layoutUnit = ["grid","card","flex","div","tabs","divider","title","button","lowcodeImage","videoUpAndPlay","table","baidumap","lowcodeCarsusel","signaturemap","component"] //edit by han2015: layoutUnit删掉了table字段,因为ai触发条件要支持子表字段
export const layoutUnit = ["grid","card","flex","div","tabs","divider","title","button","lowcodeImage","videoUpAndPlay","baidumap","lowcodeCarsusel","signaturemap","component"]

22
src/api/DesignForm/filterUnit.ts

@ -13,7 +13,27 @@ const analysisFromUnit = (unitInfo:formStruct) => {
// console.log("解析出表单可作为AI变量的元素------1---1--->",item.label?1:2) // console.log("解析出表单可作为AI变量的元素------1---1--->",item.label?1:2)
if(!layoutUnit.includes(item.type)){ if(!layoutUnit.includes(item.type)){
//by han2015: 暂时只支持普通类型字段 //by han2015: 暂时只支持普通类型字段
if (item.type!='input' && item.type!='digitpage') return; //if (item.type!='input' && item.type!='digitpage') return;
//显示子表单字段
if(item.type=="table"){
item.list.forEach(eles => {
let labelName = ""
if(eles.label){
labelName = eles.label
}else if(eles.item && eles.item.label){
labelName = eles.item.label
}else{
labelName = eles.unitName
}
optionsInfo.push({
label:labelName,
value:eles.name
})
});
return;//退出该字段
}
let labelName = "" let labelName = ""
if(item.label){ if(item.label){
labelName = item.label labelName = item.label

17
src/api/doc/space.ts

@ -106,7 +106,7 @@ export function doAiTraining(_url:string,data?: any){
export interface aiChatData{ export interface aiChatData{
inputs:object; inputs:object;
query:string; query?:string;
response_mode:string; response_mode:string;
conversation_id?:string; conversation_id?:string;
user:string, user:string,
@ -129,6 +129,21 @@ export function doAiChat(_url:string,data: aiChatData,sig?:AbortSignal){
} }
) )
} }
/**
*
*/
export function doAiWorkflow(_url:string,data: aiChatData){
return fetch(
_url,{
method: 'post',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(data)
}
)
}
/** /**
* userid获取记录列表 * userid获取记录列表
* @requires userid * @requires userid

3
src/components/DesignForm/public/expand/digitpage.vue

@ -23,6 +23,7 @@ const props = withDefaults(
data?: Object; data?: Object;
modelValue?: string; modelValue?: string;
disabled?: boolean; disabled?: boolean;
rowIndex:number;
}>(), }>(),
{} {}
); );
@ -46,7 +47,7 @@ const config = computed(() => {
const changeEvent = inject(constAiEffect, '') as any const changeEvent = inject(constAiEffect, '') as any
function onValueChange(){ function onValueChange(){
changeEvent && changeEvent &&
changeEvent({key:props.data.name,value:props.modelValue, field:props.data.item.label}) changeEvent({key:props.data.name,value:props.modelValue, field:props.data.item.label,rowdex:props.rowIndex})
} }
//-------------------------------------- //--------------------------------------
/** /**

52
src/components/DesignForm/public/form/aiassist.vue

@ -6,24 +6,17 @@
<script lang="ts" setup> <script lang="ts" setup>
import { doAiChat,aiChatData} from "@/api/doc/space" import { doAiChat,aiChatData} from "@/api/doc/space"
import {ElText,ElInput, ButtonInstance} from "element-plus"; import { useUserStore } from "@/store/modules/user";
import { VueMarkdown } from '@crazydos/vue-markdown'
import rehypeRaw from 'rehype-raw'
import remarkGfm from 'remark-gfm'
// //
const checkedModel = ref([]) const userStore = useUserStore();
const userid="p0"+userStore.userInfoCont.userId;
const baseURL=import.meta.env.VITE_APP_BASE_API const baseURL=import.meta.env.VITE_APP_BASE_API
const conversation=ref("") //uuid const conversation=ref("") //uuid
const myquestion=ref('')
const controller = ref<AbortController | null>(null) const controller = ref<AbortController | null>(null)
const interact_msg=ref<{ask:boolean,think:string,content:string}[]>([]) const interact_msg=ref<{ask:boolean,think:string,content:string}[]>([])
const props = withDefaults(defineProps<{
//closefunc:()=>void,
//agent:{model:boolean,name:string,uuid:string[]}
}>(),{})
// //
@ -40,22 +33,15 @@ interface chatRecord{
messages:message[] messages:message[]
} }
/* 中断函数,供按钮调用 */
function abortFetch() {
if (controller.value) {
controller.value.abort()
controller.value = null
}
}
defineExpose({onSendParamToAI}) defineExpose({onSendParamToAI})
async function onSendParamToAI(user:string,arr:Array<{ uuids: string[]; params: { [key: string]: any } }>){ async function onSendParamToAI(arr:Array<{ uuids: string[]; params: { [key: string]: any } }>){
interact_msg.value=[] interact_msg.value=[]
for (let ele of arr){ for (let ele of arr){
interact_msg.value.unshift({ask:true,think:"", content:"AI正在分析。。。"}) interact_msg.value.unshift({ask:true,think:"", content:"AI正在分析。。。"})
for (let uid of ele.uuids){ for (let uid of ele.uuids){
await doRequest(user,uid,ele.params) await doRequest(userid,uid,ele.params)
} }
} }
} }
@ -63,21 +49,15 @@ async function onSendParamToAI(user:string,arr:Array<{ uuids: string[]; params:
async function doRequest(_user:string,uuid:string,param:any){ async function doRequest(_user:string,uuid:string,param:any){
let mRespMsg="" let mRespMsg=""
const params={ const params={
"onlineSearch":"否", "checkType":"travel",
"useDataset":"否" "checkInfo":JSON.stringify(param)
}
for (let item of checkedModel.value){
if(item==="onlineSearch") params.onlineSearch="是"
if(item==="useDataset") params.useDataset="是"
} }
controller.value = new AbortController(); controller.value = new AbortController();
try{ try{
const res= await doAiChat(`${baseURL}/aibot/assisted/${uuid}/chat`,{ const res= await doAiChat(`${baseURL}/aibot/assisted/${uuid}/workflow`,{
inputs: params, inputs: params,
query:JSON.stringify(param),
response_mode:"streaming", response_mode:"streaming",
conversation_id:"",//conversation.value,
user:_user,//base64 user:_user,//base64
},controller.value.signal },controller.value.signal
) )
@ -103,9 +83,9 @@ async function doRequest(_user:string,uuid:string,param:any){
if (line.startsWith('data: ')) { if (line.startsWith('data: ')) {
const data = line.slice(6); const data = line.slice(6);
const json = JSON.parse(data); const json = JSON.parse(data);
if(json.event==="message"){ if(json.event==="text_chunk"){
//conversation.value=json.conversation_id //conversation.value=json.conversation_id
mRespMsg+=json.answer mRespMsg+=json.data.text
} }
} }
} }
@ -122,9 +102,15 @@ async function doRequest(_user:string,uuid:string,param:any){
interact_msg.value.unshift({ask:false,think:"",content:arr[0]}) interact_msg.value.unshift({ask:false,think:"",content:arr[0]})
}else{ }else{
// //
let st = arr[1].trim().match(/({.*})/s)
if (st){
let res= JSON.parse(st[1])
interact_msg.value.unshift({ask:false,think:res.success,content:res.reason})
}else{
interact_msg.value.unshift({ask:false,think:arr[0],content:arr[1]}) interact_msg.value.unshift({ask:false,think:arr[0],content:arr[1]})
} }
} }
}
function resetContext(){ function resetContext(){
interact_msg.value=[] interact_msg.value=[]
@ -142,7 +128,7 @@ function resetContext(){
<div class="reply_area" > <div class="reply_area" >
<template v-for="msg of interact_msg"> <template v-for="msg of interact_msg">
<div v-if="msg.ask" class="t_ask" >{{ msg.content }}</div> <div v-if="msg.ask" class="t_ask" >{{ msg.content }}</div>
<div v-else class="t_resp"> <div v-else class="t_resp" :class="{merr:msg.think==false}">
{{ msg.content }} {{ msg.content }}
<!-- <VueMarkdown :markdown="msg.content"></VueMarkdown> --> <!-- <VueMarkdown :markdown="msg.content"></VueMarkdown> -->
</div> </div>
@ -170,8 +156,12 @@ function resetContext(){
} }
.t_resp{ .t_resp{
margin: 5px; margin: 5px;
font-size:14px;
align-self: start; align-self: start;
color: black; color: black;
background-color: rgb(222, 243, 222); background-color: rgb(222, 243, 222);
} }
.merr{
background-color: rgb(253 176 211);
}
</style> </style>

44
src/components/DesignForm/public/form/form.vue

@ -165,10 +165,12 @@ const getInitModel = () => {
currentAgent.value.push({ currentAgent.value.push({
name: "test", name: "test",
model: false, model: false,
rowdex:0,
uuid: item.library, uuid: item.library,
fields: item.title, fields: item.title,
trigger: item.trigger, trigger: item.trigger,
params: {}, params: {},
subparams:[]
}); });
}); });
} }
@ -503,45 +505,63 @@ watch(
//-----------------------AI setting-------------------------- //-----------------------AI setting--------------------------
//AIform //AIform
//params subparams ; rowdex:
const currentAgent = ref< const currentAgent = ref<
{ {
model: boolean; model: boolean;
name: string; name: string;
rowdex:number,
uuid: string[]; uuid: string[];
fields: string[]; fields: string[];
trigger: number; trigger: number;
params: { [key: string]: any }; params: { [key: string]: any };
subparams:{[key: string]: any}[];
}[] }[]
>([]); >([]);
const aiassistRef = ref(); const aiassistRef = ref();
//AI //AI
provide(constAiEffect, ({ key, value, field }: any) => { provide(constAiEffect, ({ key, value, field,rowdex}: any) => {
//ai_envents //ai_envents
const ai_events: Array<{ uuids: string[]; params: { [key: string]: any } }> = []; const ai_events: Array<{ uuids: string[]; params: { [key: string]: any } }> = [];
currentAgent.value.forEach((ag) => { currentAgent.value.forEach(ag=>{
if (ag.fields.includes(key)) { if(ag.fields.includes(key)){ //trigger: 1: 2 3
//trigger: 1: 2 3 if (rowdex!=null){//
ag.rowdex=rowdex //rowdex
if(rowdex>=ag.subparams.length){
ag.subparams.push({[field]:value})
}else{
ag.subparams[rowdex][field]=value
}
}else{ //, params
ag.params[field]=value; //keyfieldName ag.params[field]=value; //keyfieldName
}
let mergedObj;
if(ag.subparams.length>0){
mergedObj = Object.assign({}, ag.params, ag.subparams[ag.rowdex]); //
}else{
mergedObj = ag.params
}
switch(ag.trigger){ switch(ag.trigger){
case 2: case 2:
if (Object.keys(ag.params).length >= ag.fields.length / 2) { if(Object.keys(mergedObj).length>=ag.fields.length/2){
ai_events.push({ uuids: ag.uuid, params: ag.params }); ai_events.push({uuids:ag.uuid,params:mergedObj })
} }
break; break;
case 3: case 3:
if (Object.keys(ag.params).length == ag.fields.length) { if(Object.keys(mergedObj).length==ag.fields.length){
ai_events.push({ uuids: ag.uuid, params: ag.params }); ai_events.push({uuids:ag.uuid,params:mergedObj})
} }
break; break;
default: default:
ai_events.push({ uuids: ag.uuid, params: ag.params }); ai_events.push({uuids:ag.uuid,params:mergedObj})
} }
} }
}); })
if(ai_events.length>0){ if(ai_events.length>0){
aiassistRef.value.onSendParamToAI(props.formData.form.formName, ai_events); aiassistRef.value.onSendParamToAI(ai_events)
} }
}); })
//------------------------------------------------------------ //------------------------------------------------------------
// tProp // tProp

45
src/components/DesignForm/public/form/formItem.vue

@ -128,14 +128,24 @@ const updateModel = (val: any) => {
//changeEventchangeEventfieldChange //changeEventchangeEventfieldChange
const fieldChangeEnt = inject(constAiEffect, "") as any; const fieldChangeEnt = inject(constAiEffect, "") as any;
function onValueChange(_type: string) { function onValueChange(_type: string) {
if (_type == "password") return; if(["password","description"].includes(_type)) return;
fieldChangeEnt && fieldChangeEnt &&
fieldChangeEnt({ fieldChangeEnt({
key: props.data.name, key: props.data.name,
value: props.modelValue, value: value.value,
field: props.data.item.label, field: props.data.item.label,
rowdex: props.rowIndex,
}); });
} }
//select
function onSekectValueChange(news:number){
if(props.data.options){
fieldChangeEnt &&
fieldChangeEnt({key:props.data.name,value:props.data.options[news-1].label, field:props.data.item.label,rowdex:props.rowIndex})
}
}
//-------------------------------------- //--------------------------------------
const value = computed({ const value = computed({
@ -1252,7 +1262,7 @@ const diGuiJilian = (val: any, options: any[]) => {
:placeholder=" :placeholder="
data.control.placeholder data.control.placeholder
? data.control.placeholder ? data.control.placeholder
: '请输入>>>' + getLabel(data.item) : '请输入' + getLabel(data.item)
" "
> >
<template #prepend v-if="config.prepend"> <template #prepend v-if="config.prepend">
@ -1293,6 +1303,7 @@ const diGuiJilian = (val: any, options: any[]) => {
" "
:style="getFormItemInputStyle(configStyle, 2)" :style="getFormItemInputStyle(configStyle, 2)"
:input-style="getFormItemInputStyle(configStyle, 3)" :input-style="getFormItemInputStyle(configStyle, 3)"
@change="onValueChange(data.type)"
v-if="['textarea', 'description'].includes(data.type)" v-if="['textarea', 'description'].includes(data.type)"
/> />
<el-radio-group <el-radio-group
@ -1300,6 +1311,7 @@ const diGuiJilian = (val: any, options: any[]) => {
:disabled="judgeIsDisabled(data.name)" :disabled="judgeIsDisabled(data.name)"
v-model="value" v-model="value"
v-if="data.type === 'radio'" v-if="data.type === 'radio'"
@change="onValueChange(data.type)"
:style="getFormItemInputStyle(configStyle, 4)" :style="getFormItemInputStyle(configStyle, 4)"
> >
<el-radio <el-radio
@ -1315,6 +1327,7 @@ const diGuiJilian = (val: any, options: any[]) => {
:disabled="judgeIsDisabled(data.name)" :disabled="judgeIsDisabled(data.name)"
v-model="value" v-model="value"
v-if="data.type === 'checkbox'" v-if="data.type === 'checkbox'"
@change="onValueChange(data.type)"
:style="getFormItemInputStyle(configStyle, 4)" :style="getFormItemInputStyle(configStyle, 4)"
> >
<el-checkbox <el-checkbox
@ -1333,6 +1346,7 @@ const diGuiJilian = (val: any, options: any[]) => {
:options="props.data.options" :options="props.data.options"
:remote-method="getAxiosOptions" :remote-method="getAxiosOptions"
:transformOption="transformOption" :transformOption="transformOption"
@update:model-value="(news)=>onSekectValueChange(news)"
:placeholder=" :placeholder="
data.control.placeholder data.control.placeholder
? data.control.placeholder ? data.control.placeholder
@ -1408,14 +1422,32 @@ const diGuiJilian = (val: any, options: any[]) => {
" "
v-model="value" v-model="value"
/> />
<component <component
v-if=" v-if="
[ [
'rate',
'slider',
'switch', 'switch',
'inputNumber', 'inputNumber',
].includes(data.type)
"
:is="currentComponent"
v-bind="control"
:disabled="judgeIsDisabled(data.name)"
:placeholder="
data.control.placeholder
? data.control.placeholder
: '请选择' + getLabel(data.item)
"
:data="data"
:type="type"
:rowIndex="rowIndex"
@change="onValueChange(data.type)"
v-model="value"
/>
<component
v-if="
[
'rate',
'slider',
'colorPicker', 'colorPicker',
'component', 'component',
'expand-user', 'expand-user',
@ -1435,6 +1467,7 @@ const diGuiJilian = (val: any, options: any[]) => {
" "
:data="data" :data="data"
:type="type" :type="type"
:rowIndex="rowIndex"
v-model="value" v-model="value"
/> />
<component <component

3
src/views/doc/space.vue

@ -23,6 +23,7 @@ import aiagent from './agent.vue';
import router from "@/router"; import router from "@/router";
import SvgIcon from "@/components/SvgIcon/index.vue"; import SvgIcon from "@/components/SvgIcon/index.vue";
const defaultAiAgent=import.meta.env.VITE_DEFAULT_AI_AGENT
const matterList = ref<matterInfo[]>([]) const matterList = ref<matterInfo[]>([])
const newdir=ref("") // const newdir=ref("") //
const currentHoverRow=ref("") //table const currentHoverRow=ref("") //table
@ -445,7 +446,7 @@ function getSpaceImageDURL(_uuid:string,_name:string){
onMounted(() => { onMounted(() => {
currentNode.value.uuid="root" currentNode.value.uuid="root"
//AI //AI
currentAgent.value={name:"通用AI",model:false,uuid:"5bd9b0e9-d3f4-4089-670a-880009e925a8"} currentAgent.value={name:"通用AI",model:false,uuid:defaultAiAgent}
onLoadMatterList() onLoadMatterList()
}); });

Loading…
Cancel
Save