index.vue 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247
  1. <template>
  2. <div class="fireGoaf">
  3. <div class="composite-left-box">
  4. <basicTree :treeData="treeData" @selectChange="selectChange"></basicTree>
  5. </div>
  6. <div class="composite-right-box">
  7. <div class="composite-top-box">
  8. <basicCard3 :card3List="card3List" :warningLevel="warningLevel" @toggleChange="toggleChange"></basicCard3>
  9. </div>
  10. <div class="composite-bot-box">
  11. <div class="search-area">
  12. <div class="area-title">束管系统监测</div>
  13. <RangePicker v-model="TimeRange" size="small" style="width: 260px" :show-time="{ format: 'HH:mm:ss' }"
  14. format="YYYY-MM-DD HH:mm:ss" :placeholder="['开始时间', '结束时间']" @change="onDataChange" />
  15. </div>
  16. <div class="content-area">
  17. <basicEchartLine :gridV="gridV" :echartData="echartData"></basicEchartLine>
  18. </div>
  19. </div>
  20. </div>
  21. </div>
  22. </template>
  23. <script setup lang="ts">
  24. import { ref, reactive, onMounted,onUnmounted } from 'vue'
  25. import basicCard3 from '../../common/basicCard3.vue';
  26. import basicEchartLine from '../../common/basicEchartLine.vue';
  27. import basicTree from '../../common/basicTree.vue'
  28. import { RangePicker, } from 'ant-design-vue';
  29. import dayjs from 'dayjs';
  30. import { getFireAreaInfo, getMbRealData, getMbHistoryData } from './goaf.api'
  31. let TimeRange = ref<any>([dayjs().subtract(60, 'minute').format('YYYY-MM-DD HH:mm:ss'), dayjs().format('YYYY-MM-DD HH:mm:ss')]) //查询时间
  32. let card3List = reactive<any[]>([])
  33. //左侧菜单树
  34. const treeData = reactive<any[]>([])
  35. let areaCode = ref('')
  36. let warningLevel = ref('')//风险等级
  37. let type = ref('')
  38. let gridV = reactive({
  39. top: '8%',
  40. left: '3%',
  41. right: '3%',
  42. bottom: '10%',
  43. })
  44. let echartData = reactive({
  45. xData: [],
  46. yData: [],
  47. yData1: [],
  48. legendName: ['实时值', '预测值']
  49. })
  50. // https获取监测数据
  51. let timer: null | NodeJS.Timeout = null;
  52. function getMonitor() {
  53. timer = setTimeout(
  54. async () => {
  55. //工作面
  56. await getFireAreaInfos()
  57. if (timer) {
  58. timer = null;
  59. }
  60. getMonitor();
  61. },
  62. 5000
  63. );
  64. }
  65. //时间选项切换
  66. function onDataChange(value, dateString) {
  67. TimeRange.value = [dateString[0], dateString[1]]
  68. console.log(TimeRange, 'TimeRange')
  69. }
  70. //点击左侧树节点
  71. function selectChange(treeNode) {
  72. console.log(treeNode, 'treeNode---')
  73. areaCode.value = treeData.filter((v) => v.name == treeNode.node.dataRef.title)[0]['areaCode']
  74. let level = treeData.filter((m) => m.name == treeNode.node.dataRef.title)[0]['warningLevel']
  75. warningLevel.value = level == 1 ? '低风险' : level == 2 ? '中风险' : level == 3 ? '较高风险' : level == 4 ? '重大风险' : '--'
  76. getMbRealDataList()
  77. }
  78. //获取左侧菜单树
  79. async function getFireAreaInfos() {
  80. const res = await getFireAreaInfo({ fireCauseType: 2 })
  81. if (res.length != 0) {
  82. treeData.length = 0
  83. res.forEach((el, ind) => {
  84. if (el.areaType == 1) {
  85. treeData.push({ name: el.areaName, value: el.ind, id: el.ind, pid: null, areaCode: el.areaCode, warningLevel: el.warningLevel })
  86. }
  87. })
  88. areaCode.value = areaCode.value ? areaCode.value : treeData[0]['areaCode']
  89. warningLevel.value = treeData[0].warningLevel == 1 ? '低风险' : treeData[0].warningLevel == 2 ? '中风险' : treeData[0].warningLevel == 3 ? '较高风险' : treeData[0].warningLevel == 4 ? '重大风险' : '--'
  90. console.log(treeData, 'treeData-------')
  91. getMbRealDataList()
  92. }
  93. }
  94. //获取密闭监测实时数据
  95. async function getMbRealDataList() {
  96. let res = await getMbRealData({ areaCode: areaCode.value })
  97. console.log(res, '密闭监测实时数据------')
  98. if (res.length != 0) {
  99. card3List.length = 0
  100. res.forEach(el => {
  101. card3List.push({ title: el.type, ndLabel: '浓度 : ', ndVal: el.currentValue, tLabel: '时间 : ', tVal: el.time, aLabel: '位置 : ', aVal: el.position })
  102. })
  103. type.value = type.value ? type.value : card3List[0]['title']
  104. //获取密闭图表数据
  105. getMbHistoryDataList()
  106. }
  107. }
  108. //密闭实时数据选项切换
  109. function toggleChange(title) {
  110. console.log(title, 'title---------')
  111. type.value = title
  112. getMbHistoryDataList()
  113. }
  114. //获取密闭图表数据
  115. async function getMbHistoryDataList() {
  116. let res = await getMbHistoryData({ areaCode: areaCode.value, type: type.value, startTime: TimeRange.value[0], endTime: TimeRange.value[1] })
  117. console.log(res, '密闭图表数据------')
  118. echartData.xData.length = 0
  119. echartData.yData.length = 0
  120. echartData.yData1.length = 0
  121. res.time.forEach(el => {
  122. echartData.xData.push(el)
  123. })
  124. res.value.forEach(el => {
  125. echartData.yData.push(el)
  126. })
  127. }
  128. onMounted(() => {
  129. getFireAreaInfos()
  130. getMonitor()
  131. })
  132. onUnmounted(() => {
  133. if (timer) {
  134. clearTimeout(timer);
  135. timer = null;
  136. }
  137. });
  138. </script>
  139. <style lang="less" scoped>
  140. .fireGoaf {
  141. display: flex;
  142. position: relative;
  143. align-items: center;
  144. justify-content: space-between;
  145. width: calc(100% - 20px);
  146. // height: calc(100vh - 82px);
  147. height: 863px;
  148. margin: 50px 10px 15px;
  149. background: #282828;
  150. .composite-left-box {
  151. width: 220px;
  152. height: 100%;
  153. background-color: rgb(27 35 39 / 80%);
  154. }
  155. .composite-right-box {
  156. box-sizing: border-box;
  157. width: calc(100% - 230px);
  158. height: 100%;
  159. margin-left: 10px;
  160. padding: 15px 10px;
  161. background-color: rgb(27 35 39 / 80%);
  162. .composite-top-box {
  163. width: 100%;
  164. height: 250px;
  165. margin-bottom: 15px;
  166. }
  167. .composite-bot-box {
  168. box-sizing: border-box;
  169. width: 100%;
  170. height: calc(100% - 265px);
  171. padding: 10px 15px;
  172. border: 1px solid #1e96cd;
  173. background-color: rgb(41 49 53 / 80%);
  174. .search-area {
  175. display: flex;
  176. box-sizing: border-box;
  177. align-items: center;
  178. justify-content: space-between;
  179. height: 30px;
  180. .area-title {
  181. color: #fff;
  182. font-family: douyuFont;
  183. font-size: 16px;
  184. }
  185. }
  186. .content-area {
  187. height: calc(100% - 30px);
  188. }
  189. }
  190. }
  191. }
  192. :deep(.vMonitor-picker) {
  193. border: none !important;
  194. background-color: rgb(15 64 88) !important;
  195. box-shadow: none;
  196. color: #a1dff8 !important;
  197. }
  198. :deep(.vMonitor-picker-input >input) {
  199. color: #a1dff8 !important;
  200. text-align: center !important;
  201. }
  202. :deep(.vMonitor-picker-separator) {
  203. color: #a1dff8 !important;
  204. }
  205. :deep(.vMonitor-picker-active-bar) {
  206. display: none !important;
  207. }
  208. :deep(.vMonitor-picker-suffix) {
  209. color: #a1dff8 !important;
  210. }
  211. </style>