diff --git a/src/layout/components/TopBar/aiAssistant.vue b/src/layout/components/TopBar/aiAssistant.vue index 3542919..8d2f7ca 100644 --- a/src/layout/components/TopBar/aiAssistant.vue +++ b/src/layout/components/TopBar/aiAssistant.vue @@ -385,12 +385,17 @@ watch(selectedFormSettingId, async (formSettingId) => { // proxy.$store.commit('aiFormSettingId', formSettingId) // proxy.$store.commit('aiFormSetting', formPageMap.value[formSettingId]) } else { - isShowLeft.value = true - currentSize.value = "form"; - const mod = await formPageMap.value[formSettingId].loader() - console.log(formPageMap.value[formSettingId].props) - currentComponent.value = mod.default - currentProps.value = {...formPageMap.value[formSettingId].props, userInput: ''} + isShowLeft.value = false + currentSize.value = "menu"; + router.push({path: "/" + formPageMap.value[formSettingId].props.formPath, query: {from: "ai"}}) + + // alert(2) + // isShowLeft.value = true + // currentSize.value = "form"; + // const mod = await formPageMap.value[formSettingId].loader() + // console.log(formPageMap.value[formSettingId].props) + // currentComponent.value = mod.default + // currentProps.value = {...formPageMap.value[formSettingId].props, userInput: ''} } @@ -659,7 +664,12 @@ const handleSend = async (selectedText?: string) => { }) } else { //直接打开表单赋值使用 - currentProps.value = sendForm.value; + // currentProps.value = sendForm.value; + + sharedStore.updateDynamicValue({ + message: sendForm.value, + timestamp: new Date().toLocaleString() + }) } @@ -796,7 +806,7 @@ const toggleRecording = () => { // 开始录音 async function startRecording() { try { - // 检查浏览器支持 + // 检查浏览器支持(放在服务器中必须使用https) if (!navigator.mediaDevices || !navigator.mediaDevices.getUserMedia) { proxy.$modal.msgError('您的浏览器不支持录音功能') return diff --git a/src/views/ai/skill/aiForm/prodPlanFillTest.vue b/src/views/ai/skill/aiForm/prodPlanFillTest.vue index 3fd7503..dfe13ab 100644 --- a/src/views/ai/skill/aiForm/prodPlanFillTest.vue +++ b/src/views/ai/skill/aiForm/prodPlanFillTest.vue @@ -90,6 +90,10 @@ import { ref } from 'vue'; import { ElMessage } from 'element-plus'; +import { filterEmptyValues, copyNonEmptyValues } from '@/api/objectUtil'; +import { useSharedDataStore } from '@/api/monitorData' +const sharedStore = useSharedDataStore() + interface FormData { completeAmount: number; productionTime: number; @@ -111,19 +115,35 @@ const formData = reactive({ // } // }) -// 响应props变化 +// 监听数据变化 watch( - () => ({ ...props }), - (newProps) => { - Object.keys(formData).forEach(key => { - if (newProps[key] !== undefined) { - formData[key] = newProps[key] - } - }) + () => sharedStore.dynamicValue, + (newValue, oldValue) => { + if (newValue!=null && newValue.message!=null && newValue !== oldValue) { + ElMessage.info('收到新数据更新') + // 这里可以执行数据更新后的业务逻辑 + // handleDataUpdate(newValue) + copyNonEmptyValues(newValue.message,formData); +//如果字段有onchange方法,则需要判断执行 + + } }, - { immediate: true, deep: true } + { deep: true } // 深度监听对象变化 ) +// 响应props变化 +// watch( +// () => ({ ...props }), +// (newProps) => { +// Object.keys(formData).forEach(key => { +// if (newProps[key] !== undefined) { +// formData[key] = newProps[key] +// } +// }) +// }, +// { immediate: true, deep: true } +// ) + const processOptions = [ { label: '工序A', value: 'processA' }, { label: '工序B', value: 'processB' },