1
0

index.vue 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386
  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-center">
  21. <!-- <div class="input-box">
  22. <span class="input-title">风窗面积:</span>
  23. <a-input-number size="small" placeholder="0" :min="0" :max="90" :step="1" v-model:value="windowAngle" />
  24. </div> -->
  25. <div v-if="selectData.nwindownum == 2" class="row">
  26. <div class="button-box" @click="setArea(1)">设定前窗面积</div>
  27. <div class="button-box" @click="setArea(2)">设定后窗面积</div>
  28. </div>
  29. <div v-if="selectData.nwindownum == 1" class="row">
  30. <div class="button-box" @click="setArea(1)">设定风窗面积</div>
  31. </div>
  32. </div>
  33. <div class="top-right row">
  34. <div class="control-type row">
  35. <div class="control-title">控制模式:</div>
  36. <a-radio-group v-model:value="controlType">
  37. <a-radio :value="1">就地</a-radio>
  38. <a-radio :value="2">远程</a-radio>
  39. </a-radio-group>
  40. </div>
  41. <div class="run-type row">
  42. <div class="control-title">运行状态:</div>
  43. <a-radio-group v-model:value="controlType">
  44. <a-radio :value="1">检修</a-radio>
  45. </a-radio-group>
  46. </div>
  47. <div class="run-state row">
  48. <div class="control-title">网络状态:</div>
  49. <a-radio-group v-model:value="controlType">
  50. <a-radio :value="1">运行</a-radio>
  51. </a-radio-group>
  52. </div>
  53. </div>
  54. </div>
  55. <div class="title-text">
  56. {{ selectData.strname }}
  57. </div>
  58. <div class="bottom-tabs-box" @mousedown="setDivHeight($event, 250, scroll)">
  59. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  60. <a-tab-pane key="1" tab="实时监测">
  61. <MonitorTable
  62. v-if="activeKey === '1' && isRefresh"
  63. columnsType="window_monitor"
  64. :dataSource="dataSource"
  65. @selectRow="getSelectRow"
  66. design-scope="window-monitor"
  67. :scroll="scroll"
  68. title="风窗监测"
  69. :isShowPagination="false"
  70. >
  71. <template #filterCell="{ column, record }">
  72. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : 'red'">{{
  73. record.warnFlag == 0 ? '正常' : '报警'
  74. }}</a-tag>
  75. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == 0 ? 'default' : 'green'">{{
  76. record.netStatus == 0 ? '断开' : '连接'
  77. }}</a-tag>
  78. <div v-if="record.nwindownum == 1 && column.dataIndex === 'rearArea'">/</div>
  79. </template>
  80. </MonitorTable>
  81. </a-tab-pane>
  82. <a-tab-pane key="2" tab="实时曲线图" force-render>
  83. <div class="tab-item" v-if="activeKey === '2' && isRefresh">
  84. <DeviceEcharts
  85. chartsColumnsType="window_chart"
  86. xAxisPropType="strname"
  87. :dataSource="dataSource"
  88. height="100%"
  89. :chartsColumns="chartsColumns"
  90. :device-list-api="baseList"
  91. device-type="window"
  92. />
  93. </div>
  94. </a-tab-pane>
  95. <a-tab-pane key="3" tab="历史数据">
  96. <div class="tab-item" v-if="activeKey === '3' && isRefresh">
  97. <HistoryTable columns-type="window" device-type="window" :device-list-api="baseList" designScope="window-history" :scroll="scroll"/>
  98. </div>
  99. </a-tab-pane>
  100. <a-tab-pane key="4" tab="报警历史">
  101. <div class="tab-item" v-if="activeKey === '4' && isRefresh">
  102. <AlarmHistoryTable columns-type="alarm" device-type="window" :device-list-api="baseList" designScope="alarm-history" :scroll="scroll"/>
  103. </div>
  104. </a-tab-pane>
  105. <a-tab-pane key="5" tab="操作历史">
  106. <div class="tab-item" v-if="activeKey === '5' && isRefresh">
  107. <HandlerHistoryTable columns-type="operatorhistory" device-type="fanlocal" :device-list-api="baseList" designScope="alarm-history" :scroll="scroll"/>
  108. </div>
  109. </a-tab-pane>
  110. </a-tabs>
  111. </div>
  112. </div>
  113. <div style="z-index: -1; position: absolute; top: 50px; right: 10px; width: 300px; height: 280px; margin: auto" class="palyer1">
  114. <LivePlayer id="fc-player1" ref="player1" :videoUrl="flvURL1()" muted live loading controls />
  115. <LivePlayer id="fc-player2" ref="player2" :videoUrl="flvURL1()" muted live loading controls style="margin-top: 10px" />
  116. </div>
  117. <HandleModal :modal-is-show="modalIsShow" :modal-title="modalTitle" :modal-type="modalType" @handle-ok="handleOK" @handle-cancel="handleCancel" />
  118. </template>
  119. <script setup lang="ts">
  120. import { message } from 'ant-design-vue';
  121. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  122. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, toRaw, watch, nextTick } from 'vue';
  123. import MonitorTable from '../comment/MonitorTable.vue';
  124. import HistoryTable from '../comment/HistoryTable.vue';
  125. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  126. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  127. import HandleModal from './modal.vue';
  128. import { mountedThree, destroy, addFmText, play, setModelType } from './window.threejs';
  129. import { list, getTableList } from './window.api';
  130. import { list as baseList } from '../../deviceManager/windWindowTabel/ventanalyWindow.api';
  131. import { chartsColumns } from './window.data';
  132. import { deviceControlApi } from '/@/api/vent/index';
  133. import lodash from 'lodash';
  134. import LivePlayer from '@liveqing/liveplayer-v3';
  135. import { setDivHeight } from '/@/utils/event';
  136. const player1 = ref(null);
  137. const player2 = ref(null);
  138. const isRefresh = ref(true)
  139. const scroll = reactive({
  140. y: 240
  141. })
  142. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  143. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  144. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  145. const deviceBaseList = ref([]);
  146. const activeKey = ref('1');
  147. const loading = ref(false);
  148. const windowAngle = ref(0);
  149. const rotationParam = {
  150. frontDeg0: 0, // 前门初始
  151. frontDeg1: windowAngle.value, // 前门目标
  152. backDeg0: 0, // 后门初始
  153. backDeg1: windowAngle.value, // 后门目标
  154. };
  155. // 默认初始是第一行
  156. const selectRowIndex = ref(0);
  157. const dataSource = ref([]);
  158. // webSocket 请求
  159. // const dataSource = computed(() => {
  160. // const data = [...getRecordList()] || [];
  161. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  162. // addFmText(selectData);
  163. // return data;
  164. // });
  165. const flvURL1 = () => {
  166. // return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  167. return ''
  168. };
  169. const flvURL2 = () => {
  170. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  171. };
  172. // 设备数据
  173. const controlType = ref(1);
  174. const tabChange = (activeKeyVal) => {
  175. activeKey.value = activeKeyVal;
  176. };
  177. const initData = {
  178. deviceID: '',
  179. deviceType: '',
  180. strname: '',
  181. dataDh: '-', //压差
  182. dataDtestq: '-', //测试风量
  183. sourcePressure: '-', //气源压力
  184. dataDequivalarea: '-',
  185. netStatus: '0', //通信状态
  186. fault: '气源压力超限',
  187. forntArea: '0',
  188. rearArea: '0',
  189. frontRearDifference: '-',
  190. rearPresentValue: '-',
  191. maxarea: '',
  192. nwindownum: 0
  193. };
  194. // 监测数据
  195. const selectData = reactive(lodash.cloneDeep(initData));
  196. // https获取监测数据
  197. let timer: null | NodeJS.Timeout = null;
  198. const getMonitor = () => {
  199. if (Object.prototype.toString.call(timer) === '[object Null]') {
  200. timer = setTimeout(async () => {
  201. const data = await getDataSource();
  202. Object.assign(selectData, data);
  203. playAnimation(selectData, selectData.maxarea);
  204. addFmText(selectData);
  205. if (timer) {
  206. timer = null;
  207. }
  208. getMonitor();
  209. }, 1000);
  210. }
  211. };
  212. const getDataSource = async () => {
  213. const res = await list({ devicetype: 'window', pagetype: 'normal' });
  214. dataSource.value = res.msgTxt[0].datalist || [];
  215. dataSource.value.forEach((data: any) => {
  216. const readData = data.readData;
  217. data = Object.assign(data, readData);
  218. });
  219. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  220. return data;
  221. };
  222. // 获取设备基本信息列表
  223. const getDeviceBaseList = () => {
  224. getTableList({ pageSize: 1000 }).then((res) => {
  225. deviceBaseList.value = res.records;
  226. });
  227. };
  228. // 切换检测数据
  229. const getSelectRow = (selectRow, index) => {
  230. if (!selectRow) return;
  231. selectRowIndex.value = index;
  232. loading.value = true;
  233. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  234. Object.assign(selectData, initData, selectRow, baseData);
  235. const type = selectData.nwindownum == 1 ? 'singleWindow' : 'doubleWindow';
  236. setModelType(type).then(() => {
  237. addFmText(selectData);
  238. playAnimation(selectRow, baseData.maxarea, true);
  239. loading.value = false;
  240. });
  241. };
  242. // 判断前后窗的面积是否发生改变,如果改变则开启动画
  243. const playAnimation = (data, maxarea = 90, isFirst = false) => {
  244. rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.forntArea);
  245. rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.rearArea);
  246. rotationParam.frontDeg1 = (90 / maxarea) * Number(data.forntArea) || 0;
  247. rotationParam.backDeg1 = (90 / maxarea) * Number(data.rearArea) || 0;
  248. if (isFirst) {
  249. console.log('最大面积---->', maxarea, '前窗实际面积---->', selectData.forntArea, '后窗实际面积---->', selectData.rearArea, '计算的值---->', rotationParam);
  250. }
  251. console.log('最大面积---->', maxarea, '前窗实际面积---->', selectData.forntArea, '后窗实际面积---->', selectData.rearArea, '计算的值---->', rotationParam);
  252. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  253. // 当返回值有误时默认关闭
  254. play(rotationParam, 0);
  255. } else {
  256. if (data.nwindownum == 1 || data.nwindownum == 2) {
  257. setTimeout(() => {
  258. play(rotationParam, 1);
  259. }, 0);
  260. }
  261. if (data.nwindownum == 2) {
  262. setTimeout(() => {
  263. play(rotationParam, 2);
  264. }, 0);
  265. }
  266. }
  267. };
  268. // 设置风窗面积
  269. const setArea = (flag) => {
  270. if(selectData.nwindownum == 2){
  271. modalTitle.value = flag === 1 ? '设定前窗面积' : '设定后窗面积';
  272. }else {
  273. modalTitle.value = '设定风窗面积'
  274. }
  275. modalType.value = flag+'';
  276. modalIsShow.value = true;
  277. };
  278. const handleOK = (passWord, handlerState, windowAngleNum) => {
  279. windowAngle.value = windowAngleNum;
  280. if (passWord !== '123456') {
  281. message.warning('密码不正确,请重新输入');
  282. return;
  283. }
  284. const data = {
  285. deviceid: selectData.deviceID,
  286. devicetype: selectData.deviceType,
  287. paramcode: handlerState == 1 ? 'frontSetValue' : 'rearSetValue',
  288. value: windowAngle.value,
  289. };
  290. deviceControlApi(data)
  291. .then(() => {
  292. message.success('设置成功')
  293. })
  294. .finally(() => {
  295. handleCancel();
  296. });
  297. };
  298. const handleCancel = () => {
  299. modalIsShow.value = false;
  300. modalTitle.value = '';
  301. modalType.value = '';
  302. };
  303. const addPlayVideo = () => {
  304. if (player1.value.play && player2.value.play) {
  305. if (!player1.value.paused()) player1.value.play();
  306. if (!player2.value.paused()) player2.value.play();
  307. document.body.removeEventListener('mousedown', addPlayVideo);
  308. }
  309. };
  310. watch(() => scroll.y, () => {
  311. isRefresh.value = false
  312. nextTick(() => {
  313. isRefresh.value = true
  314. })
  315. })
  316. onBeforeMount(() => {
  317. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'window', orgcode: '', ids: '', systemID: '' });
  318. // initWebSocket(sendVal);
  319. getDeviceBaseList();
  320. });
  321. onMounted(() => {
  322. loading.value = true;
  323. mountedThree(player1.value, player2.value).then(async () => {
  324. // await setModelType('singleWindow');
  325. loading.value = false;
  326. addFmText(selectData);
  327. getMonitor();
  328. });
  329. document.body.addEventListener('mousedown', addPlayVideo, false);
  330. });
  331. onUnmounted(() => {
  332. destroy();
  333. if (timer) {
  334. clearTimeout(timer);
  335. timer = undefined;
  336. }
  337. });
  338. </script>
  339. <style lang="less" scoped>
  340. @import '/@/design/vent/modal.less';
  341. @ventSpace: zxm;
  342. // :deep(.@{ventSpace}-tabs-tabpane-active) {
  343. // height: 100%;
  344. // }
  345. .input-box {
  346. display: flex;
  347. align-items: center;
  348. padding-left: 10px;
  349. .input-title {
  350. color: #73e8fe;
  351. width: auto;
  352. }
  353. .@{ventSpace}-input-number {
  354. border-color: #ffffff88 !important;
  355. }
  356. margin-right: 10px;
  357. }
  358. </style>