index.vue 33 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, 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. v-if="renderPlayer"
  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, onBeforeUnmount } 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 renderPlayer = ref(true);
  209. const activeKey = ref('1');
  210. const loading = ref(false);
  211. // 默认初始是第一行
  212. const selectRowIndex = ref(-1);
  213. // 监测数据
  214. const selectData = reactive({
  215. deviceID: '',
  216. deviceType: '',
  217. strname: '',
  218. dataDh: '-', //压差
  219. dataDtestq: '-', //测试风量
  220. // sourcePressure: '-', //气源压力
  221. dataDequivalarea: '-',
  222. netStatus: '0', //通信状态
  223. fault: '气源压力超限',
  224. sign: -1,
  225. sensorRight: 0,
  226. sensorMiddle: 1,
  227. sensorLeft: 0,
  228. });
  229. const deviceType = ref('windrect');
  230. const deviceId = ref('');
  231. const chartsColumnArr = getTableHeaderColumns('windrect_chart');
  232. const chartsColumnList = ref(chartsColumnArr.length > 0 ? chartsColumnArr : chartsColumns);
  233. // const dataSource = computed(() => {
  234. // const data = [...getRecordList()] || [];
  235. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  236. // addMonitorText(selectData);
  237. // return data;
  238. // });
  239. const dataSource = ref([]);
  240. const [regModal, { openModal }] = useModal();
  241. const { getCamera, removeCamera } = useCamera();
  242. const tabChange = (activeKeyVal) => {
  243. activeKey.value = activeKeyVal;
  244. if (activeKeyVal == 1) {
  245. nextTick(() => {
  246. MonitorDataTable.value.setSelectedRowKeys([selectData.deviceID]);
  247. });
  248. }
  249. };
  250. // 设备数据
  251. const controlType = ref(1);
  252. //表单赋值
  253. const [registerModal, { setModalProps, closeModal }] = useModalInner();
  254. // https获取监测数据
  255. let timer: null | NodeJS.Timeout = null;
  256. // function getMonitor(flag?) {
  257. // if (Object.prototype.toString.call(timer) === '[object Null]') {
  258. // timer = setTimeout(
  259. // () => {
  260. // list({ devicetype: deviceType.value, pagetype: 'normal' }).then((res) => {
  261. // if (res && res.msgTxt[0]) {
  262. // // dataSource.value = res.msgTxt[0].datalist || [];
  263. // const getData = res.msgTxt[0].datalist || [];
  264. // getData.forEach((data) => {
  265. // if (data.regulation) {
  266. // getRegulationList(data.regulation);
  267. // }
  268. // });
  269. // dataSource.value = getData;
  270. // if (dataSource.value.length > 0) {
  271. // dataSource.value.forEach((data: any) => {
  272. // const readData = data.readData;
  273. // data = Object.assign(data, readData);
  274. // });
  275. // if (dataSource.value.length > 0 && selectRowIndex.value == -1) {
  276. // // 初始打开页面
  277. // if (currentRoute.value && currentRoute.value['query'] && currentRoute.value['query']['id']) {
  278. // MonitorDataTable.value.setSelectedRowKeys([currentRoute.value['query']['id']]);
  279. // } else {
  280. // MonitorDataTable.value.setSelectedRowKeys([dataSource.value[0]['deviceID']]);
  281. // }
  282. // }
  283. // const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  284. // Object.assign(selectData, data);
  285. // addMonitorText(selectData);
  286. // palyAnimation(selectData);
  287. // }
  288. // }
  289. // if (timer) {
  290. // timer = null;
  291. // }
  292. // getMonitor();
  293. // });
  294. // },
  295. // flag ? 0 : 1000
  296. // );
  297. // }
  298. // }
  299. // function getRegulationList(data) {
  300. // getRegulation().then((res) => {
  301. // if (res) {
  302. // const regulation = res.find((item) => item.id == data);
  303. // data.regulation = regulation;
  304. // data.fmin = data.regulation.fmin;
  305. // data.fmax = data.regulation.fmax;
  306. // }
  307. // });
  308. // }
  309. // 缓存
  310. let allRegulations: any[] | null = null;
  311. async function getMonitor(flag?: boolean) {
  312. if (timer === null) {
  313. timer = setTimeout(
  314. async () => {
  315. try {
  316. // 1. 获取监控列表数据
  317. const res = await list({
  318. devicetype: deviceType.value,
  319. pagetype: 'normal',
  320. });
  321. if (res?.msgTxt[0]) {
  322. const rawData = res.msgTxt[0].datalist || [];
  323. const processedData = [...rawData];
  324. // 首次请求获取去所有regulation数据
  325. if (allRegulations === null) {
  326. const regulationRes = await getRegulation({
  327. deviceKind: deviceType.value,
  328. });
  329. allRegulations = regulationRes || [];
  330. }
  331. // 根据id创建一个映射表
  332. const regulationMap = new Map();
  333. allRegulations.forEach((reg) => {
  334. regulationMap.set(reg.id, reg);
  335. });
  336. // 对regulation字段进行替换
  337. processedData.forEach((data) => {
  338. if (data.regulation) {
  339. const reg = regulationMap.get(data.regulation);
  340. if (reg) {
  341. data.regulation = reg; // 替换为完整对象
  342. data.fmin = reg.fmin;
  343. data.fmax = reg.fmax;
  344. }
  345. }
  346. });
  347. dataSource.value = processedData;
  348. if (dataSource.value.length > 0) {
  349. await processReadData(processedData);
  350. await handleInitialSelection();
  351. }
  352. }
  353. } catch (error) {
  354. console.error('Error', error);
  355. } finally {
  356. timer = null;
  357. getMonitor();
  358. }
  359. },
  360. flag ? 0 : 1000
  361. );
  362. }
  363. }
  364. // async function getRegulationList(regulationId: string, data: any) {
  365. // const res = await getRegulation();
  366. // if (res) {
  367. // const regulation = res.find((item) => item.id === regulationId);
  368. // if (regulation) {
  369. // data.regulation = regulation;
  370. // data.fmin = regulation.fmin;
  371. // data.fmax = regulation.fmax;
  372. // }
  373. // }
  374. // }
  375. async function processReadData(data: any[]) {
  376. const promises = data
  377. .filter((item) => item.readData)
  378. .map(async (item) => {
  379. item.readData && Object.assign(item, item.readData);
  380. });
  381. await Promise.all(promises);
  382. }
  383. async function handleInitialSelection() {
  384. if (dataSource.value.length > 0) {
  385. const selectedData = toRaw(dataSource.value[selectRowIndex.value]);
  386. Object.assign(selectData, selectedData);
  387. addMonitorText(selectData);
  388. if (selectedData) palyAnimation(selectedData);
  389. }
  390. }
  391. let deviceRunState = '',
  392. tanTouRunState = '';
  393. // 根据3个点位分别执行动画
  394. function palyAnimation(selectData) {
  395. if (selectData.deviceType == 'windrect_normal') {
  396. if (selectData['apparatusRun'] == 1) {
  397. const flag = selectData.sign == '0' ? 'up' : selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : null;
  398. if (flag) play(flag);
  399. } else {
  400. const flag = selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : null;
  401. if (flag) play(flag, true);
  402. }
  403. }
  404. // 运行中是0,运行到达是1
  405. if (selectData.deviceType == 'windrect_rect_single') {
  406. if (selectData['apparatusRun'] == 1) {
  407. // 镜头指向横杆
  408. // if(!deviceRunState && !tanTouRunState)playCamera('start')
  409. // 正在执行或是开始执行
  410. //开始执行时,
  411. // selectData['poleIncipient'] == 1 selectData.sensorMiddle == 1 代表可是执行 或是 执行结束
  412. // 1. selectData['poleIncipient'] == 1 selectData.sensorMiddle == 1, 执行 play('up', true),play('middle', true)
  413. // 2. 探头左移play('left')
  414. // 3. 探头右移play('right')
  415. // 4. 横杆向中位移动,探头在右边
  416. // 5. 探头移到中间play('middle')
  417. // 6. 探头移到左边play('left')
  418. // 7. 横杆向低位移动,探头在左边
  419. // 8. 探头移到中间play('middle')
  420. // 9. 探头右移play('right')
  421. // 10. 测风结束,探头移到中间play('middle'),横杆向高位移动
  422. if (selectData['poleIncipient'] == 1) {
  423. // 横杆在高位,开始执行 或是 执行结束
  424. if (selectData.sensorMiddle == 1 && !deviceRunState && !tanTouRunState) {
  425. // 1. 开始执行
  426. deviceRunState = 'up';
  427. tanTouRunState = 'middle';
  428. play('up', true);
  429. play('middle', true);
  430. }
  431. if (deviceRunState == 'up-m') {
  432. play('up', true);
  433. play('middle', true);
  434. deviceRunState = '';
  435. tanTouRunState = '';
  436. playCamera('end');
  437. }
  438. // 初始已经在运行
  439. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  440. //2.探头左移play('left')
  441. if (tanTouRunState == 'middle') {
  442. tanTouRunState = 'left-m';
  443. play('left');
  444. }
  445. //3. 探头右移play('right')
  446. if (tanTouRunState == 'left') {
  447. tanTouRunState = 'right-m';
  448. play('right');
  449. }
  450. }
  451. if (selectData.sensorLeft == 1) {
  452. tanTouRunState = 'left';
  453. if (!tanTouRunState || tanTouRunState == 'left-m') {
  454. play('left', true);
  455. }
  456. }
  457. if (selectData.sensorRight == 1) {
  458. tanTouRunState = 'right';
  459. if (!tanTouRunState || tanTouRunState == 'right-m') {
  460. play('right', true);
  461. }
  462. }
  463. } else if (selectData['poleMiddle'] == 1) {
  464. if (deviceRunState == 'center-m') {
  465. play('center', true);
  466. deviceRunState = 'center';
  467. tanTouRunState = 'right';
  468. play('right', true);
  469. }
  470. if (!deviceRunState) {
  471. deviceRunState = 'center';
  472. play('center', true);
  473. }
  474. if (!tanTouRunState) {
  475. play('right', true);
  476. }
  477. // 横杆在中位
  478. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  479. //5. 探头移到中间play('middle')
  480. if (tanTouRunState == 'right') {
  481. tanTouRunState = 'middle-m';
  482. play('middle');
  483. }
  484. //6. 探头移到左边play('left')
  485. if (tanTouRunState == 'middle') {
  486. tanTouRunState = 'left-m';
  487. play('left');
  488. }
  489. }
  490. if (selectData.sensorMiddle == 1) {
  491. tanTouRunState = 'middle';
  492. if (!tanTouRunState || tanTouRunState == 'middle-m') {
  493. play('middle', true);
  494. }
  495. }
  496. if (selectData.sensorLeft == 1) {
  497. tanTouRunState = 'left';
  498. if (!tanTouRunState || tanTouRunState == 'left-m') {
  499. play('left', true);
  500. }
  501. }
  502. } else if (selectData['poleNether'] == 1) {
  503. if (deviceRunState == 'down-m') {
  504. play('down', true);
  505. deviceRunState = 'down';
  506. tanTouRunState = 'left';
  507. play('left', true);
  508. }
  509. if (!deviceRunState) {
  510. play('down', true);
  511. deviceRunState = 'down';
  512. }
  513. if (!tanTouRunState) {
  514. play('left', true);
  515. }
  516. // 横杆在低位
  517. if (selectData.sensorLeft == '0' && selectData.sensorMiddle == '0' && selectData.sensorRight == '0') {
  518. //8. 探头移到中间play('middle')
  519. if (tanTouRunState == 'left') {
  520. tanTouRunState = 'left-middle-m';
  521. play('middle');
  522. }
  523. //9. 探头右移play('right')
  524. if (tanTouRunState == 'middle1') {
  525. tanTouRunState = 'right-m';
  526. play('right');
  527. }
  528. // 10. 测风结束,探头移到中间play('middle'),横杆向高位移动
  529. if (tanTouRunState == 'right') {
  530. tanTouRunState = 'right-middle-m';
  531. play('middle');
  532. }
  533. }
  534. if (selectData.sensorMiddle == 1) {
  535. if (tanTouRunState == 'left-middle-m') tanTouRunState = 'middle1';
  536. if (tanTouRunState == 'right-middle-m') tanTouRunState = 'middle2';
  537. if (!tanTouRunState || tanTouRunState == 'left-middle-m' || tanTouRunState == 'right-middle-m') {
  538. play('middle', true);
  539. }
  540. }
  541. if (selectData.sensorRight == 1) {
  542. tanTouRunState = 'right';
  543. if (!tanTouRunState || tanTouRunState == 'right-m') {
  544. play('right', true);
  545. }
  546. }
  547. } else {
  548. // 横杆正在运行
  549. if (deviceRunState == 'up') {
  550. deviceRunState = 'center-m';
  551. play('center');
  552. }
  553. if (deviceRunState == 'center') {
  554. deviceRunState = 'down-m';
  555. play('down');
  556. }
  557. if (deviceRunState == 'down') {
  558. deviceRunState = 'up-m';
  559. play('up');
  560. }
  561. }
  562. // //正在执行时
  563. // // 判断上中下是否都为0
  564. // if(selectData['poleIncipient'] == 0 && selectData['poleMiddle'] == 0 && selectData['poleNether'] == 0) {
  565. // // 判断是否有前一个状态值,有的话执行
  566. // //没有前一个状态
  567. // //有前一个状态
  568. // // 横杆前状态在上位时,横杆中位移动,探头在右边
  569. // // 横杆前状态在中位时,横杆下位移动,探头在左边
  570. // // 横杆前状态在下位时,横杆上位移动,探头在中间
  571. // }else{
  572. // // 判断当前动画停在固定位置
  573. // if(selectData['poleIncipient'] == 1) {
  574. // // 滑杆停在上面,探头在中间
  575. // }else if (selectData['poleMiddle'] == 1) {
  576. // // 滑杆停在中间面,初始探头在右边
  577. // } else if (selectData['poleNether'] == 1) {
  578. // // 滑杆停在下面,初始探头在左边
  579. // }
  580. // }
  581. } else {
  582. // if(selectData['poleIncipient'] == 1){
  583. // deviceRunState = ''
  584. // tanTouRunState = ''
  585. // }
  586. }
  587. }
  588. if (selectData.deviceType == 'windrect_rect') {
  589. if (selectData['apparatusRun'] == 1) {
  590. const flag = selectData.sign == '0' ? 'center' : selectData.sign == 1 ? 'down' : selectData.sign == 2 ? 'up' : null;
  591. if (flag) play(flag);
  592. } else {
  593. const flag = selectData.sign == 1 ? 'center' : selectData.sign == 2 ? 'down' : selectData.sign == '0' ? 'up' : null;
  594. if (flag) play(flag, true);
  595. }
  596. }
  597. if (selectData.deviceType == 'windrect_ds') {
  598. if (selectData['apparatusRun'] == 1 && selectData['sign'] == 2) {
  599. if (!deviceRunState) {
  600. deviceRunState = 'start';
  601. play('down');
  602. modelRef.value?.animate?.('down');
  603. }
  604. } else if (selectData['apparatusRun'] == 0 && selectData['sign'] == 0 && deviceRunState == 'start') {
  605. deviceRunState = '';
  606. play('up');
  607. modelRef.value?.animate?.('up');
  608. }
  609. }
  610. }
  611. // 自测动画方法
  612. function testPlay(flag) {
  613. if (selectData.deviceType == 'windrect_rect') {
  614. setTimeout(() => {
  615. play('center');
  616. }, 0);
  617. setTimeout(() => {
  618. play('down');
  619. }, 4000);
  620. setTimeout(() => {
  621. play('up');
  622. }, 10000);
  623. }
  624. if (selectData.deviceType == 'windrect_normal') {
  625. setTimeout(() => {
  626. play('up');
  627. }, 0);
  628. setTimeout(() => {
  629. play('center');
  630. }, 10000);
  631. setTimeout(() => {
  632. play('down');
  633. }, 18000);
  634. setTimeout(() => {
  635. play('up');
  636. }, 21000);
  637. }
  638. if (selectData.deviceType == 'windrect_ds') {
  639. play('moni');
  640. }
  641. }
  642. function clearPlay() {
  643. modalType.value = 'autoClear';
  644. modalIsShow.value = true;
  645. if (globalConfig?.simulatedPassword) {
  646. controlDevice('', modalType.value);
  647. }
  648. }
  649. function startRun() {
  650. modalType.value = 'sing';
  651. modalIsShow.value = true;
  652. if (globalConfig?.simulatedPassword) {
  653. controlDevice('', modalType.value);
  654. }
  655. }
  656. // 切换检测数据
  657. async function getSelectRow(selectRow, index) {
  658. if (selectRow) {
  659. loading.value = true;
  660. selectRowIndex.value = index;
  661. Object.assign(selectData, selectRow);
  662. let type = '';
  663. if (selectRow['modelType']) {
  664. type = selectRow['modelType'];
  665. // debugger;
  666. } else {
  667. if (selectRow.deviceType.startsWith('windrect_rect')) {
  668. type = 'lmWindRect';
  669. }
  670. if (selectRow.deviceType.startsWith('windrect_normal')) {
  671. type = 'zdWindRect';
  672. }
  673. if (selectRow.deviceType.startsWith('windrect_rect_single')) {
  674. type = 'lmWindSide';
  675. }
  676. if (selectRow.deviceType.startsWith('windrect_ds')) {
  677. type = 'dsWindRect_move';
  678. // type = 'duisheFixed';
  679. }
  680. if (selectRow.deviceType.startsWith('windrect_ds_four')) {
  681. //windrect_ds_two
  682. type = 'dsWindRect_four';
  683. }
  684. if (selectRow.deviceType.startsWith('windrect_ds_two')) {
  685. type = 'dsWindRect_two';
  686. }
  687. if (selectRow.deviceType.startsWith('windrect_ds_sut') || selectRow.deviceType.startsWith('windrect_muti')) {
  688. type = 'duisheFixed';
  689. }
  690. if (selectRow.deviceType.startsWith('windrect_dd') || selectRow.deviceType == 'windrect_safety' || selectRow.deviceType == 'windrect_sensor') {
  691. type = 'ddWindSide';
  692. }
  693. }
  694. // const type = selectRowIndex.value >= 1 ? 'lmWindRect' : selectRowIndex.value <= 3 ? 'zdWindRect' : 'dsWindRect';
  695. /**
  696. * 模型对应的组件,根据实际情况分为二维三维
  697. * 这里传入类型type而不是sysOrgCode进行判断展示哪个装置
  698. * */
  699. if (globalConfig.is2DModel) await setSVGModelType(type);
  700. await setModelType(type);
  701. loading.value = false;
  702. deviceRunState = '';
  703. tanTouRunState = '';
  704. await getCamera(selectRow.deviceID, playerRef, renderPlayer);
  705. }
  706. }
  707. // 设置模型类型
  708. function setSVGModelType(type) {
  709. modelComponent.value = getModelComponent(globalConfig.is2DModel, type);
  710. return nextTick();
  711. }
  712. /* 一键测风 */
  713. function handleOk() {
  714. modalType.value = 'multiple';
  715. modalIsShow.value = true;
  716. if (globalConfig?.simulatedPassword) {
  717. controlDevice('', modalType.value);
  718. }
  719. }
  720. /* 打开一键测风弹窗 */
  721. function openModel() {
  722. setModalProps({ visible: true });
  723. }
  724. function resetHandle() {
  725. modalType.value = 'resetWind';
  726. modalIsShow.value = true;
  727. }
  728. function exportExcel(id) {
  729. exportXls({ testid: id });
  730. }
  731. /* 关闭一键测风弹窗 */
  732. function handleCancel() {
  733. setModalProps({ visible: false });
  734. modalTable.value.clearSelectedRowKeys();
  735. }
  736. /* 关闭一键测风控制*/
  737. function handleCancelControl() {
  738. modalIsShow.value = false;
  739. }
  740. function controlDevice(passWord, type) {
  741. try {
  742. if (type == 'sing') {
  743. testWind({
  744. ids: [selectData.deviceID],
  745. maxnum: 1000,
  746. windnum: 1,
  747. password: passWord || globalConfig?.simulatedPassword,
  748. }).then((res) => {
  749. if (res && res.success === false) {
  750. message.error(res.message);
  751. } else {
  752. if (globalConfig.History_Type == 'remote') {
  753. message.success('指令已下发至生产管控平台成功!');
  754. } else {
  755. message.success('指令已下发成功!');
  756. }
  757. }
  758. modalIsShow.value = false;
  759. });
  760. } else if (type == 'multiple') {
  761. const ids = toRaw(modalTable.value.selectedRowKeys);
  762. testWind({
  763. ids: ids,
  764. maxnum: 1000,
  765. windnum: modalTable.value.selectedRowKeys.length,
  766. password: passWord || globalConfig?.simulatedPassword,
  767. }).then((res) => {
  768. if (res && res.success === false) {
  769. message.error(res.message);
  770. } else {
  771. if (globalConfig.History_Type == 'remote') {
  772. message.success('指令已下发至生产管控平台成功!');
  773. } else {
  774. message.success('指令已下发成功!');
  775. }
  776. }
  777. modalIsShow.value = false;
  778. setModalProps({ visible: false });
  779. modalTable.value.clearSelectedRowKeys();
  780. });
  781. } else if (type == 'autoClear') {
  782. const data = {
  783. deviceid: selectData.deviceID,
  784. devicetype: selectData.deviceType,
  785. paramcode: 'autoClear',
  786. value: null,
  787. password: passWord || globalConfig?.simulatedPassword,
  788. masterComputer: selectData.masterComputer,
  789. };
  790. deviceControlApi(data).then((res) => {
  791. // 模拟时开启
  792. if (res.success) {
  793. if (globalConfig.History_Type == 'remote') {
  794. message.success('指令已下发至生产管控平台成功!');
  795. } else {
  796. message.success('指令已下发成功!');
  797. }
  798. } else {
  799. message.error(res.message);
  800. }
  801. modalIsShow.value = false;
  802. });
  803. } else if (type == 'resetWind') {
  804. resetWind({}).then((res: any) => {
  805. message.info(res);
  806. });
  807. modalIsShow.value = false;
  808. }
  809. } catch (error) {
  810. message.error('测风失败,请联系管理员。。。');
  811. modalIsShow.value = false;
  812. }
  813. }
  814. /** 避灾路线上的测风装置 */
  815. async function getPathList() {
  816. const pathArr = await pathList({});
  817. criticalPathList.value = pathArr.records.filter((item) => {
  818. return item.strsystype == 3;
  819. });
  820. }
  821. /* 根据路线选择测风装置 */
  822. function selectCriticalPath(pathId) {
  823. deviceList({ deviceType: 'wind', sysId: pathId }).then((res) => {
  824. const ids: string[] = [];
  825. res.records.forEach((item) => {
  826. ids.push(item.id);
  827. });
  828. if (modalTable.value) modalTable.value.setSelectedRowKeys(ids);
  829. });
  830. }
  831. function deviceEdit(e: Event, type: string, record) {
  832. e.stopPropagation();
  833. openModal(true, {
  834. type,
  835. deviceId: record['deviceID'],
  836. });
  837. }
  838. onBeforeMount(() => {
  839. getPathList();
  840. });
  841. onMounted(async () => {
  842. // const playerDom = document.getElementById('cf-player1')?.getElementsByClassName('vjs-tech')[0];
  843. // loading.value = true;
  844. // mountedThree(playerDom).then(async () => {
  845. // getMonitor(true);
  846. // // loading.value = false;
  847. // });
  848. const { query } = unref(currentRoute);
  849. if (query['deviceType']) deviceType.value = query['deviceType'] as string;
  850. if (globalConfig.is2DModel) {
  851. await getMonitor(true);
  852. } else {
  853. loading.value = true;
  854. mountedThree(null).then(async () => {
  855. await getMonitor(true);
  856. loading.value = false;
  857. });
  858. }
  859. });
  860. onBeforeUnmount(() => {
  861. removeCamera(playerRef);
  862. });
  863. onUnmounted(() => {
  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>