index.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  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 { ExclamationCircleFilled } from '@ant-design/icons-vue';
  195. import { onBeforeMount, ref, onMounted, nextTick, toRaw, reactive, onUnmounted } from 'vue';
  196. import BarSingle from '../../../../components/chart/BarSingle.vue';
  197. import GroupMonitorTable from '../comment/GroupMonitorTable.vue';
  198. import HistoryTable from '../comment/HistoryTable.vue';
  199. import AlarmHistoryTable from '../comment/AlarmHistoryTable.vue';
  200. import HandlerHistoryTable from '../comment/HandlerHistoryTable.vue';
  201. import { mountedThree, setModelType, destroy, addCssText, addText, playSmoke } from './fanLocal.three';
  202. import lodash from 'lodash';
  203. import { getTableList, list } from '/@/views/vent/monitorManager/fanLocalMonitor/fanLocal.api';
  204. import { list as baseList } from '../../deviceManager/fanTabel/fan.api';
  205. import { chartsColumns, chartsColumns1 } from './fanLocal.data';
  206. import { deviceControlApi } from '/@/api/vent/index';
  207. import LivePlayer from '@liveqing/liveplayer-v3';
  208. import { message } from 'ant-design-vue';
  209. const modalTypeArr = reactive({
  210. leftBtnArr: [
  211. {
  212. key: 'startSmoke',
  213. value: '启动风机',
  214. },
  215. {
  216. key: 'changeSmoke',
  217. value: '一键倒机',
  218. },
  219. {
  220. key: 'windPower',
  221. value: '风电闭锁',
  222. },
  223. {
  224. key: 'gasPower',
  225. value: '瓦斯电闭锁',
  226. },
  227. {
  228. key: 'needAir',
  229. value: '需风量',
  230. },
  231. {
  232. key: 'diameter',
  233. value: '风筒直径',
  234. },
  235. {
  236. key: 'len',
  237. value: '风筒长度',
  238. },
  239. ],
  240. rightBtnArr: [
  241. {
  242. key: 'frequency',
  243. value: '调频',
  244. },
  245. {
  246. key: 'windPowerLimit',
  247. value: '风电闭锁限值',
  248. },
  249. {
  250. key: 'gasPowerLimit',
  251. value: '瓦斯电闭锁限值',
  252. },
  253. {
  254. key: 'airVolumeAlarm',
  255. value: '风量报警',
  256. min: 0,
  257. max: 100,
  258. },
  259. {
  260. key: 'disAirAlarm',
  261. value: '漏风率报警',
  262. },
  263. {
  264. key: 'gasAlarm',
  265. value: '瓦斯报警',
  266. },
  267. ],
  268. });
  269. const sensorList = ref<any[]>([
  270. {
  271. value: '1',
  272. label: 'T1',
  273. },
  274. {
  275. value: '2',
  276. label: 'T2',
  277. },
  278. {
  279. value: '3',
  280. label: 'T3',
  281. },
  282. ]);
  283. const modalSensor = ref(null);
  284. const loading = ref(false);
  285. const activeKey = ref('1');
  286. const player1 = ref();
  287. const modalIsShow = ref<boolean>(false); // 是否显示模态框
  288. const modalTitle = ref(''); // 模态框标题显示内容,根据设备操作类型决定
  289. const modalType = ref(''); // 模态框内容显示类型,设备操作类型
  290. const frequencyVal = ref(40); //频率
  291. const mainWindIsShow1 = ref('stop'); // 1#风机默认启动
  292. const mainWindIsShow2 = ref('stop'); // 2#风机默认不启动
  293. const passWord = ref('');
  294. // 默认初始是第一行
  295. const selectRowIndex = ref(0);
  296. // 设备数据
  297. const controlType = ref(1);
  298. // 监测数据
  299. const initData = {
  300. deviceID: '',
  301. deviceType: '',
  302. strname: '',
  303. dataDh: '-', //压差
  304. dataDtestq: '-', //测试风量
  305. sourcePressure: '-', //气源压力
  306. dataDequivalarea: '-',
  307. netStatus: '0', //通信状态
  308. fault: '气源压力超限',
  309. };
  310. // 监测数据
  311. const selectData = reactive(lodash.cloneDeep(initData));
  312. // const dataSource = computed(() => {
  313. // const data = [...getRecordList()] || [];
  314. // Object.assign(selectData, toRaw(data[selectRowIndex.value]));
  315. // return data;
  316. // });
  317. const dataSource = ref([]);
  318. const getDataSource = async () => {
  319. const res = await list({ devicetype: 'fan', pagetype: 'normal' });
  320. const dataArr = res.msgTxt[0].datalist || [];
  321. dataSource.value = [];
  322. dataArr.forEach((data) => {
  323. if (data.deviceType?.startsWith('fanlocal')) {
  324. const readData = data.readData;
  325. data = Object.assign(data, readData);
  326. dataSource.value.push(data);
  327. }
  328. });
  329. // // dataSource.value = res.msgTxt[0].datalist || [];
  330. // dataSource.value.forEach((data: any) => {
  331. // const readData = data.readData;
  332. // data = Object.assign(data, readData);
  333. // });
  334. const data: any = toRaw(dataSource.value[selectRowIndex.value]); //maxarea
  335. return data;
  336. };
  337. // https获取监测数据
  338. let timer: null | NodeJS.Timeout = null;
  339. const getMonitor = () => {
  340. if (Object.prototype.toString.call(timer) === '[object Null]') {
  341. timer = setTimeout(async () => {
  342. await getDataSource();
  343. Object.assign(selectData, deviceBaseList.value, dataSource.value[selectRowIndex.value]);
  344. addText(selectData);
  345. // playAnimation(data, selectData.maxarea);
  346. if (timer) {
  347. timer = null;
  348. }
  349. getMonitor();
  350. }, 1000);
  351. }
  352. };
  353. // 获取设备基本信息列表
  354. const deviceBaseList = ref([]);
  355. const getDeviceBaseList = () => {
  356. getTableList({ pageSize: 1000 }).then((res) => {
  357. deviceBaseList.value = res.records;
  358. });
  359. };
  360. // 切换检测数据
  361. const getSelectRow = (id) => {
  362. if (!id) return;
  363. loading.value = true;
  364. const baseDataIndex: any = dataSource.value.findIndex((baseData: any) => baseData.deviceID === id);
  365. selectRowIndex.value = baseDataIndex;
  366. const type = baseDataIndex > 0 ? 'fm' : 'fc';
  367. setModelType(type).then(() => {
  368. loading.value = false;
  369. });
  370. const data = dataSource.value[baseDataIndex];
  371. mainWindIsShow1.value = 'stop';
  372. mainWindIsShow2.value = 'stop';
  373. if (data['fanStart1'] == 1) {
  374. mainWindIsShow1.value = 'open';
  375. } else if (data['fanStart2'] == 1) {
  376. mainWindIsShow2.value = 'open';
  377. }
  378. return;
  379. };
  380. const tabChange = (activeKeyVal) => {
  381. activeKey.value = activeKeyVal;
  382. };
  383. const flvURL1 = () => {
  384. return `https://sf1-hscdn-tos.pstatp.com/obj/media-fe/xgplayer_doc_video/flv/xgplayer-demo-360p.flv`;
  385. };
  386. // 打开并设置modal的标题
  387. const showModal = (obj) => {
  388. modalType.value = obj.key;
  389. modalTitle.value = obj.value;
  390. modalIsShow.value = true;
  391. };
  392. const changeMotor = (e) => {
  393. const target = e.target;
  394. if (target.name === 'localWind1') {
  395. if (target.value === 'open') {
  396. mainWindIsShow2.value = 'stop';
  397. }
  398. } else if (target.name === 'localWind2') {
  399. if (target.value === 'open') {
  400. mainWindIsShow1.value = 'stop';
  401. }
  402. }
  403. };
  404. const handleOk = (e: MouseEvent) => {
  405. if (passWord.value !== '123456') {
  406. message.warning('密码不正确,请重新输入');
  407. return;
  408. }
  409. const handType = modalType.value;
  410. const frequency = frequencyVal.value;
  411. const data = {
  412. deviceid: selectData.deviceID,
  413. devicetype: 'fanlocal_systeml_zj',
  414. paramcode: '',
  415. value: null,
  416. };
  417. if (handType === 'startSmoke') {
  418. console.log(mainWindIsShow1.value, mainWindIsShow2.value);
  419. // 启动风机
  420. if (mainWindIsShow1.value === 'open' && mainWindIsShow2.value === 'stop') {
  421. playSmoke(handType, 'top', frequency, 'open');
  422. data.paramcode = 'fanRun1';
  423. deviceControlApi(data).then((res) => {
  424. console.log('设备操作结果', res);
  425. });
  426. } else if (mainWindIsShow2.value === 'open' && mainWindIsShow1.value === 'stop') {
  427. playSmoke(handType, 'down', frequency, 'open');
  428. data.paramcode = 'fanRun2';
  429. deviceControlApi(data).then((res) => {
  430. console.log('设备操作结果', res);
  431. });
  432. } else if (mainWindIsShow1.value === 'stop' && mainWindIsShow2.value === 'stop') {
  433. playSmoke(handType, '', frequency, 'stop');
  434. }
  435. } else if (handType === 'frequency') {
  436. // 调频
  437. playSmoke(handType, 'top', frequency, '');
  438. if (mainWindIsShow1.value === 'open') {
  439. data.paramcode = 'power1';
  440. } else if (mainWindIsShow2.value === 'open') {
  441. data.paramcode = 'power2';
  442. }
  443. data.value = frequency;
  444. deviceControlApi(data).then((res) => {
  445. console.log('设备操作结果', res);
  446. });
  447. } else if (handType === 'changeSmoke') {
  448. // 一键倒机
  449. if (mainWindIsShow1.value === 'open' && mainWindIsShow2.value === 'stop') {
  450. playSmoke(handType, 'down', frequency, 'open');
  451. data.paramcode = 'fanRun2';
  452. deviceControlApi(data).then((res) => {
  453. console.log('设备操作结果', res);
  454. });
  455. mainWindIsShow1.value = 'stop';
  456. mainWindIsShow2.value = 'open';
  457. } else if (mainWindIsShow2.value === 'open' && mainWindIsShow1.value === 'stop') {
  458. playSmoke(handType, 'top', frequency, 'open');
  459. data.paramcode = 'fanRun1';
  460. deviceControlApi(data).then((res) => {
  461. console.log('设备操作结果', res);
  462. });
  463. mainWindIsShow1.value = 'open';
  464. mainWindIsShow2.value = 'stop';
  465. } else if (mainWindIsShow1.value === 'stop' && mainWindIsShow2.value === 'stop') {
  466. playSmoke(handType, '', frequency, 'stop');
  467. }
  468. }
  469. modalTitle.value = '';
  470. modalIsShow.value = false;
  471. };
  472. const handleChangeSensor = (value: string) => {
  473. console.log(value);
  474. };
  475. const addPlayVideo = () => {
  476. if (player1.value && player1.value.play) {
  477. if (!player1.value.paused()) player1.value.play();
  478. document.body.removeEventListener('mousedown', addPlayVideo);
  479. }
  480. };
  481. onBeforeMount(() => {
  482. // const sendVal = JSON.stringify({ pagetype: 'normal', devicetype: 'fan', orgcode: '', ids: '', systemID: '' });
  483. // initWebSocket(sendVal);
  484. getDeviceBaseList();
  485. });
  486. onMounted(() => {
  487. // loading.value = true;
  488. mountedThree(player1.value).then(() => {
  489. nextTick(() => {
  490. getMonitor();
  491. addCssText();
  492. playSmoke('startSmoke', 'top', frequencyVal.value, 'open');
  493. });
  494. });
  495. document.body.addEventListener('mousedown', addPlayVideo, false);
  496. });
  497. onUnmounted(() => {
  498. destroy();
  499. if (timer) {
  500. clearTimeout(timer);
  501. timer = undefined;
  502. }
  503. });
  504. </script>
  505. <style scoped lang="less">
  506. @import '/@/design/vent/modal.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>