index.vue 7.7 KB

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