index.vue 34 KB

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