gasPumpHomeCC.vue 16 KB

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