fireWarn.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <customHeader :options="options" @change="getSelectRow" :optionValue="optionValue"> 火灾监测预警 </customHeader>
  3. <div class="fireWarn">
  4. <a-button
  5. v-if="!hasPermission('fireWarn:return')"
  6. preIcon="ant-design:rollback-outlined"
  7. type="text"
  8. size="small"
  9. style="position: absolute; left: 15px; top: 15px; color: #fff"
  10. @click="getBack"
  11. >返回</a-button
  12. >
  13. <div class="alarm-menu">
  14. <div class="type-btn">
  15. <div :class="activeIndex == index ? 'btn1' : 'btn'" v-for="(item, index) in typeMenuList" :key="index" @click="btnClick(index)">
  16. {{ item.name }}
  17. </div>
  18. </div>
  19. <div class="card-btn">
  20. <div :class="activeIndex1 == ind ? 'btn1' : 'btn'" v-for="(item, ind) in menuList" :key="ind" @click="cardClick(ind, item)">
  21. <div class="text">{{ item.name }}</div>
  22. <div class="warn">{{ item.warn }}</div>
  23. </div>
  24. </div>
  25. </div>
  26. <div class="fire-content">
  27. <component :is="componentName[currentLoad]" :listData="listData" :strType="strType" :tableList="tableLists" />
  28. </div>
  29. </div>
  30. </template>
  31. <script setup lang="ts">
  32. import { ref, reactive, onMounted, onUnmounted, defineAsyncComponent } from 'vue';
  33. import { typeMenuList, componentName } from '../common.data';
  34. import { sysTypeWarnList, sysWarn } from '../common.api';
  35. import { useSystemSelect } from '/@/hooks/vent/useSystemSelect';
  36. import { useGlobSetting } from '/@/hooks/setting';
  37. import { useRouter } from 'vue-router';
  38. import CustomHeader from '/@/components/vent/customHeader.vue';
  39. import { usePermission } from '/@/hooks/web/usePermission';
  40. const { hasPermission } = usePermission();
  41. const { options, optionValue, getSelectRow, getSysDataSource } = useSystemSelect('sys_surface_caimei'); // 参数为场景类型(设备类型管理中可以查询到)
  42. //当前加载组件
  43. let currentLoad = ref('');
  44. //内外因火灾激活索引
  45. let activeIndex = ref(0);
  46. //当前激活菜单的索引
  47. let activeIndex1 = ref(0);
  48. let menuList = reactive<any[]>([]); //左侧菜单列表
  49. let menuList1 = reactive({
  50. external: [],
  51. internal: [],
  52. info: [],
  53. });
  54. //详情数据
  55. let listData = reactive({
  56. common: {},
  57. bundletube: [],
  58. fiber: [],
  59. fire: [],
  60. co: [],
  61. smoke: [],
  62. spray: [],
  63. temperature: [],
  64. }); //详情数据
  65. let strType = ref(''); //火灾外因-区别工作面和煤层
  66. let router = useRouter();
  67. let tableLists = ref<any[]>([]);
  68. // https获取监测数据
  69. let timer: null | NodeJS.Timeout = null;
  70. function getMonitor(deviceID, flag?) {
  71. timer = setTimeout(
  72. async () => {
  73. await getSysWarnList(deviceID, 'fire');
  74. if (timer) {
  75. timer = null;
  76. }
  77. getMonitor(deviceID);
  78. },
  79. flag ? 0 : 1000
  80. );
  81. }
  82. //返回首页
  83. function getBack() {
  84. router.push('/monitorChannel/monitor-alarm-home');
  85. }
  86. //获取左侧菜单列表
  87. async function getMenuList() {
  88. let res = await sysTypeWarnList({ type: 'fire' });
  89. console.log(res, '火灾左侧菜单列表-------');
  90. if (res.length != 0) {
  91. menuList.length = 0;
  92. menuList1.external = res.external;
  93. menuList1.internal = res.internal;
  94. menuList1.info = res.info;
  95. if (menuList1.internal && menuList1.internal.length > 0) {
  96. menuList1.internal.forEach((el) => {
  97. menuList.push({
  98. name: el.systemname,
  99. warn: '低风险',
  100. type: 'on',
  101. deviceID: el.id,
  102. strtype: el.strtype,
  103. });
  104. });
  105. }
  106. getMonitor(menuList[0].deviceID, true);
  107. }
  108. }
  109. //获取预警详情弹窗右侧数据
  110. function getSysWarnList(id, type) {
  111. sysWarn({ sysid: id, type: type }).then((res) => {
  112. listData.bundletube = res.bundletube;
  113. listData.fiber = res.fiber;
  114. listData.fire = res.fire;
  115. listData.co = res.co;
  116. listData.smoke = res.smoke;
  117. listData.spray = res.spray;
  118. listData.temperature = res.temperature;
  119. loadZj();
  120. });
  121. }
  122. //内外因火灾、预警指标选项切换
  123. function btnClick(ind) {
  124. activeIndex.value = ind;
  125. switch (ind) {
  126. case 0:
  127. activeIndex1.value = 0;
  128. menuList.length = 0;
  129. currentLoad.value = '';
  130. menuList1.internal.forEach((el) => {
  131. menuList.push({
  132. name: el.systemname,
  133. warn: '低风险',
  134. type: 'on',
  135. deviceID: el.id,
  136. strtype: el.strtype,
  137. });
  138. });
  139. clearTimeout(timer);
  140. getClearList();
  141. getMonitor(menuList[0].deviceID, true);
  142. break;
  143. case 1:
  144. activeIndex1.value = 0;
  145. menuList.length = 0;
  146. currentLoad.value = '';
  147. if (menuList1.external.length != 0) {
  148. menuList1.external.forEach((el) => {
  149. menuList.push({
  150. name: el.systemname,
  151. warn: '低风险',
  152. type: 'out',
  153. deviceID: el.id,
  154. strtype: el.strtype,
  155. });
  156. });
  157. clearTimeout(timer);
  158. getClearList();
  159. getMonitor(menuList[0].deviceID, true);
  160. strType.value = menuList[0].strtype;
  161. } else {
  162. menuList.length = 0;
  163. clearTimeout(timer);
  164. currentLoad.value = '';
  165. }
  166. break;
  167. case 2:
  168. clearTimeout(timer);
  169. menuList.length = 0;
  170. activeIndex1.value = 0;
  171. menuList1.info.forEach((el) => {
  172. menuList.push({
  173. name: el.sysname,
  174. warn: '正常',
  175. deviceID: el.sysid,
  176. strtype: '',
  177. });
  178. });
  179. loadZb();
  180. break;
  181. }
  182. }
  183. //加载预警指标组件
  184. function loadZb() {
  185. tableLists.value = menuList1.info[0].list;
  186. const { sysOrgCode } = useGlobSetting();
  187. switch (sysOrgCode) {
  188. case 'sdmtjtbdmk': // 宝德
  189. currentLoad.value = 'warnFireBd';
  190. return currentLoad.value;
  191. case 'sdmtjtbetmk': // 布尔台
  192. currentLoad.value = 'warnFireBrt';
  193. return currentLoad.value;
  194. default:
  195. currentLoad.value = 'warnFireBrt';
  196. return currentLoad.value;
  197. }
  198. }
  199. //菜单选项切换
  200. function cardClick(ind, item) {
  201. if (activeIndex.value != 2) {
  202. activeIndex1.value = ind;
  203. strType.value = item.strtype;
  204. clearTimeout(timer);
  205. getClearList();
  206. currentLoad.value = '';
  207. getMonitor(item.deviceID, true);
  208. } else {
  209. clearTimeout(timer);
  210. activeIndex1.value = ind;
  211. tableLists.value = menuList1.info[ind].list;
  212. }
  213. }
  214. //加载组件
  215. function loadZj() {
  216. if (!activeIndex.value && listData.fiber.length != 0 && listData.bundletube.length != 0) {
  217. currentLoad.value = 'fireWork';
  218. } else if (!activeIndex.value && listData.bundletube.length != 0) {
  219. currentLoad.value = 'closeWall';
  220. } else if (activeIndex.value && activeIndex.value != 2) {
  221. currentLoad.value = 'mainWell';
  222. } else {
  223. currentLoad.value = '';
  224. }
  225. }
  226. //清空数据
  227. function getClearList() {
  228. listData.common = {};
  229. listData.bundletube.length = 0;
  230. listData.fiber.length = 0;
  231. listData.fire.length = 0;
  232. listData.co.length = 0;
  233. listData.smoke.length = 0;
  234. listData.spray.length = 0;
  235. listData.temperature.length = 0;
  236. }
  237. onMounted(() => {
  238. getMenuList();
  239. });
  240. onUnmounted(() => {
  241. if (timer) {
  242. clearTimeout(timer);
  243. timer = undefined;
  244. }
  245. });
  246. </script>
  247. <style lang="less" scoped>
  248. .fireWarn {
  249. width: 100%;
  250. height: 100%;
  251. padding: 80px 10px 15px 10px;
  252. box-sizing: border-box;
  253. display: flex;
  254. justify-content: space-between;
  255. .alarm-menu {
  256. height: 100%;
  257. width: 15%;
  258. .type-btn {
  259. width: 100%;
  260. height: 28px;
  261. line-height: 28px;
  262. background-color: rgba(15, 55, 108, 0.8);
  263. border: 2px solid #1b6eab;
  264. margin-bottom: 20px;
  265. border-radius: 5px;
  266. box-sizing: border-box;
  267. display: flex;
  268. justify-content: space-between;
  269. .btn {
  270. width: 33%;
  271. height: 24px;
  272. line-height: 24px;
  273. font-size: 14px;
  274. text-align: center;
  275. color: #fff;
  276. cursor: pointer;
  277. }
  278. .btn1 {
  279. width: 33%;
  280. height: 24px;
  281. line-height: 24px;
  282. font-size: 14px;
  283. color: #fff;
  284. text-align: center;
  285. border-radius: 2px;
  286. background: #209dfc;
  287. cursor: pointer;
  288. }
  289. }
  290. .card-btn {
  291. width: 100%;
  292. height: calc(100% - 48px);
  293. overflow-y: auto;
  294. .btn {
  295. position: relative;
  296. width: 81%;
  297. height: 14%;
  298. margin-bottom: 10%;
  299. font-family: 'douyuFont';
  300. background: url('../../../../../assets/images/fire/no-choice.png') no-repeat;
  301. background-size: 100% 100%;
  302. cursor: pointer;
  303. .text {
  304. width: 80%;
  305. position: absolute;
  306. left: 50%;
  307. top: 28px;
  308. font-size: 16px;
  309. color: #01fefc;
  310. text-align: center;
  311. transform: translate(-50%, 0);
  312. }
  313. .warn {
  314. width: 100%;
  315. position: absolute;
  316. left: 50%;
  317. bottom: 14px;
  318. font-size: 14px;
  319. color: #fff;
  320. text-align: center;
  321. transform: translate(-50%, 0);
  322. }
  323. }
  324. .btn1 {
  325. position: relative;
  326. width: 100%;
  327. height: 14%;
  328. margin-bottom: 10%;
  329. font-family: 'douyuFont';
  330. background: url('../../../../../assets/images/fire/choice.png') no-repeat;
  331. background-size: 100% 100%;
  332. cursor: pointer;
  333. .text {
  334. width: 80%;
  335. position: absolute;
  336. left: 50%;
  337. top: 28px;
  338. font-size: 16px;
  339. color: #01fefc;
  340. text-align: center;
  341. transform: translate(-62%, 0);
  342. }
  343. .warn {
  344. width: 100%;
  345. position: absolute;
  346. left: 50%;
  347. bottom: 14px;
  348. font-size: 14px;
  349. color: #fff;
  350. text-align: center;
  351. transform: translate(-60%, 0);
  352. }
  353. }
  354. }
  355. }
  356. .fire-content {
  357. width: calc(85% - 10px);
  358. height: 100%;
  359. margin-left: 10px;
  360. background: url('../../../../../assets/images/fire/border.png') no-repeat;
  361. background-size: 100% 100%;
  362. }
  363. }
  364. // .fireWarn1 {
  365. // width: 100%;
  366. // height: 100%;
  367. // padding: 80px 10px 15px 10px;
  368. // box-sizing: border-box;
  369. // .alarm-menu {
  370. // width: 100%;
  371. // .type-btn {
  372. // width: 25%;
  373. // height: 36px;
  374. // line-height: 36px;
  375. // background-color: rgba(15, 55, 108, .8);
  376. // border: 2px solid #1b6eab;
  377. // border-radius: 5px;
  378. // box-sizing: border-box;
  379. // display: flex;
  380. // justify-content: space-between;
  381. // .btn {
  382. // width: 33%;
  383. // height: 32px;
  384. // line-height: 32px;
  385. // font-size: 14px;
  386. // text-align: center;
  387. // color: #fff;
  388. // cursor: pointer;
  389. // }
  390. // .btn1 {
  391. // width: 33%;
  392. // height: 32px;
  393. // line-height: 32px;
  394. // font-size: 14px;
  395. // color: #fff;
  396. // text-align: center;
  397. // border-radius: 2px;
  398. // background: #209dfc;
  399. // cursor: pointer;
  400. // }
  401. // }
  402. // .card-btn {
  403. // width: 100%;
  404. // height: calc(100% - 36px);
  405. // overflow-y: auto;
  406. // display: none;
  407. // }
  408. // }
  409. // .fire-content {
  410. // height: calc(100% - 30px)
  411. // }
  412. // }
  413. </style>