index.vue 25 KB

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