<template> <div class="CommandDispatch" :style="{ '--row': row, height: '100%' }"> <component :is="key" v-for="(_, key) in gridAreaMap" :key="key" :ref="key" :style="{ gridArea: gridAreaMap[key] }" @fullHeight="(opacityKey) => handleFullHeight(key, opacityKey)" /> </div> </template> <script> import request from "@/utils/request"; const files = require.context("./Cards", true, /[^/]+\/index\.vue$/); const components = files.keys().reduce((components, key) => { components[key.match(/[^/]+/g)[1]] = files(key).default; return components; }, {}); const originGridArea = { EventInformation: "1 / 1 / span 11 / 1", // 事件信息(左1) DispatchLiaison: "12 / 1 / span 7 / 2", // 调度联络(左2)13 / 1 / span 11 / 2 ReleaseInformation: "19 / 1/ span 9 / 2", //信息发布(左3) TrafficControl: "29 / 1 / span 5 / 2", //交通管制(左4)24 / 1 / span 10 / 2 CrowdnessIndicatorRankings: "1 / 2 / span 12 / 2", //地图 / 拥挤指数排名情况(中1) DisposalProcess: "13 / 2 / span 21 / 2", //处置过程(中2) RealTimeVideo: "1 / 3 / span 9 / 3", //实时视频(右1) DeviceControl: "10 / 3 / span 24 / 3", //设备管控(右3) // DisposalPlan: "17 / 1 / span 9 / 2", //处置预案(作废) }; export default { name: "CommandDispatch", components: { ...components, }, props: { }, provide() { return { provideData: this.provideData, }; }, data() { return { gridAreaMap: { ...originGridArea, }, row: 24, provideData: { detail: null, }, detailId: "", }; }, created() { let h = window.location.href.split("="); if (h.length === 2) { this.detailId = window.location.href.split("=")[1]; } else { this.detailId = "b825c7bbf4de43cdb8f689e270adf7a1"; } this.getDetail(); }, methods: { getDetail() { // 指挥调度 - 只有交通事件没有感知事件,感知事件完成后自动转为交通事件 request({ url: `/dc/system/event/${this.detailId}`, method: "GET", }) .then((result) => { if (result.code != 200) return; this.provideData.detail = result.data; console.log("这里是事件详情", this.provideData.detail); if ( ["设备设施隐患", "非法上路", "施工建设", "服务区异常"].includes( result.data.eventName ) ) { const gridArea = { ...originGridArea }; // 第一列变化 gridArea["DispatchLiaison"] = "12 / 1 / span 13 / 2"; gridArea["ReleaseInformation"] = "25 / 1 / span 9 / 2"; delete gridArea.TrafficControl; //交通管制(左4)24 if (["设备设施隐患", "非法上路"].includes(result.data.eventName)) { // 第三列变化 gridArea["DispatchLiaison"] = "12 / 1 / span 22 / 2"; delete gridArea.ReleaseInformation; } this.gridAreaMap = gridArea; } }) .catch((err) => {}); }, handleFullHeight(key, opacityKey) { // 还原图标 if (this.gridAreaMap[key] !== originGridArea[key]) { this.gridAreaMap[key] = originGridArea[key]; if (this.$refs[opacityKey]?.[0]) { this.$refs[opacityKey][0].$el.style.opacity = 1; this.$refs[opacityKey][0].$el.style.pointerEvents = "auto"; } } else { let index = 0; if (this.$refs[opacityKey]?.[0]) { this.$refs[opacityKey][0].$el.style.opacity = 0; this.$refs[opacityKey][0].$el.style.pointerEvents = "none"; } this.gridAreaMap[key] = originGridArea[key].replace( /[0-9]+/g, (num) => { try { return { 0: "1", 2: this.row + 1 }[index] || num; } catch (error) { } finally { index++; } } ); this.gridAreaMap["DisposalProcess"] = "1 / 2 / span 33 / 2"; } }, }, }; </script> <style lang="scss" scoped> .CommandDispatch { padding: 24px 12px 21px 12px; display: grid; grid-template-columns: 1fr 2fr 1fr; grid-template-rows: repeat(var(--row), 1fr); gap: 18px; > div { transition: all 0.18s linear; } ::v-deep { .title-button { border-radius: 65px; font-size: 12px; } .special-button { border-radius: 3px !important; padding: 3px; height: 26px; } } } </style>