fireWarn.vue 10.0 KB

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