gasPumpHomeCC.vue 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533
  1. <template>
  2. <div class="monitor-container">
  3. <div
  4. v-if="deviceType?.startsWith('pump_under') && deviceProperty.modelMonitor.length > 0"
  5. id="FlowSensor"
  6. class="FlowSensor-box"
  7. style="position: absolute; display: none"
  8. >
  9. <!-- <div class="elementContent">
  10. <fourBorderBg>
  11. <div v-for="(item, index) in deviceProperty.modelMonitor" :key="index" class="gas-monitor-row">
  12. <div class="title">{{ item.title }}</div>
  13. <template v-if="item.type !== 'sign' && item.type !== 'warning'">
  14. <div class="value">{{ selectData[item.code] ? selectData[item.code] : '-' }}</div>
  15. </template>
  16. <template v-else>
  17. <div class="value">
  18. <span
  19. :class="{
  20. 'signal-round': true,
  21. 'signal-round-run': item.type === 'sign' && selectData[item.code] == '1',
  22. 'signal-round-gry': selectData[item.code] == '0' || !selectData[item.code],
  23. 'signal-round-warning': item.type === 'warning' && selectData[item.code] == '1',
  24. }"
  25. ></span>
  26. </div>
  27. </template>
  28. </div>
  29. </fourBorderBg>
  30. </div> -->
  31. <div class="elementContent" style="position: absolute; display: none">
  32. <div v-for="(tag, index) in modelMonitorTags" :key="index" :id="tag.domId" class="modal-monitor-box">
  33. <template v-if="selectData[tag.code]">
  34. <div class="title">{{ tag.title }}</div>
  35. <div
  36. v-if="tag.type == 'sign'"
  37. class="signal-round"
  38. :class="{ 'signal-round-gry': selectData[tag.code] != 1, 'signal-round-run': selectData[tag.code] == 1 }"
  39. ></div>
  40. <div v-else class="value">{{ selectData[tag.code] }}</div>
  41. </template>
  42. </div>
  43. </div>
  44. </div>
  45. <div v-if="selectData['netStatus'] == 0" class="device-state">网络断开</div>
  46. <div class="btn-group">
  47. <a-button v-if="deviceProperty.detailCtrl.length > 0" class="btn-item" type="primary" @click="openModal">瓦斯泵控制</a-button>
  48. </div>
  49. <div class="lr left-box">
  50. <div class="left-container">
  51. <div class="monitor-box">
  52. <template v-for="(device, leftIndex) in deviceProperty.leftMonitor" :key="leftIndex">
  53. <ventBox1 :class="{ 'vent-margin-t-10': leftIndex > 0 }">
  54. <template #title>
  55. <div>{{ device.title }}</div>
  56. </template>
  57. <template #container>
  58. <template v-for="(deviceChild, deviceChildIndex) in device.children" :key="deviceChildIndex">
  59. <div v-for="(deviceKey, deviceIndex) in deviceChild.key" :key="deviceIndex">
  60. <div v-if="deviceChild.key.length > 1" class="parameter-title group-parameter-title"
  61. ><SvgIcon class="icon" size="14" name="pulp-title" /><span>{{ deviceChild.childTitle[deviceIndex] }}</span></div
  62. >
  63. <div class="input-box">
  64. <div v-for="(item, index) in deviceChild.list" class="input-item" :key="index">
  65. <div
  66. :class="{
  67. 'w-280px': item.type == 'sign' || item.type == 'warning',
  68. title: item.type !== 'sign' && item.type !== 'warning',
  69. }"
  70. >{{ item.title }}:</div
  71. >
  72. <template v-if="item.type !== 'sign' && item.type !== 'warning'">
  73. <div class="value">{{
  74. selectData && selectData[deviceKey + item.code] ? formatNum(selectData[deviceKey + item.code], 1) : '-'
  75. }}</div>
  76. </template>
  77. <template v-else>
  78. <div class="value">
  79. <span
  80. :class="{
  81. 'signal-round': true,
  82. 'signal-round-run': item.type === 'sign' && selectData[deviceKey + item.code] == '1',
  83. 'signal-round-gry': selectData[deviceKey + item.code] == '0' || !selectData[deviceKey + item.code],
  84. 'signal-round-warning': item.type === 'warning' && selectData[deviceKey + item.code] == '1',
  85. }"
  86. ></span>
  87. </div>
  88. </template>
  89. </div>
  90. </div>
  91. </div>
  92. </template>
  93. </template>
  94. </ventBox1>
  95. </template>
  96. </div>
  97. </div>
  98. </div>
  99. <div class="lr right-box">
  100. <div class="item-box sensor-container">
  101. <ventBox1 class="">
  102. <template #title>
  103. <div>泵站监测详情</div>
  104. </template>
  105. <template #container>
  106. <ListItem
  107. v-for="(item, index) in deviceProperty.modelMonitor"
  108. :key="index"
  109. class="w-100% mb-5px"
  110. :value="selectData[item.code]"
  111. :label="item.title"
  112. label-width="250px"
  113. />
  114. </template>
  115. </ventBox1>
  116. <ventBox1 v-for="(device, rightIndex) in deviceProperty.rightMonitor" :key="rightIndex" class="vent-margin-t-10">
  117. <template #title>
  118. <div>{{ device.title }}</div>
  119. </template>
  120. <template #container>
  121. <div v-if="device.type == 'table'">
  122. <div class="state-header">
  123. <div class="header-item" v-for="(header, index) in device.stateHeader" :key="index">{{ header }}</div>
  124. </div>
  125. <div class="">
  126. <div v-for="(child, index) in device.children" :key="index">
  127. <div class="device-row" v-for="(valveKey, valveIndex) in child.key" :key="valveIndex">
  128. <div class="state">{{ child.childTitle[valveIndex] }} </div>
  129. <div class="state" v-for="(state, i) in device['list']" :key="i">
  130. <span v-if="state['dict']">{{
  131. state['dict'][selectData[valveKey + state.code]] ? state['dict'][selectData[valveKey + state.code]] : '-'
  132. }}</span>
  133. <span
  134. v-else
  135. :class="{
  136. 'signal-round': true,
  137. 'signal-round-run': selectData[valveKey + state.code] == '1',
  138. 'signal-round-gry': selectData[valveKey + state.code] != '1',
  139. }"
  140. ></span>
  141. </div>
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. <div v-else>
  147. <template v-for="(deviceChild, deviceChildIndex) in device.children" :key="deviceChildIndex">
  148. <div v-for="(deviceKey, deviceIndex) in deviceChild.key" :key="deviceIndex">
  149. <div v-if="deviceChild.key.length > 1" class="parameter-title group-parameter-title"
  150. ><SvgIcon class="icon" size="14" name="pulp-title" /><span>{{ deviceChild.childTitle[deviceIndex] }}</span></div
  151. >
  152. <div class="input-box">
  153. <div v-for="(item, index) in deviceChild.list" class="input-item" :key="index">
  154. <div
  155. :class="{ 'w-280px': item.type == 'sign' || item.type == 'warning', title: item.type !== 'sign' && item.type !== 'warning' }"
  156. >{{ item.title }}:</div
  157. >
  158. <template v-if="item.type !== 'sign' && item.type !== 'warning'">
  159. <div class="value">{{
  160. selectData && selectData[deviceKey + item.code] ? formatNum(selectData[deviceKey + item.code], 1) : '-'
  161. }}</div>
  162. </template>
  163. <template v-else>
  164. <div class="value">
  165. <span
  166. :class="{
  167. 'signal-round': true,
  168. 'signal-round-run': item.type === 'sign' && selectData[deviceKey + item.code] == '1',
  169. 'signal-round-gry': selectData[deviceKey + item.code] == '0' || !selectData[deviceKey + item.code],
  170. 'signal-round-warning': item.type === 'warning' && selectData[deviceKey + item.code] == '1',
  171. }"
  172. ></span>
  173. </div>
  174. </template>
  175. </div>
  176. </div>
  177. </div>
  178. </template>
  179. </div>
  180. </template>
  181. </ventBox1>
  182. </div>
  183. </div>
  184. <div v-if="renderPlayer" ref="playerRef" class="player-box"></div>
  185. </div>
  186. <DetailModal @register="register" :device-type="deviceType" :device-id="deviceId" />
  187. <PasswordModal
  188. :modal-is-show="passwordModalIsShow"
  189. modal-title="密码检验"
  190. :modal-type="handlerType"
  191. @handle-ok="handleOK"
  192. @handle-cancel="handleCancel"
  193. />
  194. </template>
  195. <script setup lang="ts">
  196. import { ref, onMounted, onUnmounted, reactive, defineProps, watch, inject, nextTick, onBeforeUnmount } from 'vue';
  197. import ventBox1 from '/@/components/vent/ventBox1.vue';
  198. import { setModelType, playAnimate } from '../gasPump.threejs';
  199. import { getMonitorData, devicePropertyType, getModelMonitorTags } from '../gasPump.data';
  200. // import { leftMonitor, rightMonitor, modelMonitor, detailCtrl } from '../gasPump.dataCc2_2';
  201. import { list } from '../gasPump.api';
  202. import { SvgIcon } from '/@/components/Icon';
  203. import { formatNum } from '/@/utils/ventutil';
  204. import DetailModal from './DetailModalCC.vue';
  205. import { useModal } from '/@/components/Modal';
  206. import { deviceControlApi } from '/@/api/vent/index';
  207. import PasswordModal from '../../comment/components/PasswordModal.vue';
  208. import { message } from 'ant-design-vue';
  209. import fourBorderBg from '/@/components/vent/fourBorderBg.vue';
  210. import { useCamera } from '/@/hooks/system/useCamera';
  211. import ListItem from '@/views/vent/gas/components/list/listItem.vue';
  212. const globalConfig = inject('globalConfig');
  213. const props = defineProps({
  214. deviceId: {
  215. type: String,
  216. require: true,
  217. },
  218. deviceType: {
  219. type: String,
  220. require: true,
  221. },
  222. });
  223. const [register, { openModal }] = useModal();
  224. const loading = ref(false);
  225. const passwordModalIsShow = ref(false);
  226. const handlerType = ref('');
  227. const playerRef = ref();
  228. const renderPlayer = ref(true);
  229. const deviceProperty = ref({
  230. leftMonitor: [] as devicePropertyType[],
  231. rightMonitor: [] as devicePropertyType[],
  232. modelMonitor: [] as devicePropertyType[],
  233. detailCtrl: [] as devicePropertyType[],
  234. });
  235. const modelMonitorTags = getModelMonitorTags();
  236. // 监测数据
  237. const selectData = ref({});
  238. const { getCamera, removeCamera } = useCamera();
  239. // https获取监测数据
  240. let timer: null | NodeJS.Timeout = null;
  241. function getMonitor(flag?) {
  242. if (Object.prototype.toString.call(timer) === '[object Null]') {
  243. return new Promise((resolve) => {
  244. timer = setTimeout(
  245. async () => {
  246. if (props.deviceId) {
  247. const data = await getDataSource(props.deviceId);
  248. selectData.value = data;
  249. playAnimate(data);
  250. }
  251. if (timer) {
  252. timer = null;
  253. }
  254. resolve(null);
  255. await getMonitor();
  256. loading.value = false;
  257. },
  258. flag ? 0 : 1000
  259. );
  260. });
  261. }
  262. }
  263. async function getDataSource(systemID) {
  264. const res = await list({ devicetype: props.deviceType, ids: systemID });
  265. const result = res.msgTxt[0]['datalist'][0];
  266. Object.assign(result, result['readData']);
  267. return result;
  268. }
  269. function handler(passWord, paramcode) {
  270. let value = '';
  271. if (paramcode == 'ykjdqh') {
  272. value = selectData.value['paramcode'] == '1' ? '2' : '1';
  273. }
  274. if (paramcode == 'jxmsqh') {
  275. value = selectData.value['jxmsqh'] == '1' ? '2' : '1';
  276. }
  277. const data = {
  278. deviceid: selectData.value['deviceID'],
  279. devicetype: selectData.value['deviceType'],
  280. paramcode: paramcode,
  281. password: passWord,
  282. value: value,
  283. };
  284. deviceControlApi(data)
  285. .then((res) => {
  286. if (globalConfig.History_Type == 'remote') {
  287. message.success('指令已下发至生产管控平台成功!');
  288. } else {
  289. message.success('指令已下发成功!');
  290. }
  291. })
  292. .catch((err) => {
  293. message.success('控制异常');
  294. });
  295. }
  296. function handleOK(passWord, handlerState) {
  297. handler(passWord, handlerState);
  298. passwordModalIsShow.value = false;
  299. handlerType.value = '';
  300. }
  301. function handleCancel() {
  302. passwordModalIsShow.value = false;
  303. handlerType.value = '';
  304. }
  305. watch(
  306. () => props.deviceType,
  307. () => {
  308. getMonitorData(props.deviceType).then((data) => {
  309. deviceProperty.value = data;
  310. nextTick(() => {
  311. if (props.deviceType == 'pump_over') {
  312. setModelType('gasPump');
  313. } else if (props.deviceType?.startsWith('pump_under')) {
  314. setModelType('gasPumpUnder');
  315. }
  316. });
  317. });
  318. }
  319. );
  320. watch(
  321. () => props.deviceId,
  322. async (deviceID) => {
  323. removeCamera(playerRef);
  324. if (deviceID) await getCamera(deviceID, playerRef, renderPlayer);
  325. }
  326. );
  327. onMounted(async () => {
  328. timer = null;
  329. await getMonitor(true);
  330. if (selectData.value && selectData.value['deviceID']) await getCamera(selectData.value['deviceID'], playerRef, renderPlayer);
  331. });
  332. onBeforeUnmount(() => {
  333. removeCamera(playerRef);
  334. });
  335. onUnmounted(() => {
  336. if (timer) {
  337. clearTimeout(timer);
  338. timer = undefined;
  339. }
  340. });
  341. </script>
  342. <style lang="less" scoped>
  343. @import '/@/design/theme.less';
  344. @import '/@/design/vent/modal.less';
  345. @import '../../comment/less/workFace.less';
  346. @ventSpace: zxm;
  347. @{theme-deepblue} {
  348. .elementContent {
  349. --image-pump1: url('/@/assets/images/themify/deepblue/vent/pump1.png');
  350. }
  351. }
  352. .elementContent {
  353. --image-pump1: url('/@/assets/images/vent/pump1.png');
  354. :deep(.main-container) {
  355. display: flex;
  356. flex-wrap: wrap;
  357. width: 690px;
  358. padding: 10px 12px 10px 15px;
  359. border: 1px solid #d3e1ff33;
  360. background-color: #061c2a55;
  361. box-shadow: 0 0 15px #3b567f55;
  362. background-color: #38383833;
  363. }
  364. }
  365. .modal-monitor-box {
  366. background-color: #000;
  367. color: #fff;
  368. padding: 0 5px;
  369. display: flex;
  370. align-items: center;
  371. justify-content: center;
  372. .title {
  373. margin-right: 5px;
  374. }
  375. .signal-round {
  376. margin-left: 5px;
  377. }
  378. .value {
  379. width: 30px;
  380. color: #efae05;
  381. }
  382. }
  383. .device-state {
  384. width: 100%;
  385. position: absolute;
  386. top: 20px;
  387. color: #e90000;
  388. display: flex;
  389. justify-content: center;
  390. font-size: 20px;
  391. }
  392. .lr {
  393. margin-top: 0 !important;
  394. }
  395. .left-box {
  396. width: 360px !important;
  397. direction: rtl;
  398. overflow-y: auto;
  399. overflow-x: hidden;
  400. height: calc(100% - 60px);
  401. margin-top: 30px !important;
  402. .left-container {
  403. direction: ltr;
  404. :deep(.input-item .title) {
  405. width: 220px !important;
  406. }
  407. }
  408. }
  409. .right-box {
  410. width: 350px !important;
  411. overflow-y: auto;
  412. overflow-x: hidden;
  413. .environment-monitor {
  414. .item {
  415. flex: 1;
  416. margin: 0 5px;
  417. .title {
  418. color: #7ae5ff;
  419. text-align: center;
  420. margin-bottom: 2px;
  421. }
  422. .num {
  423. width: 100%;
  424. height: 30px;
  425. text-align: center;
  426. border-top: 2px solid #50c8fc;
  427. border-radius: 4px;
  428. background-image: linear-gradient(#2e4d5955, #3780b499, #2e465955);
  429. }
  430. }
  431. }
  432. .pool-box {
  433. width: 327px;
  434. height: 65px;
  435. padding: 0 5px;
  436. background: var(--image-pump1) no-repeat;
  437. background-size: cover;
  438. background-origin: content-box;
  439. margin-top: 2px;
  440. .num {
  441. color: aqua;
  442. }
  443. .center {
  444. padding-right: 5px;
  445. }
  446. }
  447. }
  448. .player-box {
  449. position: absolute;
  450. height: 100%;
  451. width: 100%;
  452. padding: 0 20px 0 20px;
  453. z-index: 9999;
  454. display: flex;
  455. align-items: end;
  456. bottom: 80px;
  457. right: 330px;
  458. :deep(#LivePlayerBox) {
  459. display: flex;
  460. justify-content: end;
  461. }
  462. }
  463. .input-box {
  464. width: calc(100%);
  465. display: flex;
  466. flex-direction: row !important;
  467. flex-wrap: wrap !important;
  468. .input-item {
  469. width: calc(50% - 8px);
  470. padding: 0 2px;
  471. &:nth-child(2n) {
  472. margin-left: 4px;
  473. }
  474. }
  475. }
  476. .btn-group {
  477. width: 100%;
  478. position: fixed;
  479. display: flex;
  480. justify-content: end;
  481. right: 380px;
  482. top: 85px;
  483. pointer-events: auto;
  484. .btn-item {
  485. width: auto;
  486. text-align: center;
  487. }
  488. }
  489. .state-header {
  490. display: flex;
  491. color: var(--vent-font-action-link);
  492. .header-item {
  493. width: 25%;
  494. text-align: center;
  495. }
  496. }
  497. .device-row {
  498. display: flex;
  499. margin-top: 10px;
  500. .state {
  501. width: 25%;
  502. text-align: center;
  503. font-size: 13px;
  504. }
  505. }
  506. :deep(.@{ventSpace}-tabs-tabpane-active) {
  507. overflow: auto;
  508. }
  509. </style>