<script lang="ts" setup name="ResourceList"> import type { Ref } from 'vue' import { getCurrentInstance, nextTick, reactive, ref } from 'vue' import { ElMessage, ElMessageBox } from 'element-plus' import { debounce } from 'lodash-es' import { videoTree } from '@/api/ycjg/aqbb' import { log } from '@/utils/log' import { init, login, logout, sipVideoFn, unInit, unSipVideo, videoInit } from '@/utils/Dispatch706' const router = useRouter() const treeRef: any = ref(null) const filterText = ref('') const data = ref([]) const defaultProps = ref({ children: 'children', label: 'name', isDisabled: 'disabled', }) const { proxy } = getCurrentInstance() as any const width = ref(0) const height = ref(0) const loading = ref(false) const title = ref(['', '', '', '']) let treeClickCount = 0 let currentIndex = 0 const currentCameras: any = [{}, {}, {}, {}] const callId: any = ['', '', '', ''] const videoLib: any = ['', '', '', ''] const handleResize = () => { const hkPlugin: any = document.getElementById('home') width.value = hkPlugin.clientWidth - 20 height.value = hkPlugin.clientHeight } function filterNode(value: any, data: { name: string | any[] }) { if (value === '' || value === null) { return true } return data.name.includes(value) } function handleNodeClick(data: any, node: any, self: any) { if (data.device.deviceStatusName === '离线') { ElMessage.warning(`设备 ${data.device.monitorName} 离线`) return false } const now = new Date().getTime() if (now - treeClickCount < 300) { // 双击事件的判断,300毫秒内重复点击 if (data.children.length !== 0) { // 点击父亲 return } for (let i = 0; i < currentIndex; i++) { // 前面有 if (currentCameras[i].device.id === data.device.id) { return } } // 这里处理双击事件 if (currentIndex === 4) { currentIndex = 0 } console.log('Double click on:', data) console.log(currentCameras) // 退出上一个callId if (callId[currentIndex] !== '' && callId[currentIndex] !== null) { unSipVideo(callId[currentIndex], videoLib[currentIndex]) // 挂断 } callId[currentIndex] = sipVideoFn(videoLib[currentIndex], data.device.cameraIndexCode, 6) currentCameras[currentIndex] = data title.value[currentIndex] = data.device.monitorName.replace('-', '|') log('场景监控', `${data.device.monitorName}`) currentIndex++ } treeClickCount = now } function cbDoubleClickWnd(iWndIndex: string | number, bFullScreen: any, event: any) { // todo if (currentCameras[iWndIndex].device !== undefined) { router.push({ path: '/ssjk/control', query: { id: currentCameras[iWndIndex].id, }, }) } } function solveData(data: any) { data.forEach((item: any) => { if (item.device) { item.name = `${item.name} (${item.device.deviceStatusName})` console.log('修改后的name', item.name) } if (item.children && item.children.length) { solveData(item.children) } }) return data } const unwatch = watch(filterText, (newVal) => { treeRef.value.filter(newVal) }) onBeforeUnmount(() => { unwatch() logout() unInit() window.removeEventListener('resize', handleResize) }) onMounted(() => { videoTree().then((response) => { if (response.code === 200) { data.value = response.data data.value = solveData(data.value) } }) setTimeout(() => { handleResize() init('ssjk/page', () => { videoLib[0] = videoInit(0) videoLib[1] = videoInit(1) videoLib[2] = videoInit(2) videoLib[3] = videoInit(3) login() }) window.addEventListener('resize', handleResize) }, 200) }) </script> <template> <app-container style="height: calc(100vh - 110px);"> <div style="display: flex;height: 100%;"> <el-card class="left"> <el-input v-model="filterText" placeholder="设备名称过滤" /> <el-tree ref="treeRef" class="filter-tree" style="width: 100%;height: 100%;" :data="data" :filter-node-method="filterNode" node-key="id" :default-expand-all="true" :props="defaultProps" @node-click="handleNodeClick" > <template #default="{ node }"> <span style="display: flex;align-items: center;"> <el-icon v-if="node.label.slice(node.label.indexOf('(')) === '(在线)'" style="margin-right: 5px"> <svg-icon name="icon-online" /> </el-icon> <el-icon v-if="node.label.slice(node.label.indexOf('(')) === '(离线)'" style="margin-right: 5px"> <svg-icon name="icon-offline" /> </el-icon> <el-tooltip class="box-item" effect="dark" :content="node.label" placement="right" > <span v-if="node.label.indexOf('(') === -1">{{ node.label }}</span> </el-tooltip> <el-tooltip class="box-item" effect="dark" :content="node.label.slice(0, node.label.indexOf('('))" placement="right" > <span v-if="node.label.indexOf('(') !== -1" :style="{ color: node.label.slice(node.label.indexOf('(')) === '(在线)' ? '#0e932e' : '#606266' , 'font-weight': node.label.slice(node.label.indexOf('(')) === '(在线)' ? 600 : 500 }">{{ node.label.slice(0, node.label.indexOf('(')) }}</span> </el-tooltip> <!-- <span v-if="node.label.slice(node.label.indexOf('(')) === '(在线)' || node.label.slice(node.label.indexOf('(')) === '(离线)'" :style="{ color: node.label.slice(node.label.indexOf('(')) === '(在线)' ? 'green' : 'red' , 'font-weight': 600 }">{{ node.label.slice(node.label.indexOf('(')) }}</span> --> </span> </template> </el-tree> </el-card> <div id="home" class="right"> <div id="video0" class="dhControl" :style="`width:${width / 2}px;height:${height / 2}px;`" style="top: 10px;left: 348px;" @dblclick="cbDoubleClickWnd(0, null, null)" /> <div id="video1" class="dhControl" :style="`width:${width / 2}px;height:${height / 2}px;`" style="top: 10px;right: 40px;" @dblclick="cbDoubleClickWnd(1, null, null)" /> <div id="video2" class="dhControl" :style="`width:${width / 2}px;height:${height / 2}px;`" style="bottom: 10px;left: 348px;" @dblclick="cbDoubleClickWnd(2, null, null)" /> <div id="video3" class="dhControl" :style="`width:${width / 2}px;height:${height / 2}px;`" style="bottom: 10px;right: 40px;" @dblclick="cbDoubleClickWnd(3, null, null)" /> <div class="video-desc title1" @dblclick="cbDoubleClickWnd(0, null, null)"> {{ title[0] }} </div> <div class="video-desc title2" @dblclick="cbDoubleClickWnd(1, null, null)"> {{ title[1] }} </div> <div class="video-desc title3" @dblclick="cbDoubleClickWnd(2, null, null)"> {{ title[2] }} </div> <div class="video-desc title4" @dblclick="cbDoubleClickWnd(3, null, null)"> {{ title[3] }} </div> <div style="width: calc(100% - 388px);left: 348px; border-top: 2px solid #71b5ff;position: absolute;top: 50%;z-index: 1111111111;" /> <div style="height: calc(100% - 20px); border-left: 2px solid #71b5ff;position: absolute;top: 10px;left: calc(50% + 153px);z-index: 1111111111;" /> </div> </div> </app-container> </template> <style lang="scss" scoped> .video-desc { position: absolute; z-index: 1000; font-size: 16px; letter-spacing: 6px; cursor: pointer; background: linear-gradient(180deg, #71b5ff, #4384ff); color: white; font-weight: bold; padding-top: 20px; width: 30px; height: calc(50% - 10px) !important; writing-mode: vertical-lr;/* 文字垂直展示 */ text-orientation: upright;/* 数字垂直展示 */ } .title1 { top: 10px; left: 318px; border-radius: 15px 0 0 15px; padding-left: 6px; } .title2 { top: 10px; right: 10px; border-radius: 0 15px 15px 0; padding-left: 6px; } .title3 { bottom: 10px; left: 318px; border-radius: 15px 0 0 15px; padding-left: 6px; } .title4 { bottom: 10px; right: 10px; border-radius: 0 15px 15px 0; padding-left: 6px; } .dhCanvas { // height: calc(50% - 10px) !important; // width: calc(50% - 195px) !important; position: absolute; } .dhControl { // height: calc(50% - 10px) !important; // width: calc(50% - 195px) !important; position: absolute; background-color: #111; } .videoControl-new { position: absolute; background-color: #111; } .videoControl { height: calc(100% - 10px) !important; width: calc(50% - 25px) !important; margin-left: 10px; margin-top: 10px; position: relative; background-color: #111; } .left { width: 300px; height: 100%; padding: 10px; overflow-y: scroll; } .right { width: calc(100% - 368px); height: 100%; margin-left: 38px; background: #111; } .video-container { display: flex; flex: 1; flex-direction: row; justify-content: center; align-items: center; margin-bottom: 5px; } video { position: relative; object-fit: fill; overflow: hidden; background: #000; } </style>