index.vue 32 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944
  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" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  5. </div>
  6. <div class="scene-box">
  7. <div class="top-box">
  8. <div class="top-center row">
  9. <div v-if="hasPermission('btn:testWind')" class="button-box" @click="startRun()">启动测风</div>
  10. <!-- <div v-if="globalConfig?.simulatedPassword" class="button-box" @click="testPlay('')">模拟动画</div> -->
  11. <!-- <div class="button-box" @click="testPlay('')">模拟动画</div> -->
  12. <!-- <div class="button-box" @click="start(0)">复位</div> -->
  13. <!-- <div class="button-box" @click="testPlay('')">模拟动画</div>
  14. <div class="button-box" @click="clearPlay()">自动清洁</div>
  15. <div class="button-box" @click="startRun()">启动测风</div> -->
  16. <!-- <div class="button-box" @click="testPlay('up')">上</div>
  17. <div class="button-box" @click="testPlay('center')">中</div>
  18. <div class="button-box" @click="testPlay('down')">下</div>
  19. <div class="button-box" @click="testPlay('reset')">复位</div> -->
  20. </div>
  21. <!-- <div class="top-right row">
  22. <div class="control-type row">
  23. <div class="control-title">控制模式:</div>
  24. <a-radio-group v-model:value="controlType">
  25. <a-radio :value="1">就地</a-radio>
  26. <a-radio :value="2">远程</a-radio>
  27. </a-radio-group>
  28. </div>
  29. <div class="run-type row">
  30. <div class="control-title">运行状态:</div>
  31. <a-radio-group v-model:value="controlType">
  32. <a-radio :value="1">检修</a-radio>
  33. </a-radio-group>
  34. </div>
  35. <div class="run-state 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-group>
  40. </div>
  41. </div> -->
  42. </div>
  43. <div class="title-text">
  44. {{ selectData.supplyAirAddr || selectData.strinstallpos || selectData.strname }}
  45. </div>
  46. <div class="bottom-tabs-box" @mousedown="setDivHeight($event, 350, scroll)">
  47. <dv-border-box8 :dur="5" :style="`padding: 5px; height: ${scroll.y + 120}px`">
  48. <div class="tabs-button-group">
  49. <a-button v-if="hasPermission('windrect:handler')" class="tabs-button" type="primary" @click="openModel">一键测风</a-button>
  50. <a-button v-if="hasPermission('windrect:reset')" class="tabs-button" type="primary" @click="resetHandle">一键复位</a-button>
  51. </div>
  52. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  53. <a-tab-pane key="1" tab="实时监测">
  54. <MonitorTable
  55. v-if="activeKey === '1'"
  56. ref="MonitorDataTable"
  57. :columnsType="deviceType"
  58. :dataSource="dataSource"
  59. design-scope="windrect-monitor"
  60. @selectRow="getSelectRow"
  61. :scroll="{ y: scroll.y - 40 }"
  62. title="测风装置监测"
  63. :isShowPagination="true"
  64. :isShowActionColumn="true"
  65. >
  66. <template #filterCell="{ column, record }">
  67. <a-tag v-if="column.dataIndex === 'netStatus'" :color="record.netStatus == '0' ? '#FF5812' : 'green'">{{
  68. record.netStatus == '0' ? '断开' : '连接'
  69. }}</a-tag>
  70. <a-tag v-if="column.dataIndex === 'warnFlag'" :color="record.warnFlag == '0' ? 'green' : record.warnFlag == 1 ? '#FF5812' : 'gray'">
  71. {{ record.warnFlag == '0' ? '正常' : record.warnFlag == 1 ? '报警' : record.warnFlag == 2 ? '断开' : '未监测' }}</a-tag
  72. >
  73. <a-tag v-if="column.dataIndex === 'sign'" :color="record.sign == '0' ? '#95CF65' : record.sign == 1 ? '#4590EA' : '#9876AA'">
  74. {{ record.sign == '0' ? '高位' : record.sign == 1 ? '中位' : '低位' }}</a-tag
  75. >
  76. <template v-if="record && column && column.dataIndex === 'isRun' && record.isRun">
  77. <a-tag v-if="record.isRun == -2 || record.isRun == -1" :color="record.isRun == -2 ? '#95CF65' : '#ED5700'">{{
  78. record.isRun == -2 ? '空闲' : '等待'
  79. }}</a-tag>
  80. <a-tag v-else-if="record.isRun == 100" color="#4693FF">空闲</a-tag>
  81. <Progress v-else :percent="Number(record.isRun)" size="small" status="active" />
  82. </template>
  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" style="height: 280px" v-if="activeKey === '2'">
  92. <DeviceEcharts
  93. chartsColumnsType="windrect_chart"
  94. xAxisPropType="strname"
  95. :dataSource="dataSource"
  96. height="100%"
  97. :chartsColumns="chartsColumnList"
  98. :device-list-api="list.bind(null, { devicetype: 'windrect', pagetype: 'normal' })"
  99. device-type="windrect"
  100. />
  101. </div>
  102. </a-tab-pane>
  103. <a-tab-pane key="3" tab="历史数据">
  104. <div class="tab-item">
  105. <HistoryTable :columns-type="deviceType" :device-type="deviceType" designScope="windrect-history" :scroll="scroll" />
  106. </div>
  107. </a-tab-pane>
  108. <a-tab-pane key="4" tab="报警历史">
  109. <div class="tab-item" v-if="activeKey === '4'">
  110. <AlarmHistoryTable columns-type="alarm" :device-type="deviceType" designScope="alarm-history" :scroll="scroll" />
  111. </div>
  112. </a-tab-pane>
  113. <a-tab-pane v-if="hasPermission('windrect:result')" key="6" tab="测风结果">
  114. <ResultTable v-if="activeKey === '6'" deviceType="windrect_list" :scroll="scroll" />
  115. </a-tab-pane>
  116. <a-tab-pane v-if="sysOrgCode != 'xjttzhqmk'" key="7" tab="报警次数统计">
  117. <div class="tab-item" v-if="activeKey === '7'">
  118. <AlarmNumTable columns-type="alarmNum" :device-type="deviceType" designScope="alarm-history" :scroll="280" />
  119. </div>
  120. </a-tab-pane>
  121. </a-tabs>
  122. </dv-border-box8>
  123. </div>
  124. </div>
  125. <div ref="playerRef" style="z-index: 999; position: absolute; top: 100px; right: 10px; width: 300px; height: 280px; margin: auto"></div>
  126. <BasicModal v-bind="$attrs" @register="registerModal" title="一键测风" width="900px" @ok="handleOk" @cancel="handleCancel">
  127. <div class="head-line">
  128. <!-- <div class="vent-flex-row">
  129. <span>同时运行数量:</span>
  130. <a-input-number v-model:value="runNum" :min="1" :max="10" />
  131. </div> -->
  132. <!-- <div class="vent-flex-row">
  133. <div v-for="(criticalPath, index) in criticalPathList" :key="index" class="button-box" @click="selectCriticalPath(criticalPath.id)">{{
  134. criticalPath.systemname
  135. }}</div>
  136. </div> -->
  137. </div>
  138. <div>
  139. <ModalTable ref="modalTable" deviceType="windrect_list" />
  140. </div>
  141. </BasicModal>
  142. <HandleModal
  143. v-if="!globalConfig?.simulatedPassword"
  144. :modal-is-show="modalIsShow"
  145. modal-title="启动测风"
  146. :modal-type="modalType"
  147. @handle-ok="controlDevice"
  148. @handle-cancel="handleCancelControl"
  149. />
  150. <DeviceBaseInfo @register="regModal" :device-type="selectData['deviceType']" />
  151. </template>
  152. <script setup lang="ts">
  153. import DeviceEcharts from '../comment/DeviceEcharts.vue';
  154. import { unref, onBeforeMount, ref, onMounted, onUnmounted, reactive, toRaw, nextTick, inject } from 'vue';
  155. import { BasicModal, useModalInner } from '/@/components/Modal';
  156. import MonitorTable from '../comment/MonitorTable.vue';
  157. import ModalTable from './components/modalTable.vue';
  158. import HandleModal from './components/modal.vue';
  159. import DeviceBaseInfo from '../comment/components/DeviceBaseInfo.vue';
  160. import ResultTable from './components/resultTable.vue';
  161. import HistoryTable from '../comment/HistoryTable.vue';
  162. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  163. import AlarmNumTable from '../comment/AlarmNumTable.vue';
  164. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  165. import { deviceControlApi } from '/@/api/vent/index';
  166. import { mountedThree, destroy, addMonitorText, play, setModelType, playCamera } from './windrect.threejs';
  167. import { list, pathList, deviceList, testWind, exportXls, resetWind, getRegulation } from './windrect.api';
  168. import { message, Progress } from 'ant-design-vue';
  169. import { chartsColumns, chartsColumnsHistory, option } from './windrect.data';
  170. import { getTableHeaderColumns } from '/@/hooks/web/useWebColumns';
  171. import { setDivHeight } from '/@/utils/event';
  172. import { BorderBox8 as DvBorderBox8 } from '@kjgl77/datav-vue3';
  173. import { useRouter } from 'vue-router';
  174. import { useModal } from '/@/components/Modal';
  175. import { useCamera } from '/@/hooks/system/useCamera';
  176. import { usePermission } from '/@/hooks/web/usePermission';
  177. import { useGlobSetting } from '/@/hooks/setting';
  178. import { device } from '../../gas/gasPipeNet/gasPipeNet.api';
  179. const { hasPermission } = usePermission();
  180. const globalConfig = inject('globalConfig');
  181. const { sysOrgCode } = useGlobSetting();
  182. const { currentRoute } = useRouter();
  183. const MonitorDataTable = ref();
  184. const scroll = reactive({
  185. y: 230,
  186. });
  187. const modalType = ref('');
  188. const modalIsShow = ref(false);
  189. const modalTable = ref();
  190. const runNum = ref(5); //设备运行数量
  191. const criticalPathList = ref([]);
  192. const playerRef = ref();
  193. const activeKey = ref('1');
  194. const loading = ref(false);
  195. // 默认初始是第一行
  196. const selectRowIndex = ref(-1);
  197. // 监测数据
  198. const selectData = reactive({
  199. deviceID: '',
  200. deviceType: '',
  201. strname: '',
  202. dataDh: '-', //压差
  203. dataDtestq: '-', //测试风量
  204. // sourcePressure: '-', //气源压力
  205. dataDequivalarea: '-',
  206. netStatus: '0', //通信状态
  207. fault: '气源压力超限',
  208. sign: -1,
  209. sensorRight: 0,
  210. sensorMiddle: 1,
  211. sensorLeft: 0,
  212. });
  213. const deviceType = ref('windrect');
  214. const deviceId = ref('');
  215. const chartsColumnArr = getTableHeaderColumns('windrect_chart');
  216. const chartsColumnList = ref(chartsColumnArr.length > 0 ? chartsColumnArr : chartsColumns);
  217. // const dataSource = computed(() => {
  218. // const data = [...getRecordList()] || [];
  219. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  220. // addMonitorText(selectData);
  221. // return data;
  222. // });
  223. const dataSource = ref([]);
  224. const [regModal, { openModal }] = useModal();
  225. const { getCamera, removeCamera } = useCamera();
  226. const tabChange = (activeKeyVal) => {
  227. activeKey.value = activeKeyVal;
  228. if (activeKeyVal == 1) {
  229. nextTick(() => {
  230. MonitorDataTable.value.setSelectedRowKeys([selectData.deviceID]);
  231. });
  232. }
  233. };
  234. // 设备数据
  235. const controlType = ref(1);
  236. //表单赋值
  237. const [registerModal, { setModalProps, closeModal }] = useModalInner();
  238. // https获取监测数据
  239. let timer: null | NodeJS.Timeout = null;
  240. // function getMonitor(flag?) {
  241. // if (Object.prototype.toString.call(timer) === '[object Null]') {
  242. // timer = setTimeout(
  243. // () => {
  244. // list({ devicetype: deviceType.value, pagetype: 'normal' }).then((res) => {
  245. // if (res && res.msgTxt[0]) {
  246. // // dataSource.value = res.msgTxt[0].datalist || [];
  247. // const getData = res.msgTxt[0].datalist || [];
  248. // getData.forEach((data) => {
  249. // if (data.regulation) {
  250. // getRegulationList(data.regulation);
  251. // }
  252. // });
  253. // dataSource.value = getData;
  254. // if (dataSource.value.length > 0) {
  255. // dataSource.value.forEach((data: any) => {
  256. // const readData = data.readData;
  257. // data = Object.assign(data, readData);
  258. // });
  259. // if (dataSource.value.length > 0 && selectRowIndex.value == -1) {
  260. // // 初始打开页面
  261. // if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  262. // MonitorDataTable.value.setSelectedRowKeys([currentRoute.value['query']['id']]);
  263. // } else {
  264. // MonitorDataTable.value.setSelectedRowKeys([dataSource.value[0]['deviceID']]);
  265. // }
  266. // }
  267. // const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  268. // Object.assign(selectData, data);
  269. // addMonitorText(selectData);
  270. // palyAnimation(selectData);
  271. // }
  272. // }
  273. // if (timer) {
  274. // timer = null;
  275. // }
  276. // getMonitor();
  277. // });
  278. // },
  279. // flag ? 0 : 1000
  280. // );
  281. // }
  282. // }
  283. // function getRegulationList(data) {
  284. // getRegulation().then((res) => {
  285. // if (res) {
  286. // const regulation = res.find((item) => item.id == data);
  287. // data.regulation = regulation;
  288. // data.fmin = data.regulation.fmin;
  289. // data.fmax = data.regulation.fmax;
  290. // }
  291. // });
  292. // }
  293. // 缓存
  294. let allRegulations: any[] | null = null;
  295. async function getMonitor(flag?: boolean) {
  296. if (timer === null) {
  297. timer = setTimeout(
  298. async () => {
  299. try {
  300. // 1. 获取监控列表数据
  301. const res = await list({
  302. devicetype: deviceType.value,
  303. pagetype: 'normal',
  304. });
  305. if (res?.msgTxt[0]) {
  306. const rawData = res.msgTxt[0].datalist || [];
  307. const processedData = [...rawData];
  308. // 首次请求获取去所有regulation数据
  309. if (allRegulations === null) {
  310. const regulationRes = await getRegulation({
  311. deviceKind: deviceType.value,
  312. });
  313. allRegulations = regulationRes || [];
  314. }
  315. // 根据id创建一个映射表
  316. const regulationMap = new Map();
  317. allRegulations.forEach((reg) => {
  318. regulationMap.set(reg.id, reg);
  319. });
  320. // 对regulation字段进行替换
  321. processedData.forEach((data) => {
  322. if (data.regulation) {
  323. const reg = regulationMap.get(data.regulation);
  324. if (reg) {
  325. data.regulation = reg; // 替换为完整对象
  326. data.fmin = reg.fmin;
  327. data.fmax = reg.fmax;
  328. }
  329. }
  330. });
  331. dataSource.value = processedData;
  332. if (dataSource.value.length > 0) {
  333. await processReadData(processedData);
  334. await handleInitialSelection();
  335. }
  336. }
  337. } catch (error) {
  338. console.error('Error', error);
  339. } finally {
  340. timer = null;
  341. getMonitor(flag);
  342. }
  343. },
  344. flag ? 0 : 1000
  345. );
  346. }
  347. }
  348. // async function getRegulationList(regulationId: string, data: any) {
  349. // const res = await getRegulation();
  350. // if (res) {
  351. // const regulation = res.find((item) => item.id === regulationId);
  352. // if (regulation) {
  353. // data.regulation = regulation;
  354. // data.fmin = regulation.fmin;
  355. // data.fmax = regulation.fmax;
  356. // }
  357. // }
  358. // }
  359. async function processReadData(data: any[]) {
  360. const promises = data
  361. .filter((item) => item.readData)
  362. .map(async (item) => {
  363. item.readData && Object.assign(item, item.readData);
  364. });
  365. await Promise.all(promises);
  366. }
  367. async function handleInitialSelection() {
  368. if (dataSource.value.length > 0) {
  369. const selectedData = toRaw(dataSource.value[selectRowIndex.value]);
  370. Object.assign(selectData, selectedData);
  371. addMonitorText(selectData);
  372. palyAnimation(selectedData);
  373. }
  374. }
  375. let deviceRunState = '',
  376. tanTouRunState = '';
  377. // 根据3个点位分别执行动画
  378. function palyAnimation(selectData) {
  379. if (selectData.deviceType == 'windrect_normal') {
  380. if (selectData['apparatusRun'] == 1) {
  381. const flag = selectData.sign == '0' ? 'up' : selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : null;
  382. if (flag) play(flag);
  383. } else {
  384. const flag = selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : null;
  385. if (flag) play(flag, true);
  386. }
  387. }
  388. // 运行中是0,运行到达是1
  389. if (selectData.deviceType == 'windrect_rect_single') {
  390. if (selectData['apparatusRun'] == 1) {
  391. // 镜头指向横杆
  392. // if(!deviceRunState && !tanTouRunState)playCamera('start')
  393. // 正在执行或是开始执行
  394. //开始执行时,
  395. // selectData['poleIncipient'] == 1 selectData.sensorMiddle == 1 代表可是执行 或是 执行结束
  396. // 1. selectData['poleIncipient'] == 1 selectData.sensorMiddle == 1, 执行 play('up', true),play('middle', true)
  397. // 2. 探头左移play('left')
  398. // 3. 探头右移play('right')
  399. // 4. 横杆向中位移动,探头在右边
  400. // 5. 探头移到中间play('middle')
  401. // 6. 探头移到左边play('left')
  402. // 7. 横杆向低位移动,探头在左边
  403. // 8. 探头移到中间play('middle')
  404. // 9. 探头右移play('right')
  405. // 10. 测风结束,探头移到中间play('middle'),横杆向高位移动
  406. if (selectData['poleIncipient'] == 1) {
  407. // 横杆在高位,开始执行 或是 执行结束
  408. if (selectData.sensorMiddle == 1 && !deviceRunState && !tanTouRunState) {
  409. // 1. 开始执行
  410. deviceRunState = 'up';
  411. tanTouRunState = 'middle';
  412. play('up', true);
  413. play('middle', true);
  414. }
  415. if (deviceRunState == 'up-m') {
  416. play('up', true);
  417. play('middle', true);
  418. deviceRunState = '';
  419. tanTouRunState = '';
  420. playCamera('end');
  421. }
  422. // 初始已经在运行
  423. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  424. //2.探头左移play('left')
  425. if (tanTouRunState == 'middle') {
  426. tanTouRunState = 'left-m';
  427. play('left');
  428. }
  429. //3. 探头右移play('right')
  430. if (tanTouRunState == 'left') {
  431. tanTouRunState = 'right-m';
  432. play('right');
  433. }
  434. }
  435. if (selectData.sensorLeft == 1) {
  436. tanTouRunState = 'left';
  437. if (!tanTouRunState || tanTouRunState == 'left-m') {
  438. play('left', true);
  439. }
  440. }
  441. if (selectData.sensorRight == 1) {
  442. tanTouRunState = 'right';
  443. if (!tanTouRunState || tanTouRunState == 'right-m') {
  444. play('right', true);
  445. }
  446. }
  447. } else if (selectData['poleMiddle'] == 1) {
  448. if (deviceRunState == 'center-m') {
  449. play('center', true);
  450. deviceRunState = 'center';
  451. tanTouRunState = 'right';
  452. play('right', true);
  453. }
  454. if (!deviceRunState) {
  455. deviceRunState = 'center';
  456. play('center', true);
  457. }
  458. if (!tanTouRunState) {
  459. play('right', true);
  460. }
  461. // 横杆在中位
  462. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  463. //5. 探头移到中间play('middle')
  464. if (tanTouRunState == 'right') {
  465. tanTouRunState = 'middle-m';
  466. play('middle');
  467. }
  468. //6. 探头移到左边play('left')
  469. if (tanTouRunState == 'middle') {
  470. tanTouRunState = 'left-m';
  471. play('left');
  472. }
  473. }
  474. if (selectData.sensorMiddle == 1) {
  475. tanTouRunState = 'middle';
  476. if (!tanTouRunState || tanTouRunState == 'middle-m') {
  477. play('middle', true);
  478. }
  479. }
  480. if (selectData.sensorLeft == 1) {
  481. tanTouRunState = 'left';
  482. if (!tanTouRunState || tanTouRunState == 'left-m') {
  483. play('left', true);
  484. }
  485. }
  486. } else if (selectData['poleNether'] == 1) {
  487. if (deviceRunState == 'down-m') {
  488. play('down', true);
  489. deviceRunState = 'down';
  490. tanTouRunState = 'left';
  491. play('left', true);
  492. }
  493. if (!deviceRunState) {
  494. play('down', true);
  495. deviceRunState = 'down';
  496. }
  497. if (!tanTouRunState) {
  498. play('left', true);
  499. }
  500. // 横杆在低位
  501. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  502. //8. 探头移到中间play('middle')
  503. if (tanTouRunState == 'left') {
  504. tanTouRunState = 'left-middle-m';
  505. play('middle');
  506. }
  507. //9. 探头右移play('right')
  508. if (tanTouRunState == 'middle1') {
  509. tanTouRunState = 'right-m';
  510. play('right');
  511. }
  512. // 10. 测风结束,探头移到中间play('middle'),横杆向高位移动
  513. if (tanTouRunState == 'right') {
  514. tanTouRunState = 'right-middle-m';
  515. play('middle');
  516. }
  517. }
  518. if (selectData.sensorMiddle == 1) {
  519. if (tanTouRunState == 'left-middle-m') tanTouRunState = 'middle1';
  520. if (tanTouRunState == 'right-middle-m') tanTouRunState = 'middle2';
  521. if (!tanTouRunState || tanTouRunState == 'left-middle-m' || tanTouRunState == 'right-middle-m') {
  522. play('middle', true);
  523. }
  524. }
  525. if (selectData.sensorRight == 1) {
  526. tanTouRunState = 'right';
  527. if (!tanTouRunState || tanTouRunState == 'right-m') {
  528. play('right', true);
  529. }
  530. }
  531. } else {
  532. // 横杆正在运行
  533. if (deviceRunState == 'up') {
  534. deviceRunState = 'center-m';
  535. play('center');
  536. }
  537. if (deviceRunState == 'center') {
  538. deviceRunState = 'down-m';
  539. play('down');
  540. }
  541. if (deviceRunState == 'down') {
  542. deviceRunState = 'up-m';
  543. play('up');
  544. }
  545. }
  546. // //正在执行时
  547. // // 判断上中下是否都为0
  548. // if(selectData['poleIncipient'] == 0 && selectData['poleMiddle'] == 0 && selectData['poleNether'] == 0) {
  549. // // 判断是否有前一个状态值,有的话执行
  550. // //没有前一个状态
  551. // //有前一个状态
  552. // // 横杆前状态在上位时,横杆中位移动,探头在右边
  553. // // 横杆前状态在中位时,横杆下位移动,探头在左边
  554. // // 横杆前状态在下位时,横杆上位移动,探头在中间
  555. // }else{
  556. // // 判断当前动画停在固定位置
  557. // if(selectData['poleIncipient'] == 1) {
  558. // // 滑杆停在上面,探头在中间
  559. // }else if (selectData['poleMiddle'] == 1) {
  560. // // 滑杆停在中间面,初始探头在右边
  561. // } else if (selectData['poleNether'] == 1) {
  562. // // 滑杆停在下面,初始探头在左边
  563. // }
  564. // }
  565. } else {
  566. // if(selectData['poleIncipient'] == 1){
  567. // deviceRunState = ''
  568. // tanTouRunState = ''
  569. // }
  570. }
  571. }
  572. if (selectData.deviceType == 'windrect_rect') {
  573. if (selectData['apparatusRun'] == 1) {
  574. const flag = selectData.sign == '0' ? 'center' : selectData.sign == 1 ? 'down' : selectData.sign == 2 ? 'up' : null;
  575. if (flag) play(flag);
  576. } else {
  577. const flag = selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : selectData.sign == '0' ? 'up' : null;
  578. if (flag) play(flag, true);
  579. }
  580. }
  581. if (selectData.deviceType == 'windrect_ds') {
  582. if (selectData['apparatusRun'] == 1 && selectData['sign'] == 2) {
  583. if (!deviceRunState) {
  584. deviceRunState = 'start';
  585. play('down');
  586. }
  587. } else if (selectData['apparatusRun'] == 0 && selectData['sign'] == 0 && deviceRunState == 'start') {
  588. deviceRunState = '';
  589. play('up');
  590. }
  591. }
  592. }
  593. // 自测动画方法
  594. function testPlay(flag) {
  595. if (selectData.deviceType == 'windrect_rect') {
  596. setTimeout(() => {
  597. play('center');
  598. }, 0);
  599. setTimeout(() => {
  600. play('down');
  601. }, 4000);
  602. setTimeout(() => {
  603. play('up');
  604. }, 10000);
  605. }
  606. if (selectData.deviceType == 'windrect_normal') {
  607. setTimeout(() => {
  608. play('up');
  609. }, 0);
  610. setTimeout(() => {
  611. play('center');
  612. }, 10000);
  613. setTimeout(() => {
  614. play('down');
  615. }, 18000);
  616. setTimeout(() => {
  617. play('up');
  618. }, 21000);
  619. }
  620. if (selectData.deviceType == 'windrect_ds') {
  621. play('moni');
  622. }
  623. }
  624. function clearPlay() {
  625. modalType.value = 'autoClear';
  626. modalIsShow.value = true;
  627. if (globalConfig?.simulatedPassword) {
  628. controlDevice('', modalType.value);
  629. }
  630. }
  631. function startRun() {
  632. modalType.value = 'sing';
  633. modalIsShow.value = true;
  634. if (globalConfig?.simulatedPassword) {
  635. controlDevice('', modalType.value);
  636. }
  637. }
  638. // 切换检测数据
  639. async function getSelectRow(selectRow, index) {
  640. if (selectRow) {
  641. loading.value = true;
  642. selectRowIndex.value = index;
  643. Object.assign(selectData, selectRow);
  644. let type = '';
  645. if (selectRow['modelType']) {
  646. type = selectRow['modelType'];
  647. // debugger;
  648. } else {
  649. if (selectRow.deviceType.startsWith('windrect_rect')) {
  650. type = 'lmWindRect';
  651. }
  652. if (selectRow.deviceType.startsWith('windrect_normal')) {
  653. type = 'zdWindRect';
  654. }
  655. if (selectRow.deviceType.startsWith('windrect_rect_single')) {
  656. type = 'lmWindSide';
  657. }
  658. if (selectRow.deviceType.startsWith('windrect_ds')) {
  659. type = 'dsWindRect_move';
  660. // type = 'duisheFixed';
  661. }
  662. if (selectRow.deviceType.startsWith('windrect_ds_four')) {
  663. //windrect_ds_two
  664. type = 'dsWindRect_four';
  665. }
  666. if (selectRow.deviceType.startsWith('windrect_ds_two')) {
  667. type = 'dsWindRect_two';
  668. }
  669. if (selectRow.deviceType.startsWith('windrect_ds_sut') || selectRow.deviceType.startsWith('windrect_muti')) {
  670. type = 'duisheFixed';
  671. }
  672. if (selectRow.deviceType.startsWith('windrect_dd') || selectRow.deviceType == 'windrect_safety' || selectRow.deviceType == 'windrect_sensor') {
  673. type = 'ddWindSide';
  674. }
  675. }
  676. // const type = selectRowIndex.value >= 1 ? 'lmWindRect' : selectRowIndex.value <= 3 ? 'zdWindRect' : 'dsWindRect';
  677. await setModelType(type);
  678. loading.value = false;
  679. deviceRunState = '';
  680. tanTouRunState = '';
  681. await getCamera(selectRow.deviceID, playerRef.value);
  682. }
  683. }
  684. /* 一键测风 */
  685. function handleOk() {
  686. modalType.value = 'multiple';
  687. modalIsShow.value = true;
  688. if (globalConfig?.simulatedPassword) {
  689. controlDevice('', modalType.value);
  690. }
  691. }
  692. /* 打开一键测风弹窗 */
  693. function openModel() {
  694. setModalProps({ visible: true });
  695. }
  696. function resetHandle() {
  697. modalType.value = 'resetWind';
  698. modalIsShow.value = true;
  699. }
  700. function exportExcel(id) {
  701. exportXls({ testid: id });
  702. }
  703. /* 关闭一键测风弹窗 */
  704. function handleCancel() {
  705. setModalProps({ visible: false });
  706. modalTable.value.clearSelectedRowKeys();
  707. }
  708. /* 关闭一键测风控制*/
  709. function handleCancelControl() {
  710. modalIsShow.value = false;
  711. }
  712. function controlDevice(passWord, type) {
  713. try {
  714. if (type == 'sing') {
  715. testWind({
  716. ids: [selectData.deviceID],
  717. maxnum: 1000,
  718. windnum: 1,
  719. password: passWord || globalConfig?.simulatedPassword,
  720. }).then((res) => {
  721. if (res && res.success === false) {
  722. message.error(res.message);
  723. } else {
  724. if (globalConfig.History_Type == 'remote') {
  725. message.success('指令已下发至生产管控平台成功!');
  726. } else {
  727. message.success('指令已下发成功!');
  728. }
  729. }
  730. modalIsShow.value = false;
  731. });
  732. } else if (type == 'multiple') {
  733. const ids = toRaw(modalTable.value.selectedRowKeys);
  734. testWind({
  735. ids: ids,
  736. maxnum: 1000,
  737. windnum: modalTable.value.selectedRowKeys.length,
  738. password: passWord || globalConfig?.simulatedPassword,
  739. }).then((res) => {
  740. if (res && res.success === false) {
  741. message.error(res.message);
  742. } else {
  743. if (globalConfig.History_Type == 'remote') {
  744. message.success('指令已下发至生产管控平台成功!');
  745. } else {
  746. message.success('指令已下发成功!');
  747. }
  748. }
  749. modalIsShow.value = false;
  750. setModalProps({ visible: false });
  751. modalTable.value.clearSelectedRowKeys();
  752. });
  753. } else if (type == 'autoClear') {
  754. const data = {
  755. deviceid: selectData.deviceID,
  756. devicetype: selectData.deviceType,
  757. paramcode: 'autoClear',
  758. value: null,
  759. password: passWord || globalConfig?.simulatedPassword,
  760. masterComputer: selectData.masterComputer,
  761. };
  762. deviceControlApi(data).then((res) => {
  763. // 模拟时开启
  764. if (res.success) {
  765. if (globalConfig.History_Type == 'remote') {
  766. message.success('指令已下发至生产管控平台成功!');
  767. } else {
  768. message.success('指令已下发成功!');
  769. }
  770. } else {
  771. message.error(res.message);
  772. }
  773. modalIsShow.value = false;
  774. });
  775. } else if (type == 'resetWind') {
  776. resetWind({}).then((res: any) => {
  777. message.info(res);
  778. });
  779. modalIsShow.value = false;
  780. }
  781. } catch (error) {
  782. message.error('测风失败,请联系管理员。。。');
  783. modalIsShow.value = false;
  784. }
  785. }
  786. /** 避灾路线上的测风装置 */
  787. async function getPathList() {
  788. const pathArr = await pathList({});
  789. criticalPathList.value = pathArr.records.filter((item) => {
  790. return item.strsystype == 3;
  791. });
  792. }
  793. /* 根据路线选择测风装置 */
  794. function selectCriticalPath(pathId) {
  795. deviceList({ deviceType: 'wind', sysId: pathId }).then((res) => {
  796. const ids: string[] = [];
  797. res.records.forEach((item) => {
  798. ids.push(item.id);
  799. });
  800. if (modalTable.value) modalTable.value.setSelectedRowKeys(ids);
  801. });
  802. }
  803. function deviceEdit(e: Event, type: string, record) {
  804. e.stopPropagation();
  805. openModal(true, {
  806. type,
  807. deviceId: record['deviceID'],
  808. });
  809. }
  810. onBeforeMount(() => {
  811. getPathList();
  812. });
  813. onMounted(async () => {
  814. // const playerDom = document.getElementById('cf-player1')?.getElementsByClassName('vjs-tech')[0];
  815. // loading.value = true;
  816. // mountedThree(playerDom).then(async () => {
  817. // getMonitor(true);
  818. // // loading.value = false;
  819. // });
  820. const { query } = unref(currentRoute);
  821. if (query['deviceType']) deviceType.value = query['deviceType'] as string;
  822. loading.value = true;
  823. mountedThree(null).then(async () => {
  824. await getMonitor(true);
  825. loading.value = false;
  826. });
  827. });
  828. onUnmounted(() => {
  829. removeCamera();
  830. if (timer) {
  831. clearTimeout(timer);
  832. timer = undefined;
  833. }
  834. destroy();
  835. });
  836. </script>
  837. <style scoped lang="less">
  838. @import '/@/design/theme.less';
  839. @import '/@/design/vent/modal.less';
  840. @ventSpace: zxm;
  841. :deep(.@{ventSpace}-tabs-tabpane-active) {
  842. height: 100%;
  843. }
  844. .scene-box {
  845. .bottom-tabs-box {
  846. height: 350px;
  847. }
  848. }
  849. .head-line {
  850. display: flex;
  851. flex-direction: row;
  852. justify-content: space-between;
  853. .button-box {
  854. position: relative;
  855. padding: 5px;
  856. border: 1px transparent solid;
  857. border-radius: 5px;
  858. margin-left: 8px;
  859. margin-right: 8px;
  860. width: auto;
  861. height: 34px;
  862. border: 1px solid var(--vent-base-border);
  863. display: flex;
  864. align-items: center;
  865. justify-content: center;
  866. color: var(--vent-font-color);
  867. padding: 0 15px;
  868. cursor: pointer;
  869. pointer-events: auto;
  870. &:hover {
  871. background: var(--vent-device-manager-control-btn-hover);
  872. }
  873. &::before {
  874. width: calc(100% - 6px);
  875. height: 26px;
  876. content: '';
  877. position: absolute;
  878. top: 3px;
  879. right: 0;
  880. left: 3px;
  881. bottom: 0;
  882. z-index: -1;
  883. border-radius: inherit; /*important*/
  884. background: var(--vent-device-manager-control-btn);
  885. }
  886. }
  887. }
  888. :deep(.@{ventSpace}-picker-datetime-panel) {
  889. height: 200px !important;
  890. overflow-y: auto !important;
  891. }
  892. </style>