index.vue 34 KB

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