| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234 |
- <template>
- <div class="warning-response-pane" :data-warning-panel="panelId" :data-event-mode="eventStore.mode">
- <div class="warning-response-pane__controls" role="group" aria-label="预警/报警和时间范围">
- <button
- v-for="option in modeOptions"
- :key="option.key"
- type="button"
- class="warning-response-pane__control"
- :class="{ 'is-active': option.key === eventStore.mode }"
- :aria-pressed="option.key === eventStore.mode"
- :data-event-switch="option.key"
- @click="eventStore.setMode(option.key)"
- >
- {{ option.label }}
- </button>
- <span class="warning-response-pane__divider" aria-hidden="true"></span>
- <button
- v-for="option in rangeOptions"
- :key="option.key"
- type="button"
- class="warning-response-pane__control"
- :class="{ 'is-active': option.key === eventStore.range }"
- :aria-pressed="option.key === eventStore.range"
- :data-event-range="option.key"
- @click="eventStore.setRange(option.key)"
- >
- {{ option.label }}
- </button>
- </div>
- <p class="warning-response-pane__range-status" role="status" aria-live="polite">
- {{ rangeLabel }} · {{ eventStore.loading ? '正在更新…' : '当前统计窗口' }}
- </p>
- <p v-if="!eventStore.loading && section && section.reason && /历史接口回显/.test(section.reason)" class="warning-response-pane__range-status" role="alert">{{ section.reason }}</p>
- <PanelBlocks v-if="view && !eventStore.loading" :key="`${panelId}-${eventStore.mode}-${eventStore.range}`" :view="view" @list-page="onListPage" @card-action="onCardAction" />
- </div>
- </template>
- <script setup>
- import { computed } from 'vue'
- import { EVENT_RANGES } from '../domain/warningResponsePanels.js'
- import { eventListSwitchOptions } from '../domain/eventList.js'
- import { panelView } from '../domain/panelViews.js'
- import { panelSideFor } from '../domain/panelCatalog.js'
- import { useEventStore } from '../stores/eventStore.js'
- import { useEntityDetailStore } from '../stores/entityDetailStore.js'
- import PanelBlocks from './PanelBlocks.vue'
- const props = defineProps({ panelId: { type: String, required: true } })
- const eventStore = useEventStore()
- const entityDetailStore = useEntityDetailStore()
- /** 详情浮层贴来源侧:本面板在哪一栏由目录单源给出,组件不自己判。 */
- const side = computed(() => panelSideFor('warningResponse', props.panelId) || 'right')
- const modeOptions = eventListSwitchOptions()
- const rangeOptions = EVENT_RANGES
- const rangeLabel = computed(() => EVENT_RANGES.find((item) => item.key === eventStore.range)?.label || '')
- const section = computed(() => eventStore.sections[props.panelId])
- const view = computed(() => {
- const current = section.value || { state: 'empty', loaded: false, data: null }
- // 票 65:把当前切换族交给 domain —— 预警效率面板要按族分流(预警不挂工单)。
- // 族是标量、跨重算稳定;`data.family`(后端回显)仍优先于它,见
- // `domain/warningResponsePanels.js` 的 `responseEfficiencyPanel`。
- // `workOrderList` 是报警模式「当前工单列表」块的数据源(另一个端点,见 store 注释)。
- // 票 71 返工:预警分析的「按事件类型」对报警族要用**事件名称**归类
- // (后端 EVENT_TYPE 对报警恒回未知桶,见 domain 的 alarmEventTypeRows),
- // 所以把已取到的历史事件行一并交给面板 —— 同窗口、同族、不发额外请求。
- const historyEvents = eventStore.sections.historyAnalysis && eventStore.sections.historyAnalysis.data
- ? eventStore.sections.historyAnalysis.data.events
- : null
- return panelView(props.panelId, current.data, current, {
- mode: eventStore.mode,
- workOrderList: eventStore.sections.workOrderList,
- historyEvents,
- })
- })
- /**
- * 服务端页码翻页出口(PanelBlocks 的 `serverPage` 块)。
- *
- * **按块标签分派,不按面板名一刀切**:同一个面板里现在有两块服务端分页块,
- * 它们背后是**两个不同端点、两个不同页码**——
- * · 历史分析:单窗范围的历史事件(多窗合并范围走块内前端集合分页,不经过这里);
- * · 报警效率:「报警列表」(票 71,随效率端点分页);
- * · 预警效率:「预警列表」(票 71,同一端点、同一个页码);
- * · 报警效率:「当前工单列表」(票 65,另一个端点 `/work-orders`)。
- * 早先这里只认 `historyAnalysis`,导致工单列表画出了翻页控件、点了却什么都没发生
- * —— 事件被 `return` 掉,页码根本没进 store(t65 的 H 组 + 变异 M27 钉住)。
- * 票 71 新增两块列表后,同样的坑会以「列表翻了工单页」的形式复现,所以这里改按标签判。
- */
- function onListPage(payload) {
- const target = payload && payload.page
- const label = String((payload && payload.label) || '')
- if (props.panelId === 'historyAnalysis') {
- eventStore.setHistoryPage(target)
- return
- }
- if (props.panelId === 'responseEfficiency') {
- // 工单列表的块标签是「当前工单列表」;其余两块是两族的事件列表(同一个页码)。
- if (label === '当前工单列表') eventStore.setWorkOrderPage(target)
- else eventStore.setEfficiencyPage(target)
- }
- }
- /** 历史事件与工单按显式身份分流,禁止把事件卡误开成工单。 */
- function onCardAction(action) {
- const row = (action && action.row) || {}
- // 工单卡的路由身份是后端 orderId(票 129);事件仍用业务编码。
- const id = (row.identityCode || action.identityCode || action.code) || ''
- if (!id) return false
- const prefill = row.identityPayload || row
- if (action.kind === 'event') {
- eventStore.closeEvent()
- return entityDetailStore.show({ kind: 'event', id, family: row.identityFamily || row.family || eventStore.mode }, prefill, { side: side.value })
- }
- if (action.kind === 'work-order') {
- return entityDetailStore.show({ kind: 'work-order', id }, prefill, { side: side.value })
- }
- return false
- }
- </script>
- <style scoped>
- .warning-response-pane,
- .warning-response-pane * {
- box-sizing: border-box;
- }
- .warning-response-pane {
- display: grid;
- gap: calc(6 * var(--u, 1px));
- min-height: 0;
- }
- .warning-response-pane__controls {
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- gap: calc(3 * var(--u, 1px));
- }
- .warning-response-pane__control {
- padding: calc(1 * var(--u, 1px)) calc(8 * var(--u, 1px));
- border: 1px solid rgba(1, 171, 234, 0.32);
- border-radius: calc(8 * var(--u, 1px));
- background: rgba(0, 20, 72, 0.6);
- color: var(--text-2);
- font: inherit;
- font-size: var(--fs-caption, 10.5px);
- cursor: pointer;
- }
- .warning-response-pane__control.is-active,
- .warning-response-pane__control:hover,
- .warning-response-pane__control:focus-visible {
- border-color: rgba(0, 184, 255, 0.85);
- background: rgba(0, 82, 168, 0.72);
- color: var(--text-strong);
- }
- .warning-response-pane__divider {
- width: 1px;
- height: calc(16 * var(--u, 1px));
- margin: 0 calc(3 * var(--u, 1px));
- background: rgba(1, 171, 234, 0.45);
- }
- .warning-response-pane__range-status {
- margin: 0;
- color: var(--text-2);
- font-size: var(--fs-caption);
- }
- .is-updating { opacity: .45; transition: opacity .15s; }
- /* ---- 票 65:工单处置轨迹浮层 ---- */
- .warning-response-pane__modal {
- position: fixed;
- z-index: 30; /* 高于两侧面板栏,低于顶栏诊断浮层(20 的上级),保证能盖住卡片列表 */
- right: calc(var(--column-w) + 12 * var(--u, 1px));
- top: calc(120 * var(--u, 1px));
- width: min(420px, 92vw);
- max-height: 62vh;
- overflow: auto;
- padding: calc(10 * var(--u, 1px)) calc(12 * var(--u, 1px));
- border: 1px solid rgba(1, 171, 234, 0.5);
- border-radius: calc(8 * var(--u, 1px));
- background: rgba(2, 10, 20, 0.96);
- box-shadow: 0 10px 32px rgba(0, 0, 0, 0.6);
- }
- .warning-response-pane__modal-head {
- display: flex;
- align-items: center;
- gap: calc(8 * var(--u, 1px));
- }
- .warning-response-pane__modal-title {
- flex: 1;
- min-width: 0;
- overflow: hidden;
- text-overflow: ellipsis;
- white-space: nowrap;
- color: var(--text-strong);
- font-size: var(--fs-body);
- }
- .warning-response-pane__modal-close {
- padding: calc(2 * var(--u, 1px)) calc(8 * var(--u, 1px));
- border: 1px solid rgba(1, 171, 234, 0.4);
- border-radius: calc(6 * var(--u, 1px));
- background: rgba(0, 20, 72, 0.7);
- color: var(--text-2);
- font: inherit;
- font-size: var(--fs-caption);
- cursor: pointer;
- }
- .warning-response-pane__modal-close:hover,
- .warning-response-pane__modal-close:focus-visible {
- border-color: rgba(0, 184, 255, 0.85);
- color: var(--text-strong);
- }
- .warning-response-pane__modal-desc {
- margin: calc(6 * var(--u, 1px)) 0 0;
- color: var(--text-2);
- font-size: var(--fs-caption);
- line-height: 1.5;
- }
- .warning-response-pane__modal-hint {
- margin: calc(8 * var(--u, 1px)) 0 0;
- color: var(--text-2);
- font-size: var(--fs-caption);
- }
- </style>
|