index-copy.vue 8.5 KB

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