index.vue 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397
  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="window3D" v-show="!loading" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  5. <!-- <div id="damper3DCSS" v-show="!loading" style="width: 100%; height: 100%; top:0; left: 0; position: absolute; overflow: hidden;">
  6. <div>
  7. <div ref="elementContent" class="elementContent">
  8. <p><span class="data-title">压力(Pa):</span>{{selectData.frontRearDP}}</p>
  9. <p><span class="data-title">动力源压力(MPa):</span>{{selectData.sourcePressure}}</p>
  10. <p><span class="data-title">故障诊断:</span>
  11. <i
  12. :class="{'state-icon': true, 'open': selectData.messageBoxStatus, 'close': !selectData.messageBoxStatus}"
  13. ></i>{{selectData.fault}}</p>
  14. </div>
  15. </div>
  16. </div> -->
  17. </div>
  18. <div class="scene-box">
  19. <div class="top-box">
  20. <div class="top-left row"> 井下风窗远程集中管理 </div>
  21. <div class="top-center row">
  22. <div class="input-box">
  23. <span class="input-title">风窗面积:</span>
  24. <a-input-number placeholder="0" :min="0" :max="90" :step="1" v-model:value="windowAngle" />
  25. </div>
  26. <div class="button-box" @click="setArea(1)">设定前窗面积</div>
  27. <div class="button-box" @click="setArea(2)">设定后窗面积</div>
  28. <div class="button-box" @click="setArea(2)" style="display: none">设定风窗面积</div>
  29. </div>
  30. <div class="top-right row">
  31. <div class="control-type row">
  32. <div class="control-title">控制模式:</div>
  33. <a-radio-group v-model:value="controlType">
  34. <a-radio :value="1">就地</a-radio>
  35. <a-radio :value="2">远程</a-radio>
  36. </a-radio-group>
  37. </div>
  38. <div class="run-type row">
  39. <div class="control-title">运行状态:</div>
  40. <a-radio-group v-model:value="controlType">
  41. <a-radio :value="1">检修</a-radio>
  42. </a-radio-group>
  43. </div>
  44. <div class="run-state row">
  45. <div class="control-title">网络状态:</div>
  46. <a-radio-group v-model:value="controlType">
  47. <a-radio :value="1">运行</a-radio>
  48. </a-radio-group>
  49. </div>
  50. </div>
  51. </div>
  52. <div class="title-box"> 2-2煤主辅三联巷自动风窗 </div>
  53. <div class="tabs-box">
  54. <a-tabs v-model:activeKey="activeKey" @change="tabChange">
  55. <a-tab-pane key="1" tab="实时监测">
  56. <MonitorTable columnsType="window_monitor" :dataSource="dataSource" @selectRow="getSelectRow" design-scope="window-monitor" title="风窗监测" />
  57. </a-tab-pane>
  58. <a-tab-pane key="2" tab="实时曲线图" force-render>
  59. <div class="tab-item" v-if="activeKey === '2'">
  60. <BarMulti :chartData="dataSource" xAxisPropType="strname" :propTypeArr="propTypeArr" height="100%" :option="option" />
  61. </div>
  62. </a-tab-pane>
  63. <a-tab-pane key="3" tab="历史数据">
  64. <div class="tab-item"> Content of Tab Pane 2 </div>
  65. </a-tab-pane>
  66. <a-tab-pane key="4" tab="操作历史">
  67. <div class="tab-item"> Content of Tab Pane 2 </div>
  68. </a-tab-pane>
  69. <a-tab-pane key="5" tab="实时报警">
  70. <div class="tab-item"> Content of Tab Pane 2 </div>
  71. </a-tab-pane>
  72. </a-tabs>
  73. </div>
  74. </div>
  75. <div style="z-index: -1; position: absolute; top: 50px; right: 10px; width: 300px; height: 280px; margin: auto" class="palyer1">
  76. <LivePlayer id="fc-player1" ref="player1" :videoUrl="flvURL1()" muted live loading controls />
  77. <LivePlayer id="fc-player2" ref="player2" :videoUrl="flvURL1()" muted live loading controls style="margin-top: 10px" />
  78. </div>
  79. </template>
  80. <script setup lang="ts">
  81. import '/@/assets/less/modal.less';
  82. import BarMulti from '/@/components/chart/BarMulti.vue';
  83. import { onBeforeMount, computed, ref, onMounted, nextTick, onUnmounted, reactive, toRaw, Ref } from 'vue';
  84. import MonitorTable from '../comment/MonitorTable.vue';
  85. import { initWebSocket, getRecordList } from '/@/hooks/web/useVentWebSocket';
  86. import { mountedThree, destroy, addFmText, play, setModelType } from './window.threejs';
  87. import { list, getTableList } from './window.api';
  88. import { deviceControlApi } from '/@/api/vent/index';
  89. import lodash from 'lodash';
  90. import LivePlayer from '@liveqing/liveplayer-v3';
  91. const player1 = ref(null);
  92. const player2 = ref(null);
  93. const deviceBaseList = ref([]);
  94. const activeKey = ref('1');
  95. const loading = ref(false);
  96. const windowAngle = ref(0);
  97. const rotationParam = {
  98. frontDeg0: 0, // 前门初始
  99. frontDeg1: windowAngle.value, // 前门目标
  100. backDeg0: 0, // 后门初始
  101. backDeg1: windowAngle.value, // 后门目标
  102. };
  103. const option = {
  104. grid: {
  105. show: false,
  106. left: 60,
  107. right: 50,
  108. bottom: 30,
  109. },
  110. xAxis: {
  111. axisLine: {
  112. show: true,
  113. lineStyle: {
  114. color: '#ffffffcc',
  115. },
  116. },
  117. },
  118. yAxis: {
  119. name: '单位(m/min)',
  120. nameTextStyle: {
  121. color: '#fff',
  122. fontSize: 14,
  123. },
  124. axisLine: {
  125. show: true,
  126. lineStyle: {
  127. color: '#ffffffcc',
  128. },
  129. },
  130. splitLine: {
  131. show: false,
  132. },
  133. },
  134. };
  135. // 默认初始是第一行
  136. const selectRowIndex = ref(0);
  137. const dataSource = ref([]);
  138. // webSocket 请求
  139. // const dataSource = computed(() => {
  140. // const data = [...getRecordList()] || [];
  141. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  142. // addFmText(selectData);
  143. // return data;
  144. // });
  145. const propTypeArr = new Map([
  146. ['frontPresentValue', '前窗风速'],
  147. ['rearPresentValue', '后窗风速'],
  148. ]);
  149. const flvURL1 = () => {
  150. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  151. };
  152. const flvURL2 = () => {
  153. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  154. };
  155. // 设备数据
  156. const controlType = ref(1);
  157. const tabChange = (activeKeyVal) => {
  158. activeKey.value = activeKeyVal;
  159. };
  160. const initData = {
  161. deviceID: '',
  162. deviceType: '',
  163. strname: '',
  164. dataDh: '-', //压差
  165. dataDtestq: '-', //测试风量
  166. sourcePressure: '-', //气源压力
  167. dataDequivalarea: '-',
  168. netStatus: '0', //通信状态
  169. fault: '气源压力超限',
  170. forntArea: '0',
  171. rearArea: '0',
  172. frontRearDifference: '-',
  173. rearPresentValue: '-',
  174. maxarea: '',
  175. };
  176. // 监测数据
  177. const selectData = reactive(lodash.cloneDeep(initData));
  178. // https获取监测数据
  179. let timer: null | NodeJS.Timeout = null;
  180. const getMonitor = () => {
  181. if (Object.prototype.toString.call(timer) === '[object Null]') {
  182. timer = setTimeout(async () => {
  183. const data = await getDataSource()
  184. Object.assign(selectData, data);
  185. playAnimation(data, selectData.maxarea);
  186. addFmText(selectData);
  187. if(timer){
  188. timer = null;
  189. }
  190. getMonitor();
  191. }, 1000);
  192. }
  193. };
  194. const getDataSource = async() => {
  195. const res = await list({ devicetype: 'window', pagetype: 'normal' })
  196. dataSource.value = res.msgTxt[0].datalist || [];
  197. dataSource.value.forEach((data: any) => {
  198. const readData = data.readData;
  199. data = Object.assign(data, readData);
  200. });
  201. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  202. return data
  203. }
  204. // 获取设备基本信息列表
  205. const getDeviceBaseList = () => {
  206. getTableList({ pageSize: 1000 }).then((res) => {
  207. deviceBaseList.value = res.records;
  208. });
  209. };
  210. // 切换检测数据
  211. const getSelectRow = (selectRow, index) => {
  212. selectRowIndex.value = index;
  213. loading.value = true;
  214. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  215. Object.assign(selectData, initData, selectRow, baseData);
  216. const type = selectRowIndex.value > 6 ? 'doubleWindow': 'singleWindow'
  217. setModelType(type).then(() => {
  218. addFmText(selectData);
  219. playAnimation(selectRow, baseData.maxarea, true);
  220. loading.value = false;
  221. })
  222. };
  223. // 判断前后窗的面积是否发生改变,如果改变则开启动画
  224. const playAnimation = (data, maxarea, isFirst = false) => {
  225. rotationParam.frontDeg0 = 90 / maxarea * Number(isFirst ? 0 : selectData.forntArea);
  226. rotationParam.backDeg0 = 90 / maxarea * Number(isFirst ? 0 : selectData.rearArea);
  227. rotationParam.frontDeg1 = 90 / maxarea * Number(data.forntArea) || 0;
  228. rotationParam.backDeg1 = 90 / maxarea * Number(data.rearArea) || 0;
  229. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  230. play(rotationParam, 0);
  231. } else {
  232. if (rotationParam.frontDeg0 >= 0 && rotationParam.frontDeg1 >= 0 && rotationParam.frontDeg0 !== rotationParam.frontDeg1) {
  233. setTimeout(() => {
  234. play(rotationParam, 1);
  235. }, 0);
  236. }
  237. if (rotationParam.backDeg0 >= 0 && rotationParam.backDeg1 >= 0 && rotationParam.backDeg0 !== rotationParam.backDeg1) {
  238. setTimeout(() => {
  239. play(rotationParam, 2);
  240. }, 0);
  241. }
  242. }
  243. };
  244. // 设置风窗面积
  245. const setArea = (flag) => {
  246. const data = {
  247. deviceid: selectData.deviceID,
  248. devicetype: selectData.deviceType,
  249. paramcode: flag === 1 ? 'frontSetValue' : 'rearSetValue',
  250. value: windowAngle.value,
  251. };
  252. deviceControlApi(data)
  253. .then((res) => {
  254. if (res.success) {
  255. }
  256. })
  257. };
  258. const addPlayVideo = () => {
  259. if (player1.value.play && player2.value.play) {
  260. if(!player1.value.paused()) player1.value.play();
  261. if(!player2.value.paused()) player2.value.play();
  262. document.body.removeEventListener('mousedown', addPlayVideo);
  263. }
  264. };
  265. onBeforeMount(() => {
  266. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'window', orgcode: '', ids: '', systemID: '' });
  267. // initWebSocket(sendVal);
  268. getDeviceBaseList();
  269. document.body.addEventListener('mousedown', addPlayVideo, false);
  270. });
  271. onMounted(() => {
  272. loading.value = true;
  273. mountedThree(player1.value, player2.value).then(() => {
  274. nextTick(() => {
  275. loading.value = false;
  276. addFmText(selectData);
  277. getMonitor();
  278. });
  279. });
  280. });
  281. onUnmounted(() => {
  282. destroy();
  283. if(timer) {
  284. clearTimeout(timer)
  285. timer = undefined;
  286. }
  287. });
  288. </script>
  289. <style lang="less" scoped>
  290. .input-box {
  291. display: flex;
  292. align-items: center;
  293. .input-title {
  294. color: rgb(0, 255, 242);
  295. width: auto;
  296. }
  297. margin-right: 10px;
  298. }
  299. :deep(.jeecg-basic-table .ant-table-wrapper) {
  300. background-color: #ffffff00;
  301. }
  302. :deep(.ant-tabs-bar) {
  303. margin: 0;
  304. }
  305. :deep(.ant-table) {
  306. background-color: #ffffff00 !important;
  307. color: #fff;
  308. }
  309. :deep(.ant-table-header) {
  310. background-color: transparent;
  311. // height: 42px;
  312. }
  313. :deep(.ant-table-thead > tr > th) {
  314. background-color: transparent;
  315. border: none;
  316. }
  317. :deep(.ant-table-body > tr > th) {
  318. background-color: transparent;
  319. border: none;
  320. }
  321. :deep(.ant-table-body > tr > td) {
  322. border: none;
  323. }
  324. :deep(.ant-table-fixed-header > .ant-table-content > .ant-table-scroll > .ant-table-body) {
  325. background-color: #ffffff05;
  326. margin-top: 8px;
  327. &::-webkit-scrollbar {
  328. display: none;
  329. }
  330. }
  331. :deep(.jeecg-basic-table .ant-table-wrapper .ant-table-title) {
  332. padding: 0;
  333. }
  334. :deep(.jeecg-basic-table-row__striped td) {
  335. background-color: transparent;
  336. }
  337. :deep(.ant-table-tbody > tr:hover.ant-table-row > td) {
  338. background-color: #ffffff22;
  339. }
  340. :deep(.ant-table-tbody > tr:hover.ant-table-row > th) {
  341. background-color: #ffffff22;
  342. }
  343. :deep(.ant-table-thead > tr:hover.ant-table-row > td) {
  344. background-color: #ffffff22;
  345. }
  346. :deep(.ant-table-tbody > tr.ant-table-row-selected td) {
  347. background-color: #ffffff22;
  348. }
  349. :deep(.ant-table-tbody > tr > td) {
  350. border-color: #ffffff22;
  351. }
  352. :deep(.ant-table-thead > tr > th:hover) {
  353. background-color: transparent !important;
  354. }
  355. :deep(.ant-table-thead > tr > th) {
  356. color: #fff;
  357. }
  358. :deep(.ant-table-fixed-header .ant-table-scroll .ant-table-header) {
  359. background: #ffffff44;
  360. position: relative;
  361. z-index: 999;
  362. padding: 4px 0 !important;
  363. &::-webkit-scrollbar {
  364. display: none;
  365. }
  366. }
  367. :deep(.ant-tabs-nav) {
  368. color: #fff;
  369. }
  370. </style>