index.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555
  1. <template>
  2. <div class="device-box" id="monitorBox">
  3. <a-tabs class="tabs-box" type="card" v-model:activeKey="activeKey" @change="tabChange" id="tabsBox" v-if="isRefresh">
  4. <a-tab-pane key="1" tab="实时监测">
  5. <template v-if="deviceType == 'fan' && activeKey == '1'">
  6. <GroupMonitorTable :dataSource="dataSource" :columnsType="`${deviceType}_monitor`" />
  7. </template>
  8. <template v-else-if="activeKey == '1' && deviceType">
  9. <MonitorTable
  10. ref="monitorTable"
  11. :columnsType="`${deviceType}_monitor`"
  12. :dataSource="dataSource"
  13. design-scope="device_monitor"
  14. :isShowPagination="true"
  15. :is-show-select="false"
  16. title="设备监测"
  17. :form-config="deviceType == 'safetymonitor' ? formConfig : undefined"
  18. :scroll="{ y: 650 }"
  19. >
  20. <template #filterCell="{ column, record }">
  21. <template v-if="deviceType.startsWith('gate')">
  22. <template v-if="record.frontGateOpenCtrl == 1 || record.frontGateOpenCtrl === true">
  23. <a-tag v-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 0" color="red"
  24. >正在打开</a-tag
  25. >
  26. <a-tag v-else-if="column.dataIndex === 'frontGateOpen'" color="processing">打开</a-tag>
  27. </template>
  28. <template v-else-if="record.frontGateOpenCtrl == 0 || record.frontGateOpenCtrl === false">
  29. <a-tag v-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 0" color="red"
  30. >正在关闭</a-tag
  31. >
  32. <a-tag v-else-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 1" color="default"
  33. >关闭</a-tag
  34. >
  35. <a-tag v-else-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 1 && record.frontGateClose == 0" color="default"
  36. >打开</a-tag
  37. >
  38. </template>
  39. <template v-if="record.rearGateOpenCtrl == 1 || record.rearGateOpenCtrl === true">
  40. <a-tag v-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 0" color="red"
  41. >正在打开</a-tag
  42. >
  43. <a-tag v-else-if="column.dataIndex === 'rearGateOpen'" color="processing">打开</a-tag>
  44. </template>
  45. <template v-else-if="record.rearGateOpenCtrl == 0 || record.rearGateOpenCtrl === false">
  46. <a-tag v-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 0" color="red"
  47. >正在关闭</a-tag
  48. >
  49. <a-tag v-else-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 1" color="default"
  50. >关闭</a-tag
  51. >
  52. <a-tag v-else-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 1 && record.rearGateClose == 0" color="default"
  53. >打开</a-tag
  54. >
  55. </template>
  56. </template>
  57. <template v-if="deviceType.startsWith('windrect')">
  58. <a-tag v-if="column.dataIndex === 'sign'" :color="record.sign == 0 ? '#95CF65' : record.sign == 1 ? '#4590EA' : '#9876AA'">
  59. {{ record.sign == 0 ? '高位' : record.sign == 1 ? '中位' : '低位' }}</a-tag
  60. >
  61. <template v-if="record && column && column.dataIndex === 'isRun' && record.isRun">
  62. <a-tag v-if="record.isRun == -2 || record.isRun == -1" :color="record.isRun == -2 ? '#95CF65' : '#ED5700'">{{
  63. record.isRun == -2 ? '空闲' : '等待'
  64. }}</a-tag>
  65. <a-tag v-else-if="record.isRun == 100" color="#4693FF">完成</a-tag>
  66. <Progress v-else :percent="Number(record.isRun)" size="small" status="active" />
  67. </template>
  68. </template>
  69. <template v-if="deviceType.startsWith('safetymonitor')">
  70. <div v-if="!record.devicename && column.dataIndex === 'devicename'">-</div>
  71. <div v-if="!record.V && column.dataIndex === 'V'">-</div>
  72. <div v-if="!record.PointUnit && column.dataIndex === 'PointUnit'">-</div>
  73. <div v-if="!record.highRange && column.dataIndex === 'highRange'">-</div>
  74. <div v-if="!record.lowRange && column.dataIndex === 'lowRange'">-</div>
  75. <div v-if="!record.dataTypeName && column.dataIndex === 'dataTypeName'">-</div>
  76. </template>
  77. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : record.warnFlag == 1 ? '#FF5812' : 'gray'">
  78. {{ record.warnFlag == 0 ? '正常' : record.warnFlag == 1 ? '报警' : record.warnFlag == 2 ? '断开' : '未监测' }}</a-tag
  79. >
  80. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == 0 ? 'default' : 'green'">{{
  81. record.netStatus == 0 ? '断开' : '连接'
  82. }}</a-tag>
  83. </template>
  84. </MonitorTable>
  85. </template>
  86. </a-tab-pane>
  87. <a-tab-pane key="2" tab="历史数据">
  88. <div class="tab-item">
  89. <HistoryTable
  90. ref="historyTable"
  91. v-if="activeKey == '2'"
  92. :columns-type="`${deviceType}`"
  93. :device-type="deviceType"
  94. :device-list-api="getDeviceList.bind(null, { devicekind: deviceType })"
  95. designScope="device-history"
  96. @change="changeHis"
  97. />
  98. </div>
  99. </a-tab-pane>
  100. <a-tab-pane key="3" tab="报警历史">
  101. <div class="tab-item">
  102. <AlarmHistoryTable
  103. ref="alarmHistoryTable"
  104. v-if="activeKey == '3'"
  105. columns-type="alarm"
  106. :device-type="deviceType"
  107. :device-list-api="getDeviceList.bind(null, { devicekind: deviceType })"
  108. designScope="alarm-history"
  109. />
  110. </div>
  111. </a-tab-pane>
  112. <a-tab-pane key="4" tab="操作历史" v-if="deviceType !== 'safetymonitor'">
  113. <div class="tab-item">
  114. <HandlerHistoryTable
  115. ref="handlerHistoryTable"
  116. v-if="activeKey == '4'"
  117. columns-type="operator_history"
  118. :device-type="deviceType"
  119. :device-list-api="getDeviceList.bind(null, { devicekind: deviceType })"
  120. designScope="operator-history"
  121. />
  122. </div>
  123. </a-tab-pane>
  124. </a-tabs>
  125. </div>
  126. </template>
  127. <script setup lang="ts">
  128. import { ref, onMounted, onUnmounted, shallowRef, defineProps, unref } from 'vue';
  129. import { list, getDeviceList } from './safety.api';
  130. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  131. import HistoryTable from '../comment/HistoryTable.vue';
  132. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  133. import MonitorTable from '../comment/MonitorTable.vue';
  134. import GroupMonitorTable from '../comment/GroupMonitorTable.vue';
  135. import { Progress } from 'ant-design-vue';
  136. import { useRouter } from 'vue-router';
  137. import { formConfig } from './safety.data';
  138. import { getDictItemsByCode } from '/@/utils/dict';
  139. // import { BorderBox8 as DvBorderBox8 } from '@kjgl77/datav-vue3';
  140. // const echartsOption = {
  141. // grid: {
  142. // top: '60px',
  143. // left: '10px',
  144. // right: '25px',
  145. // bottom: '5%',
  146. // containLabel: true,
  147. // },
  148. // toolbox: {
  149. // feature: {},
  150. // },
  151. // };
  152. // let alive = ref(true)
  153. type DeviceType = { deviceType: string; deviceName: string; datalist: any[] };
  154. const props = defineProps({
  155. pageData: {
  156. type: Object,
  157. default: () => {},
  158. },
  159. });
  160. const scroll = {
  161. y: 360,
  162. };
  163. const monitorTable = ref();
  164. const historyTable = ref();
  165. const alarmHistoryTable = ref();
  166. const handlerHistoryTable = ref();
  167. const isRefresh = ref(true);
  168. const activeKey = ref('1'); // tab key
  169. const dataSource = ref([]); // 实时监测数据
  170. const deviceType = ref(''); // 监测设备类型
  171. // let dataSourceHis = shallowRef([])//历史数据
  172. //历史数据
  173. async function changeHis(data) {
  174. // alive.value = false
  175. // nextTick(() => {
  176. // dataSourceHis = data
  177. // alive.value = true
  178. // })
  179. }
  180. async function tabChange(activeKeyVal) {
  181. activeKey.value = activeKeyVal;
  182. if (activeKey.value != '1') {
  183. if (timer != undefined) {
  184. clearTimeout(timer);
  185. timer = undefined;
  186. }
  187. } else {
  188. timer = null;
  189. await getMonitor(true);
  190. }
  191. }
  192. // https获取监测数据
  193. let timer: null | NodeJS.Timeout = null;
  194. function getMonitor(flag?) {
  195. if (deviceType.value) {
  196. if (timer) timer = null;
  197. if (Object.prototype.toString.call(timer) === '[object Null]') {
  198. timer = setTimeout(
  199. async () => {
  200. await getDataSource();
  201. if (timer) {
  202. getMonitor();
  203. }
  204. },
  205. flag ? 0 : 1000
  206. );
  207. }
  208. }
  209. }
  210. async function getDataSource() {
  211. let resultData, searchForm;
  212. if (monitorTable.value) {
  213. const formData = monitorTable.value.getForm();
  214. searchForm = formData.getFieldsValue();
  215. }
  216. if (monitorTable.value) {
  217. if (deviceType.value.startsWith('safetymonitor')) {
  218. resultData = await list({ devicetype: deviceType.value, pagetype: 'normal', filterParams: { ...searchForm } });
  219. } else{
  220. resultData = await list({ devicetype: deviceType.value, pagetype: 'normal' });
  221. }
  222. } else {
  223. // 非安全监控
  224. resultData = await list({ devicetype: deviceType.value, pagetype: 'normal' });
  225. }
  226. if (resultData && resultData.msgTxt) {
  227. const result = resultData.msgTxt[0];
  228. if (result) {
  229. const data = result['datalist'].filter((data: any) => {
  230. const readData = data.readData;
  231. return Object.assign(data, readData);
  232. });
  233. if (deviceType.value.startsWith('safetymonitor')) {
  234. const resultData = <any[]>[];
  235. // 如果是安全监控的数据时需要过滤常见设备数据,根据设定的常用安全监控字典去匹配
  236. const dictCodes = getDictItemsByCode('safetynormal');
  237. if (searchForm && !searchForm['dataTypeName'] && dictCodes && dictCodes.length) {
  238. for (let i = 0; i < dictCodes.length; i++) {
  239. const dict = dictCodes[i];
  240. data.forEach((item) => {
  241. if (dict['value'] == item['dataTypeName']) {
  242. resultData.push(item);
  243. }
  244. });
  245. }
  246. dataSource.value = resultData;
  247. } else {
  248. dataSource.value = data;
  249. }
  250. } else {
  251. let tableData: any[] = [];
  252. let noNetData: any[] = [];
  253. data.filter((el) => {
  254. if (el.netStatus == 1) {
  255. tableData.push(el);
  256. } else {
  257. noNetData.push(el);
  258. }
  259. });
  260. dataSource.value = [...tableData, ...noNetData];
  261. }
  262. } else {
  263. dataSource.value = [];
  264. }
  265. } else {
  266. dataSource.value = [];
  267. }
  268. }
  269. onMounted(async () => {
  270. const { currentRoute } = useRouter();
  271. if (unref(currentRoute)) {
  272. const path = unref(currentRoute).path;
  273. if (path) {
  274. deviceType.value = path.substring(path.lastIndexOf('/') + 1);
  275. }
  276. await getMonitor(true);
  277. }
  278. });
  279. onUnmounted(() => {
  280. if (timer) {
  281. clearTimeout(timer);
  282. }
  283. timer = undefined;
  284. });
  285. </script>
  286. <style lang="less" scoped>
  287. @import '/@/design/vent/color.less';
  288. @import '/@/design/vent/modal.less';
  289. @ventSpace: zxm;
  290. .device-box {
  291. width: 100%;
  292. height: calc(100% - 100px);
  293. padding-bottom: 10px;
  294. margin-top: 20px;
  295. display: flex;
  296. justify-content: center;
  297. .tabs-box {
  298. width: calc(100% - 12px) !important;
  299. height: 100% !important;
  300. bottom: 3px !important;
  301. }
  302. .device-button-group {
  303. position: absolute;
  304. top: -30px;
  305. display: flex;
  306. width: 100%;
  307. .device-button {
  308. height: 26px;
  309. padding: 0 20px;
  310. background: linear-gradient(45deg, #04e6fb55, #0c5cab55);
  311. clip-path: polygon(10px 0, 0 50%, 10px 100%, 100% 100%, calc(100% - 10px) 50%, 100% 0);
  312. display: flex;
  313. justify-content: center;
  314. align-items: center;
  315. color: #fff;
  316. position: relative;
  317. cursor: pointer;
  318. &:nth-child(1) {
  319. left: calc(-6px * 1);
  320. }
  321. &:nth-child(2) {
  322. left: calc(-6px * 2);
  323. }
  324. &:nth-child(3) {
  325. left: calc(-6px * 3);
  326. }
  327. &:nth-child(4) {
  328. left: calc(-6px * 4);
  329. }
  330. &:nth-child(5) {
  331. left: calc(-6px * 5);
  332. }
  333. &:nth-child(6) {
  334. left: calc(-6px * 6);
  335. }
  336. &:nth-child(7) {
  337. left: calc(-6px * 7);
  338. }
  339. &:nth-child(8) {
  340. left: calc(-6px * 8);
  341. }
  342. &:nth-child(9) {
  343. left: calc(-6px * 9);
  344. }
  345. &:nth-child(10) {
  346. left: calc(-6px * 10);
  347. }
  348. &:nth-child(11) {
  349. left: calc(-6px * 11);
  350. }
  351. &:nth-child(12) {
  352. left: calc(-6px * 12);
  353. }
  354. &:nth-child(13) {
  355. left: calc(-6px * 13);
  356. }
  357. &:nth-child(14) {
  358. left: calc(-6px * 14);
  359. }
  360. &:nth-child(15) {
  361. left: calc(-6px * 15);
  362. }
  363. &:first-child {
  364. clip-path: polygon(0 0, 10px 50%, 0 100%, 100% 100%, calc(100% - 10px) 50%, 100% 0);
  365. }
  366. }
  367. .device-active {
  368. background: linear-gradient(45deg, #04e6fb, #0c5cab);
  369. &::before {
  370. border-color: #0efcff;
  371. box-shadow: 1px 1px 3px 1px #0efcff inset;
  372. }
  373. }
  374. }
  375. .enter-detail {
  376. color: #fff;
  377. cursor: pointer;
  378. position: absolute;
  379. right: 120px;
  380. top: -6px;
  381. padding: 5px;
  382. border-radius: 5px;
  383. margin-left: 8px;
  384. margin-right: 8px;
  385. width: auto;
  386. height: 33px !important;
  387. display: flex;
  388. align-items: center;
  389. justify-content: center;
  390. color: #fff;
  391. padding: 5px 15px 5px 15px;
  392. cursor: pointer;
  393. &:hover {
  394. background: linear-gradient(#2cd1ff55, #1eb0ff55);
  395. }
  396. &::before {
  397. width: calc(100% - 6px);
  398. height: 27px;
  399. content: '';
  400. position: absolute;
  401. top: 3px;
  402. right: 0;
  403. left: 3px;
  404. bottom: 0;
  405. z-index: -1;
  406. border-radius: inherit;
  407. /*important*/
  408. background: linear-gradient(#1fa6cb, #127cb5);
  409. }
  410. }
  411. }
  412. :deep(.@{ventSpace}-tabs-tabpane-active) {
  413. height: 100%;
  414. border: 1px solid #44d3ff70;
  415. border-radius: 2px;
  416. -webkit-backdrop-filter: blur(8px);
  417. box-shadow: 0 0 20px #44b4ff33 inset;
  418. background-color: #ffffff11;
  419. overflow-y: auto;
  420. }
  421. :deep(.@{ventSpace}-tabs-card) {
  422. .@{ventSpace}-tabs-tab {
  423. background: linear-gradient(#2cd1ff55, #1eb0ff55);
  424. border-color: #74e9fe;
  425. border-radius: 0%;
  426. &:hover {
  427. color: #64d5ff;
  428. }
  429. }
  430. .@{ventSpace}-tabs-content {
  431. height: 100% !important;
  432. }
  433. .@{ventSpace}-tabs-tab.@{ventSpace}-tabs-tab-active .@{ventSpace}-tabs-tab-btn {
  434. color: aqua;
  435. }
  436. .@{ventSpace}-tabs-nav::before {
  437. border-color: #74e9fe;
  438. }
  439. .@{ventSpace}-picker,
  440. .@{ventSpace}-select-selector {
  441. width: 100% !important;
  442. background: #00000017 !important;
  443. border: 1px solid @vent-form-item-boder !important;
  444. input,
  445. .@{ventSpace}-select-selection-item,
  446. .@{ventSpace}-picker-suffix {
  447. color: #fff !important;
  448. }
  449. .@{ventSpace}-select-selection-placeholder {
  450. color: #b7b7b7 !important;
  451. }
  452. }
  453. .@{ventSpace}-pagination-next,
  454. .action,
  455. .@{ventSpace}-select-arrow,
  456. .@{ventSpace}-picker-separator {
  457. color: #fff !important;
  458. }
  459. .@{ventSpace}-table-cell-row-hover {
  460. background: #264d8833 !important;
  461. }
  462. .@{ventSpace}-table-row-selected {
  463. background: #00c0a311 !important;
  464. td {
  465. background-color: #00000000 !important;
  466. }
  467. }
  468. .@{ventSpace}-table-thead {
  469. // background: linear-gradient(#004a8655 0%, #004a86aa 10%) !important;
  470. background: #3d9dd45d !important;
  471. & > tr > th,
  472. .@{ventSpace}-table-column-title {
  473. // color: #70f9fc !important;
  474. border-color: #84f2ff !important;
  475. border-left: none !important;
  476. border-right: none !important;
  477. padding: 7px;
  478. }
  479. }
  480. .@{ventSpace}-table-tbody {
  481. tr > td {
  482. padding: 12px;
  483. }
  484. }
  485. .@{ventSpace}-table-tbody > tr:hover.@{ventSpace}-table-row > td {
  486. background-color: #26648855 !important;
  487. }
  488. .jeecg-basic-table-row__striped {
  489. // background: #97efff11 !important;
  490. td {
  491. background-color: #97efff11 !important;
  492. }
  493. }
  494. }
  495. </style>