index.vue 4.8 KB

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