balancePressHome.vue 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398
  1. <template>
  2. <a-spin tip="Loading..." :spinning="loading">
  3. <div class="monitor-container">
  4. <div class="lr left-box">
  5. <div class="monitor-info item-box">
  6. <ventBox1>
  7. <template #title>
  8. <div>均压与低氧参数监测与设置</div>
  9. </template>
  10. <template #container>
  11. <div class="vent-flex-row-between auto-control">
  12. <div class="title">自动调节:</div>
  13. <a-radio-group v-model:value="isAutoControl" name="radioGroup" @change="changeType(isAutoControl)">
  14. <a-radio value="1">关闭</a-radio>
  15. <a-radio value="2">开启</a-radio>
  16. </a-radio-group>
  17. </div>
  18. <div class="input-box">
  19. <div class="divider-line">开始条件</div>
  20. <div v-for="(item, index) in settingParam1" class="input-item" :key="index">
  21. <div class="title">{{ item.title }}:</div>
  22. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  23. <div class="unit">{{ item.unit }}</div>
  24. </div>
  25. <div class="divider-line">调节参数</div>
  26. <div v-for="(item, index) in settingParam2" class="input-item" :key="index">
  27. <div class="title">{{ item.title }}:</div>
  28. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  29. <div class="unit">{{ item.unit }}</div>
  30. </div>
  31. <div class="divider-line">结束时间</div>
  32. <div v-for="(item, index) in settingParam3" class="input-item" :key="index">
  33. <div class="title">{{ item.title }}:</div>
  34. <a-input-number class="input-value" v-model:value="formData[item.code]" placeholder="" />
  35. <div class="unit">{{ item.unit }}</div>
  36. </div>
  37. </div>
  38. <div class="btn-box" style="text-align: center">
  39. <div class="btn btn1" @click="onSubmit">提交</div>
  40. </div>
  41. </template>
  42. </ventBox1>
  43. </div>
  44. </div>
  45. <div class="lr right-box ml-auto">
  46. <div class="item-box sensor-container">
  47. <ventBox1 class="">
  48. <template #title>
  49. <div>设备监测详情</div>
  50. </template>
  51. <template #container>
  52. <div class="overflow-y-auto max-h-500px">
  53. <template v-for="monitor in windrectMonitorData" :key="monitor.deviceId">
  54. <div class="parameter-title group-parameter-title"
  55. ><SvgIcon class="icon" size="14" name="fiber-title" />
  56. <span>测风装置:{{ monitor.strinstallpos }}</span>
  57. </div>
  58. <div class="input-box">
  59. <div v-for="(item, index) in windrectParam" class="input-item" :key="index">
  60. <div class="title">{{ item.title }}</div>
  61. <div class="value">{{ get(monitor, item.code, '-') }}</div>
  62. <div class="unit">{{ item.unit }}</div>
  63. </div>
  64. </div>
  65. </template>
  66. </div>
  67. </template>
  68. </ventBox1>
  69. <ventBox1 class="">
  70. <template #title>
  71. <div>基于大气压的氧气浓度预测值</div>
  72. </template>
  73. <template #container> <CustomChart :chart-config="PressO2Option" :chart-data="mockData" height="220px" /> </template>
  74. </ventBox1>
  75. </div>
  76. </div>
  77. <div class="lr right-box ml-5px">
  78. <div class="item-box sensor-container">
  79. <ventBox1>
  80. <template #title>
  81. <!-- <div>CO与O2监测</div> -->
  82. <div>传感器/安全监控监测</div>
  83. </template>
  84. <template #container>
  85. <div class="overflow-y-auto max-h-300px">
  86. <template v-for="monitor in safetyMonitorData" :key="monitor.deviceId">
  87. <div class="parameter-title group-parameter-title"
  88. ><SvgIcon class="icon" size="14" name="fiber-title" />
  89. <span>{{ monitor.strinstallpos }}</span>
  90. </div>
  91. <div class="input-box">
  92. <div v-for="(item, index) in monitorParam" class="input-item" :key="index">
  93. <div class="title">{{ item.title }}</div>
  94. <div class="value" style="width: 50%">{{ get(monitor, item.code, '-') }}</div>
  95. </div>
  96. </div>
  97. </template>
  98. </div>
  99. </template>
  100. </ventBox1>
  101. <ventBox1 class="vent-margin-t-10">
  102. <template #title>
  103. <div>设备监测详情</div>
  104. </template>
  105. <template #container>
  106. <div class="overflow-y-auto max-h-400px">
  107. <template v-for="monitor in windowMonitorData" :key="monitor.deviceId">
  108. <div class="parameter-title group-parameter-title"
  109. ><SvgIcon class="icon" size="14" name="fiber-title" />
  110. <span>风窗:{{ monitor.strinstallpos }}</span>
  111. </div>
  112. <div class="input-box">
  113. <div v-for="(item, index) in windowParam" class="input-item" :key="index">
  114. <div class="title">{{ item.title }}</div>
  115. <div class="value">{{ get(monitor, item.code, '-') }}</div>
  116. <div class="unit">{{ item.unit }}</div>
  117. </div>
  118. </div>
  119. </template>
  120. <template v-for="monitor in fanlocalMonitorData" :key="monitor.deviceId">
  121. <div class="parameter-title group-parameter-title"
  122. ><SvgIcon class="icon" size="14" name="fiber-title" />
  123. <span>局扇:{{ monitor.strinstallpos }}</span>
  124. </div>
  125. <div class="input-box">
  126. <div v-for="(item, index) in localFanParam" class="input-item" :key="index">
  127. <div class="title">{{ item.title }}</div>
  128. <div class="value">{{ get(monitor, item.code, '-') }}</div>
  129. <div class="unit">{{ item.unit }}</div>
  130. </div>
  131. </div>
  132. </template>
  133. </div>
  134. </template>
  135. </ventBox1>
  136. </div>
  137. </div>
  138. </div>
  139. </a-spin>
  140. </template>
  141. <script setup lang="ts" name="balancePressHome">
  142. import { onBeforeMount, ref, onMounted, onUnmounted, reactive, defineProps, watch, computed } from 'vue';
  143. import ventBox1 from '/@/components/vent/ventBox1.vue';
  144. import CustomChart from '@/views/vent/home/configurable/components/detail/CustomChart.vue';
  145. import { PressO2Option, mockData1 } from '../balancePressO2.data';
  146. import { SvgIcon } from '/@/components/Icon';
  147. import { mountedThree, destroy, setModelType, updateText, play } from '../balancePress.threejs';
  148. import { settingParam1, settingParam2, settingParam3, windowParam, localFanParam, windrectParam } from '../balancePress.data';
  149. import { list, submit, subList, submitEdit, getO2PressData } from '../balancePress.api';
  150. import { message } from 'ant-design-vue';
  151. import { get } from 'lodash-es';
  152. const props = defineProps({
  153. deviceId: {
  154. type: String,
  155. require: true,
  156. },
  157. });
  158. const loading = ref(false);
  159. // 默认初始是第一行
  160. const isAutoControl = ref('1');
  161. const O2PressDataFetched = ref(false);
  162. // 监测数据
  163. const selectData = reactive({
  164. frontRearDP: '-',
  165. sourcePressure: '-',
  166. fault: '-',
  167. });
  168. const monitorParam = [
  169. {
  170. title: '监测值',
  171. code: 'readData.ss_analog_value',
  172. unit: '',
  173. },
  174. ];
  175. const changeType = (isAutoControl) => {
  176. isAutoControl;
  177. //
  178. };
  179. let listData = ref<any[]>([]);
  180. // https获取监测数据
  181. let timer: any = null;
  182. function getMonitor(flag?) {
  183. if (Object.prototype.toString.call(timer) === '[object Null]') {
  184. timer = setTimeout(
  185. async () => {
  186. if (props.deviceId) {
  187. const data = await getDataSource(props.deviceId);
  188. Object.assign(selectData, data);
  189. updateText(selectData);
  190. }
  191. if (timer) {
  192. timer = null;
  193. }
  194. await getMonitor();
  195. loading.value = false;
  196. },
  197. flag ? 0 : 1000
  198. );
  199. }
  200. }
  201. const safetyMonitorData = ref<any[]>([]);
  202. const fanlocalMonitorData = ref<any[]>([]);
  203. const windowMonitorData = ref<any[]>([]);
  204. const windrectMonitorData = ref<any[]>([]);
  205. const modelsensorO2Data = ref<any[]>([]);
  206. const mockData = ref<{ chartData: { dateTime: string; o2Val: string; pressureVal: string }[] }>({
  207. chartData: [],
  208. });
  209. const chartData1 = ref<any[]>([]);
  210. async function getDataSource(systemID) {
  211. const res = await list({ devicetype: 'sys', systemID });
  212. const result = res.msgTxt;
  213. safetyMonitorData.value = [];
  214. fanlocalMonitorData.value = [];
  215. windowMonitorData.value = [];
  216. windrectMonitorData.value = [];
  217. modelsensorO2Data.value = [];
  218. result.forEach((item) => {
  219. if (item.type.startsWith('safetymonitor')) {
  220. safetyMonitorData.value.push(...item.datalist);
  221. }
  222. if (item.type.startsWith('fanlocal')) {
  223. item.datalist.forEach((e) => {
  224. const f1Run = e.readData.Fan1StartStatus == '1';
  225. e.FanfHz = f1Run ? e.readData.Fan1_Frequency : e.readData.Fan2_Frequency;
  226. e.FanRun = f1Run ? '1#风机' : '2#风机';
  227. });
  228. fanlocalMonitorData.value.push(...item.datalist);
  229. }
  230. if (item.type.startsWith('window')) {
  231. windowMonitorData.value.push(...item.datalist);
  232. }
  233. if (item.type.startsWith('windrect')) {
  234. windrectMonitorData.value.push(...item.datalist);
  235. }
  236. if (item.type.startsWith('modelsensor_o2')) {
  237. modelsensorO2Data.value.push(...item.datalist);
  238. }
  239. });
  240. if (!O2PressDataFetched.value) {
  241. O2PressDataFetched.value = true;
  242. getO2Press(modelsensorO2Data.value);
  243. }
  244. }
  245. async function getO2Press(params) {
  246. const deviceID = params[0].deviceID;
  247. const param = {
  248. deviceId: deviceID,
  249. };
  250. const res = await getO2PressData(param);
  251. const chartData = [...res.o2HistoryDataList, ...res.o2List];
  252. mockData.value = { chartData };
  253. O2PressDataFetched.value = true;
  254. }
  255. // 喷粉操作
  256. async function onSubmit() {
  257. if (listData.value.length != 0) {
  258. //编辑
  259. let res = await submitEdit(listData.value[0]);
  260. if (res) {
  261. initParamList();
  262. }
  263. } else {
  264. //新增
  265. let res = await submit(formData.value);
  266. if (res) {
  267. initParamList();
  268. message.success('提交成功');
  269. }
  270. }
  271. }
  272. //获取低氧参数监测返显列表
  273. async function initParamList() {
  274. let res = await subList();
  275. if (res && res.records && res.records.length != 0) {
  276. listData.value = res.records;
  277. formData.value = res.records[0];
  278. }
  279. }
  280. watch(
  281. () => props.deviceId,
  282. (newVal, oldVal) => {
  283. if (newVal && oldVal != undefined) {
  284. setModelType('balancePressBase');
  285. }
  286. loading.value = true;
  287. }
  288. );
  289. const formData = ref({
  290. id: '',
  291. coMaxStart: 0,
  292. o2MinStart: 0,
  293. coRiseStart: 0,
  294. o2DownStart: 0,
  295. windowAreaSetGrad: 0,
  296. windowSetTime: 0,
  297. windowMinArea: 0,
  298. windowAreaDef: 0,
  299. setMinTime: 0,
  300. coEnd: 0,
  301. coTimeEnd: 0,
  302. o2End: 0,
  303. o2TimeEnd: 0,
  304. });
  305. onBeforeMount(() => {});
  306. onMounted(() => {
  307. loading.value = true;
  308. mountedThree().then(async () => {
  309. await setModelType('balancePressBase'); //balancePressBase
  310. loading.value = false;
  311. timer = null;
  312. await initParamList();
  313. await getMonitor(true);
  314. play('startSmoke', 'top', 30, 'open', 0);
  315. });
  316. });
  317. onUnmounted(() => {
  318. destroy();
  319. if (timer) {
  320. clearTimeout(timer);
  321. }
  322. });
  323. </script>
  324. <style lang="less" scoped>
  325. @import '/@/design/vent/modal.less';
  326. @import '../../comment/less/workFace.less';
  327. @ventSpace: zxm;
  328. .monitor-container {
  329. margin-top: 60px;
  330. }
  331. .lr {
  332. width: 340px !important;
  333. }
  334. .auto-control {
  335. padding: 10px 8px;
  336. margin: 0 4px 4px 4px;
  337. border-radius: 4px;
  338. border: 1px solid #ffffff05;
  339. background-image: linear-gradient(to left, #39deff15, #3977e500, #39deff15);
  340. }
  341. .divider-line {
  342. position: relative;
  343. color: aqua;
  344. padding-left: 20px;
  345. font-size: 14px;
  346. &::before {
  347. position: absolute;
  348. content: '';
  349. display: block;
  350. top: 10px;
  351. left: 0;
  352. height: 1px;
  353. width: 15px;
  354. background-color: #ffffff33;
  355. }
  356. &::after {
  357. position: absolute;
  358. content: '';
  359. display: block;
  360. top: 10px;
  361. right: 0;
  362. height: 1px;
  363. width: calc(100% - 85px);
  364. background-color: #ffffff33;
  365. }
  366. }
  367. .input-value {
  368. width: 120px !important;
  369. }
  370. .unit {
  371. text-align: right;
  372. }
  373. .btn-box {
  374. margin: 10px 4px;
  375. .btn1 {
  376. padding: 4px 0;
  377. }
  378. }
  379. :deep(.@{ventSpace}-tabs-tabpane-active) {
  380. overflow: auto;
  381. }
  382. :deep(.@{ventSpace}-input-number) {
  383. border-color: #ffffff88 !important;
  384. }
  385. </style>