index.vue 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677
  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="deviceDetail" class="device-detail">
  6. <div id="deviceCard" class="device-card" style="z-index: -1; position: absolute">
  7. <div class="title">KJ-980-F矿用本安型监控分站</div>
  8. <div class="detail-box">
  9. <div class="left-box"></div>
  10. <div class="right-box">
  11. <div><span class="detail-title">规格型号:</span> <span>KJ-980-F</span></div>
  12. <div><span class="detail-title">技术参数:</span>
  13. <span>380V,电机功率22kW,50Hz,B级绝缘,额定电流42.2A,效率90.5%,能效等级3,接法角型,2940r/min,轴承6311/CM 6211/CM,功率因数0.89</span>
  14. </div>
  15. </div>
  16. </div>
  17. </div>
  18. </div>
  19. <div id="damper3D" style="width: 100%; height: 100%; position: absolute; overflow: hidden"></div>
  20. </div>
  21. <div class="scene-box">
  22. <div class="top-box">
  23. <div class="top-center row">
  24. <!-- <div class="button-box" :class="{ 'button-disable': backDoorIsOpen }" @click="playAnimation(1)">打开前门</div>
  25. <div class="button-box" :class="{ 'button-disable': backDoorIsOpen }" @click="playAnimation(2)">关闭前门</div>
  26. <div class="button-box" :class="{ 'button-disable': frontDoorIsOpen }" @click="playAnimation(3)">打开后门</div>
  27. <div class="button-box" :class="{ 'button-disable': frontDoorIsOpen }" @click="playAnimation(4)">关闭后门</div>
  28. <div class="button-box" :class="{ 'button-disable': frontDoorIsOpen || backDoorIsOpen }" @click="playAnimation(5)">打开前后门</div> -->
  29. <!-- <div
  30. class="button-box"
  31. :class="{ 'button-disable': (frontDoorIsOpen && !backDoorIsOpen) || (backDoorIsOpen && !frontDoorIsOpen) }"
  32. @click="playAnimation(6)"
  33. >关闭前后门</div> -->
  34. <div class="button-box" @click="playAnimation(1)">打开前门</div>
  35. <div class="button-box" @click="playAnimation(2)">关闭前门</div>
  36. <div class="button-box" @click="playAnimation(3)">打开后门</div>
  37. <div class="button-box" @click="playAnimation(4)">关闭后门</div>
  38. <div class="button-box" @click="playAnimation(5)">打开前后门</div>
  39. <div class="button-box" @click="playAnimation(6)">关闭前后门</div>
  40. <!-- <div class="button-box" @click="enterMY">漫游</div> -->
  41. </div>
  42. <div class="top-right row">
  43. <div class="control-type row">
  44. <div class="control-title">控制模式:</div>
  45. <a-radio-group v-model:value="selectData.autoRoManual" @change="changeType">
  46. <a-radio :value="`0`">就地</a-radio>
  47. <a-radio :value="`1`">远程</a-radio>
  48. </a-radio-group>
  49. </div>
  50. <div class="run-type row">
  51. <div class="control-title">运行状态:</div>
  52. <a-radio-group v-model:value="selectData.runRoRecondition">
  53. <a-radio :value="`0`">检修</a-radio>
  54. <a-radio :value="`1`">运行</a-radio>
  55. </a-radio-group>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="title-text">
  60. {{ selectData.strname }}
  61. </div>
  62. <div class="bottom-tabs-box" @mousedown="setDivHeight($event, 250, scroll)">
  63. <dv-border-box8 :dur="5" :style="`padding: 5px; height: ${scroll.y + 100}px`">
  64. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  65. <a-tab-pane key="1" tab="实时监测">
  66. <MonitorTable v-if="activeKey === '1'" ref="MonitorDataTable" class="monitor-table" columnsType="gate_monitor"
  67. :dataSource="dataSource" design-scope="gate-monitor" @selectRow="getSelectRow" :scroll="scroll" title="风门监测"
  68. :isShowPagination="false">
  69. <template #filterCell="{ column, record }">
  70. <template v-if="record.frontGateOpenCtrl == 1 || record.frontGateOpenCtrl === true">
  71. <a-tag
  72. v-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 0"
  73. color="red">正在打开</a-tag>
  74. <a-tag v-else-if="column.dataIndex === 'frontGateOpen'" color="processing">打开</a-tag>
  75. </template>
  76. <template v-else-if="record.frontGateOpenCtrl == 0 || record.frontGateOpenCtrl === false">
  77. <a-tag
  78. v-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 0"
  79. color="red">正在关闭</a-tag>
  80. <a-tag
  81. v-else-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 0 && record.frontGateClose == 1"
  82. color="default">关闭</a-tag>
  83. <a-tag
  84. v-else-if="column.dataIndex === 'frontGateOpen' && record.frontGateOpen == 1 && record.frontGateClose == 0"
  85. color="default">打开</a-tag>
  86. </template>
  87. <template v-if="record.rearGateOpenCtrl == 1 || record.rearGateOpenCtrl === true">
  88. <a-tag
  89. v-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 0"
  90. color="red">正在打开</a-tag>
  91. <a-tag v-else-if="column.dataIndex === 'rearGateOpen'" color="processing">打开</a-tag>
  92. </template>
  93. <template v-else-if="record.rearGateOpenCtrl == 0 || record.rearGateOpenCtrl === false">
  94. <a-tag
  95. v-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 0"
  96. color="red">正在关闭</a-tag>
  97. <a-tag
  98. v-else-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 0 && record.rearGateClose == 1"
  99. color="default">关闭</a-tag>
  100. <a-tag
  101. v-else-if="column.dataIndex === 'rearGateOpen' && record.rearGateOpen == 1 && record.rearGateClose == 0"
  102. color="default">打开</a-tag>
  103. </template>
  104. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == 0 ? 'green' : 'red'">{{
  105. record.warnFlag == 0 ? '正常' : '报警'
  106. }}</a-tag>
  107. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == 0 ? 'default' : 'green'">{{
  108. record.netStatus == 0 ? '断开' : '连接'
  109. }}</a-tag>
  110. </template>
  111. </MonitorTable>
  112. </a-tab-pane>
  113. <a-tab-pane key="2" tab="实时曲线图" force-render>
  114. <div class="tab-item" v-if="activeKey === '2'">
  115. <DeviceEcharts chartsColumnsType="gate_chart" xAxisPropType="strname" :dataSource="dataSource" height="100%"
  116. :chartsColumns="chartsColumns" :device-list-api="list" device-type="gate" />
  117. </div>
  118. </a-tab-pane>
  119. <a-tab-pane key="3" tab="历史数据">
  120. <div class="tab-item" v-if="activeKey === '3'">
  121. <HistoryTable columns-type="gate" device-type="gate" :device-list-api="getTableList"
  122. designScope="gate-history" :scroll="scroll" />
  123. </div>
  124. </a-tab-pane>
  125. <a-tab-pane key="4" tab="报警历史">
  126. <div class="tab-item" v-if="activeKey === '4'">
  127. <AlarmHistoryTable columns-type="alarm" device-type="gate" :device-list-api="getTableList"
  128. designScope="alarm-history" :scroll="scroll" />
  129. </div>
  130. </a-tab-pane>
  131. <a-tab-pane key="5" tab="操作历史">
  132. <div class="tab-item" v-if="activeKey === '5'">
  133. <HandlerHistoryTable columns-type="operatorhistory" device-type="gate" :device-list-api="getTableList"
  134. designScope="alarm-history" :scroll="scroll" />
  135. </div>
  136. </a-tab-pane>
  137. </a-tabs>
  138. </dv-border-box8>
  139. </div>
  140. </div>
  141. <div ref="playerRef" style="z-index: -1; position: absolute; top: 50px; right: 10px; width: 300px; height: 280px; margin: auto">
  142. <!-- <div id="fmPlayer1">
  143. <video controls></video>
  144. </div>
  145. <div id="fmPlayer2">
  146. <video controls muted autoplay></video>
  147. </div> -->
  148. <!-- <template v-if="flvURL1.startsWith('rtsp://')">
  149. <video id="fmPlayer1" muted autoplay width="400" height="400" style="border: 1px solid #fff;"></video>
  150. </template>
  151. <template v-else>
  152. <LivePlayer v-if="flvURL1" id="fmPlayer1" ref="player1" :videoUrl="flvURL1" muted live loading controls />
  153. </template>
  154. <template v-if="flvURL2.startsWith('rtsp://')">
  155. <video id="fmPlayer2" muted autoplay width="400" height="400" style="border: 1px solid #fff;"></video>
  156. </template>
  157. <template v-else>
  158. <LivePlayer v-if="flvURL2" id="fmPlayer2" ref="player2" :videoUrl="flvURL2" muted live loading controls style="margin-top: 10px" />
  159. </template> -->
  160. </div>
  161. <!-- <a-modal v-model:visible="modalIsShow" :title="modalTitle" @ok="handleOk">
  162. <div class="modal-container">
  163. <div class="vent-flex-row">
  164. <ExclamationCircleFilled style="color: #ffb700; font-size: 30px" />
  165. <div class="warning-text">您是否要进行{{ modalTitle }}操作?</div>
  166. </div>
  167. </div>
  168. </a-modal> -->
  169. <HandleModal :modal-is-show="modalIsShow" :modal-title="modalTitle" :modal-type="modalType" @handle-ok="handleOK"
  170. @handle-cancel="handleCancel" />
  171. </template>
  172. <script setup lang="ts">
  173. import LivePlayer from '@liveqing/liveplayer-v3';
  174. import { onBeforeUnmount, onUnmounted, onMounted, ref, reactive, nextTick, h, render } from 'vue';
  175. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  176. import MonitorTable from '../comment/MonitorTable.vue';
  177. import HistoryTable from '../comment/HistoryTable.vue';
  178. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  179. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  180. import HandleModal from './modal.vue';
  181. import { mountedThree, addMonitorText, play, destroy, setModelType, initCameraCanvas } from './gate.threejs';
  182. import { deviceControlApi } from '/@/api/vent/index';
  183. import { message } from 'ant-design-vue';
  184. import { list, getTableList, cameraList, cameraAddrList } from './gate.api';
  185. import { chartsColumns, echartsOption, echartsOption1 } from './gate.data';
  186. import lodash from 'lodash';
  187. import { setDivHeight } from '/@/utils/event';
  188. import { BorderBox8 as DvBorderBox8 } from '@kjgl77/datav-vue3';
  189. import { useRouter } from 'vue-router';
  190. import { deviceCameraInit } from '/@/utils/ventutil.ts'
  191. const { currentRoute } = useRouter();
  192. const MonitorDataTable = ref()
  193. const playerRef = ref();
  194. const activeKey = ref('1'); // tab
  195. const loading = ref(false);
  196. const scroll = reactive({
  197. y: 240
  198. })
  199. const frontDoorIsOpen = ref(false); //前门是否开启
  200. const backDoorIsOpen = ref(false); //后门是否开启
  201. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  202. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  203. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  204. const selectRowIndex = ref(-1); // 选中行
  205. const dataSource = ref([]);
  206. const deviceBaseList = ref([]); // 设备基本信息
  207. let webRtcServer: any[] = []
  208. const tabChange = (activeKeyVal) => {
  209. activeKey.value = activeKeyVal;
  210. if (activeKeyVal == 1) {
  211. nextTick(() => {
  212. MonitorDataTable.value.setSelectedRowKeys([selectData.deviceID])
  213. })
  214. }
  215. };
  216. const initData = {
  217. deviceID: '',
  218. deviceType: '',
  219. strname: '',
  220. frontRearDP: '-', //压差
  221. sourcePressure: '-', //气源压力
  222. runRoRecondition: null,
  223. autoRoManual: null,
  224. netStatus: '0', //通信状态
  225. frontGateOpen: '0',
  226. frontGateClose: '1',
  227. rearGateOpen: '0',
  228. rearGateClose: '1',
  229. fault: '气源压力超限',
  230. masterComputer: 0,
  231. frontGateOpenCtrl: false,
  232. rearGateOpenCtrl: false,
  233. cameras: []
  234. };
  235. // 监测数据
  236. const selectData = reactive(lodash.cloneDeep(initData));
  237. const flvURL1 = ref('')
  238. const flvURL2 = ref('')
  239. // 获取设备基本信息列表
  240. function getDeviceBaseList() {
  241. getTableList({ pageSize: 1000 }).then((res) => {
  242. deviceBaseList.value = res.records;
  243. });
  244. };
  245. // https获取监测数据
  246. let timer: null | NodeJS.Timeout = null;
  247. async function getMonitor(flag?) {
  248. if (Object.prototype.toString.call(timer) === '[object Null]') {
  249. timer = await setTimeout(async () => {
  250. const res = await list({ devicetype: 'gate', pagetype: 'normal' })
  251. if (res.msgTxt && res.msgTxt[0]) {
  252. dataSource.value = res.msgTxt[0].datalist || [];
  253. dataSource.value.forEach((data: any) => {
  254. const readData = data.readData;
  255. data = Object.assign(data, readData);
  256. });
  257. if (dataSource.value.length > 0 && selectRowIndex.value == -1) {
  258. // 初始打开页面
  259. if (currentRoute.value['query'] && currentRoute.value['query']['id']) {
  260. MonitorDataTable.value.setSelectedRowKeys([currentRoute.value['query']['id']])
  261. } else {
  262. MonitorDataTable.value.setSelectedRowKeys([dataSource.value[0]['deviceID']])
  263. }
  264. }
  265. Object.assign(selectData, dataSource.value[selectRowIndex.value]);
  266. addMonitorText(selectData);
  267. monitorAnimation(selectData)
  268. if (timer) {
  269. timer = null;
  270. }
  271. getMonitor();
  272. }
  273. }, flag ? 0 : 1000);
  274. }
  275. };
  276. async function getCamera() {
  277. const res = await cameraList({ deviceid: selectData['deviceID'] })
  278. const cameras: [] = res.records || []
  279. let playerDom1, playerDom2, cameraAddrs:string[] = [], cameraNames:string[] = [];
  280. if (cameras.length > 0){
  281. cameras.forEach(item => {
  282. if (item['devicekind'] == 'toRtsp' || item['devicekind'] == 'toHLS') {
  283. cameraNames.push(item['name'])
  284. } else {
  285. cameraAddrs.push(item['addr'])
  286. }
  287. })
  288. }
  289. if (cameraNames.length > 0) {
  290. // 请求接口从装备院拿数据
  291. const addrs: string[] = await cameraAddrList({ cameraNameList: cameraNames })
  292. cameraAddrs.push(...addrs)
  293. }
  294. const obj = await deviceCameraInit(cameraAddrs, playerRef.value, webRtcServer)
  295. webRtcServer = obj.webRtcServer
  296. const playerDoms = obj.playerDoms
  297. await initCameraCanvas(...playerDoms)
  298. }
  299. // 切换检测数据
  300. async function getSelectRow(selectRow, index) {
  301. if (!selectRow) return;
  302. loading.value = true;
  303. selectRowIndex.value = index;
  304. const baseData: any = deviceBaseList.value.find((baseData: any) => baseData.id === selectRow.deviceID);
  305. Object.assign(selectData, initData, selectRow, baseData);
  306. isFrontOpenRunning = false //开关门动作是否在进行
  307. isFrontCloseRunning = false //开关门动作是否在进行
  308. isRearOpenRunning = false //开关门动作是否在进行
  309. isRearCloseRunning = false //开关门动作是否在进行
  310. frontDeviceState = 0 //记录设备状态,为了与下一次监测数据做比较
  311. rearDeviceState = 0 //记录设备状态,为了与下一次监测数据做比较
  312. // const type = selectData.nwindownum == 1 ? 'singleWindow' : 'doubleWindow';
  313. let type;
  314. if (selectData.deviceType == 'gate_ss') {
  315. type = 'fm2'
  316. } else {
  317. type = 'fm1'
  318. }
  319. setModelType(type).then(async() => {
  320. addMonitorText(selectData);
  321. loading.value = false;
  322. });
  323. await getCamera()
  324. };
  325. // 播放动画
  326. function playAnimation(handlerState) {
  327. switch (handlerState) {
  328. case 1: // 打开前门
  329. if (selectData.frontGateOpen == '0' && selectData.frontGateClose == '1') {
  330. modalTitle.value = '打开前门';
  331. modalType.value = '1';
  332. modalIsShow.value = true;
  333. } else {
  334. message.warning('前门已经打开或正在打开,请勿重新操作')
  335. }
  336. break;
  337. case 2: // 关闭前门
  338. if (selectData.frontGateOpen == '1' && selectData.frontGateClose == '0') {
  339. modalTitle.value = '关闭前门';
  340. modalType.value = '2';
  341. modalIsShow.value = true;
  342. } else {
  343. message.warning('前门已经关闭或正在关闭,请勿重新操作')
  344. }
  345. break;
  346. case 3: // 打开后门
  347. if (selectData.rearGateOpen == '0' && selectData.rearGateClose == '1') {
  348. modalTitle.value = '打开后门';
  349. modalType.value = '3';
  350. modalIsShow.value = true;
  351. } else {
  352. message.warning('后门已经打开或正在打开,请勿重新操作')
  353. }
  354. break;
  355. case 4: // 关闭后门
  356. if (selectData.rearGateOpen == '1' && selectData.rearGateClose == '0') {
  357. modalTitle.value = '关闭后门';
  358. modalType.value = '4';
  359. modalIsShow.value = true;
  360. } else {
  361. message.warning('后门已经关闭或正在关闭,请勿重新操作')
  362. }
  363. break;
  364. case 5: // 打开前后门
  365. if (selectData.frontGateOpen == '0' && selectData.frontGateClose == '1' && selectData.rearGateOpen == '0' && selectData.rearGateClose == '1') {
  366. modalTitle.value = '打开前后门';
  367. modalType.value = '5';
  368. modalIsShow.value = true;
  369. } else {
  370. message.warning('前后门已经打开或正在打开,请勿重新操作')
  371. }
  372. break;
  373. case 6: // 关闭前后门
  374. if (selectData.frontGateOpen == '1' && selectData.frontGateClose == '0' && selectData.rearGateOpen == '1' && selectData.rearGateClose == '0') {
  375. modalTitle.value = '关闭前后门';
  376. modalType.value = '6';
  377. modalIsShow.value = true;
  378. } else {
  379. message.warning('前后门已经关闭或正在关闭,请勿重新操作')
  380. }
  381. break;
  382. }
  383. };
  384. function handleOK(passWord, handlerState) {
  385. if (passWord !== '123456') {
  386. message.warning('密码不正确,请重新输入');
  387. return;
  388. }
  389. if ((isFrontOpenRunning || isFrontCloseRunning) && (handlerState == 2 || handlerState == 1 || handlerState == 5 || handlerState == 6)) {
  390. return
  391. }
  392. if ((isRearOpenRunning || isRearCloseRunning) && (handlerState == 3 || handlerState == 4 || handlerState == 5 || handlerState == 6)) {
  393. return
  394. }
  395. const data = {
  396. deviceid: selectData.deviceID,
  397. devicetype: selectData.deviceType,
  398. paramcode: '',
  399. value: null,
  400. masterComputer: selectData.masterComputer,
  401. };
  402. let handler = () => { };
  403. switch (handlerState) {
  404. case '1': // 打开前门
  405. if (selectData.frontGateOpen == '0' && selectData.frontGateClose == '1') {
  406. handler = () => {
  407. frontDoorIsOpen.value = true;
  408. };
  409. data.paramcode = 'frontGateOpen_S';
  410. }
  411. break;
  412. case '2': // 关闭前门
  413. if (selectData.frontGateOpen == '1' && selectData.frontGateClose == '0') {
  414. handler = () => {
  415. frontDoorIsOpen.value = false;
  416. };
  417. data.paramcode = 'frontGateClose_S';
  418. }
  419. break;
  420. case '3': // 打开后门
  421. if (selectData.rearGateOpen == '0' && selectData.rearGateClose == '1') {
  422. handler = () => {
  423. backDoorIsOpen.value = true;
  424. };
  425. data.paramcode = 'rearGateOpen_S';
  426. }
  427. break;
  428. case '4': // 关闭后门
  429. if (selectData.rearGateOpen == '1' && selectData.rearGateClose == '0') {
  430. handler = () => {
  431. backDoorIsOpen.value = false;
  432. };
  433. data.paramcode = 'rearGateClose_S';
  434. }
  435. break;
  436. case '5': // 打开前后门
  437. if (selectData.frontGateOpen == '0' && selectData.frontGateClose == '1' && selectData.rearGateOpen == '0' && selectData.rearGateClose == '1') {
  438. handler = () => {
  439. frontDoorIsOpen.value = true;
  440. backDoorIsOpen.value = true;
  441. };
  442. data.paramcode = 'sameTimeOpen';
  443. }
  444. break;
  445. case '6': // 关闭前后门
  446. if (selectData.frontGateOpen == '1' && selectData.frontGateClose == '0' && selectData.rearGateOpen == '1' && selectData.rearGateClose == '0') {
  447. handler = () => {
  448. frontDoorIsOpen.value = false;
  449. backDoorIsOpen.value = false;
  450. };
  451. data.paramcode = 'sameTimeClose';
  452. }
  453. break;
  454. }
  455. if (data.paramcode) {
  456. deviceControlApi(data)
  457. .then((res) => {
  458. // 模拟时开启
  459. if (res.success) {
  460. modalIsShow.value = false;
  461. message.success('操作成功!')
  462. }
  463. })
  464. }
  465. };
  466. /** 开关门动画调用 */
  467. let isFrontOpenRunning = false //开关门动作是否在进行
  468. let isFrontCloseRunning = false //开关门动作是否在进行
  469. let isRearOpenRunning = false //开关门动作是否在进行
  470. let isRearCloseRunning = false //开关门动作是否在进行
  471. let frontDeviceState = 0 //记录设备状态,为了与下一次监测数据做比较
  472. let rearDeviceState = 0 //记录设备状态,为了与下一次监测数据做比较
  473. function monitorAnimation(selectData) {
  474. const timeScale = 0.003
  475. if (selectData.frontGateOpenCtrl == 1 || selectData.frontGateOpenCtrl === true) {
  476. isFrontCloseRunning = false
  477. if (selectData.frontGateOpen == 0 && selectData.frontGateClose == 0) {
  478. //打开前门1
  479. if (!isFrontOpenRunning) {
  480. frontDoorIsOpen.value = true
  481. backDoorIsOpen.value = true
  482. isFrontOpenRunning = true
  483. play(1, timeScale)
  484. frontDeviceState = 1
  485. }
  486. }
  487. if (selectData.frontGateOpen == 1 && selectData.frontGateClose == 0) {
  488. isFrontOpenRunning = false
  489. if (frontDeviceState != 1) {
  490. import.meta.env.VITE_GLOB_IS_SIMULATE ? play(1, timeScale) : play(1)
  491. frontDeviceState = 1
  492. frontDoorIsOpen.value = false
  493. backDoorIsOpen.value = true
  494. }
  495. }
  496. } else {
  497. if (selectData.frontGateOpen == 0 && selectData.frontGateClose == 0) {
  498. //关闭前门
  499. isFrontOpenRunning = false
  500. if (!isFrontCloseRunning) {
  501. isFrontCloseRunning = true
  502. play(2, timeScale)
  503. frontDeviceState = 2
  504. frontDoorIsOpen.value = true
  505. backDoorIsOpen.value = true
  506. }
  507. }
  508. if (selectData.frontGateClose == 1 && selectData.frontGateOpen == 0) {
  509. isFrontCloseRunning = false
  510. if (frontDeviceState == 1) {
  511. import.meta.env.VITE_GLOB_IS_SIMULATE ? play(2, timeScale) : play(2)
  512. frontDeviceState = 2
  513. frontDoorIsOpen.value = false
  514. // backDoorIsOpen.value = false
  515. }
  516. }
  517. }
  518. if (selectData.rearGateOpenCtrl == 1 || selectData.rearGateOpenCtrl === true) {
  519. isRearCloseRunning = false
  520. if (selectData.rearGateOpen == 0 && selectData.rearGateClose == 0) {
  521. //打开后门
  522. if (!isRearOpenRunning) {
  523. isRearOpenRunning = true
  524. play(3, timeScale)
  525. rearDeviceState = 3
  526. frontDoorIsOpen.value = true
  527. backDoorIsOpen.value = true
  528. }
  529. }
  530. if (selectData.rearGateOpen == 1 && selectData.rearGateClose == 0) {
  531. isRearOpenRunning = false
  532. if (rearDeviceState != 3) {
  533. rearDeviceState = 3
  534. import.meta.env.VITE_GLOB_IS_SIMULATE ? play(3, timeScale) : play(3)
  535. backDoorIsOpen.value = false
  536. frontDoorIsOpen.value = true
  537. }
  538. }
  539. } else {
  540. if (selectData.rearGateOpen == 0 && selectData.rearGateClose == 0) {
  541. //关闭后门
  542. isRearOpenRunning = false
  543. if (!isRearCloseRunning) {
  544. isRearCloseRunning = true
  545. play(4, timeScale)
  546. rearDeviceState = 4
  547. frontDoorIsOpen.value = true
  548. backDoorIsOpen.value = true
  549. }
  550. }
  551. if (selectData.rearGateClose == 1 && selectData.rearGateOpen == 0) {
  552. isRearCloseRunning = false
  553. if (rearDeviceState == 3) {
  554. rearDeviceState = 4
  555. import.meta.env.VITE_GLOB_IS_SIMULATE ? play(4, timeScale) : play(4)
  556. backDoorIsOpen.value = false
  557. }
  558. }
  559. }
  560. console.log('frontGateOpen:', selectData.frontGateOpen, ' frontGateClose:', selectData.frontGateClose, ' rearGateOpen:', selectData.rearGateOpen, ' rearGateClose:', selectData.rearGateClose, ' frontGateOpenCtrl:', selectData.frontGateOpenCtrl, ' rearGateOpenCtrl:', selectData.rearGateOpenCtrl)
  561. }
  562. function handleCancel() {
  563. modalIsShow.value = false;
  564. modalTitle.value = '';
  565. modalType.value = '';
  566. };
  567. // 远程、就地切换
  568. function changeType() {
  569. const data = {
  570. deviceid: selectData.deviceID,
  571. devicetype: selectData.deviceType,
  572. paramcode: 'autoRoManualControl',
  573. value: selectData.autoRoManual,
  574. };
  575. deviceControlApi(data).then(() => {
  576. message.success('状态切换成功!');
  577. });
  578. };
  579. onMounted(async () => {
  580. loading.value = true;
  581. mountedThree().then(async () => {
  582. await getMonitor(true);
  583. loading.value = false;
  584. });
  585. });
  586. onBeforeUnmount(() => {
  587. getDeviceBaseList();
  588. });
  589. onUnmounted(() => {
  590. if (timer) {
  591. clearTimeout(timer);
  592. timer = undefined;
  593. }
  594. if(webRtcServer.length > 0){
  595. webRtcServer.forEach(item => {
  596. item.disconnect()
  597. })
  598. }
  599. destroy()
  600. });
  601. </script>
  602. <style lang="less" scoped>
  603. @import '/@/design/vent/modal.less';
  604. .button-box {
  605. border: none !important;
  606. height: 34px !important;
  607. &:hover {
  608. background: linear-gradient(#2cd1ff55, #1eb0ff55) !important;
  609. }
  610. &::before {
  611. height: 27px !important;
  612. background: linear-gradient(#1fa6cb, #127cb5) !important;
  613. }
  614. &::after {
  615. top: 35px !important;
  616. }
  617. }
  618. :deep(.@{ventSpace}-tabs-tabpane-active) {
  619. height: 100%;
  620. }
  621. ::-webkit-scrollbar-thumb {
  622. -webkit-box-shadow: inset 0 0 5px rgba(0, 0, 0, 0.2);
  623. background: #4288A444;
  624. }</style>