wujingjing
2025-02-11 4f328976cedcdfe23ef0c98a435198bff0d1e6c2
src/components/chat/smallChat/index.vue
@@ -92,7 +92,7 @@
                           <template v-else>
                              <span
                                 v-if="(historyMessages[index+1].content as AssistantContent).isError"
                                 class="flex items-center ml-4 text-danger before:content-['('] after:content-[')']"
                                 class="flex items-center text-nowrap ml-4 text-danger before:content-['('] after:content-[')']"
                              >
                                 {{ (historyMessages[index + 1].content as AssistantContent).value }}
                                 <el-tooltip
@@ -105,7 +105,7 @@
                                    </el-icon>
                                 </el-tooltip>
                              </span>
                              <span v-else class="ml-4 text-success before:content-['('] after:content-[')']">
                              <span v-else class="ml-4 text-success text-nowrap before:content-['('] after:content-[')']">
                                 {{ (historyMessages[index + 1].content as AssistantContent).value }}
                              </span>
                           </template>
@@ -137,6 +137,9 @@
            <ChatInput v-model="inputText" @sendClick="sendClick" @toggleHistory="toggleHistory" :showHistory="showHistory" />
         </div>
      </div>
      <Teleport to="body">
         <WorkOrderDlg v-model="optDlgIsShow" :item="optDlgMapRow" @insert="submitDlg" @cancelSubmit="cancelSubmit"></WorkOrderDlg>
      </Teleport>
   </div>
</template>
@@ -152,7 +155,7 @@
import userPic from '/static/images/role/user-200x206.png';
import { useDrag } from '/@/hooks/useDrag';
import { cloneDeep, defaults } from 'lodash-es';
import WorkOrderDlg from './WorkOrderDlg.vue';
const props = defineProps<{
   olMap?: OLMap;
}>();
@@ -177,7 +180,12 @@
      x: 200,
   },
});
const cancelSubmit = (reason) =>{
   refreshAssistantMessage({ reason: reason });
}
const submitDlg = () => {
   refreshAssistantMessage({ value: `成功`, isError: false });
};
const historyMessages = ref<ChatMessage[]>([]);
const isInit = computed(() => historyMessages.value.length === 0);
const initQuestionList = ref([
@@ -185,6 +193,7 @@
   { title: '地图缩放', question: '放大' },
   { title: '设备显隐', question: '隐藏设备' },
   { title: '设备聚焦', question: '聚焦设备' },
   { title: '创建工单', question: '松福大道DN800松岗联通监测设备没有数据,创建一个设备维修工单,请及时派人维修。' },
]);
const chatContentRef = ref<HTMLDivElement>(null);
@@ -193,6 +202,18 @@
   const result = last.role === 'assistant' ? last : null;
   return result as ChatMessage<AssistantContent>;
};
//#region ====================== 添加工单 ======================
const optDlgIsShow = ref(false);
const optDlgMapRow = ref(null);
const openOptDlg = (row?: any) => {
   optDlgMapRow.value = row;
   optDlgIsShow.value = true;
};
const submit = () => {};
//#endregion
const mockCommand = (question: string) => {
   if (question === `切换${gaoDeSourceTypeMap[GaoDeSourceType.Vector]}`) {
@@ -219,6 +240,12 @@
const startStream = (question: string) => {
   if (lastIsInit) {
      showHistory.value = false;
   }
   if (question === '松福大道DN800松岗联通监测设备没有数据,创建一个设备维修工单,请及时派人维修。') {
      setTimeout(() => {
         openOptDlg();
      }, 400);
      return;
   }
   // mockCommand(question);
@@ -273,6 +300,7 @@
const handleMapCommand = (command: any) => {
   if (!command) return;
   // openOptDlg();
   switch (command.operate) {
      case '放大':
         props.olMap.zoomIn();
@@ -297,7 +325,8 @@
         if (equipOverlay) {
            equipOverlay.isVisible = true;
            // 强制触发更新
            props.olMap.layerInfo.value = props.olMap.layerInfo.value.concat([])
            props.olMap.layerInfo.value = props.olMap.layerInfo.value.concat([]);
            // props.olMap.toggleMarkerOverlayVisible(true);
         }
         break;
      case '隐藏设备':
@@ -305,8 +334,8 @@
         if (equipOverlay1) {
            equipOverlay1.isVisible = false;
            // 强制触发更新
            props.olMap.layerInfo.value = props.olMap.layerInfo.value.concat([])
            props.olMap.layerInfo.value = props.olMap.layerInfo.value.concat([]);
            // props.olMap.toggleMarkerOverlayVisible(false);
         }
         break;
      case '聚焦设备':