| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322 |
- <template>
- <aside v-if="open" class="pipe-enhancement" data-pipe-enhancement role="dialog" aria-label="地下管线详情视图" @keydown.esc.stop.prevent="$emit('close')">
- <header class="pipe-enhancement__header">
- <div>
- <span class="pipe-enhancement__eyebrow">地下管线详情视图</span>
- <h2 data-pipe-enhancement-title>{{ plan.object.title }}</h2>
- <p class="pipe-enhancement__controls">左键拖动平移 · 右键旋转 · 滚轮缩放 · Esc 关闭</p>
- </div>
- <button type="button" class="pipe-enhancement__close" aria-label="关闭地下管线详情视图" title="关闭地下管线详情视图" data-pipe-enhancement-close @click="$emit('close')">×</button>
- </header>
- <div class="pipe-enhancement__scope" v-if="plan.coverage">
- <label>附近范围
- <select aria-label="附近范围" :value="plan.radiusM" @change="$emit('radius-change', Number($event.target.value))">
- <option v-for="radius in [25, 50, 100]" :key="radius" :value="radius">{{ radius }} 米</option>
- </select>
- </label>
- <span>管道 {{ plan.coverage.pipeCount }} 条 · 构件 {{ plan.coverage.componentCount }} 个 · 邻近管道按范围裁切</span>
- </div>
- <div class="pipe-enhancement__workspace">
- <div ref="viewport" class="pipe-enhancement__viewport" data-pipe-enhancement-viewport role="region" aria-label="地下管线详情视图三维场景"></div>
- <!--
- 维护者 2026-11-12:设备/设施详情不再浮在三维场景上(遮挡 3D 区域),
- 改为右侧「资产详情」页签;「管道临近资产」保留原有的管道 + 设备双列列表。
- -->
- <aside class="pipe-enhancement__side" aria-label="管道临近资产与资产详情">
- <nav class="pipe-enhancement__side-tabs" role="tablist" aria-label="管线详情分区">
- <button v-for="tab in sideTabs" :key="tab.key" type="button" role="tab"
- :aria-selected="sideTab === tab.key" :class="{ 'is-active': sideTab === tab.key }"
- :data-side-tab="tab.key" @click="sideTab = tab.key">{{ tab.label }}</button>
- </nav>
- <div v-show="sideTab === 'nearby'" class="pipe-enhancement__nearby" data-side-panel="nearby">
- <aside class="pipe-enhancement__devices" aria-label="附近资产列表">
- <section v-if="localPipeStates.length" class="pipe-enhancement__pipe-list" data-pipe-status-list aria-label="附近管道状态">
- <h3>附近管道状态({{ localPipeStates.length }})</h3>
- <div class="pipe-enhancement__pipe-scroll">
- <button v-for="pipe in pagedPipeStates" :key="pipe.code" type="button"
- class="pipe-enhancement__asset-card" data-pipe-card
- :aria-pressed="plan.object.sourceKind === 'pipe' && plan.object.code === pipe.code"
- @click="$emit('object-pick', { objectKind: 'pipe', code: pipe.code })">
- <b>{{ pipe.title }}</b>
- <small>{{ pipe.code }} · {{ pipe.stateText || '状态未提供' }}</small>
- <small>{{ pipe.diameterM ? pipe.diameter + ' mm' : '管径未提供' }} · {{ pipe.material || '材质未提供' }}</small>
- </button>
- </div>
- <nav v-if="pipePageCount > 1" class="pipe-enhancement__pager" data-pipe-pager aria-label="附近管道状态翻页">
- <button type="button" :disabled="pipePage <= 1" @click="pipePage -= 1">上一页</button>
- <span>第 {{ pipePage }} / {{ pipePageCount }} 页</span>
- <button type="button" :disabled="pipePage >= pipePageCount" @click="pipePage += 1">下一页</button>
- </nav>
- </section>
- <section class="pipe-enhancement__device-list" data-device-list aria-label="监测设备">
- <h3>监测设备({{ plan.deviceList?.length || 0 }})</h3>
- <div class="pipe-enhancement__device-scroll">
- <p v-if="plan.deviceCoverage?.loading">设备读取中({{ plan.deviceCoverage.loadedPoints || 0 }}/{{ plan.deviceCoverage.totalPoints || 0 }} 点),已返回设备可先查看。</p>
- <p>场景设备 {{ plan.devices?.length || 0 }} 个 · 清单 {{ plan.deviceList?.length || 0 }} 台</p>
- <p v-if="!plan.deviceCoverage?.loading && plan.deviceCoverage?.partial">设备覆盖不完整:快照未齐、设备待确认或部分点位读取失败。</p>
- <button v-if="plan.deviceCoverage?.partial && !plan.deviceCoverage?.loading" type="button" @click="$emit('devices-reload')">重新读取设备清单</button>
- <p v-if="plan.deviceCoverage?.stalePoints">部分设备为上次保留数据,非实时。</p>
- <p v-if="!plan.deviceList?.length && !plan.deviceCoverage?.loading">当前可用数据中没有附近设备。</p>
- <button v-for="device in plan.deviceList || []" :key="device.code" :data-device-code="device.code"
- class="pipe-enhancement__asset-card" data-device-card type="button"
- :aria-pressed="deviceState.selected?.code === device.code" @click="selectDevice(device)">
- <b>{{ device.name || device.code }}</b>
- <small>{{ device.code }} · {{ device.placementText }}{{ device.retained ? ' · 过期数据' : '' }}</small>
- </button>
- </div>
- </section>
- </aside>
- </div>
- <div v-show="sideTab === 'detail'" class="pipe-enhancement__asset-pane" data-side-panel="detail">
- <AssetDetailPanel :context="assetContext">
- <template v-if="assetKind === 'device'">
- <div class="pipe-enhancement__device-status-card" data-enhancement-device-status-card>
- <DeviceStateTags data-enhancement-device-status :device-code="deviceState.selected.code"
- :fallback-status="deviceState.selected.status || ''" :aggregate="deviceState.aggregate" />
- <span class="pipe-enhancement__device-status-label">设备状态</span>
- </div>
- <p v-if="deviceState.loadingDetail && !deviceState.aggregate?.data" class="pipe-enhancement__hint">设备详情加载中</p>
- <template v-else-if="!deviceState.aggregate?.data">
- <p class="pipe-enhancement__hint">设备详情暂不可用</p>
- <button type="button" class="pipe-enhancement__action" @click="$emit('device-retry')">重新加载</button>
- </template>
- <EquipmentDetailSections v-else :aggregate="deviceState.aggregate" :device-code="deviceState.selected.code" monitor-source="enhancement" />
- </template>
- <template v-else-if="assetKind === 'facility'">
- <p v-if="assetFacility?.loading" class="pipe-enhancement__hint" data-asset-facility-loading>设施详情加载中…</p>
- <p v-else-if="assetFacility?.error" class="pipe-enhancement__hint is-error" data-asset-facility-error>
- 设施详情未取到,已保留现有信息。
- <button type="button" class="pipe-enhancement__action" @click="$emit('facility-retry')">重试</button>
- </p>
- <EntityDetailSections v-if="assetFacility?.detail" :detail="assetFacility.detail" presentation="device" />
- </template>
- </AssetDetailPanel>
- </div>
- </aside>
- </div>
- <dl class="pipe-enhancement__facts">
- <div><dt>对象</dt><dd>{{ plan.object.renderKind === 'manhole' ? '窨井剖切' : plan.object.sourceKind === 'pipe' ? '重点管段' : '重点构件' }}</dd></div>
- <div><dt>编码</dt><dd>{{ plan.object.code }}</dd></div>
- <div v-if="plan.object.diameter !== null"><dt>源管径</dt><dd>{{ plan.object.diameter }} mm</dd></div>
- <div v-if="plan.object.sourceKind === 'pipe'"><dt>地理路径长度</dt><dd>{{ plan.object.geographicLengthM?.toFixed(2) }} m</dd></div>
- <div v-if="plan.object.sourceKind === 'pipe'"><dt>后端管长(源值)</dt><dd>{{ plan.object.lengthM ?? '未提供' }}</dd></div>
- <div><dt>状态</dt><dd>{{ plan.object.stateText || '状态未提供' }}</dd></div>
- <div v-if="plan.object.material"><dt>材质</dt><dd>{{ plan.object.material }}</dd></div>
- </dl>
- <p class="pipe-enhancement__note" data-pipe-enhancement-note>{{ plan.disclaimer }} · {{ plan.connectionNote }} · 管径横向8倍显示,源管径独立保留;长度保持地理路径,后端管长源值不用于拉伸。材质纹理与设备尺寸为显示示意。</p>
- </aside>
- </template>
- <script setup>
- import { computed, nextTick, onBeforeUnmount, watch, ref } from 'vue'
- import { mountPipeEnhancement } from '../services/threePipeEnhancement.js'
- import EquipmentDetailSections from './EquipmentDetailSections.vue'
- import EntityDetailSections from './EntityDetailSections.vue'
- import DeviceStateTags from './DeviceStateTags.vue'
- import AssetDetailPanel from './AssetDetailPanel.vue'
- import { ASSET_KIND } from '../domain/assetDetail.js'
- import { resolveAssetKind } from '../domain/assetDetailKind.js'
- const props = defineProps({
- plan: { type: Object, required: true },
- deviceState: { type: Object, default: () => ({ selected: null, aggregate: null, loadingDetail: false }) },
- /** 设施详情状态:{ detail, loading, error };由外壳把选中设施接进来,与设备详情并列可选。 */
- facilityState: { type: Object, default: () => ({ detail: null, loading: false, error: false }) },
- })
- const emit = defineEmits(['close', 'radius-change', 'device-pick', 'device-close', 'device-retry', 'devices-reload', 'object-pick', 'facility-retry'])
- /**
- * 右侧两个页签:管道临近资产(原双列列表)|资产详情(设备或设施)。
- * 选中的资产一变就自动切到详情页,避免用户还要手动点一下才知道有详情。
- */
- const SIDE_TABS = [
- { key: 'nearby', label: '管道临近资产' },
- { key: 'detail', label: '资产详情' },
- ]
- const sideTabs = SIDE_TABS
- const sideTab = ref('nearby')
- const assetFacility = computed(() => props.facilityState || { detail: null, loading: false, error: false })
- const assetContext = computed(() => ({
- device: props.deviceState?.selected || null,
- facility: assetFacility.value?.detail ? {
- id: assetFacility.value.detail.id || '',
- category: assetFacility.value.detail.kind === 'facility' ? (assetFacility.value.detail.category || '') : '',
- title: assetFacility.value.detail.name || assetFacility.value.detail.code || '',
- subtitle: assetFacility.value.detail.industry || '',
- } : null,
- }))
- const assetKind = computed(() => {
- // 设施详情优先(维护者 2026-11-16):用户是在这里主动选了窨井才进来的,
- // 上一次残留的设备选择不该继续霸占「资产详情」。判据收在 domain/assetDetailKind.js。
- const kind = resolveAssetKind({
- deviceCode: props.deviceState?.selected?.code || '',
- facilityDetail: assetFacility.value?.detail || null,
- })
- return kind === 'facility' ? ASSET_KIND.FACILITY : kind === 'device' ? ASSET_KIND.DEVICE : ''
- })
- // 有资产被选中就切到详情页;全部取消则退回列表页,避免停在空白详情。
- watch(assetKind, (kind) => { sideTab.value = kind ? 'detail' : 'nearby' }, { immediate: true })
- const viewport = ref(null)
- const localPipeStates = computed(() => [...new Map((props.plan.objects || [])
- .filter((object) => object.sourceKind === 'pipe').map((object) => [object.code, object])).values()])
- /**
- * 附近管道状态分页(维护者 2026-10-22):邻域管网很容易几十条,
- * 一屏铺开会把设备区挤到看不见。每页固定 8 条,翻页只切窗口、不改数据。
- */
- const PIPE_PAGE_SIZE = 8
- const pipePage = ref(1)
- const pipePageCount = computed(() => Math.max(1, Math.ceil(localPipeStates.value.length / PIPE_PAGE_SIZE)))
- const pagedPipeStates = computed(() => {
- const page = Math.min(Math.max(1, pipePage.value), pipePageCount.value)
- const start = (page - 1) * PIPE_PAGE_SIZE
- return localPipeStates.value.slice(start, start + PIPE_PAGE_SIZE)
- })
- // 同一管段的后台数据更新保留页码;换对象/邻域范围才回首页。
- watch(() => JSON.stringify([props.plan.object?.sourceKind, props.plan.object?.code, props.plan.radiusM]), () => { pipePage.value = 1 })
- watch(pipePageCount, (count) => { pipePage.value = Math.min(pipePage.value, count) })
- let viewer = null
- let mountGeneration = 0
- const open = ref(false)
- /**
- * 设备被选中(清单点击或场景图标点击)时的统一处理:先让镜头**飞行定位**到该设备,
- * 再打开内部详情。
- *
- * 维护者 2026-10-22:「地下管线详情视图的相机位移没成功实现。」
- * 根因是**场景图标点击**走的是 `onDevicePick`,而那条路径只 emit、从不调用 `focusDevice`,
- * 所以只有右侧清单点击才会定位。现在两条入口共用本函数,不会再分叉。
- */
- function pickDevice(device) {
- // 只有能上图(有合法坐标)的设备才有可定位的模型;仅清单项没有位置可飞。
- if (device && device.placement !== 'list-only') viewer?.focusDevice?.(device.code)
- emit('device-pick', device)
- }
- function selectDevice(device) {
- pickDevice(device)
- }
- function disposeViewer() {
- if (viewer) viewer.destroy()
- viewer = null
- }
- async function mount() {
- const generation = ++mountGeneration
- open.value = props.plan?.visible === true
- if (!open.value) { disposeViewer(); return }
- if (viewer?.sync) { viewer.sync(props.plan); return }
- await nextTick()
- if (generation !== mountGeneration || !open.value || !viewport.value) return
- viewer = mountPipeEnhancement(viewport.value, props.plan, {
- onDevicePick: (device) => pickDevice(device),
- onObjectPick: (hit) => emit('object-pick', hit),
- })
- }
- watch(
- () => props.plan?.visible === true ? JSON.stringify([props.plan.object, props.plan.radiusM, props.plan.objects, props.plan.devices]) : 'hidden',
- mount,
- { immediate: true },
- )
- onBeforeUnmount(() => {
- mountGeneration += 1
- disposeViewer()
- })
- </script>
- <style scoped>
- .pipe-enhancement {
- position: absolute;
- z-index: 5;
- left: 50%;
- top: 50%;
- transform: translate(-50%, -50%);
- /* 票 90(维护者 2026-10-27):尺寸跟着一张图的分辨率走,不再有固定的 1100×760 顶盖。
- 包含块就是这个浮层的定位祖先 .cockpit-shell__main(一张图铺满的那块),
- 所以 % 指的就是「一张图多大」。
- 宽度(2026-10-27 第二条反馈):**不得覆盖左右两侧信息面板**。
- 两侧栏各占一条 `--rail-w`(超宽屏 ≥3:1 时栏内两块并排,该 token 自动变成两条栏宽;
- 见 tokens.css 的注释「消费点用这一条而不是直接乘 --column-w」),
- 所以可用宽度 = 容器 − 2 × rail − 边距。浮层仍是 50% 居中:两侧栏等宽 ⇒ 中间带也居中,
- 不需要额外偏移。这里刻意**不留比例/下限顶盖**——任何「至少多宽」的下限都会在窄容器上
- 重新压到面板上,而「不覆盖面板」是本条唯一的硬约束;容器窄时浮层就跟着窄。
- 高度(不受两侧栏影响):min(容器 − 边距, max(--u 下限, 84%)),随分辨率长大且不溢出。
- 三维视口不必另写 resize:threePipeEnhancement.js 已用 ResizeObserver 观察宿主并 setSize。 */
- width: calc(100% - 2 * var(--rail-w, 300px) - calc(24 * var(--u, 1px)));
- height: min(calc(100% - 24px), max(calc(340 * var(--u, 1px)), 84%));
- display: grid;
- grid-template-rows: auto auto minmax(0, 1fr) auto auto;
- /* 内边距与间距也走设计像素:外框与字号都随 --u 放大,只留固定 px 会在大屏上显得拥挤。
- 取值按 1080p(--u≈1.3338)反算,1080p 下与原来的 12px / 16px 逐像素一致。 */
- gap: calc(9 * var(--u, 1px));
- min-height: 0;
- overflow: hidden;
- box-sizing: border-box;
- padding: calc(12 * var(--u, 1px));
- border: 1px solid rgba(1, 171, 234, .58);
- border-radius: 6px;
- background: rgba(2, 12, 32, .94);
- box-shadow: 0 14px 34px rgba(0, 0, 0, .5), 0 0 22px rgba(1, 171, 234, .12);
- color: var(--text-1, #e4f4ff);
- }
- .pipe-enhancement__header { display: flex; justify-content: space-between; gap: 12px; align-items: flex-start; }
- .pipe-enhancement__eyebrow { color: var(--cyan, #01abea); font-size: 10px; letter-spacing: .08em; }
- .pipe-enhancement h2 { margin: 3px 0 0; font-size: 20px; line-height: 1.35; overflow-wrap: anywhere; }
- .pipe-enhancement__controls { margin: 6px 0 0; color: var(--text-3, #7ba4c3); font-size: 12px; }
- .pipe-enhancement__close { width: 28px; height: 28px; border: 1px solid rgba(1, 171, 234, .46); border-radius: 4px; background: transparent; color: inherit; font-size: 20px; line-height: 1; cursor: pointer; }
- .pipe-enhancement__close:hover, .pipe-enhancement__close:focus-visible { border-color: var(--cyan, #01abea); color: #fff; outline: none; }
- /* 右侧块(附近管道状态 + 监测设备)从 32% 放宽到 42%:两块改成左右并排后,
- 每块仍需要能读下「源管径 / 源材质 / 地理路径」那几行小字,否则并排只是把两列都挤扁。 */
- .pipe-enhancement__workspace { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) minmax(calc(300 * var(--u, 1px)), 46%); gap: 12px; min-height: 0; }
- /* 票 90 第二条(维护者 2026-10-27):右侧的「附近管道状态」与「监测设备」改为**左右并排**,
- 不再上下堆叠 —— 两块本就各自独立滚动,竖排等于把同一块纵向空间切成两半,谁都读不全。
- 分隔线跟着从「上边框」改成两列之间的竖线。 */
- .pipe-enhancement__side { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-left: 1px solid #174969; padding-left: 12px; font-size: 12px; }
- .pipe-enhancement__side-tabs { display: flex; flex: none; gap: 6px; margin-bottom: 8px; }
- .pipe-enhancement__side-tabs button { flex: 1; padding: 6px 8px; border: 1px solid #226286; border-radius: calc(8 * var(--u, 1px)); background: #072039; color: #a7c4d9; font: inherit; cursor: pointer; }
- .pipe-enhancement__side-tabs button.is-active { border-color: var(--cyan, #01abea); background: linear-gradient(180deg, rgba(1, 171, 234, .85), rgba(0, 82, 168, .85)); color: #fff; }
- .pipe-enhancement__nearby, .pipe-enhancement__asset-pane { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
- .pipe-enhancement__asset-pane { overflow: auto; }
- .pipe-enhancement__nearby { overflow: hidden; }
- .pipe-enhancement__devices { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 10px; min-height: 0; overflow: hidden; }
- .pipe-enhancement__pipe-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; border-right: 1px solid #174969; padding-right: 10px; }
- .pipe-enhancement__device-list { display: flex; flex-direction: column; min-height: 0; overflow: hidden; }
- .pipe-enhancement__pipe-scroll, .pipe-enhancement__device-scroll { min-height: 0; overflow: auto; overscroll-behavior: contain; }
- /* 卡片:只留卡片信息(标题 + 编码/状态 + 管径/材质),不再铺长串描述。 */
- .pipe-enhancement__asset-card { display: block; width: 100%; margin-bottom: 6px; padding: 7px 8px; text-align: left; border: 1px solid #21618a; border-radius: calc(8 * var(--u, 1px)); background: #08213a; color: #e4f4ff; font: inherit; cursor: pointer; }
- .pipe-enhancement__asset-card b { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
- .pipe-enhancement__asset-card small { display: block; margin-top: 3px; color: #a7c4d9; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
- .pipe-enhancement__asset-card[aria-pressed="true"] { border-color: #d8fbff; box-shadow: inset 0 0 4px #38bac9; }
- .pipe-enhancement__hint { margin: 0 0 8px; color: #a7c4d9; line-height: 1.5; }
- .pipe-enhancement__hint.is-error { color: var(--lv1, #ff3b52); }
- .pipe-enhancement__action { align-self: flex-start; padding: 5px 10px; border: 1px solid #21618a; border-radius: calc(8 * var(--u, 1px)); background: #08213a; color: #e4f4ff; cursor: pointer; }
- .pipe-enhancement__device-status-card {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: 10px;
- margin: 6px 0 10px;
- padding: 7px 10px;
- border: 1px solid rgba(1, 171, 234, .36);
- border-radius: 8px;
- background: linear-gradient(135deg, rgba(4, 42, 76, .72), rgba(5, 23, 47, .88));
- }
- .pipe-enhancement__device-status-label { color: #7ba4c3; }
- .pipe-enhancement__pager { display: flex; align-items: center; justify-content: space-between; gap: 6px; margin-top: 6px; font-size: 11px; color: #a7c4d9; }
- .pipe-enhancement__pager button { padding: 3px 8px; }
- .pipe-enhancement__pager button:disabled { opacity: .4; cursor: default; }
- .pipe-enhancement__scope { display: flex; flex-wrap: wrap; align-items: center; gap: 12px; color: #a7c4d9; font-size: 12px; }
- .pipe-enhancement__scope select { margin-left: 8px; padding: 5px 10px; border: 1px solid #168bff; border-radius: 4px; background: #031226; color: #e4f4ff; }
- .pipe-enhancement__viewport { min-height: 0; overflow: hidden; border: 1px solid rgba(1, 171, 234, .24); background: #031226; outline: none; touch-action: none;
- border-radius: calc(8 * var(--u, 1px));}
- .pipe-enhancement__viewport[data-scene-focused] { border-color: var(--cyan, #01abea); box-shadow: inset 0 0 0 1px var(--cyan, #01abea); }
- .pipe-enhancement__viewport :deep(canvas) { display: block; width: 100%; height: 100%; }
- .pipe-enhancement__facts { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px 16px; margin: 0; font-size: 14px; }
- .pipe-enhancement__facts div { min-width: 0; }
- .pipe-enhancement__facts dt { color: var(--text-3, #7ba4c3); }
- .pipe-enhancement__facts dd { margin: 2px 0 0; overflow-wrap: anywhere; }
- .pipe-enhancement__note { margin: 0; color: #a7c4d9; font-size: 12px; line-height: 1.45; }
- </style>
|