index.vue 7.3 KB

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