index.vue 5.5 KB

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