index.vue 18 KB

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