index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!-- eslint-disable vue/multi-word-component-names -->
  2. <template>
  3. <!-- 把 dedust3D 放到这里则模型可以正常旋转 -->
  4. <div id="dedust3D" v-show="activeKey == 'monitor'" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  5. <div class="scene-box">
  6. <customHeader
  7. :fieldNames="{ label: 'systemname', value: 'id', options: 'children' }"
  8. :options="options"
  9. :optionValue="optionValue"
  10. @change="getSelectRow"
  11. >
  12. 除尘风机智能管控
  13. </customHeader>
  14. <div class="center-container">
  15. <template v-if="activeKey == 'monitor'">
  16. <DedustHome :deviceId="optionValue" />
  17. </template>
  18. <div v-else class="history-group">
  19. <div class="device-button-group" v-if="deviceList.length > 0 && activeKey !== 'faultRecord'">
  20. <div
  21. class="device-button"
  22. :class="{ 'device-active': deviceActive == device.deviceType }"
  23. v-for="(device, index) in deviceList"
  24. :key="index"
  25. @click="deviceChange(index)"
  26. >{{ device.deviceName }}</div
  27. >
  28. </div>
  29. <div class="history-container">
  30. <DedustHistory
  31. v-if="activeKey == 'monitor_history'"
  32. ref="historyTable"
  33. class="vent-margin-t-20"
  34. :deviceId="optionValue"
  35. :device-type="deviceType"
  36. />
  37. <HandleHistory
  38. v-if="activeKey == 'handler_history'"
  39. ref="alarmHistoryTable"
  40. class="vent-margin-t-20"
  41. :deviceId="optionValue"
  42. :device-type="deviceType"
  43. />
  44. <AlarmHistory
  45. v-if="activeKey == 'faultRecord'"
  46. ref="handlerHistoryTable"
  47. class="vent-margin-t-20"
  48. :deviceId="optionValue"
  49. :device-type="deviceType"
  50. />
  51. </div>
  52. </div>
  53. </div>
  54. <BottomMenu @change="changeActive" />
  55. </div>
  56. </template>
  57. <script setup lang="ts">
  58. import { onBeforeMount, ref, onMounted, reactive } from 'vue';
  59. import { systemList, getTableList } from './dedust.api';
  60. import customHeader from '/@/components/vent/customHeader.vue';
  61. import BottomMenu from '/@/views/vent/comment/components/bottomMenu.vue';
  62. import DedustHome from './components/DedustHome.vue';
  63. import DedustHistory from './components/DedustHistory.vue';
  64. import HandleHistory from './components/HandleHistory.vue';
  65. import AlarmHistory from './components/AlarmHistory.vue';
  66. import { useRouter } from 'vue-router';
  67. type DeviceType = { deviceType: string; deviceName: string; datalist: any[] };
  68. const { currentRoute } = useRouter();
  69. const activeKey = ref('monitor');
  70. const historyTable = ref();
  71. const alarmHistoryTable = ref();
  72. const handlerHistoryTable = ref();
  73. //关联设备
  74. const deviceList = ref<DeviceType[]>([]);
  75. const deviceActive = ref('');
  76. const deviceType = ref('');
  77. const options = ref();
  78. // 默认初始是第一行
  79. // const selectRowIndex = ref(0);
  80. const dataSource = ref([]);
  81. const optionValue = ref('');
  82. // 监测数据
  83. const selectData = reactive({});
  84. function changeActive(activeValue) {
  85. activeKey.value = activeValue;
  86. }
  87. function deviceChange(index) {
  88. deviceActive.value = deviceType.value = deviceList.value[index].deviceType;
  89. }
  90. // 查询关联设备列表
  91. async function getDeviceList() {
  92. const res = await systemList({ devicetype: 'sys', systemID: optionValue.value });
  93. if (res && res.msgTxt && res.msgTxt.length) {
  94. const result = res.msgTxt;
  95. const deviceArr: DeviceType[] = [];
  96. result.forEach((item) => {
  97. const data = item['datalist'].filter((data: any) => {
  98. const readData = data.readData;
  99. return Object.assign(data, readData);
  100. });
  101. if (item.type != 'sys') {
  102. deviceArr.unshift({
  103. deviceType: item.type,
  104. deviceName: item['typeName'] ? item['typeName'] : item['datalist'][0]['typeName'],
  105. datalist: data,
  106. });
  107. }
  108. });
  109. deviceList.value = deviceArr;
  110. deviceActive.value = deviceArr[0].deviceType;
  111. deviceChange(0);
  112. }
  113. }
  114. async function getSysDataSource() {
  115. const res = await getTableList({ strtype: 'sys_surface_juejin', pagetype: 'normal' });
  116. if (!options.value && res) {
  117. // 初始时选择第一条数据
  118. options.value = res.records || [];
  119. if (!optionValue.value) {
  120. optionValue.value = options.value[0]['id'];
  121. getDeviceList();
  122. }
  123. }
  124. }
  125. // 切换检测数据
  126. async function getSelectRow(deviceID) {
  127. const currentData = dataSource.value.find((item: any) => {
  128. return item.deviceID == deviceID;
  129. });
  130. if (currentData) {
  131. optionValue.value = currentData['deviceID'];
  132. Object.assign(selectData, currentData);
  133. await getDeviceList();
  134. }
  135. }
  136. onBeforeMount(() => {});
  137. onMounted(async () => {
  138. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  139. optionValue.value = currentRoute.value['query']['id'] as string;
  140. }
  141. await getSysDataSource();
  142. await getDeviceList();
  143. });
  144. </script>
  145. <style lang="less" scoped>
  146. @import '/@/design/theme.less';
  147. @import '/@/design/vent/modal.less';
  148. .history-group {
  149. padding: 0 20px;
  150. margin-top: 90px;
  151. .history-container {
  152. position: relative;
  153. background: #6195af1a;
  154. width: calc(100% + 10px);
  155. top: 0px;
  156. left: -10px;
  157. border: 1px solid #00fffd22;
  158. padding: 10px 0;
  159. box-shadow: 0 0 20px #44b4ff33 inset;
  160. }
  161. }
  162. .device-button-group {
  163. // margin: 0 20px;
  164. display: flex;
  165. pointer-events: auto;
  166. position: relative;
  167. &::after {
  168. position: absolute;
  169. content: '';
  170. width: calc(100% + 10px);
  171. height: 2px;
  172. top: 30px;
  173. left: -10px;
  174. border-bottom: 1px solid var(--vent-base-border);
  175. }
  176. .device-button {
  177. padding: 4px 15px;
  178. position: relative;
  179. display: flex;
  180. justify-content: center;
  181. align-items: center;
  182. font-size: 14px;
  183. color: var(--vent-font-color);
  184. cursor: pointer;
  185. margin: 0 3px;
  186. &::before {
  187. content: '';
  188. position: absolute;
  189. top: 0;
  190. right: 0;
  191. bottom: 0;
  192. left: 0;
  193. border: 1px solid #6176af;
  194. transform: skewX(-38deg);
  195. background-color: rgba(0, 77, 103, 85%);
  196. z-index: -1;
  197. }
  198. }
  199. .device-active {
  200. // color: #0efcff;
  201. &::before {
  202. border-color: #0efcff;
  203. box-shadow: 1px 1px 3px 1px #0efcff inset;
  204. }
  205. }
  206. }
  207. </style>