index.vue 5.3 KB

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