realTimeShow.vue 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840
  1. <!-- 感知信息实时展示(重写) -->
  2. <template>
  3. <div class="app-container perception-page">
  4. <div class="grid-main">
  5. <!-- ============ 左:设备状态总览 ============ -->
  6. <div class="card">
  7. <div class="card-head">
  8. <div class="card-title">
  9. 设备状态总览
  10. <span class="title-sub">按片区聚合 · 设备点阵</span>
  11. </div>
  12. <div class="row gap8 wrap">
  13. <el-input
  14. v-model="locateKeyword"
  15. placeholder="定位设备:编码 / 名称"
  16. style="width: 260px"
  17. clearable
  18. @keyup.enter="locateDevice"
  19. />
  20. <el-button type="primary" :loading="locateLoading" @click="locateDevice">定位</el-button>
  21. <el-button type="primary" plain size="small" :icon="Refresh" :loading="refreshing" @click="refreshAll">刷新</el-button>
  22. </div>
  23. </div>
  24. <div class="ov-toolbar">
  25. <span class="legend-inline">
  26. <span><i style="background:#16a34a"></i>在线</span>
  27. <span><i style="background:#cbd5e1"></i>离线</span>
  28. <span><i class="flash" style="background:#ef4444"></i>报警</span>
  29. </span>
  30. </div>
  31. <!-- 全域健康度带 -->
  32. <div class="health-band">
  33. <div class="hb-rate">
  34. <b :class="{ 'text-red': (stats.online ?? 0) < (stats.total ?? 1) * 0.6 }">{{ onlineRate }}%</b>
  35. <span>设备在线率</span>
  36. </div>
  37. <div class="hb-bar">
  38. <i class="on" :style="{ width: onlineRate + '%' }"></i>
  39. <i class="off" :style="{ width: offlineRate + '%' }"></i>
  40. <i class="al" :style="{ width: alarmRate + '%' }"></i>
  41. </div>
  42. <div class="hb-items">
  43. <div><b>{{ stats.total ?? 0 }}</b><span>总数(台)</span></div>
  44. <div><b class="text-green">{{ stats.online ?? 0 }}</b><span>在线(台)</span></div>
  45. <div><b class="text-gray">{{ stats.offline ?? 0 }}</b><span>离线(台)</span></div>
  46. <div><b class="text-red">{{ stats.alarm ?? 0 }}</b><span>报警(台)</span></div>
  47. </div>
  48. </div>
  49. <!-- 片区卡 + 点阵 -->
  50. <div class="area-grid">
  51. <div
  52. v-for="a in areaRank"
  53. :key="a.district"
  54. class="acard"
  55. :class="{ 'has-alarm': a.alarm > 0 }"
  56. >
  57. <div class="ac-head">
  58. <div class="ac-id">
  59. <div class="ac-name">{{ a.districtName }}</div>
  60. <div class="ac-sub">片区设备总览</div>
  61. </div>
  62. <div class="ac-rate">
  63. <b>{{ areaOnlineRate(a) }}%</b>
  64. <span>在线率</span>
  65. </div>
  66. </div>
  67. <div class="ac-bar">
  68. <i class="on" :style="{ width: areaOnlineRate(a) + '%' }"></i>
  69. <i class="off" :style="{ width: areaOfflineRate(a) + '%' }"></i>
  70. <i class="al" :style="{ width: areaAlarmRate(a) + '%' }"></i>
  71. </div>
  72. <div class="ac-metrics">
  73. <div><span>总数</span><b>{{ a.total }}</b></div>
  74. <div><span>在线</span><b class="text-green">{{ a.online }}</b></div>
  75. <div><span>离线</span><b class="text-gray">{{ a.offline }}</b></div>
  76. </div>
  77. <div class="dot-matrix">
  78. <div
  79. v-for="d in devicesByDistrict(a.district)"
  80. :key="d.equipmentId"
  81. class="dot"
  82. :class="dotClass(d)"
  83. :title="`${d.equipmentName}(${d.equipmentCode})`"
  84. @click="openProfile(d)"
  85. ></div>
  86. <span v-if="!devicesByDistrict(a.district).length" class="ac-tip">暂无设备</span>
  87. </div>
  88. </div>
  89. </div>
  90. <!-- 类型构成 -->
  91. <div class="type-dist">
  92. <div class="sr-head">设备类型构成</div>
  93. <div class="td-grid">
  94. <div v-for="t in typeDistribution" :key="t.name" class="td-row">
  95. <span class="td-name">{{ t.name }}</span>
  96. <div class="td-track"><i :style="{ width: t.rate + '%' }"></i></div>
  97. <span class="td-num">{{ t.count }} 台 · 在线 {{ t.online }}</span>
  98. </div>
  99. </div>
  100. </div>
  101. <!-- 定位结果 -->
  102. <div v-if="locateResults.length" class="search-result">
  103. <div class="sr-head">定位结果(回车或点击定位,可精确打开档案)</div>
  104. <div class="sr-list">
  105. <div
  106. v-for="d in locateResults"
  107. :key="d.equipmentId"
  108. class="sr-item"
  109. @click="openProfile(d)"
  110. >
  111. <span class="sr-dot" :class="dotClass(d)"></span>
  112. <span class="sr-name">{{ d.equipmentName }}</span>
  113. <span class="sr-meta">{{ d.equipmentTypeName || "未分类" }}</span>
  114. <span class="sr-code">{{ d.equipmentCode }}</span>
  115. </div>
  116. </div>
  117. </div>
  118. <el-empty v-if="!equipmentList.length" description="暂无可展示的感知设备" />
  119. </div>
  120. <!-- ============ 右:实时报警 / 片区健康排行 / 报警类型分布 ============ -->
  121. <div class="side-col">
  122. <div class="card alarm-card">
  123. <div class="card-head">
  124. <div class="card-title">实时报警 <span class="badge" :class="{ zero: !alarms.length }">{{ alarms.length }}</span></div>
  125. </div>
  126. <div class="alarm-list">
  127. <div v-for="a in alarms" :key="a.id" class="alarm-item">
  128. <div class="alarm-top">
  129. <span class="alarm-dev">{{ a.deviceName || a.deviceCode }}<span class="alarm-code">{{ a.deviceCode }}</span></span>
  130. <span class="alarm-level" :style="{ color: levelColor(a.alarmLevel) }">{{ levelName(a.alarmLevel) }}</span>
  131. </div>
  132. <div class="alarm-time">
  133. <span v-if="a.alarmNo" class="alarm-no">{{ a.alarmNo }}</span>
  134. <span>{{ a.createTime }}</span>
  135. </div>
  136. <div class="alarm-desc">{{ a.alarmContent || "—" }} <span v-if="a.actualValue != null">实测 {{ a.actualValue }}</span></div>
  137. </div>
  138. <el-empty v-if="!alarms.length" description="当前无未解除报警" :image-size="60" />
  139. </div>
  140. </div>
  141. <div class="card">
  142. <div class="card-head"><div class="card-title">报警类型分布</div></div>
  143. <div class="type-dist side">
  144. <div v-for="t in alarmTypeDist" :key="t.warningCode" class="td-row">
  145. <span class="td-name">{{ indicatorName(t, '监测指标') }}</span>
  146. <div class="td-track"><i :style="{ width: typeDistRate(t) + '%' }"></i></div>
  147. <span class="td-num">{{ t.count }} 条</span>
  148. </div>
  149. <el-empty v-if="!alarmTypeDist.length" description="暂无报警分布" :image-size="50" />
  150. </div>
  151. </div>
  152. <div class="card">
  153. <div class="card-head"><div class="card-title">片区健康排行</div></div>
  154. <div class="rank-list">
  155. <div v-for="(a, i) in areaRank" :key="a.district" class="rank-row" :class="{ top: i === 0 }">
  156. <span class="rank-no">{{ i + 1 }}</span>
  157. <span class="rank-name">{{ a.districtName }}</span>
  158. <div class="rank-track"><i :style="{ width: areaOnlineRate(a) + '%', background: '#16a34a' }"></i></div>
  159. <span class="rank-val">在线 {{ a.online }} / {{ a.total }}</span>
  160. </div>
  161. </div>
  162. </div>
  163. </div>
  164. </div>
  165. <!-- ============ 设备档案抽屉 ============ -->
  166. <el-drawer
  167. v-model="profileOpen"
  168. title="设备档案"
  169. size="720px"
  170. append-to-body
  171. direction="rtl"
  172. @closed="onDrawerClosed"
  173. >
  174. <template #header>
  175. <div class="drawer-title" v-if="profile.base">
  176. <span class="dt-name">{{ profile.base.equipmentName }}</span>
  177. <span class="tag" :class="profileTagClass(profile.base)">
  178. {{ statusText(profile.base) }}
  179. </span>
  180. </div>
  181. </template>
  182. <div v-loading="profileLoading">
  183. <template v-if="profile.base">
  184. <div class="ctl-dev">
  185. <div class="ctl-dev-grid">
  186. <div>设备编号:<b>{{ profile.base.equipmentCode }}</b></div>
  187. <div>设备类型:<b>{{ profile.base.equipmentTypeName || "—" }}</b></div>
  188. <div>所属片区:<b>{{ districtName(profile.base.district) }}</b></div>
  189. <div>安装位置:<b>{{ profile.base.equipmentLocation || "—" }}</b></div>
  190. <div class="full">最后通信:<b>{{ profile.lastCommTime || "—" }}</b></div>
  191. </div>
  192. </div>
  193. <div class="form-item">
  194. <div class="record-head">
  195. <span>采集记录(最近 50 条)</span>
  196. <el-button link type="primary" icon="Refresh" :loading="profileLoading" @click="refreshProfile">刷新</el-button>
  197. </div>
  198. <div class="hist-wrap">
  199. <el-table :data="pagedRecordRows" max-height="480" size="small">
  200. <el-table-column
  201. v-for="c in recordViewColumns"
  202. :key="c.key"
  203. :label="c.label + (c.unit ? '(' + c.unit + ')' : '')"
  204. :min-width="c.key === 'create_time' ? 168 : (c.key === 'filepath' ? 170 : 104)"
  205. >
  206. <template #default="{ row, $index }">
  207. <span v-if="c.key === 'create_time'">{{ row.createTime || '—' }}</span>
  208. <span v-else-if="c.key === 'filepath'" class="rec-audio-cell">
  209. <audio
  210. v-if="valueOf(row, c.key) && valueOf(row, c.key) !== '—'"
  211. class="rec-audio"
  212. controls
  213. preload="none"
  214. :src="buildMinioAttachmentUrl(valueOf(row, c.key))"
  215. @play="pauseOtherAudios"
  216. ></audio>
  217. <span v-else>—</span>
  218. </span>
  219. <span v-else :class="{ 'cell-alarm': alarmOf(row, c.key) }">{{ valueOf(row, c.key) }}</span>
  220. </template>
  221. </el-table-column>
  222. <template #empty>
  223. <div class="rec-empty">暂无采集记录</div>
  224. </template>
  225. </el-table>
  226. <el-pagination
  227. v-if="recordRows.length"
  228. class="rec-pager"
  229. layout="prev, pager, next"
  230. :total="recordRows.length"
  231. :page-size="recordPageSize"
  232. small
  233. v-model:current-page="recordPage"
  234. />
  235. </div>
  236. </div>
  237. <div class="drawer-actions">
  238. <el-button @click="profileOpen = false">关闭</el-button>
  239. </div>
  240. </template>
  241. <el-empty v-else description="未找到设备档案" />
  242. </div>
  243. </el-drawer>
  244. </div>
  245. </template>
  246. <script setup>
  247. import { computed, onMounted, reactive, ref } from "vue";
  248. import { Refresh } from "@element-plus/icons-vue";
  249. import { getEquipmentStatusStatistics, listEquipmentTypeAll } from "@/api/pipeNetwork/pdeviceInform";
  250. import {
  251. pagePerceptionEquipment,
  252. getEquipmentProfile,
  253. pageActiveAlarms,
  254. getAreaRank,
  255. getAlarmTypeDist
  256. } from "@/api/pipeNetwork/perception";
  257. import { buildMinioAttachmentUrl } from "@/utils/minioAttachment";
  258. import { indicatorName, loadIndicatorNames } from "@/utils/warningIndicator";
  259. const loading = ref(false);
  260. const refreshing = ref(false);
  261. const stats = ref({});
  262. const equipmentList = ref([]);
  263. const total = ref(0);
  264. const areaRank = ref([]);
  265. const alarmTypeDist = ref([]);
  266. const alarms = ref([]);
  267. const typeOptions = ref([]);
  268. const locateKeyword = ref("");
  269. const locateResults = ref([]);
  270. const locateLoading = ref(false);
  271. const filters = reactive({
  272. onlineStatus: undefined,
  273. district: undefined,
  274. equipmentTypeId: undefined
  275. });
  276. const queryParams = reactive({
  277. pageNum: 1,
  278. pageSize: 300
  279. });
  280. const profileOpen = ref(false);
  281. const profileLoading = ref(false);
  282. const profile = ref({ base: null, records: [], indicators: [], origCollTable: "", recordView: { columns: [], rows: [] } });
  283. const currentProfileId = ref("");
  284. const districtOptions = [
  285. { value: 0, label: "城南" },
  286. { value: 1, label: "城北" },
  287. { value: 2, label: "太常" }
  288. ];
  289. const onlineRate = computed(() => {
  290. const t = stats.value.total || 0;
  291. return t ? Math.round(((stats.value.online || 0) / t) * 100) : 0;
  292. });
  293. const offlineRate = computed(() => {
  294. const t = stats.value.total || 0;
  295. return t ? Math.round(((stats.value.offline || 0) / t) * 100) : 0;
  296. });
  297. const alarmRate = computed(() => {
  298. const t = stats.value.total || 0;
  299. return t ? Math.round(((stats.value.alarm || 0) / t) * 100) : 0;
  300. });
  301. const typeDistribution = computed(() => {
  302. const map = {};
  303. equipmentList.value.forEach((d) => {
  304. const name = d.equipmentTypeName || "未分类";
  305. if (!map[name]) map[name] = { count: 0, online: 0 };
  306. map[name].count += 1;
  307. if (d.onlineStatus === 1) map[name].online += 1;
  308. });
  309. const entries = Object.keys(map).map((name) => ({
  310. name,
  311. count: map[name].count,
  312. online: map[name].online
  313. }));
  314. // 按总台数降序排布
  315. entries.sort((a, b) => b.count - a.count);
  316. const max = Math.max(1, ...entries.map((e) => e.count));
  317. return entries.map((e) => ({ ...e, rate: Math.round((e.count / max) * 100) }));
  318. });
  319. const recordView = computed(() => profile.value.recordView || { columns: [], rows: [] });
  320. const recordViewColumns = computed(() => recordView.value.columns || []);
  321. const recordRows = computed(() => recordView.value.rows || []);
  322. // 采集记录分页(每页 10 条)
  323. const recordPage = ref(1);
  324. const recordPageSize = 10;
  325. const pagedRecordRows = computed(() => {
  326. const start = (recordPage.value - 1) * recordPageSize;
  327. return recordRows.value.slice(start, start + recordPageSize);
  328. });
  329. function districtName(district) {
  330. const found = districtOptions.find((d) => d.value === district);
  331. return found ? found.label : "—";
  332. }
  333. function isOnline(d) {
  334. return d.onlineStatus === 1;
  335. }
  336. function isAlarm(d) {
  337. return d.alarmStatus === 1;
  338. }
  339. function dotClass(d) {
  340. if (isAlarm(d)) return "al";
  341. return isOnline(d) ? "on" : "off";
  342. }
  343. function profileTagClass(base) {
  344. if (isAlarm(base)) return "tag-red";
  345. return isOnline(base) ? "tag-green" : "tag-gray";
  346. }
  347. function statusText(d) {
  348. if (isAlarm(d)) return "报警";
  349. return isOnline(d) ? "在线" : "离线";
  350. }
  351. function areaOnlineRate(a) {
  352. return a.total ? Math.round((a.online / a.total) * 100) : 0;
  353. }
  354. function areaOfflineRate(a) {
  355. return a.total ? Math.round((a.offline / a.total) * 100) : 0;
  356. }
  357. function areaAlarmRate(a) {
  358. return a.total ? Math.round((a.alarm / a.total) * 100) : 0;
  359. }
  360. function typeDistRate(t) {
  361. const max = Math.max(1, ...alarmTypeDist.value.map((x) => x.count || 0));
  362. return Math.round(((t.count || 0) / max) * 100);
  363. }
  364. function devicesByDistrict(district) {
  365. return equipmentList.value.filter((d) => d.district === district);
  366. }
  367. function valueOf(row, key) {
  368. const cells = row.cells || [];
  369. const c = cells.find((x) => x.key === key);
  370. if (!c) return "—";
  371. // 竖表(水质指标)展示串已含指标名与单位;宽表使用不含单位的纯值
  372. if (recordView.value.layout === "long") return c.display;
  373. return c.value && c.value !== "" ? c.value : c.display;
  374. }
  375. function alarmOf(row, key) {
  376. const cells = row.cells || [];
  377. const c = cells.find((x) => x.key === key);
  378. return c ? !!c.alarm : false;
  379. }
  380. // 采集记录音频:行内原生播放器,一次只播一条
  381. function pauseOtherAudios(e) {
  382. document.querySelectorAll("audio.rec-audio").forEach((el) => {
  383. if (el !== e.target) el.pause();
  384. });
  385. }
  386. function onDrawerClosed() {
  387. document.querySelectorAll("audio.rec-audio").forEach((el) => el.pause());
  388. }
  389. // 报警等级配色(与系统 alarm 模块保持一致:1红 2橙 3蓝 4绿)
  390. function levelColor(level) {
  391. return ({ 1: "#f56c6c", 2: "#e6a23c", 3: "#409eff", 4: "#67c23a" }[level] || "#909399");
  392. }
  393. // 报警等级字典名称(与 alarm_level 字典一致:一级/二级/三级/四级报警)
  394. function levelName(level) {
  395. return ({ 1: "一级报警", 2: "二级报警", 3: "三级报警", 4: "四级报警" }[level] || (level != null ? level + "级" : "—"));
  396. }
  397. function loadStatistics() {
  398. return getEquipmentStatusStatistics().then((res) => {
  399. stats.value = res.data || {};
  400. });
  401. }
  402. function loadEquipment() {
  403. loading.value = true;
  404. return pagePerceptionEquipment({
  405. pageNum: queryParams.pageNum,
  406. pageSize: queryParams.pageSize,
  407. equipmentCode: undefined,
  408. equipmentName: undefined,
  409. equipmentTypeId: filters.equipmentTypeId,
  410. rootTypeId: undefined,
  411. onlineStatus: filters.onlineStatus,
  412. alarmStatus: undefined,
  413. district: filters.district,
  414. currentStatus: undefined
  415. })
  416. .then((res) => {
  417. const page = res.data || {};
  418. equipmentList.value = page.records || [];
  419. total.value = page.total || 0;
  420. })
  421. .finally(() => {
  422. loading.value = false;
  423. });
  424. }
  425. function loadAreaRank() {
  426. return getAreaRank().then((res) => {
  427. areaRank.value = res.data || [];
  428. });
  429. }
  430. function loadAlarmTypeDist() {
  431. return getAlarmTypeDist().then((res) => {
  432. alarmTypeDist.value = res.data || [];
  433. });
  434. }
  435. function loadAlarms() {
  436. return pageActiveAlarms({ pageNum: 1, pageSize: 20 }).then((res) => {
  437. const page = res.data || {};
  438. alarms.value = page.records || [];
  439. });
  440. }
  441. function loadProfile(id) {
  442. profileLoading.value = true;
  443. return getEquipmentProfile(id)
  444. .then((res) => {
  445. profile.value = res.data || { base: null, records: [], indicators: [], origCollTable: "", recordView: { columns: [], rows: [] } };
  446. })
  447. .finally(() => {
  448. profileLoading.value = false;
  449. });
  450. }
  451. async function locateDevice() {
  452. const kw = locateKeyword.value.trim();
  453. if (!kw) {
  454. locateResults.value = [];
  455. return;
  456. }
  457. locateLoading.value = true;
  458. try {
  459. // 不再只在当前页 300 条里找,交给后端按编码/名称全局模糊匹配
  460. const res = await pagePerceptionEquipment({ pageNum: 1, pageSize: 20, keyword: kw });
  461. const rows = (res.data || {}).records || [];
  462. locateResults.value = rows;
  463. if (rows.length === 1) {
  464. openProfile(rows[0]);
  465. }
  466. } catch (e) {
  467. console.warn("设备定位失败", e);
  468. locateResults.value = [];
  469. } finally {
  470. locateLoading.value = false;
  471. }
  472. }
  473. function locateByCode(code) {
  474. locateKeyword.value = code || "";
  475. const matched = equipmentList.value.filter((d) => d.equipmentCode === code);
  476. locateResults.value = matched;
  477. if (matched.length) openProfile(matched[0]);
  478. }
  479. function openProfile(d) {
  480. currentProfileId.value = d.equipmentId;
  481. profileOpen.value = true;
  482. recordPage.value = 1;
  483. loadProfile(d.equipmentId);
  484. }
  485. function refreshProfile() {
  486. if (!currentProfileId.value) return;
  487. loadProfile(currentProfileId.value);
  488. }
  489. async function refreshAll() {
  490. refreshing.value = true;
  491. try {
  492. await Promise.allSettled([
  493. loadStatistics(),
  494. loadEquipment(),
  495. loadAreaRank(),
  496. loadAlarmTypeDist(),
  497. loadAlarms()
  498. ]);
  499. } finally {
  500. refreshing.value = false;
  501. }
  502. }
  503. function loadTypeOptions() {
  504. return listEquipmentTypeAll().then((res) => {
  505. typeOptions.value = res.data || [];
  506. });
  507. }
  508. onMounted(() => {
  509. loadIndicatorNames();
  510. loadTypeOptions();
  511. refreshAll();
  512. });
  513. </script>
  514. <style scoped>
  515. .perception-page {
  516. background: #f0f3f8;
  517. /* 84 = 顶部导航 50 + 标签栏 34,与 AppMain 的 .hasTagsView .app-main 高度一致,
  518. 使整页恰好占满内容区、不产生页面级滚动条,溢出由各内部区域消化 */
  519. height: calc(100vh - 84px);
  520. overflow: hidden;
  521. display: flex;
  522. flex-direction: column;
  523. }
  524. /* 顶部 KPI(与设备统计页一致) */
  525. .kpi-row {
  526. display: flex;
  527. gap: 16px;
  528. margin-bottom: 20px;
  529. }
  530. .kpi {
  531. flex: 1 1 0;
  532. min-width: 0;
  533. border-radius: 12px;
  534. }
  535. .kpi :deep(.el-card__body) {
  536. display: flex;
  537. align-items: center;
  538. gap: 16px;
  539. padding: 20px;
  540. }
  541. .kpi-icon {
  542. display: flex;
  543. align-items: center;
  544. justify-content: center;
  545. width: 44px;
  546. height: 44px;
  547. flex: 0 0 44px;
  548. border-radius: 10px;
  549. font-size: 22px;
  550. }
  551. .kpi-icon.total { background: #edf3fc; color: #014db2; }
  552. .kpi-icon.online { background: #e7f8f1; color: #10b981; }
  553. .kpi-icon.offline { background: #fef4e2; color: #f59e0b; }
  554. .kpi-icon.alarm { background: #fdecec; color: #ef4444; }
  555. .kpi-label { font-size: 13px; font-weight: 400; color: #6b7280; }
  556. .kpi-value { margin-top: 6px; font-size: 28px; font-weight: 700; line-height: 1; color: #0a1628; }
  557. /* 主区 + 侧栏 */
  558. .grid-main {
  559. display: grid;
  560. grid-template-columns: minmax(0, 1fr) 380px;
  561. gap: 16px;
  562. align-items: stretch;
  563. flex: 1;
  564. min-height: 0;
  565. overflow: hidden;
  566. }
  567. /* 左侧主卡片内部滚动,避免页面级滚动条 */
  568. .grid-main > .card {
  569. min-height: 0;
  570. overflow-y: auto;
  571. }
  572. .grid-main > .card > .card-head {
  573. position: sticky;
  574. top: 0;
  575. background: #fff;
  576. z-index: 1;
  577. }
  578. .card {
  579. background: #fff;
  580. border: 1px solid #e3e9f2;
  581. border-radius: 10px;
  582. box-shadow: 0 2px 8px rgba(15, 34, 67, 0.06);
  583. margin-bottom: 16px;
  584. }
  585. .card-head {
  586. display: flex;
  587. align-items: center;
  588. justify-content: space-between;
  589. gap: 10px;
  590. padding: 14px 16px;
  591. border-bottom: 1px solid #eef2f7;
  592. flex-wrap: wrap;
  593. }
  594. .card-title { font-size: 15px; font-weight: 600; display: flex; align-items: center; gap: 8px; }
  595. .card-title:before { content: ""; width: 3px; height: 15px; border-radius: 2px; background: #1677ff; }
  596. .title-sub { font-size: 12px; color: #97a3b7; font-weight: 400; }
  597. .row { display: flex; align-items: center; }
  598. .row.gap8 { gap: 8px; }
  599. .wrap { flex-wrap: wrap; }
  600. .ov-toolbar {
  601. display: flex;
  602. align-items: center;
  603. gap: 10px;
  604. padding: 10px 16px;
  605. border-bottom: 1px solid #eef2f7;
  606. background: #fbfdff;
  607. font-size: 12px;
  608. color: #97a3b7;
  609. flex-wrap: wrap;
  610. }
  611. .legend-inline { display: flex; align-items: center; gap: 13px; font-size: 12px; color: #5e6d82; }
  612. .legend-inline i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 5px; vertical-align: -1px; }
  613. .legend-inline i.flash { animation: dotFlash 0.9s steps(1, end) infinite; }
  614. .sp { flex: 1; }
  615. .ov-stat { color: #5e6d82; }
  616. /* 健康带 */
  617. .health-band { display: flex; align-items: center; gap: 28px; padding: 22px 24px; border-bottom: 1px solid #eef2f7; background: linear-gradient(180deg, #fbfdff 0%, #fff 100%); flex-wrap: wrap; }
  618. .hb-rate { display: flex; flex-direction: column; gap: 4px; flex: none; min-width: 150px; }
  619. .hb-rate b { font-size: 44px; font-weight: 700; color: #16a34a; font-variant-numeric: tabular-nums; line-height: 1; }
  620. .hb-rate span { font-size: 12px; color: #97a3b7; }
  621. .hb-bar { flex: 1; min-width: 240px; height: 16px; border-radius: 8px; overflow: hidden; background: #eef2f7; display: flex; }
  622. .hb-bar i { display: block; height: 100%; transition: width 0.4s; }
  623. .hb-bar i.on { background: #16a34a; }
  624. .hb-bar i.off { background: #94a3b8; }
  625. .hb-bar i.al { background: #ef4444; }
  626. .hb-items { display: flex; gap: 32px; font-size: 12px; color: #5e6d82; flex: none; }
  627. .hb-items div { display: flex; flex-direction: column; gap: 3px; }
  628. .hb-items b { font-size: 24px; font-weight: 700; font-variant-numeric: tabular-nums; line-height: 1; }
  629. .text-green { color: #16a34a; }
  630. .text-gray { color: #64748b; }
  631. .text-red { color: #ef4444; }
  632. /* 片区卡 */
  633. .area-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 16px; padding: 20px; }
  634. .acard { border: 1px solid #e3e9f2; border-radius: 14px; background: #fff; overflow: hidden; transition: 0.18s; display: flex; flex-direction: column; }
  635. .acard:hover { border-color: #1677ff; box-shadow: 0 10px 30px rgba(22, 119, 255, 0.14); transform: translateY(-2px); }
  636. .acard.has-alarm { border-color: #fca5a5; background: linear-gradient(180deg, #fffafa 0%, #fff 42%); }
  637. .ac-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 10px; padding: 18px 20px 14px; }
  638. .ac-name { font-size: 22px; font-weight: 700; letter-spacing: 0.5px; line-height: 1.2; }
  639. .ac-sub { font-size: 12px; color: #97a3b7; }
  640. .ac-rate { text-align: right; flex: none; line-height: 1.1; }
  641. .ac-rate b { display: block; font-size: 30px; font-weight: 700; color: #16a34a; font-variant-numeric: tabular-nums; }
  642. .ac-rate span { font-size: 11px; color: #97a3b7; }
  643. .ac-bar { display: flex; height: 7px; background: #eef2f7; overflow: hidden; margin: 0 20px 16px; border-radius: 4px; }
  644. .ac-bar i { display: block; height: 100%; transition: width 0.4s; }
  645. .ac-metrics { display: grid; grid-template-columns: repeat(3, 1fr); gap: 1px; background: #eef2f7; margin: 0 20px 16px; border: 1px solid #eef2f7; border-radius: 10px; overflow: hidden; }
  646. .ac-metrics div { background: #fff; padding: 11px 6px; text-align: center; }
  647. .ac-metrics span { display: block; font-size: 11px; color: #97a3b7; margin-bottom: 3px; }
  648. .ac-metrics b { font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
  649. .dot-matrix { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 20px 18px; align-content: flex-start; flex: 1; }
  650. .dot { width: 11px; height: 11px; border-radius: 3px; background: #16a34a; cursor: pointer; transition: transform 0.1s; }
  651. .dot.off { background: #cbd5e1; }
  652. .dot.al { background: #ef4444; animation: dotFlash 0.9s steps(1, end) infinite; }
  653. .dot:hover { transform: scale(1.55); box-shadow: 0 0 0 2px rgba(15, 23, 42, 0.16); position: relative; z-index: 2; }
  654. .ac-tip { font-size: 11px; color: #1677ff; padding: 4px; }
  655. /* 类型构成 */
  656. .type-dist { padding: 4px 20px 20px; }
  657. .td-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px 28px; }
  658. .td-row { display: flex; align-items: center; gap: 12px; font-size: 13px; }
  659. .td-name { width: 150px; color: #5e6d82; flex: none; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  660. .td-track { flex: 1; height: 16px; border-radius: 5px; background: #f1f5f9; display: flex; overflow: hidden; min-width: 120px; }
  661. .td-track i { display: block; height: 100%; background: #1677ff; }
  662. .td-num { width: 104px; text-align: right; color: #97a3b7; flex: none; font-variant-numeric: tabular-nums; font-size: 12px; }
  663. .type-dist.side { padding: 4px 18px 18px; }
  664. .type-dist.side .td-grid { grid-template-columns: 1fr; }
  665. .type-dist.side .td-name { width: 160px; }
  666. /* 定位结果 */
  667. .search-result { padding: 0 16px 16px; }
  668. .sr-head { font-size: 13px; font-weight: 600; margin-bottom: 9px; display: flex; align-items: center; gap: 7px; }
  669. .sr-head:before { content: ""; width: 3px; height: 13px; border-radius: 2px; background: #1677ff; }
  670. .sr-list { display: flex; flex-wrap: wrap; gap: 8px; }
  671. .sr-item { display: inline-flex; align-items: center; gap: 7px; border: 1px solid #e3e9f2; border-radius: 8px; padding: 6px 11px; background: #fff; cursor: pointer; font-size: 12px; transition: 0.15s; max-width: 340px; }
  672. .sr-item:hover { border-color: #1677ff; background: #f4f9ff; }
  673. .sr-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  674. .sr-meta { color: #97a3b7; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  675. .sr-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; color: #1677ff; background: #eef5ff; border: 1px solid #d6e6ff; border-radius: 4px; padding: 1px 5px; white-space: nowrap; }
  676. .sr-dot { width: 8px; height: 8px; border-radius: 50%; flex: none; }
  677. .sr-dot.on { background: #16a34a; }
  678. .sr-dot.off { background: #cbd5e1; }
  679. .sr-dot.al { background: #ef4444; }
  680. /* 侧栏 */
  681. .side-col { display: flex; flex-direction: column; gap: 16px; min-height: 0; overflow: hidden; }
  682. .alarm-card { display: flex; flex-direction: column; flex: 1; min-height: 200px; }
  683. .alarm-list { overflow-y: auto; flex: 1; }
  684. .badge { display: inline-flex; min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px; background: #ef4444; color: #fff; font-size: 12px; align-items: center; justify-content: center; font-weight: 600; }
  685. .badge.zero { background: #cbd5e1; }
  686. .alarm-item { padding: 11px 16px; border-bottom: 1px solid #eef2f7; border-left: 3px solid #ef4444; }
  687. .alarm-item:hover { background: #f8fbff; }
  688. .alarm-top { display: flex; justify-content: space-between; align-items: center; gap: 8px; margin-bottom: 4px; }
  689. .alarm-time { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: #97a3b7; font-variant-numeric: tabular-nums; margin-bottom: 4px; }
  690. .alarm-no { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; color: #8a96a8; white-space: nowrap; }
  691. .alarm-dev { font-size: 13px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; display: flex; align-items: center; min-width: 0; }
  692. .alarm-code { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 11px; font-weight: 600; color: #5e6d82; background: #f1f5f9; border: 1px solid #e3e9f2; border-radius: 4px; padding: 1px 5px; margin-left: 6px; flex: none; white-space: nowrap; }
  693. .alarm-level { font-size: 12px; font-weight: 600; flex: none; }
  694. .alarm-desc { font-size: 12px; color: #5e6d82; line-height: 1.6; margin: 2px 0 6px; }
  695. .rank-list { padding: 6px 18px 16px; }
  696. .rank-row { display: flex; align-items: center; gap: 11px; padding: 11px 0; border-bottom: 1px solid #f1f5f9; font-size: 13px; }
  697. .rank-row:last-child { border-bottom: none; }
  698. .rank-no { width: 22px; height: 22px; border-radius: 6px; background: #eef2f7; color: #97a3b7; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; flex: none; }
  699. .rank-row.top .rank-no { background: #1677ff; color: #fff; }
  700. .rank-name { font-weight: 600; width: 58px; flex: none; }
  701. .rank-track { flex: 1; height: 9px; border-radius: 5px; background: #eef2f7; overflow: hidden; display: flex; }
  702. .rank-track i { display: block; height: 100%; }
  703. .rank-val { width: 110px; text-align: right; color: #97a3b7; font-size: 12px; flex: none; font-variant-numeric: tabular-nums; }
  704. /* 抽屉 */
  705. .drawer-title { display: flex; align-items: center; gap: 10px; }
  706. .dt-name { font-weight: 700; }
  707. .tag { display: inline-flex; align-items: center; gap: 5px; padding: 2px 9px; border-radius: 20px; font-size: 12px; font-weight: 500; }
  708. .tag-green { background: #dcfce7; color: #16a34a; }
  709. .tag-gray { background: #f1f5f9; color: #64748b; }
  710. .tag-red { background: #fee2e2; color: #ef4444; }
  711. .hist-wrap { overflow: auto; border-radius: 8px; background: #fff; }
  712. .cell-alarm { color: #ef4444; font-weight: 600; }
  713. /* 采集记录表格边框与基本信息 .ctl-dev 一致(1px #e3e9f2 / 圆角 8px),仅保留淡行线,不画竖线 */
  714. .hist-wrap :deep(.el-table) { font-size: 12px; border: 1px solid #e3e9f2; border-radius: 8px; }
  715. .hist-wrap :deep(.el-table th.el-table__cell) {
  716. background: #f7f9fc;
  717. color: #5e6d82;
  718. font-weight: 600;
  719. }
  720. .hist-wrap :deep(.el-table td.el-table__cell) { padding: 6px 0; border-bottom: 1px solid #eef2f7; }
  721. .hist-wrap :deep(.el-table .cell) { padding: 0 10px; line-height: 1.5; }
  722. .hist-wrap :deep(.el-table td.el-table__cell .cell) { white-space: nowrap; }
  723. .hist-wrap :deep(.el-table__header th.el-table__cell) { border-bottom: 1px solid #e3e9f2; }
  724. /* 去掉 el-table 自带底部/右侧伪元素线(含新版 inner-wrapper 上的),避免与外框叠加变粗;末行行线交给外框封底 */
  725. .hist-wrap :deep(.el-table::before),
  726. .hist-wrap :deep(.el-table::after),
  727. .hist-wrap :deep(.el-table__inner-wrapper::before),
  728. .hist-wrap :deep(.el-table__inner-wrapper::after) { display: none; }
  729. .hist-wrap :deep(.el-table .el-table__row:last-child td.el-table__cell) { border-bottom: none; }
  730. .rec-empty { color: #9aa7b8; font-size: 12px; padding: 28px 0; }
  731. .rec-audio-cell { display: flex; align-items: center; overflow: hidden; }
  732. .rec-audio { width: 150px; max-width: 100%; height: 26px; vertical-align: middle; }
  733. .rec-pager { margin-top: 10px; justify-content: flex-end; }
  734. @keyframes pulse {
  735. 0%, 100% { transform: scale(1); }
  736. 50% { transform: scale(1.08); }
  737. }
  738. @keyframes dotFlash {
  739. 0%, 50% { opacity: 1; }
  740. 51%, 100% { opacity: 0.25; }
  741. }
  742. @media (max-width: 1280px) {
  743. .grid-main { grid-template-columns: 1fr; }
  744. .kpi { flex: 1 1 45%; }
  745. .area-grid { grid-template-columns: 1fr; }
  746. .td-grid { grid-template-columns: 1fr; }
  747. }
  748. @media (max-width: 768px) {
  749. .kpi { flex: 1 1 100%; }
  750. }
  751. /* 设备档案抽屉(严格参考原型 view-monitor) */
  752. .ctl-dev { background: #f8fafc; border: 1px solid #e3e9f2; border-radius: 8px; padding: 14px; margin-bottom: 16px; }
  753. .ctl-dev-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; font-size: 12px; color: #5e6d82; }
  754. .ctl-dev-grid .full { grid-column: 1 / -1; }
  755. .ctl-dev-grid b { color: #0a1628; font-weight: 500; }
  756. .form-item { display: block; margin-bottom: 14px; }
  757. .form-item > span { display: block; font-size: 13px; color: #5e6d82; margin-bottom: 6px; font-weight: 500; }
  758. .record-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 6px; }
  759. .record-head > span { font-size: 13px; color: #5e6d82; font-weight: 500; }
  760. .drawer-actions { display: flex; gap: 10px; margin-top: 20px; }
  761. .drawer-actions :deep(.el-button) {
  762. flex: 1;
  763. height: 36px;
  764. padding: 0 14px;
  765. border-radius: 6px;
  766. border: 1px solid #e3e9f2;
  767. background: #fff;
  768. color: #0a1628;
  769. font-size: 13px;
  770. }
  771. .drawer-actions :deep(.el-button:hover) {
  772. border-color: #1677ff;
  773. color: #1677ff;
  774. background: #fff;
  775. }
  776. :deep(.el-drawer__header) {
  777. margin-bottom: 0;
  778. padding: 10px 20px;
  779. border-bottom: 1px solid #e3e9f2;
  780. color: #0a1628;
  781. }
  782. :deep(.el-drawer__body) { padding: 10px 20px 20px; }
  783. </style>