index.vue 8.3 KB

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