index.vue 34 KB

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