index.vue 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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" :module-type-name="moduleTypeName" />
  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. let moduleTypeName=ref('')
  47. function changeActive(activeValue) {
  48. activeKey.value = activeValue;
  49. }
  50. function deviceChange(index) {
  51. deviceActive.value = deviceType.value = deviceList.value[index].deviceType;
  52. isRefresh.value = false;
  53. nextTick(() => {
  54. isRefresh.value = true;
  55. });
  56. }
  57. async function getDeviceList() {
  58. const res = await systemList({ devicetype: 'sys', systemID: optionValue.value });
  59. const result = res.msgTxt;
  60. if (!result || result.length < 1) return;
  61. const deviceArr = <DeviceType[]>[];
  62. result.forEach((item) => {
  63. const data = item['datalist'].filter((data: any) => {
  64. const readData = data.readData;
  65. return Object.assign(data, readData);
  66. });
  67. if (item.type !== 'sys') {
  68. deviceArr.unshift({
  69. deviceType: item.type,
  70. deviceName: item['typeName'] ? item['typeName'] : item['datalist'][0]['typeName'],
  71. datalist: data,
  72. });
  73. }
  74. });
  75. deviceList.value = deviceArr;
  76. deviceActive.value = deviceArr[0].deviceType;
  77. deviceChange(0);
  78. }
  79. async function getSysDataSource() {
  80. const res = await getTableList({ strtype: 'sys_nitrogen', pagetype: 'normal' });
  81. if (!options.value) {
  82. // 初始时选择第一条数据
  83. options.value = res.records || [];
  84. if (!optionValue.value) {
  85. getSelectRow(options.value[0]['id']);
  86. getDeviceList();
  87. }
  88. }
  89. }
  90. // 切换检测数据
  91. async function getSelectRow(deviceID) {
  92. console.log(deviceID,'deviceID---')
  93. console.log(options.value,'options.value')
  94. const currentData = options.value.find((item: any) => {
  95. return item.id == deviceID;
  96. });
  97. optionValue.value = deviceID;
  98. changeModalType(currentData);
  99. getDeviceList();
  100. }
  101. // 获取模型类型
  102. function changeModalType(currentData) {
  103. optionType.value = currentData['strtype'];
  104. if (currentData['strsystype'] == '1') {
  105. // 空压机
  106. // modalType.value = 'nitrogen';
  107. moduleTypeName.value='KYJ'
  108. } else {
  109. // 制氮机
  110. // modalType.value = 'nitrogenUnderground';
  111. moduleTypeName.value='ZDJ'
  112. }
  113. }
  114. onMounted(async () => {
  115. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) optionValue.value = currentRoute.value['query']['id'];
  116. await getSysDataSource();
  117. // getSelectRow(optionValue.value)
  118. });
  119. onUnmounted(() => {});
  120. </script>
  121. <style lang="less" scoped>
  122. @import '/@/design/vent/modal.less';
  123. @ventSpace: zxm;
  124. .nitrogen-home-header {
  125. width: 100%;
  126. height: 100px;
  127. position: fixed;
  128. top: 0;
  129. background: url('/@/assets/images/vent/new-home/header-bg.png') no-repeat;
  130. background-size: contain;
  131. display: flex;
  132. justify-content: center;
  133. .header-icon {
  134. margin-top: 45px;
  135. }
  136. .header-text {
  137. position: fixed;
  138. top: 18px;
  139. color: #fff;
  140. font-size: 24px;
  141. }
  142. }
  143. .nitrogen-box {
  144. width: 100%;
  145. height: 100%;
  146. display: flex;
  147. justify-content: center;
  148. .bottom-btn-group {
  149. display: flex;
  150. position: fixed;
  151. width: calc(100% - 400px);
  152. height: 100px;
  153. bottom: 10px;
  154. align-items: center;
  155. justify-content: center;
  156. z-index: 2;
  157. .btn-item {
  158. width: 200px;
  159. height: 60px;
  160. margin: 10px;
  161. color: #fff;
  162. cursor: pointer;
  163. pointer-events: auto;
  164. }
  165. }
  166. &:deep(.win) {
  167. margin: 0 !important;
  168. }
  169. }
  170. </style>