index.vue 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449
  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 class="row" v-if="hasPermission('window:control') && selectData.nwindownum > 1">
  26. <div class="button-box" @click="setArea(1)">设定前窗面积</div>
  27. <div class="button-box" @click="setArea(2)">设定后窗面积</div>
  28. </div>
  29. <div class="row" v-if="hasPermission('window:control') && selectData.nwindownum == 1">
  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, 350, scroll)">
  59. <dv-border-box8 :dur="5" :style="`padding: 5px; height: ${scroll.y + 120}px`">
  60. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  61. <a-tab-pane key="1" tab="实时监测">
  62. <MonitorTable
  63. v-if="activeKey === '1'"
  64. ref="MonitorDataTable"
  65. columnsType="window_monitor"
  66. :dataSource="dataSource"
  67. @selectRow="getSelectRow"
  68. design-scope="window-monitor"
  69. :scroll="{ y: scroll.y - 40 }"
  70. title="风窗监测"
  71. :isShowPagination="true"
  72. :isShowActionColumn="true"
  73. >
  74. <template #filterCell="{ column, record }">
  75. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == '0' ? 'green' : 'red'">{{
  76. record.warnFlag == '0' ? '正常' : '报警'
  77. }}</a-tag>
  78. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == '0' ? 'default' : 'green'">{{
  79. record.netStatus == '0' ? '断开' : '连接'
  80. }}</a-tag>
  81. <div v-if="record.nwindownum == 1 && column.dataIndex === 'rearArea'">/</div>
  82. </template>
  83. <template #action="{ record }">
  84. <a v-if="globalConfig?.showReport" class="table-action-link" @click="deviceEdit($event, 'reportInfo', record)">报表录入</a>
  85. <a class="table-action-link" @click="deviceEdit($event, 'deviceInfo', record)">设备编辑</a>
  86. </template>
  87. </MonitorTable>
  88. </a-tab-pane>
  89. <!-- <a-tab-pane key="2" tab="实时曲线图" force-render>
  90. <div class="tab-item" v-if="activeKey === '2'">
  91. <DeviceEcharts
  92. chartsColumnsType="window_chart"
  93. xAxisPropType="strname"
  94. :dataSource="dataSource"
  95. height="100%"
  96. :chartsColumns="chartsColumns"
  97. :device-list-api="baseList"
  98. device-type="window"
  99. />
  100. </div>
  101. </a-tab-pane> -->
  102. <a-tab-pane key="3" tab="历史数据">
  103. <div class="tab-item" v-if="activeKey === '3'">
  104. <HistoryTable columns-type="window" device-type="window" :device-list-api="baseList" designScope="window-history" :scroll="scroll" />
  105. </div>
  106. </a-tab-pane>
  107. <a-tab-pane key="4" tab="报警历史">
  108. <div class="tab-item" v-if="activeKey === '4'">
  109. <AlarmHistoryTable columns-type="alarm" device-type="window" :device-list-api="baseList" designScope="alarm-history" :scroll="scroll" />
  110. </div>
  111. </a-tab-pane>
  112. <a-tab-pane key="5" tab="操作历史">
  113. <div class="tab-item" v-if="activeKey === '5'">
  114. <HandlerHistoryTable
  115. columns-type="operator_history"
  116. device-type="window"
  117. :device-list-api="baseList"
  118. designScope="alarm-history"
  119. :scroll="scroll"
  120. />
  121. </div>
  122. </a-tab-pane>
  123. </a-tabs>
  124. </dv-border-box8>
  125. </div>
  126. </div>
  127. <div ref="playerRef" style="z-index: 999; position: absolute; top: 100px; right: 10px; width: 300px; height: 280px; margin: auto"></div>
  128. <LivePlayer
  129. id="fc-player1"
  130. style="height: 220px; width: 300px; position: absolute; top: 0px; z-index: -1"
  131. ref="player1"
  132. :videoUrl="flvURL1()"
  133. muted
  134. loading
  135. autoplay
  136. controls
  137. loop
  138. fluent
  139. />
  140. <HandleModal :modal-is-show="modalIsShow" :modal-title="modalTitle" :modal-type="modalType" @handle-ok="handleOK" @handle-cancel="handleCancel" />
  141. <DeviceBaseInfo @register="regModal" :device-type="selectData['deviceType']" />
  142. </template>
  143. <script setup lang="ts">
  144. import { message } from 'ant-design-vue';
  145. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  146. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, toRaw, watch, nextTick, inject } from 'vue';
  147. import MonitorTable from '../comment/MonitorTable.vue';
  148. import HistoryTable from '../comment/HistoryTable.vue';
  149. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  150. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  151. import HandleModal from './modal.vue';
  152. import DeviceBaseInfo from '../comment/components/DeviceBaseInfo.vue';
  153. import { mountedThree, destroy, addMonitorText, play, setModelType, initCameraCanvas } from './window.threejs';
  154. import { list, getTableList, cameraList, cameraAddrList } from './window.api';
  155. import { list as baseList } from '../../deviceManager/windWindowTabel/ventanalyWindow.api';
  156. import { chartsColumns } from './window.data';
  157. import { deviceControlApi } from '/@/api/vent/index';
  158. import lodash from 'lodash';
  159. import { setDivHeight } from '/@/utils/event';
  160. import { BorderBox8 as DvBorderBox8 } from '@kjgl77/datav-vue3';
  161. import { useRouter } from 'vue-router';
  162. import LivePlayer from '@liveqing/liveplayer-v3';
  163. import { useModal } from '/@/components/Modal';
  164. import { useCamera } from '/@/hooks/system/useCamera';
  165. import { usePermission } from '/@/hooks/web/usePermission';
  166. const { hasPermission } = usePermission();
  167. const globalConfig = inject('globalConfig');
  168. const { currentRoute } = useRouter();
  169. const MonitorDataTable = ref();
  170. const playerRef = ref();
  171. const scroll = reactive({
  172. y: 230,
  173. });
  174. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  175. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  176. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  177. const deviceBaseList = ref([]);
  178. const activeKey = ref('1');
  179. const loading = ref(false);
  180. const windowAngle = ref(0);
  181. const rotationParam = {
  182. frontDeg0: 0, // 前门初始
  183. frontDeg1: windowAngle.value, // 前门目标
  184. backDeg0: 0, // 后门初始
  185. backDeg1: windowAngle.value, // 后门目标
  186. };
  187. // 默认初始是第一行
  188. const selectRowIndex = ref(-1);
  189. const dataSource = ref([]);
  190. // 设备数据
  191. const controlType = ref(1);
  192. const flvURL1 = () => {
  193. return `/video/window.mp4`;
  194. };
  195. const [regModal, { openModal }] = useModal();
  196. const { getCamera, removeCamera } = useCamera();
  197. const tabChange = (activeKeyVal) => {
  198. activeKey.value = activeKeyVal;
  199. if (activeKeyVal == 1) {
  200. nextTick(() => {
  201. MonitorDataTable.value.setSelectedRowKeys([selectData.deviceID]);
  202. });
  203. }
  204. };
  205. const initData = {
  206. deviceID: '',
  207. deviceType: '',
  208. strname: '',
  209. dataDh: '-', //压差
  210. dataDtestq: '-', //测试风量
  211. sourcePressure: '-', //气源压力
  212. dataDequivalarea: '-',
  213. netStatus: '0', //通信状态
  214. fault: '气源压力超限',
  215. forntArea: '0',
  216. rearArea: '0',
  217. frontRearDifference: '-',
  218. rearPresentValue: '-',
  219. maxarea: 0,
  220. nwindownum: 0,
  221. };
  222. // 监测数据
  223. const selectData = reactive(lodash.cloneDeep(initData));
  224. // https获取监测数据
  225. let timer: null | NodeJS.Timeout = null;
  226. const getMonitor = (flag?) => {
  227. if (Object.prototype.toString.call(timer) === '[object Null]') {
  228. timer = setTimeout(
  229. async () => {
  230. const data = await getDataSource();
  231. Object.assign(selectData, data);
  232. playAnimation(selectData, selectData.maxarea);
  233. addMonitorText(selectData);
  234. if (timer) {
  235. timer = null;
  236. }
  237. getMonitor();
  238. },
  239. flag ? 0 : 2000
  240. );
  241. }
  242. };
  243. const getDataSource = async () => {
  244. const res = await list({ devicetype: 'window', pagetype: 'normal' });
  245. dataSource.value = res.msgTxt[0].datalist || [];
  246. dataSource.value.forEach((data: any) => {
  247. const readData = data.readData;
  248. data = Object.assign(data, readData);
  249. });
  250. if (dataSource.value.length > 0 && selectRowIndex.value == -1) {
  251. // 初始打开页面
  252. if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  253. MonitorDataTable.value.setSelectedRowKeys([currentRoute.value['query']['id']]);
  254. } else {
  255. MonitorDataTable.value.setSelectedRowKeys([dataSource.value[0]['deviceID']]);
  256. }
  257. }
  258. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  259. return data;
  260. };
  261. // 获取设备基本信息列表
  262. const getDeviceBaseList = () => {
  263. getTableList({ pageSize: 1000 }).then((res) => {
  264. deviceBaseList.value = res.records;
  265. });
  266. };
  267. // 切换检测数据
  268. const getSelectRow = async (selectRow, index) => {
  269. if (!selectRow) return;
  270. selectRowIndex.value = index;
  271. loading.value = true;
  272. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  273. Object.assign(selectData, initData, selectRow, baseData);
  274. const type = selectData.nwindownum == 1 ? 'singleWindow' : 'doubleWindow';
  275. setModelType(type).then(() => {
  276. addMonitorText(selectData);
  277. playAnimation(selectRow, selectData.maxarea, true);
  278. loading.value = false;
  279. });
  280. await getCamera(selectRow.deviceID, playerRef.value);
  281. };
  282. // 判断前后窗的面积是否发生改变,如果改变则开启动画
  283. const playAnimation = (data, maxarea = 90, isFirst = false) => {
  284. rotationParam.frontDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.forntArea);
  285. rotationParam.backDeg0 = (90 / maxarea) * Number(isFirst ? 0 : selectData.rearArea);
  286. rotationParam.frontDeg1 = (90 / maxarea) * Number(data.forntArea) || 0;
  287. rotationParam.backDeg1 = (90 / maxarea) * Number(data.rearArea) || 0;
  288. if (isFirst) {
  289. console.log(
  290. '最大面积---->',
  291. maxarea,
  292. '前窗实际面积---->',
  293. selectData.forntArea,
  294. '后窗实际面积---->',
  295. selectData.rearArea,
  296. '计算的值---->',
  297. rotationParam
  298. );
  299. }
  300. console.log(
  301. '最大面积---->',
  302. maxarea,
  303. '前窗实际面积---->',
  304. selectData.forntArea,
  305. '后窗实际面积---->',
  306. selectData.rearArea,
  307. '计算的值---->',
  308. rotationParam
  309. );
  310. if (!rotationParam.frontDeg1 && !rotationParam.backDeg1) {
  311. // 当返回值有误时默认关闭
  312. play(rotationParam, 0);
  313. } else {
  314. if (data.nwindownum == 1 || data.nwindownum == 2) {
  315. setTimeout(() => {
  316. play(rotationParam, 1);
  317. }, 0);
  318. }
  319. if (data.nwindownum == 2) {
  320. setTimeout(() => {
  321. play(rotationParam, 2);
  322. }, 0);
  323. }
  324. }
  325. };
  326. // 设置风窗面积
  327. const setArea = (flag) => {
  328. if (selectData.nwindownum == 2) {
  329. modalTitle.value = flag === 1 ? '设定前窗面积' : '设定后窗面积';
  330. } else {
  331. modalTitle.value = '设定风窗面积';
  332. }
  333. modalType.value = flag + '';
  334. modalIsShow.value = true;
  335. };
  336. const handleOK = (passWord, handlerState, windowAngleNum) => {
  337. windowAngle.value = windowAngleNum;
  338. // if (passWord !== '123456') {
  339. // message.warning('密码不正确,请重新输入');
  340. // return;
  341. // }
  342. const data = {
  343. deviceid: selectData.deviceID,
  344. devicetype: selectData.deviceType,
  345. paramcode: handlerState == 1 ? 'frontSetValue' : 'rearSetValue',
  346. password: passWord || globalConfig?.simulatedPassword,
  347. value: windowAngle.value,
  348. };
  349. deviceControlApi(data)
  350. .then(() => {
  351. if (globalConfig.History_Type == 'remote') {
  352. message.success('指令已下发至生产管控平台成功!');
  353. } else {
  354. message.success('指令已下发成功!');
  355. }
  356. })
  357. .finally(() => {
  358. handleCancel();
  359. });
  360. };
  361. const handleCancel = () => {
  362. modalIsShow.value = false;
  363. modalTitle.value = '';
  364. modalType.value = '';
  365. };
  366. function deviceEdit(e: Event, type: string, record) {
  367. e.stopPropagation();
  368. openModal(true, {
  369. type,
  370. deviceId: record['deviceID'],
  371. });
  372. }
  373. onBeforeMount(() => {
  374. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'window', orgcode: '', ids: '', systemID: '' });
  375. // initWebSocket(sendVal);
  376. getDeviceBaseList();
  377. });
  378. onMounted(() => {
  379. loading.value = true;
  380. const playerDom = document.getElementById('fc-player1')?.getElementsByClassName('vjs-tech')[0];
  381. mountedThree(playerDom).then(async () => {
  382. // await setModelType('singleWindow');
  383. getMonitor(true);
  384. loading.value = false;
  385. addMonitorText(selectData);
  386. });
  387. });
  388. onUnmounted(() => {
  389. destroy();
  390. removeCamera();
  391. if (timer) {
  392. clearTimeout(timer);
  393. timer = undefined;
  394. }
  395. });
  396. </script>
  397. <style lang="less" scoped>
  398. @import '/@/design/vent/modal.less';
  399. @ventSpace: zxm;
  400. // :deep(.@{ventSpace}-tabs-tabpane-active) {
  401. // height: 100%;
  402. // }
  403. .input-box {
  404. display: flex;
  405. align-items: center;
  406. padding-left: 10px;
  407. .input-title {
  408. color: #73e8fe;
  409. width: auto;
  410. }
  411. .@{ventSpace}-input-number {
  412. border-color: #ffffff88 !important;
  413. }
  414. margin-right: 10px;
  415. }
  416. .scene-box {
  417. .bottom-tabs-box {
  418. height: 350px;
  419. }
  420. }
  421. </style>