index.vue 5.4 KB

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