fire-detail.vue 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356
  1. <template>
  2. <view class="fire-detail">
  3. <u-tabs
  4. class="devic-box-tab"
  5. :current="PageCur"
  6. :list="tabList"
  7. :activeStyle="{ color: '#000', fontWeight: 'bold' }"
  8. @click="NavChange"
  9. ></u-tabs>
  10. <view class="fire-content-box">
  11. <view class="search-area" v-if="PageCur != 2">
  12. <view class="search-l">
  13. <view class="search-label">
  14. <text class="req">*</text>
  15. <text>监测点 </text>
  16. </view>
  17. <view class="search-select" @click="changeSelect">
  18. <view class="select-val">{{ searchText }}</view>
  19. <view class="select-icon">
  20. <u-icon
  21. v-if="isShowSelect"
  22. name="arrow-down"
  23. color="#2b7cff"
  24. size="14"
  25. ></u-icon>
  26. <u-icon v-else name="arrow-up" color="#2b7cff" size="14"></u-icon>
  27. </view>
  28. </view>
  29. <view class="select-item" v-if="!isShowSelect">
  30. <view
  31. class="item-box"
  32. v-for="(ite, ind) in selectList"
  33. :key="ind"
  34. @click="choiceSelect(ite)"
  35. >{{ ite.name }}
  36. </view>
  37. </view>
  38. </view>
  39. <view class="search-r">
  40. <!-- <image src="/static/model/alarmTrue.svg" alt="" class="icon-style" /> -->
  41. <u-icon name="warning-fill" color="#2b7cff" size="14"></u-icon>
  42. <text class="icon-text">低风险</text>
  43. </view>
  44. </view>
  45. <!-- 内因火灾-密闭监测 -->
  46. <view class="fire-content" v-if="PageCur == 0 && isShow">
  47. <fireDetailMb :detailMb="detailData"></fireDetailMb>
  48. </view>
  49. <!-- 内因火灾-采空区 -->
  50. <view class="fire-content" v-if="PageCur == 0 && !isShow">
  51. <fireDetailCkq :detailCkq="detailData"></fireDetailCkq>
  52. </view>
  53. <!-- 外因火灾 -->
  54. <view class="fire-content" v-if="PageCur == 1">
  55. <fireDetailOut :detailWy="detailData"></fireDetailOut>
  56. </view>
  57. <!-- 火灾指标 -->
  58. <view class="fire-content-zb" v-if="PageCur == 2">
  59. <fireDetailZb :detailZb="menuList"></fireDetailZb>
  60. </view>
  61. </view>
  62. </view>
  63. </template>
  64. <script>
  65. import api from "@/api/api";
  66. import fireDetailMb from "./fire-detail-mb.vue";
  67. import fireDetailCkq from "./fire-detail-ckq.vue";
  68. import fireDetailOut from "./fire-detail-out.vue";
  69. import fireDetailZb from "./fire-detail-zb.vue";
  70. export default {
  71. name: "fireDetail",
  72. components: {
  73. fireDetailMb,
  74. fireDetailCkq,
  75. fireDetailOut,
  76. fireDetailZb,
  77. },
  78. props: {},
  79. watch: {},
  80. data() {
  81. return {
  82. timer: "",
  83. isShow: false,
  84. // 必须是数字,u-tabs 内部用 === 比较下标,字符串 "0" 会导致默认选中项拿不到 activeStyle
  85. PageCur: 0,
  86. tabList: [
  87. { name: "内因火灾" },
  88. { name: "外因火灾" },
  89. { name: "火灾指标" },
  90. ],
  91. searchText: "",
  92. isShowSelect: true,
  93. selectList: [],
  94. menuList: [],
  95. detailData: {},
  96. };
  97. },
  98. beforeDestroy() {
  99. this.timer = null;
  100. clearTimeout(this.timer);
  101. },
  102. mounted() {
  103. this.getTabList();
  104. },
  105. methods: {
  106. NavChange: function (item) {
  107. clearTimeout(this.timer);
  108. this.PageCur = item.index;
  109. if (this.PageCur == 1) {
  110. this.selectList = this.menuList.external.map((el) => {
  111. return {
  112. name: el.systemname,
  113. warn: "低风险",
  114. deviceID: el.id,
  115. strtype: el.strtype,
  116. };
  117. });
  118. this.searchText = this.selectList[0].name;
  119. this.getMonitor(this.selectList[0].deviceID, true);
  120. } else if (this.PageCur == 0) {
  121. this.selectList = this.menuList.internal.map((el) => {
  122. return {
  123. name: el.systemname,
  124. warn: "低风险",
  125. deviceID: el.id,
  126. strtype: el.strtype,
  127. };
  128. });
  129. this.searchText = this.selectList[0].name;
  130. this.getMonitor(this.selectList[0].deviceID, true);
  131. } else {
  132. this.selectList = [];
  133. }
  134. },
  135. changeSelect() {
  136. this.isShowSelect = !this.isShowSelect;
  137. },
  138. choiceSelect(val) {
  139. clearTimeout(this.timer);
  140. this.searchText = val.name;
  141. this.isShowSelect = true;
  142. if (this.searchText.indexOf("采空") != -1) {
  143. this.isShow = false;
  144. } else {
  145. this.isShow = true;
  146. }
  147. this.getMonitor(val.deviceID, true);
  148. },
  149. getMonitor(deviceID, flag) {
  150. let than = this;
  151. than.timer = setTimeout(
  152. async () => {
  153. await than.getSysWarnList(deviceID, "fire");
  154. if (than.timer) {
  155. than.timer = null;
  156. }
  157. than.getMonitor(deviceID);
  158. },
  159. flag ? 0 : 3000
  160. );
  161. },
  162. //获取内因火灾下拉选项数据
  163. getTabList() {
  164. new Promise((resolve, reject) => {
  165. api
  166. .sysTypeWarn({ type: "fire" })
  167. .then((response) => {
  168. if (response.data.code == 200 && response.data.result.length != 0) {
  169. let result = response.data.result;
  170. console.log(result, "result-------");
  171. this.menuList = result;
  172. this.selectList = result.internal.map((el) => {
  173. return {
  174. name: el.systemname,
  175. warn: "低风险",
  176. deviceID: el.id,
  177. strtype: el.strtype,
  178. };
  179. });
  180. this.searchText = this.selectList[0].name;
  181. this.getMonitor(this.selectList[0].deviceID, true);
  182. } else {
  183. reject(response);
  184. }
  185. })
  186. .catch((error) => {
  187. console.log("catch===>response", response);
  188. reject(error);
  189. });
  190. });
  191. },
  192. //获取选项详情数据
  193. getSysWarnList(id, type) {
  194. new Promise((resolve, reject) => {
  195. api
  196. .sysWarn({ sysid: id, type: type })
  197. .then((response) => {
  198. if (response.data.code == 200) {
  199. let data = response.data.result;
  200. this.detailData = data;
  201. console.log(this.detailData, "火灾详情数据----------");
  202. } else {
  203. reject(response);
  204. }
  205. })
  206. .catch((error) => {
  207. console.log("catch===>response", response);
  208. reject(error);
  209. });
  210. });
  211. },
  212. },
  213. computed: {},
  214. };
  215. </script>
  216. <style lang="scss" scoped>
  217. .fire-detail {
  218. position: relative;
  219. // 撑满父容器高度:tab 固定在顶部,滚动区域在 tab 下面
  220. display: flex;
  221. flex-direction: column;
  222. height: 100%;
  223. box-sizing: border-box;
  224. .devic-box-tab {
  225. flex-shrink: 0;
  226. position: sticky;
  227. top: 0;
  228. z-index: 10;
  229. background-color: #f9f9fb;
  230. border-radius: 5px;
  231. border: 1px solid #fff;
  232. margin-bottom: 10px;
  233. }
  234. .fire-content-box {
  235. flex: 1;
  236. min-height: 0;
  237. box-sizing: border-box;
  238. overflow-y: auto;
  239. .search-area {
  240. width: 100%;
  241. padding: 10px;
  242. display: flex;
  243. justify-content: center;
  244. align-items: center;
  245. box-sizing: border-box;
  246. background-color: #eaeefc;
  247. border-radius: 10px;
  248. margin-bottom: 10px;
  249. .search-l {
  250. position: relative;
  251. flex: 1;
  252. min-width: 0;
  253. display: flex;
  254. align-items: center;
  255. .search-label {
  256. flex-shrink: 0;
  257. display: flex;
  258. align-items: center;
  259. font-size: 13px;
  260. color: #333;
  261. .req {
  262. color: #f5222d;
  263. font-size: 13px;
  264. margin-right: 3px;
  265. }
  266. }
  267. .search-select {
  268. flex: 1;
  269. min-width: 0;
  270. display: flex;
  271. justify-content: space-between;
  272. align-items: center;
  273. height: 32px;
  274. margin-left: 8px;
  275. padding: 0px 8px;
  276. box-sizing: border-box;
  277. border-radius: 4px;
  278. border: 1px solid #2b7cff;
  279. .select-val {
  280. flex: 1;
  281. min-width: 0;
  282. font-size: 13px;
  283. color: #333;
  284. overflow: hidden;
  285. white-space: nowrap;
  286. text-overflow: ellipsis;
  287. }
  288. .select-icon {
  289. flex-shrink: 0;
  290. display: flex;
  291. align-items: center;
  292. }
  293. }
  294. .select-item {
  295. position: absolute;
  296. top: 40px;
  297. left: 58px;
  298. width: calc(100% - 58px);
  299. max-height: 150px;
  300. box-sizing: border-box;
  301. padding: 5px 10px;
  302. background-color: #fff;
  303. border: 1px solid #e5e9f2;
  304. border-radius: 5px;
  305. box-shadow: 0 2px 8px rgba(43, 124, 255, 0.12);
  306. overflow-y: auto;
  307. z-index: 10;
  308. .item-box {
  309. height: 26px;
  310. line-height: 26px;
  311. font-size: 13px;
  312. color: #333;
  313. }
  314. }
  315. }
  316. .search-r {
  317. flex-shrink: 0;
  318. display: flex;
  319. align-items: center;
  320. justify-content: center;
  321. height: 32px;
  322. margin-left: 8px;
  323. padding: 0px 8px;
  324. box-sizing: border-box;
  325. border-radius: 4px;
  326. border: 1px solid #2b7cff;
  327. background-color: #d2e0fc;
  328. .icon-style {
  329. width: 14px;
  330. height: 14px;
  331. }
  332. .icon-text {
  333. margin-left: 3px;
  334. font-size: 12px;
  335. color: #2b7cff;
  336. }
  337. }
  338. }
  339. }
  340. }
  341. </style>