yangyin
2024-10-12 ffbed33d0cdc00ff1699bbc608c6d24f88157706
指标管理新增对话操作
已修改2个文件
90 ■■■■ 文件已修改
src/views/project/yw/systemManage/metricAgentMgr/MetricAgentMgr.vue 11 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/yw/systemManage/metricMgr/MetricMgr.vue 79 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/views/project/yw/systemManage/metricAgentMgr/MetricAgentMgr.vue
@@ -205,20 +205,19 @@
import { useQueryTable } from '/@/hooks/useQueryTable';
// import { useTableSort } from '/@/hooks/useTableSort';
// import { useValidateUniqueness } from '/@/hooks/useValidateUniqueness';
import axios, { CancelTokenSource } from 'axios';
import { ElMessage } from 'element-plus';
import { nextTick } from 'vue';
import * as metricApi from '/@/api/metrics';
import { updatePublishStatus } from '/@/api/supervisorAdmin';
import Chat from '/@/components/chat/Chat.vue';
import { useCompRef } from '/@/utils/types';
import axios, { CancelTokenSource } from 'axios';
import { SupervisorPublished, supervisorPublishedMap } from '../../lowCode/sqlAmis/types';
import MetricName from './optDlg/MetricName.vue';
import MetricPrompt from './optDlg/MetricPrompt.vue';
import * as agentGroupApi from '/@/api/ai/agentGroup';
import * as metricApi from '/@/api/metrics';
import { updatePublishStatus } from '/@/api/supervisorAdmin';
import Chat from '/@/components/chat/Chat.vue';
import AMContainer from '/@/components/layout/AMContainer.vue';
import LeftTreeByMgr from '/@/components/tree/leftTreeByMgr.vue';
import { useCompRef } from '/@/utils/types';
import { convertListToTree } from '/@/utils/util';
//#region ====================== 左侧树数据,tree init ======================
src/views/project/yw/systemManage/metricMgr/MetricMgr.vue
@@ -96,28 +96,48 @@
                                        "
                                    ></i>
                                </el-tooltip>
                                <el-tooltip effect="dark" content="对话测试" placement="top">
                                    <i class="ywifont ywicon-ceshi !text-[20px] text-blue-400 cursor-pointer" @click="openChatTest(scope.row)"></i>
                                </el-tooltip>
                            </div>
                        </template>
                    </el-table-column>
                </el-table>
                <div
                    v-if="chatTestIsShow"
                    ref="draggableChatRef"
                    :style="style"
                    class="fixed z-50 w-[700px] h-[800px] flex flex-col bg-[rgb(239,244,253)] right-0 bottom-0 rounded-lg"
                >
                    <div ref="chatDragHandlerRef" class="flex-0">
                        <div class="flex items-center justify-between py-2 px-4">
                            <div class="font-bold cursor-move">
                                WI水务智能管家——【{{ chatTestMapRow?.title }}】测试
                                <!-- <img src="/static/images/logo/logo-mini.svg" width="10" height="10" /> -->
                            </div>
                            <i class="ywifont ywicon-guanbi font-[10px] font-bold cursor-pointer" @click="closeChatTest"></i>
                        </div>
                    </div>
                    <Chat ref="chatRef" class="flex-auto px-2" :questionApi="questionAi"> </Chat>
                </div>
            </div>
        </template>
        <!-- <OptDlg v-model="optDlgIsShow" :item="optDlgMapRow" @insert="insertOpt" @update="updateOpt" :groupId="currentListID"></OptDlg> -->
        <!-- <MetricPrompt v-model="infoDlgIsShow" :metricItem="infoDlgMapRow"></MetricPrompt>
        <MetricName v-model="metricNameIsShow" :metricItem="metricNameMapRow"></MetricName> -->
    </HMContainer>
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useDraggable } from '@vueuse/core';
import axios, { CancelTokenSource } from 'axios';
import { computed, nextTick, onMounted, ref } from 'vue';
import { useRouter } from 'vue-router';
import { SupervisorPublished } from '../../lowCode/sqlAmis/types';
import * as agentGroupApi from '/@/api/ai/agentGroup';
import * as metricApi from '/@/api/metrics';
import Chat from '/@/components/chat/Chat.vue';
import HMContainer from '/@/components/layout/HMContainer.vue';
import { usePageDisplay } from '/@/hooks/usePageDisplay';
import { useQueryTable } from '/@/hooks/useQueryTable';
import { useCompRef } from '/@/utils/types';
import { convertListToTree } from '/@/utils/util';
import { eMetrics_Ops, eMetrics_Ops_Color } from '/@/views/types/metrics';
const router = useRouter();
@@ -182,8 +202,55 @@
    }
);
//#endregion
//#region ====================== 操作按钮 ======================
//#region ====================== 操作按钮  测试 ======================
const publishStatusChange = async (status: SupervisorPublished, id: number, index: number) => {};
const chatRef = useCompRef(Chat);
const chatTestMapRow = ref(null);
const chatTestIsShow = ref(false);
const openChatTest = (row) => {
    chatTestMapRow.value = row;
    chatTestIsShow.value = true;
    nextTick(() => {
        chatRef.value.clear();
        // setTimeout(() => {
        //     chatRef.value.autoSend(row.title);
        // }, 30);
    });
};
const closeChatTest = () => {
    chatTestMapRow.value = null;
    chatTestIsShow.value = false;
};
const draggableChatRef = ref<HTMLElement | null>(null);
const chatDragHandlerRef = ref<HTMLDivElement>(null);
const chatDragContainerRef = ref<HTMLDivElement>(null);
// `style` will be a helper computed for `left: ?px; top: ?px;`
const { x, y, style } = useDraggable(draggableChatRef, {
    handle: chatDragHandlerRef,
    initialValue: {
        x: document.body.clientWidth / 2 - 350,
        y: document.body.clientHeight / 2 - 400,
    },
});
const questionAi = async (text, sourceObj: { source: CancelTokenSource }) => {
    const currentSource = axios.CancelToken.source();
    sourceObj.source = currentSource;
    const res = await metricApi.checkMetricAgentValidateByPost(
        {
            agent_id: chatTestMapRow.value.id,
            question: text,
        },
        {
            loading: false,
            cancelToken: currentSource.token,
        }
    );
    return res;
};
//#endregion
onMounted(() => {
    initThemeDomainData();