index.vue 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  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. if (!optionValue.value) {
  77. getSelectRow(options.value[0]['id'])
  78. getDeviceList()
  79. }
  80. }
  81. };
  82. // 切换检测数据
  83. async function getSelectRow(deviceID) {
  84. const currentData = options.value.find((item: any) => {
  85. return item.id == deviceID
  86. })
  87. optionValue.value = deviceID
  88. changeModalType(currentData)
  89. getDeviceList()
  90. }
  91. // 获取模型类型
  92. function changeModalType(currentData) {
  93. optionType.value = currentData['strtype']
  94. if (currentData['strsystype'] === '1') {
  95. // 地上
  96. modalType.value = 'nitrogen'
  97. } else if (currentData['strsystype'] === '2') {
  98. // 地下
  99. modalType.value = 'nitrogenUnderground'
  100. }
  101. }
  102. onMounted(async () => {
  103. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) optionValue.value = currentRoute.value['query']['id']
  104. await getSysDataSource()
  105. getSelectRow(optionValue.value)
  106. });
  107. onUnmounted(() => {
  108. });
  109. </script>
  110. <style lang="less" scoped>
  111. @ventSpace: zxm;
  112. .nitrogen-home-header {
  113. width: 100%;
  114. height: 100px;
  115. position: fixed;
  116. top: 0;
  117. background: url('/@/assets/images/vent/new-home/header-bg.png') no-repeat;
  118. background-size: contain;
  119. display: flex;
  120. justify-content: center;
  121. .header-icon {
  122. margin-top: 45px;
  123. }
  124. .header-text {
  125. position: fixed;
  126. top: 18px;
  127. color: #fff;
  128. font-size: 24px;
  129. }
  130. }
  131. .nitrogen-box{
  132. width: 100%;
  133. height: 100%;
  134. display: flex;
  135. justify-content: center;
  136. .bottom-btn-group {
  137. display: flex;
  138. position: fixed;
  139. width: calc(100% - 400px);
  140. height: 100px;
  141. bottom: 10px;
  142. align-items: center;
  143. justify-content: center;
  144. z-index: 2;
  145. .btn-item {
  146. width: 200px;
  147. height: 60px;
  148. margin: 10px;
  149. color: #fff;
  150. cursor: pointer;
  151. pointer-events: auto;
  152. }
  153. }
  154. &:deep(.win) {
  155. margin: 0 !important;
  156. }
  157. }
  158. </style>