index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538
  1. <template>
  2. <div class="bg" style="width: 100%; height: 100%; display: flex; justify-content: center; align-items: center; overflow: hidden">
  3. <a-spin :spinning="loading" />
  4. <div id="fanLocal3D" style="width: 100%; height: 100%; position: absolute; overflow: hidden"> </div>
  5. <div id="fanLocal3DCSS" class="threejs-Object-CSS" style="width: 100%; height: 100%; position: absolute; overflow: hidden">
  6. <div style="z-index: -1; position: relative">
  7. <div class="elementTag" id="inputBox">
  8. <div class="elementContent">
  9. <p>进风口风速:{{ selectData.windSpeed1 ? selectData.windSpeed1 : '-' }}</p>
  10. <p>进风口瓦斯浓度 {{ selectData.gas1 ? selectData.gas1 : '-' }}</p>
  11. </div>
  12. </div>
  13. <div class="elementTag" id="outBox">
  14. <div class="elementContent elementContent-r">
  15. <p>出风口风速:{{ selectData.windSpeed12 ? selectData.windSpeed2 : '-' }}</p>
  16. <p>出风口瓦斯1浓度:{{ selectData.gas1 ? selectData.gas1 : '-' }}</p>
  17. <p>出风口瓦斯2浓度:{{ selectData.gas2 ? selectData.gas2 : '-' }}</p>
  18. </div>
  19. </div>
  20. <div class="elementTag" id="returnBox">
  21. <div class="elementContent">
  22. <p>回风侧瓦斯浓度:{{ selectData.gas3 ? selectData.gas3 : '-' }}</p>
  23. </div>
  24. </div>
  25. <div class="elementTag" id="gateBox">
  26. <div class="elementContent">
  27. <p>风门状态:关</p>
  28. <p>风门过风面积:{{ selectData.gas1 ? selectData.gas1 : '-' }}</p>
  29. </div>
  30. </div>
  31. <div class="elementTag" id="windownBox">
  32. <div class="elementContent">
  33. <p>风窗开度:{{ selectData.getRotate1 ? selectData.getRotate1 : '-' }}</p>
  34. <p>过风面积:{{ selectData.getRotate2 ? selectData.getRotate2 : '-' }}</p>
  35. </div>
  36. </div>
  37. </div>
  38. </div>
  39. </div>
  40. <div class="scene-box">
  41. <div class="top-box">
  42. <div class="top-center row">
  43. <div class="button-box" v-for="(item, index) in modalTypeArr.leftBtnArr" :key="index" @click="showModal(item)">{{ item.value }}</div>
  44. </div>
  45. <div class="top-right row">
  46. <div class="button-box" v-for="(item, index) in modalTypeArr.rightBtnArr" :key="index" @click="showModal(item)">{{ item.value }}</div>
  47. </div>
  48. </div>
  49. <div class="title-text">
  50. {{ selectData.stationname }}
  51. </div>
  52. <div class="bottom-tabs-box">
  53. <a-tabs class="tabs-box" v-model:activeKey="activeKey" @change="tabChange">
  54. <a-tab-pane key="1" tab="实时监测">
  55. <GroupMonitorTable :dataSource="dataSource" columnsType="fanlocal_monitor" @selectRow="getSelectRow" />
  56. <!-- <MonitorTable
  57. columnsType="fanlocal_monitor"
  58. :dataSource="dataSource"
  59. @selectRow="getSelectRow"
  60. design-scope="fanlocal-monitor"
  61. title="局部通风机监测"
  62. /> -->
  63. </a-tab-pane>
  64. <a-tab-pane key="2" tab="实时曲线图" force-render>
  65. <div class="tab-item" v-if="activeKey === '2'">
  66. <div class="vent-flex-row-between" style="height: 100%">
  67. <BarSingle
  68. :xAxisData="[
  69. { key: 'T1', valueKey: 'gas1' },
  70. { key: 'T2', valueKey: 'gas2' },
  71. { key: 'T3', valueKey: 'gas3' },
  72. { key: 'T4', valueKey: 'gas4' },
  73. ]"
  74. :dataSource="dataSource[selectRowIndex]"
  75. height="100%"
  76. :chartsColumns="chartsColumns"
  77. style="flex: 3"
  78. />
  79. <BarSingle
  80. :xAxisData="[
  81. { key: 'F1', valueKey: 'windQuantity1' },
  82. { key: 'F2', valueKey: 'windQuantity2' },
  83. ]"
  84. :dataSource="dataSource[selectRowIndex]"
  85. height="100%"
  86. :chartsColumns="chartsColumns1"
  87. style="flex: 2"
  88. />
  89. </div>
  90. </div>
  91. </a-tab-pane>
  92. <a-tab-pane key="3" tab="历史数据">
  93. <div class="tab-item">
  94. <HistoryTable columns-type="fanlocal_history" device-type="fanlocal" :device-list-api="baseList" designScope="fanlocal-history" />
  95. </div>
  96. </a-tab-pane>
  97. <a-tab-pane key="4" tab="报警历史">
  98. <div class="tab-item">
  99. <AlarmHistoryTable columns-type="alarm_history" device-type="fanlocal" :device-list-api="baseList" designScope="alarm-history" />
  100. </div>
  101. </a-tab-pane>
  102. <a-tab-pane key="5" tab="操作历史">
  103. <div class="tab-item">
  104. <HandlerHistoryTable columns-type="alarm_history" device-type="fanlocal" :device-list-api="baseList" designScope="alarm-history" />
  105. </div>
  106. </a-tab-pane>
  107. </a-tabs>
  108. </div>
  109. </div>
  110. <div style="z-index: -1; position: absolute; top: 50px; right: 10px; width: 300px; height: 280px; margin: auto" class="player1">
  111. <LivePlayer id="jb-player1" ref="player1" :videoUrl="flvURL1()" muted live loading controls />
  112. </div>
  113. <a-modal v-model:visible="modalIsShow" :title="modalTitle" @ok="handleOk">
  114. <div class="modal-container">
  115. <div class="vent-flex-row">
  116. <ExclamationCircleFilled style="color: #ffb700; font-size: 30px" />
  117. <div class="warning-text">您是否要进行{{ modalTitle }}操作?</div>
  118. </div>
  119. <div class="" v-if="modalType == 'startSmoke'">
  120. <div class="startSmoke-select">
  121. <div class="label">1#风机:</div>
  122. <a-radio-group v-model:value="mainWindIsShow1" @change="changeMotor" name="localWind1">
  123. <a-radio value="open">开启</a-radio>
  124. <a-radio value="stop">停止</a-radio>
  125. </a-radio-group>
  126. </div>
  127. <div class="startSmoke-select">
  128. <div class="label">2#风机:</div>
  129. <a-radio-group v-model:value="mainWindIsShow2" @change="changeMotor" name="localWind2">
  130. <a-radio value="open">开启</a-radio>
  131. <a-radio value="stop">停止</a-radio>
  132. </a-radio-group>
  133. </div>
  134. </div>
  135. <!-- 调频 -->
  136. <div class="vent-flex-row input-box" v-if="modalType == 'frequency'">
  137. <div class="label">运行频率(单位):</div>
  138. <a-input-number size="small" v-model:value="frequencyVal" :min="30" :max="50" :step="0.1" />
  139. </div>
  140. <div class="vent-flex-row input-box" v-if="modalType == 'needAir'">
  141. <div class="label">需风量(单位):</div>
  142. <a-input-number size="small" v-model:value="frequencyVal" :min="30" :max="50" :step="0.1" />
  143. </div>
  144. <div class="vent-flex-row input-box" v-if="modalType == 'disAirAlarm'">
  145. <div class="label">漏风率(%):</div>
  146. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  147. </div>
  148. <div class="vent-flex-row input-box" v-if="modalType == 'diameter'">
  149. <div class="label">风筒直径(m):</div>
  150. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  151. </div>
  152. <div class="vent-flex-row input-box" v-if="modalType == 'len'">
  153. <div class="label">风筒长度(m):</div>
  154. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  155. </div>
  156. <div class="vent-flex-row input-box" v-if="modalType == 'windPowerLimit'">
  157. <div class="label">风电闭锁限值(m³/min):</div>
  158. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  159. </div>
  160. <div class="vent-flex-row input-box" v-if="modalType == 'gasPowerLimit'">
  161. <div class="label">瓦斯电闭锁限值(m³/min):</div>
  162. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  163. </div>
  164. <div v-if="modalType == 'gasAlarm'">
  165. <div class="vent-flex-row input-box">
  166. <div class="label">传感器名称:</div>
  167. <a-select placeholder="传感器" @change="handleChangeSensor" :options="sensorList" v-model:value="modalSensor" />
  168. </div>
  169. <div class="vent-flex-row input-box">
  170. <div class="label">传感器值:</div>
  171. <a-input-number size="small" v-model:value="frequencyVal" :min="0" :max="50" :step="0.1" />
  172. </div>
  173. </div>
  174. <div v-if="modalType == 'airVolumeAlarm'">
  175. <div class="vent-flex-row input-box">
  176. <div class="label">风量上限(m³/min):</div>
  177. <a-input-number size="small" v-model:value="modalTypeArr.rightBtnArr[3].min" :min="0" :max="50" :step="0.1" />
  178. </div>
  179. <div class="vent-flex-row input-box">
  180. <div class="label">风量下限(m³/min):</div>
  181. <a-input-number size="small" v-model:value="modalTypeArr.rightBtnArr[3].max" :min="0" :max="50" :step="0.1" />
  182. </div>
  183. </div>
  184. <!-- 启动或停止 -->
  185. <div class="" v-if="modalType == 'startSmoke'"> </div>
  186. <div class="vent-flex-row input-box">
  187. <div class="label">操作密码:</div>
  188. <a-input size="small" type="password" v-model:value="passWord" />
  189. </div>
  190. </div>
  191. </a-modal>
  192. </template>
  193. <script setup lang="ts">
  194. import '/@/design/vent/modal.less';
  195. import { ExclamationCircleFilled } from '@ant-design/icons-vue';
  196. import { onBeforeMount, ref, onMounted, nextTick, toRaw, reactive, onUnmounted } from 'vue';
  197. import BarSingle from '../../../../components/chart/BarSingle.vue';
  198. import GroupMonitorTable from '../comment/GroupMonitorTable.vue';
  199. import HistoryTable from '../comment/HistoryTable.vue';
  200. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  201. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  202. import { mountedThree, setModelType, destroy, addCssText, addText, playSmoke } from './fanLocal.three';
  203. import lodash from 'lodash';
  204. import { getTableList, list } from '/@/views/vent/monitorManager/fanLocalMonitor/fanLocal.api';
  205. import { list as baseList } from '../../deviceManager/fanTabel/fan.api';
  206. import { chartsColumns, chartsColumns1 } from './fanLocal.data';
  207. import { deviceControlApi } from '/@/api/vent/index';
  208. import LivePlayer from '@liveqing/liveplayer-v3';
  209. import { message } from 'ant-design-vue';
  210. const modalTypeArr = reactive({
  211. leftBtnArr: [
  212. {
  213. key: 'startSmoke',
  214. value: '启动风机',
  215. },
  216. {
  217. key: 'changeSmoke',
  218. value: '一键倒机',
  219. },
  220. {
  221. key: 'windPower',
  222. value: '风电闭锁',
  223. },
  224. {
  225. key: 'gasPower',
  226. value: '瓦斯电闭锁',
  227. },
  228. {
  229. key: 'needAir',
  230. value: '需风量',
  231. },
  232. {
  233. key: 'diameter',
  234. value: '风筒直径',
  235. },
  236. {
  237. key: 'len',
  238. value: '风筒长度',
  239. },
  240. ],
  241. rightBtnArr: [
  242. {
  243. key: 'frequency',
  244. value: '调频',
  245. },
  246. {
  247. key: 'windPowerLimit',
  248. value: '风电闭锁限值',
  249. },
  250. {
  251. key: 'gasPowerLimit',
  252. value: '瓦斯电闭锁限值',
  253. },
  254. {
  255. key: 'airVolumeAlarm',
  256. value: '风量报警',
  257. min: 0,
  258. max: 100,
  259. },
  260. {
  261. key: 'disAirAlarm',
  262. value: '漏风率报警',
  263. },
  264. {
  265. key: 'gasAlarm',
  266. value: '瓦斯报警',
  267. },
  268. ],
  269. });
  270. const sensorList = ref<any[]>([
  271. {
  272. value: '1',
  273. label: 'T1',
  274. },
  275. {
  276. value: '2',
  277. label: 'T2',
  278. },
  279. {
  280. value: '3',
  281. label: 'T3',
  282. },
  283. ]);
  284. const modalSensor = ref(null);
  285. const loading = ref(false);
  286. const activeKey = ref('1');
  287. const player1 = ref();
  288. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  289. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  290. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  291. const frequencyVal = ref(40); //频率
  292. const mainWindIsShow1 = ref('stop'); // 1#风机默认启动
  293. const mainWindIsShow2 = ref('stop'); // 2#风机默认不启动
  294. const passWord = ref('');
  295. // 默认初始是第一行
  296. const selectRowIndex = ref(0);
  297. // 设备数据
  298. const controlType = ref(1);
  299. // 监测数据
  300. const initData = {
  301. deviceID: '',
  302. deviceType: '',
  303. strname: '',
  304. dataDh: '-', //压差
  305. dataDtestq: '-', //测试风量
  306. sourcePressure: '-', //气源压力
  307. dataDequivalarea: '-',
  308. netStatus: '0', //通信状态
  309. fault: '气源压力超限',
  310. };
  311. // 监测数据
  312. const selectData = reactive(lodash.cloneDeep(initData));
  313. // const dataSource = computed(() => {
  314. // const data = [...getRecordList()] || [];
  315. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  316. // return data;
  317. // });
  318. const dataSource = ref([]);
  319. const getDataSource = async () => {
  320. const res = await list({ devicetype: 'fan', pagetype: 'normal' });
  321. const dataArr = res.msgTxt[0].datalist || [];
  322. dataSource.value = [];
  323. dataArr.forEach((data) => {
  324. if (data.deviceType?.startsWith('fanlocal')) {
  325. const readData = data.readData;
  326. data = Object.assign(data, readData);
  327. dataSource.value.push(data);
  328. }
  329. });
  330. // // dataSource.value = res.msgTxt[0].datalist || [];
  331. // dataSource.value.forEach((data: any) => {
  332. // const readData = data.readData;
  333. // data = Object.assign(data, readData);
  334. // });
  335. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  336. return data;
  337. };
  338. // https获取监测数据
  339. let timer: null | NodeJS.Timeout = null;
  340. const getMonitor = () => {
  341. if (Object.prototype.toString.call(timer) === '[object Null]') {
  342. timer = setTimeout(async () => {
  343. await getDataSource();
  344. Object.assign(selectData, deviceBaseList.value, dataSource.value[selectRowIndex.value]);
  345. addText(selectData);
  346. // playAnimation(data, selectData.maxarea);
  347. if (timer) {
  348. timer = null;
  349. }
  350. getMonitor();
  351. }, 1000);
  352. }
  353. };
  354. // 获取设备基本信息列表
  355. const deviceBaseList = ref([]);
  356. const getDeviceBaseList = () => {
  357. getTableList({ pageSize: 1000 }).then((res) => {
  358. deviceBaseList.value = res.records;
  359. });
  360. };
  361. // 切换检测数据
  362. const getSelectRow = (id) => {
  363. if (!id) return;
  364. loading.value = true;
  365. const baseDataIndex: any = dataSource.value.findIndex((baseData: any) => baseData.deviceID === id);
  366. selectRowIndex.value = baseDataIndex;
  367. const type = baseDataIndex > 0 ? 'fm' : 'fc';
  368. setModelType(type).then(() => {
  369. loading.value = false;
  370. });
  371. const data = dataSource.value[baseDataIndex];
  372. mainWindIsShow1.value = 'stop';
  373. mainWindIsShow2.value = 'stop';
  374. if (data['fanStart1'] == 1) {
  375. mainWindIsShow1.value = 'open';
  376. } else if (data['fanStart2'] == 1) {
  377. mainWindIsShow2.value = 'open';
  378. }
  379. return;
  380. };
  381. const tabChange = (activeKeyVal) => {
  382. activeKey.value = activeKeyVal;
  383. };
  384. const flvURL1 = () => {
  385. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  386. };
  387. // 打开并设置modal的标题
  388. const showModal = (obj) => {
  389. modalType.value = obj.key;
  390. modalTitle.value = obj.value;
  391. modalIsShow.value = true;
  392. };
  393. const changeMotor = (e) => {
  394. const target = e.target;
  395. if (target.name === 'localWind1') {
  396. if (target.value === 'open') {
  397. mainWindIsShow2.value = 'stop';
  398. }
  399. } else if (target.name === 'localWind2') {
  400. if (target.value === 'open') {
  401. mainWindIsShow1.value = 'stop';
  402. }
  403. }
  404. };
  405. const handleOk = (e: MouseEvent) => {
  406. if (passWord.value !== '123456') {
  407. message.warning('密码不正确,请重新输入');
  408. return;
  409. }
  410. const handType = modalType.value;
  411. const frequency = frequencyVal.value;
  412. const data = {
  413. deviceid: selectData.deviceID,
  414. devicetype: 'fanlocal_systeml_zj',
  415. paramcode: '',
  416. value: null,
  417. };
  418. if (handType === 'startSmoke') {
  419. console.log(mainWindIsShow1.value, mainWindIsShow2.value);
  420. // 启动风机
  421. if (mainWindIsShow1.value === 'open' && mainWindIsShow2.value === 'stop') {
  422. playSmoke(handType, 'top', frequency, 'open');
  423. data.paramcode = 'fanRun1';
  424. deviceControlApi(data).then((res) => {
  425. console.log('设备操作结果', res);
  426. });
  427. } else if (mainWindIsShow2.value === 'open' && mainWindIsShow1.value === 'stop') {
  428. playSmoke(handType, 'down', frequency, 'open');
  429. data.paramcode = 'fanRun2';
  430. deviceControlApi(data).then((res) => {
  431. console.log('设备操作结果', res);
  432. });
  433. } else if (mainWindIsShow1.value === 'stop' && mainWindIsShow2.value === 'stop') {
  434. playSmoke(handType, '', frequency, 'stop');
  435. }
  436. } else if (handType === 'frequency') {
  437. // 调频
  438. playSmoke(handType, 'top', frequency, '');
  439. if (mainWindIsShow1.value === 'open') {
  440. data.paramcode = 'power1';
  441. } else if (mainWindIsShow2.value === 'open') {
  442. data.paramcode = 'power2';
  443. }
  444. data.value = frequency;
  445. deviceControlApi(data).then((res) => {
  446. console.log('设备操作结果', res);
  447. });
  448. } else if (handType === 'changeSmoke') {
  449. // 一键倒机
  450. if (mainWindIsShow1.value === 'open' && mainWindIsShow2.value === 'stop') {
  451. playSmoke(handType, 'down', frequency, 'open');
  452. data.paramcode = 'fanRun2';
  453. deviceControlApi(data).then((res) => {
  454. console.log('设备操作结果', res);
  455. });
  456. mainWindIsShow1.value = 'stop';
  457. mainWindIsShow2.value = 'open';
  458. } else if (mainWindIsShow2.value === 'open' && mainWindIsShow1.value === 'stop') {
  459. playSmoke(handType, 'top', frequency, 'open');
  460. data.paramcode = 'fanRun1';
  461. deviceControlApi(data).then((res) => {
  462. console.log('设备操作结果', res);
  463. });
  464. mainWindIsShow1.value = 'open';
  465. mainWindIsShow2.value = 'stop';
  466. } else if (mainWindIsShow1.value === 'stop' && mainWindIsShow2.value === 'stop') {
  467. playSmoke(handType, '', frequency, 'stop');
  468. }
  469. }
  470. modalTitle.value = '';
  471. modalIsShow.value = false;
  472. };
  473. const handleChangeSensor = (value: string) => {
  474. console.log(value);
  475. };
  476. const addPlayVideo = () => {
  477. if (player1.value && player1.value.play) {
  478. if (!player1.value.paused()) player1.value.play();
  479. document.body.removeEventListener('mousedown', addPlayVideo);
  480. }
  481. };
  482. onBeforeMount(() => {
  483. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'fan', orgcode: '', ids: '', systemID: '' });
  484. // initWebSocket(sendVal);
  485. getDeviceBaseList();
  486. });
  487. onMounted(() => {
  488. // loading.value = true;
  489. mountedThree(player1).then(() => {
  490. nextTick(() => {
  491. getMonitor();
  492. addCssText();
  493. playSmoke('startSmoke', 'top', frequencyVal.value, 'open');
  494. });
  495. });
  496. document.body.addEventListener('mousedown', addPlayVideo, false);
  497. });
  498. onUnmounted(() => {
  499. destroy();
  500. if (timer) {
  501. clearTimeout(timer);
  502. timer = undefined;
  503. }
  504. });
  505. </script>
  506. <style scoped lang="less">
  507. :deep(.ant-tabs-tabpane-active) {
  508. overflow: auto;
  509. }
  510. .input-box {
  511. display: flex;
  512. align-items: center;
  513. .input-title {
  514. color: #73e8fe;
  515. width: auto;
  516. }
  517. margin-right: 10px;
  518. }
  519. .label {
  520. max-width: 220px;
  521. }
  522. .ant-input {
  523. width: 150px;
  524. }
  525. </style>