index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652
  1. <template>
  2. <div class="safetyList">
  3. <customHeader>数据中心-分站管理</customHeader>
  4. <div class="content">
  5. <a-tabs class="tab-box" v-model:activeKey="activeKey" @change="onChangeTab">
  6. <a-tab-pane tab="分站监测" key="device" />
  7. </a-tabs>
  8. <div class="box-content">
  9. <!-- 分站监测 -->
  10. <div class="now-content">
  11. <div class="left-box">
  12. <div class="left-content">
  13. <div class="card-box" v-for="(item, index) in cardList" :key="index">
  14. <div :class="item.isNewAccess ? 'card-itemN' : item.linkstatus ? 'card-itemL' : 'card-itemD'" @click="cardClick(item, index)">
  15. <div class="card-item-label">{{ item.strname }}</div>
  16. </div>
  17. <div :class="activeIndex % 4 == 3 ? 'card-modal1' : 'card-modal'" v-if="activeIndex == index && isShow">
  18. <div class="modal-name">站点名称:</div>
  19. <a-input v-model:value="stationName" size="small" placeholder="请输入" @blur="changeName" />
  20. <div class="modal-lj">连接状态:</div>
  21. <a-radio-group v-model:value="stationStatus" size="small" :options="ljList" @change="changeStatus" />
  22. </div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="right-box">
  27. <div class="right-title">详细信息:</div>
  28. <a-table
  29. size="small"
  30. :scroll="{ y: 680 }"
  31. :columns="outerColumns"
  32. :data-source="deviceList"
  33. :pagination="pagination"
  34. :row-key="(record) => record.id"
  35. :expand-row-by-click="true"
  36. :expanded-row-keys="expandedRowKeys"
  37. @expand="onExpand"
  38. >
  39. <!-- 自定义展开图标 -->
  40. <template #expandIcon="{ expanded, onExpand, record }">
  41. <a-button
  42. type="text"
  43. size="small"
  44. @click="
  45. (e) => {
  46. e.stopPropagation();
  47. toggleExpand(record.id);
  48. }
  49. "
  50. >
  51. <DownOutlined v-if="expandedRowKeys.includes(record.id)" />
  52. <RightOutlined v-else />
  53. </a-button>
  54. </template>
  55. <!-- 嵌套表格 -->
  56. <template #expandedRowRender="{ record }">
  57. <a-table
  58. size="small"
  59. :columns="innerColumns"
  60. :data-source="record.monitoringFields"
  61. :pagination="false"
  62. :loading="loadingMap[record.id]"
  63. bordered
  64. >
  65. <template #bodyCell="{ column, record: innerRecord }">
  66. <template v-if="column.dataIndex === 'value'">
  67. <span :class="getValueClass(innerRecord.value)">
  68. {{ innerRecord.value }}
  69. </span>
  70. </template>
  71. </template>
  72. </a-table>
  73. </template>
  74. </a-table>
  75. </div>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. </template>
  81. <script setup lang="ts">
  82. import { ref, nextTick, reactive, onMounted, onUnmounted, inject } from 'vue';
  83. import { usePermission } from '/@/hooks/web/usePermission';
  84. import customHeader from '/@/components/vent/customHeader.vue';
  85. import { AesEncryption } from '/@/utils/cipher';
  86. import { loginCipher } from '/@/settings/encryptionSetting';
  87. import { message, TreeProps } from 'ant-design-vue';
  88. import { list, getDeviceList, getDeviceTypeList, devPosition, getDepartmentInfo, getExportUrl, getRegulation } from './device.api';
  89. import { DownOutlined, RightOutlined } from '@ant-design/icons-vue';
  90. const { hasPermission } = usePermission();
  91. let activeKey = ref('device');
  92. const treeData = ref<TreeProps['treeData']>([]);
  93. const selectedKeys = ref<string[]>([]);
  94. const expandedKeys = ref<string[]>([]);
  95. const systemID = ref(''); // 系统监测时,系统id
  96. //树形菜单选择事件
  97. const onSelect: TreeProps['onSelect'] = (keys, e) => {};
  98. // 获取树形菜单数据
  99. async function getDeviceType(sysType?) {
  100. if (treeData.value?.length > 0) return;
  101. const result = await getDeviceTypeList({});
  102. if (result.length > 0) {
  103. const dataSource = <TreeProps['treeData']>[];
  104. let key = '0';
  105. const getData = (resultList, dataSourceList, keyVal) => {
  106. resultList.forEach((item, index) => {
  107. if (item.deviceType != 'sys' && item.children && item.children.length > 0) {
  108. const children = getData(item.children, [], `${keyVal}-${index}`);
  109. // 判断关键阻力路线
  110. if (item.itemValue.startsWith(sysType) && children[0]) {
  111. systemID.value = item.children[0]['itemValue'];
  112. }
  113. dataSourceList.push({
  114. children: children,
  115. title: item.itemText,
  116. key: `${keyVal}-${index}`,
  117. type: item.itemValue,
  118. parentKey: `${keyVal}`,
  119. });
  120. } else {
  121. dataSourceList.push({
  122. children: [],
  123. title: item.itemText,
  124. key: `${keyVal}-${index}`,
  125. type: item.itemValue,
  126. parentKey: `${keyVal}`,
  127. });
  128. }
  129. });
  130. return dataSourceList;
  131. };
  132. treeData.value = getData(result, dataSource, key);
  133. }
  134. }
  135. // 设备数据结构
  136. const deviceList = ref([
  137. {
  138. id: 'D001',
  139. name: '模拟设备1',
  140. status: '在线',
  141. monitoringFields: [], // 初始为空,点击时加载
  142. },
  143. {
  144. id: 'D002',
  145. name: '模拟设备2',
  146. status: '离线',
  147. monitoringFields: [],
  148. },
  149. {
  150. id: 'D003',
  151. name: '模拟设备3',
  152. status: '在线',
  153. monitoringFields: [],
  154. },
  155. ]);
  156. // 当前展开的行key数组
  157. const expandedRowKeys = ref([]);
  158. // 加载状态映射
  159. const loadingMap = reactive({});
  160. // 外层表格列配置
  161. const outerColumns = [
  162. {
  163. title: '设备ID',
  164. dataIndex: 'id',
  165. key: 'id',
  166. },
  167. {
  168. title: '设备名称',
  169. dataIndex: 'name',
  170. key: 'name',
  171. },
  172. {
  173. title: '状态',
  174. dataIndex: 'status',
  175. key: 'status',
  176. customRender: ({ text }) => {
  177. text = '在线';
  178. return `${text}`;
  179. },
  180. },
  181. ];
  182. // 内层表格列配置
  183. const innerColumns = [
  184. {
  185. title: '监测字段',
  186. dataIndex: 'field',
  187. key: 'field',
  188. width: '40%',
  189. },
  190. {
  191. title: '当前值',
  192. dataIndex: 'value',
  193. key: 'value',
  194. width: '30%',
  195. },
  196. {
  197. title: '单位',
  198. dataIndex: 'unit',
  199. key: 'unit',
  200. width: '30%',
  201. },
  202. ];
  203. // 分页配置
  204. const pagination = reactive({
  205. current: 1,
  206. pageSize: 10,
  207. total: 3,
  208. showSizeChanger: true,
  209. pageSizeOptions: ['10', '20', '50'],
  210. });
  211. // 切换展开状态
  212. const toggleExpand = (deviceId) => {
  213. const index = expandedRowKeys.value.indexOf(deviceId);
  214. if (index > -1) {
  215. // 如果已经展开,则关闭
  216. expandedRowKeys.value.splice(index, 1);
  217. } else {
  218. // 如果未展开,则打开
  219. expandedRowKeys.value.push(deviceId);
  220. loadMonitoringData(deviceId);
  221. }
  222. };
  223. // 加载监测数据
  224. const loadMonitoringData = async (deviceId) => {
  225. const device = deviceList.value.find((d) => d.id === deviceId);
  226. if (device && device.monitoringFields.length === 0) {
  227. loadingMap[deviceId] = true;
  228. try {
  229. // 模拟API请求
  230. await new Promise((resolve) => setTimeout(resolve, 800));
  231. // 根据设备ID加载对应数据
  232. device.monitoringFields = mockFetchMonitoringData(deviceId);
  233. } catch (error) {
  234. console.error(`加载设备 ${deviceId} 数据失败:`, error);
  235. } finally {
  236. loadingMap[deviceId] = false;
  237. }
  238. }
  239. };
  240. // 值样式分类
  241. const getValueClass = (value) => {
  242. if (value > 30) return 'high-value';
  243. if (value < 10) return 'low-value';
  244. return 'normal-value';
  245. };
  246. // 模拟API获取监测数据
  247. const mockFetchMonitoringData = (deviceId) => {
  248. const dataMap = {
  249. D001: [
  250. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  251. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  252. ],
  253. D002: [
  254. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  255. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  256. ],
  257. D003: [
  258. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  259. { field: '模拟数据', value: (Math.random() * 10).toFixed(2), unit: '1' },
  260. ],
  261. };
  262. return dataMap[deviceId] || [];
  263. };
  264. onMounted(async () => {
  265. getDeviceType();
  266. });
  267. onUnmounted(() => {});
  268. </script>
  269. <style lang="less" scoped>
  270. .safetyList {
  271. width: calc(100% - 20px);
  272. height: calc(100% - 80px);
  273. position: relative;
  274. margin: 70px 10px 10px 10px;
  275. .content {
  276. position: relative;
  277. width: 100%;
  278. height: 100%;
  279. .tab-box {
  280. display: flex;
  281. color: #fff;
  282. position: relative;
  283. background: linear-gradient(#001325, #012e4f);
  284. :deep(.zxm-tabs-nav) {
  285. margin: 0 !important;
  286. .zxm-tabs-tab {
  287. width: 180px;
  288. height: 45px;
  289. background: url('/@/assets/images/top-btn.png') center no-repeat;
  290. background-size: cover;
  291. display: flex;
  292. justify-content: center;
  293. font-size: 16px;
  294. }
  295. .zxm-tabs-tab-active {
  296. width: 180px;
  297. position: relative;
  298. background: url('/@/assets/images/top-btn-select.png') center no-repeat;
  299. background-size: cover;
  300. .zxm-tabs-tab-btn {
  301. color: #fff !important;
  302. }
  303. }
  304. .zxm-tabs-ink-bar {
  305. width: 0 !important;
  306. }
  307. .zxm-tabs-tab + .zxm-tabs-tab {
  308. margin: 0 !important;
  309. }
  310. }
  311. }
  312. .box-content {
  313. height: calc(100% - 50px);
  314. padding-top: 10px;
  315. box-sizing: border-box;
  316. .now-content {
  317. position: relative;
  318. width: 100%;
  319. height: 100%;
  320. display: flex;
  321. justify-content: space-between;
  322. align-items: center;
  323. .left-box {
  324. width: 30%;
  325. height: 100%;
  326. margin-right: 15px;
  327. padding: 10px;
  328. box-sizing: border-box;
  329. background: url('/@/assets/images/fire/bj1.png') no-repeat center;
  330. background-size: 100% 100%;
  331. }
  332. .right-box {
  333. width: calc(70% - 15px);
  334. height: 100%;
  335. padding: 10px;
  336. box-sizing: border-box;
  337. background: url('/@/assets/images/fire/bj1.png') no-repeat center;
  338. background-size: 100% 100%;
  339. .right-title {
  340. display: flex;
  341. height: 30px;
  342. align-items: center;
  343. font-size: 14px;
  344. color: #fff;
  345. margin-bottom: 10px;
  346. }
  347. }
  348. }
  349. .detail-content {
  350. width: 100%;
  351. height: 100%;
  352. }
  353. .history-content {
  354. position: relative;
  355. width: 100%;
  356. height: 100%;
  357. display: flex;
  358. justify-content: space-between;
  359. align-items: center;
  360. background: url('/@/assets/images/fire/bj1.png') no-repeat center;
  361. background-size: 100% 100%;
  362. color: #fff;
  363. .left-box {
  364. width: 40%;
  365. height: 100%;
  366. margin-right: 15px;
  367. padding: 10px;
  368. box-sizing: border-box;
  369. background: url('/@/assets/images/fire/bj1.png') no-repeat center;
  370. background-size: 100% 100%;
  371. .left-content {
  372. display: flex;
  373. justify-content: flex-start;
  374. align-items: flex-start;
  375. flex-wrap: wrap;
  376. height: calc(100% - 40px);
  377. overflow-y: auto;
  378. .card-box {
  379. position: relative;
  380. // width: 242px;
  381. width: 182px;
  382. height: 120px;
  383. margin-bottom: 15px;
  384. display: flex;
  385. justify-content: center;
  386. .card-itemN {
  387. position: relative;
  388. width: 85px;
  389. height: 120px;
  390. background: url('/@/assets/images/zd-2.png') no-repeat center;
  391. background-size: 100% 100%;
  392. cursor: pointer;
  393. .card-item-label {
  394. width: 100%;
  395. position: absolute;
  396. bottom: 5px;
  397. font-size: 12px;
  398. color: #fff;
  399. text-align: center;
  400. }
  401. }
  402. .card-itemL {
  403. position: relative;
  404. width: 85px;
  405. height: 120px;
  406. background: url('/@/assets/images/zd-3.png') no-repeat center;
  407. background-size: 100% 100%;
  408. cursor: pointer;
  409. .card-item-label {
  410. width: 100%;
  411. position: absolute;
  412. bottom: 5px;
  413. font-size: 12px;
  414. color: #fff;
  415. text-align: center;
  416. }
  417. }
  418. .card-itemD {
  419. position: relative;
  420. width: 85px;
  421. height: 120px;
  422. background: url('/@/assets/images/zd-1.png') no-repeat center;
  423. background-size: 100% 100%;
  424. cursor: pointer;
  425. .card-item-label {
  426. width: 100%;
  427. position: absolute;
  428. bottom: 5px;
  429. font-size: 12px;
  430. color: #fff;
  431. text-align: center;
  432. }
  433. }
  434. .card-modal {
  435. width: 86px;
  436. position: absolute;
  437. left: 140px;
  438. color: #fff;
  439. top: 50%;
  440. transform: translate(0, -50%);
  441. font-size: 12px;
  442. }
  443. .card-modal1 {
  444. width: 86px;
  445. position: absolute;
  446. left: -42px;
  447. color: #fff;
  448. top: 50%;
  449. transform: translate(0, -50%);
  450. font-size: 12px;
  451. }
  452. }
  453. }
  454. }
  455. .right-box {
  456. width: calc(60% - 15px);
  457. height: 100%;
  458. padding: 10px;
  459. box-sizing: border-box;
  460. background: url('/@/assets/images/fire/bj1.png') no-repeat center;
  461. background-size: 100% 100%;
  462. .historytable {
  463. height: 100%;
  464. }
  465. .right-title {
  466. display: flex;
  467. height: 30px;
  468. align-items: center;
  469. font-size: 14px;
  470. color: #fff;
  471. margin-bottom: 10px;
  472. }
  473. }
  474. }
  475. }
  476. }
  477. }
  478. .down-btn {
  479. line-height: 15px;
  480. height: 20px;
  481. padding: 0px 17px;
  482. font-size: 12px;
  483. }
  484. .zxm-form {
  485. width: 50%;
  486. height: 100%;
  487. padding-top: 20px !important;
  488. box-sizing: border-box;
  489. }
  490. .zxm-picker,
  491. .zxm-input {
  492. border: 1px solid #3ad8ff77 !important;
  493. background-color: #ffffff !important;
  494. color: #fff !important;
  495. }
  496. .card-item.selected {
  497. border: 2px solid #3ad8ff77;
  498. /* 选中时的边框颜色 */
  499. }
  500. ::v-deep(.zxm-radio-wrapper) {
  501. font-size: 12px;
  502. }
  503. ::v-deep(.zxm-input) {
  504. font-size: 12px;
  505. }
  506. ::v-deep(.zxm-select:not(.zxm-select-customize-input) .zxm-select-selector) {
  507. border: 1px solid #3ad8ff77 !important;
  508. }
  509. // ::v-deep(.zxm-select-selection-item) {
  510. // color: #fff ;
  511. // }
  512. // ::v-deep(.zxm-form-item-label > label) {
  513. // color: #fff !important;
  514. // }
  515. /* 值样式 */
  516. .high-value {
  517. color: #f5222d;
  518. font-weight: bold;
  519. }
  520. .low-value {
  521. color: #1890ff;
  522. font-weight: bold;
  523. }
  524. .normal-value {
  525. color: #52c41a;
  526. }
  527. /* 嵌套表格样式 */
  528. :deep(.ant-table-expanded-row) > td {
  529. background-color: #f9f9f9 !important;
  530. padding: 0 !important;
  531. }
  532. :deep(.ant-table-expanded-row .ant-table) {
  533. margin: -10px -8px;
  534. background: #f9f9f9;
  535. }
  536. /* 自定义展开按钮 */
  537. :deep(.ant-table-row-expand-icon) {
  538. margin-right: 8px;
  539. }
  540. .device-select-box {
  541. margin-top: 60px;
  542. width: 208px;
  543. height: calc(100% - 70px);
  544. overflow-y: auto;
  545. color: #fff;
  546. :deep(.zxm-tree) {
  547. background: transparent !important;
  548. color: #fff !important;
  549. .zxm-tree-switcher {
  550. background: transparent !important;
  551. }
  552. .zxm-tree-node-content-wrapper.zxm-tree-node-selected {
  553. background-color: var(--tree-node-select);
  554. }
  555. .zxm-tree-node-content-wrapper:hover {
  556. background-color: var(--tree-node-hover);
  557. }
  558. input {
  559. height: 0px !important;
  560. }
  561. }
  562. &::-webkit-scrollbar-track {
  563. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  564. border-radius: 10px;
  565. background: #ededed22;
  566. height: 100px;
  567. }
  568. &::-webkit-scrollbar-thumb {
  569. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  570. background: #4288a444;
  571. }
  572. }
  573. .device-select {
  574. width: 250px;
  575. height: calc(100% - 70px);
  576. background: var(--image-tree-bg) no-repeat;
  577. position: fixed;
  578. top: 100px;
  579. left: 55px;
  580. background-size: contain;
  581. pointer-events: auto;
  582. padding: 20px 10px 30px 10px;
  583. }
  584. </style>
  585. <style>
  586. div[aria-hidden='true'] {
  587. display: none !important;
  588. }
  589. </style>