index.vue 19 KB

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