index.vue 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  1. <template>
  2. <div class="nitrogen-box">
  3. <customHeader :fieldNames="{ label: 'systemname', value: 'id', options: 'children' }" :options = 'options' @change="getSelectRow" :optionValue="optionValue">智能注氮管控系统</customHeader>
  4. <!-- 阿里云 -->
  5. <!-- <nitrogenHome v-if="activeKey == 'nitrogen_page' && optionValue && optionValue !='1702602347296399361'" :device-id="optionValue" :modal-type="modalType" /> -->
  6. <!-- 布尔台 -->
  7. <!-- <nitrogenHome1 v-if="activeKey == 'nitrogen_page' && optionValue" :device-id="optionValue" :modal-type="modalType" /> -->
  8. <!-- 保德 -->
  9. <!-- <nitrogenHome2 v-if="activeKey == 'nitrogen_page' && optionValue" :device-id="optionValue" :modal-type="modalType" /> -->
  10. <nitrogenHomeBlt v-if="activeKey == 'nitrogen_page' && optionValue" :device-id="optionValue" :modal-type="modalType" />
  11. <nitrogenEcharts v-if="activeKey == 'yfj_monitor_echarts'"/>
  12. <nitrogenHistory ref="historyTable" :device-id="optionValue" :device-type="optionType" v-if="activeKey == 'yfj_history'"/>
  13. <nitrogenHandleHistory ref="alarmHistoryTable" v-if="activeKey == 'yfj_handler_history'"/>
  14. <nitrogenAlarmHistory ref="handlerHistoryTable" v-if="activeKey == 'yfj_faultRecord'"/>
  15. <BottomMenu :nav-list="navList" @change="changeActive"/>
  16. </div>
  17. </template>
  18. <script lang="ts" setup>
  19. import { ref, onMounted, onUnmounted, nextTick } from 'vue'
  20. import customHeader from '/@/views/vent/comment/components/customHeader.vue';
  21. import nitrogenHome from './components/nitrogenHome.vue'
  22. import nitrogenHome1 from './components/nitrogenHome1.vue' // 布尔台
  23. import nitrogenHome2 from './components/nitrogenHome2.vue' // 保德
  24. import nitrogenHomeBlt from './components/nitrogenHome_blt.vue' // 保德
  25. import nitrogenEcharts from './components/nitrogenEcharts.vue'
  26. import nitrogenHistory from './components/nitrogenHistory.vue'
  27. import nitrogenHandleHistory from './components/nitrogenHandleHistory.vue'
  28. import nitrogenAlarmHistory from './components/nitrogenAlarmHistory.vue'
  29. import BottomMenu from '/@/views/vent/comment/components/bottomMenu.vue';
  30. import { useRouter } from 'vue-router';
  31. import { navList } from './nitrogen.data'
  32. import { getTableList, systemList, } from "./nitrogen.api";
  33. type DeviceType = { deviceType: string, deviceName: string, datalist: any[] };
  34. const { currentRoute } = useRouter();
  35. const activeKey = ref('nitrogen_page');
  36. const historyTable = ref()
  37. const alarmHistoryTable = ref()
  38. const handlerHistoryTable = ref()
  39. //关联设备
  40. const deviceList = ref<DeviceType[]>([])
  41. const deviceActive = ref('')
  42. const deviceType = ref('')
  43. const options = ref()
  44. const optionValue = ref('')
  45. const optionType = ref('')
  46. const modalType = ref('')
  47. const isRefresh = ref(true)
  48. function changeActive(activeValue) {
  49. activeKey.value = activeValue
  50. }
  51. function deviceChange(index) {
  52. deviceActive.value = deviceType.value = deviceList.value[index].deviceType
  53. isRefresh.value = false
  54. nextTick(() => {
  55. isRefresh.value = true
  56. })
  57. }
  58. async function getDeviceList() {
  59. const res = await systemList({ devicetype: 'sys', systemID: optionValue.value });
  60. const result = res.msgTxt;
  61. if(!result || result.length < 1) return
  62. const deviceArr = <DeviceType[]>[]
  63. result.forEach(item => {
  64. const data = item['datalist'].filter((data: any) => {
  65. const readData = data.readData;
  66. return Object.assign(data, readData);
  67. })
  68. if (item.type !== 'sys') {
  69. deviceArr.unshift({ deviceType: item.type, deviceName: item['typeName'] ? item['typeName'] : item['datalist'][0]['typeName'], datalist: data })
  70. }
  71. })
  72. deviceList.value = deviceArr
  73. deviceActive.value = deviceArr[0].deviceType
  74. deviceChange(0)
  75. };
  76. async function getSysDataSource() {
  77. const res = await getTableList({ strtype: 'sys_nitrogen', pagetype: 'normal' });
  78. if (!options.value) {
  79. // 初始时选择第一条数据
  80. options.value = res.records || [];
  81. if (!optionValue.value) {
  82. getSelectRow(options.value[0]['id'])
  83. getDeviceList()
  84. }
  85. }
  86. };
  87. // 切换检测数据
  88. async function getSelectRow(deviceID) {
  89. const currentData = options.value.find((item: any) => {
  90. return item.id == deviceID
  91. })
  92. optionValue.value = deviceID
  93. changeModalType(currentData)
  94. getDeviceList()
  95. }
  96. // 获取模型类型
  97. function changeModalType(currentData) {
  98. optionType.value = currentData['strtype']
  99. if (currentData['strsystype'] === '1') {
  100. // 地上
  101. modalType.value = 'nitrogen'
  102. } else if (currentData['strsystype'] === '2') {
  103. // 地下
  104. modalType.value = 'nitrogenUnderground'
  105. }
  106. }
  107. onMounted(async () => {
  108. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) optionValue.value = currentRoute.value['query']['id']
  109. await getSysDataSource()
  110. getSelectRow(optionValue.value)
  111. });
  112. onUnmounted(() => {
  113. });
  114. </script>
  115. <style lang="less" scoped>
  116. @ventSpace: zxm;
  117. .nitrogen-home-header {
  118. width: 100%;
  119. height: 100px;
  120. position: fixed;
  121. top: 0;
  122. background: url('/@/assets/images/vent/new-home/header-bg.png') no-repeat;
  123. background-size: contain;
  124. display: flex;
  125. justify-content: center;
  126. .header-icon {
  127. margin-top: 45px;
  128. }
  129. .header-text {
  130. position: fixed;
  131. top: 18px;
  132. color: #fff;
  133. font-size: 24px;
  134. }
  135. }
  136. .nitrogen-box{
  137. width: 100%;
  138. height: 100%;
  139. display: flex;
  140. justify-content: center;
  141. .bottom-btn-group {
  142. display: flex;
  143. position: fixed;
  144. width: calc(100% - 400px);
  145. height: 100px;
  146. bottom: 10px;
  147. align-items: center;
  148. justify-content: center;
  149. z-index: 2;
  150. .btn-item {
  151. width: 200px;
  152. height: 60px;
  153. margin: 10px;
  154. color: #fff;
  155. cursor: pointer;
  156. pointer-events: auto;
  157. }
  158. }
  159. &:deep(.win) {
  160. margin: 0 !important;
  161. }
  162. }
  163. </style>