|
@@ -5,6 +5,7 @@ import SvgIcon from '@/components/SvgIcon.vue';
|
|
|
import { useRequest } from '@/hooks/request';
|
|
|
import { getDevWorkRealTimeData, getDevWorkTypeCount, queryDevicesList } from '@/api';
|
|
|
import { DeviceRunningStatus, DeviceStatusQuery } from '@/constants';
|
|
|
+import { DevParamCtrlCabinet } from '@/constants/device-params';
|
|
|
|
|
|
import { deviceCardData, DeviceType } from './device-card';
|
|
|
import DeviceWorkParams from './DeviceWorkParams.vue';
|
|
@@ -33,8 +34,22 @@ onMounted(() => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
+/**
|
|
|
+ * 设备实时数据映射对象
|
|
|
+ * - 以设备 id 作为 key
|
|
|
+ * - 时间与设备参数的值构成的对象作为 value
|
|
|
+ */
|
|
|
+type DeviceRTDMap = Record<
|
|
|
+ number,
|
|
|
+ {
|
|
|
+ [key: string]: number | string | undefined;
|
|
|
+ time?: string;
|
|
|
+ }
|
|
|
+>;
|
|
|
+
|
|
|
const deviceList = ref<DevicesListItem[]>([]);
|
|
|
const deviceTotal = ref(0);
|
|
|
+const deviceRealTimeData = ref<DeviceRTDMap>({});
|
|
|
const pageParams = ref<PageParams>({
|
|
|
pageIndex: 1,
|
|
|
pageSize: 100,
|
|
@@ -65,7 +80,17 @@ const getDeviceList = () => {
|
|
|
const deviceIds = records.map((item) => item.id);
|
|
|
const deviceParamCode = deviceCardData[activeDeviceType.value]?.paramCodes || [];
|
|
|
|
|
|
- await getDevWorkRealTimeData(deviceIds, deviceParamCode);
|
|
|
+ const data = await getDevWorkRealTimeData(deviceIds, deviceParamCode);
|
|
|
+
|
|
|
+ data.forEach((item) => {
|
|
|
+ if (!deviceRealTimeData.value[item.deviceId]) {
|
|
|
+ deviceRealTimeData.value[item.deviceId] = {};
|
|
|
+ }
|
|
|
+
|
|
|
+ item.deviceParamMapList.forEach((paramItem) => {
|
|
|
+ Object.assign(deviceRealTimeData.value[item.deviceId], paramItem);
|
|
|
+ });
|
|
|
+ });
|
|
|
|
|
|
deviceList.value = records;
|
|
|
deviceTotal.value = total;
|
|
@@ -116,12 +141,23 @@ const viewDevParam = () => {
|
|
|
]"
|
|
|
></span>
|
|
|
<div class="ellipsis-text device-card-header-title">{{ item.deviceName }}</div>
|
|
|
- <div class="device-cop-value">5.17</div>
|
|
|
- <div class="device-cop-level">中</div>
|
|
|
- <span class="device-card-header-time">2025-3-21 09:40</span>
|
|
|
+ <div
|
|
|
+ v-if="
|
|
|
+ activeDeviceType === DeviceType.控制柜 &&
|
|
|
+ deviceRealTimeData[item.id]?.[DevParamCtrlCabinet.系统控制模式设定]
|
|
|
+ "
|
|
|
+ class="ctrl-cabinet-mode"
|
|
|
+ >
|
|
|
+ {{ deviceRealTimeData[item.id][DevParamCtrlCabinet.系统控制模式设定] }}
|
|
|
+ </div>
|
|
|
+ <template v-if="activeDeviceType === DeviceType.冷水主机">
|
|
|
+ <div class="device-cop-value">5.17</div>
|
|
|
+ <div class="device-cop-level">中</div>
|
|
|
+ </template>
|
|
|
+ <span class="device-card-header-time">{{ deviceRealTimeData[item.id]?.time }}</span>
|
|
|
<SvgIcon class="device-card-header-button" name="adjustment" @click="viewDevParam" />
|
|
|
</div>
|
|
|
- <component :is="deviceCardData[activeDeviceType]?.component" />
|
|
|
+ <component :is="deviceCardData[activeDeviceType]?.component" :real-time-data="deviceRealTimeData[item.id]" />
|
|
|
</div>
|
|
|
</ACol>
|
|
|
</ARow>
|
|
@@ -160,6 +196,7 @@ const viewDevParam = () => {
|
|
|
}
|
|
|
|
|
|
.device-card-container {
|
|
|
+ position: relative;
|
|
|
height: 328px;
|
|
|
padding: 16px 24px;
|
|
|
background-color: #fff;
|
|
@@ -186,6 +223,19 @@ const viewDevParam = () => {
|
|
|
color: var(--antd-color-text);
|
|
|
}
|
|
|
|
|
|
+.ctrl-cabinet-mode {
|
|
|
+ width: 86px;
|
|
|
+ height: 24px;
|
|
|
+ font-size: 14px;
|
|
|
+ font-weight: 500;
|
|
|
+ line-height: 22px;
|
|
|
+ color: var(--antd-color-primary);
|
|
|
+ text-align: center;
|
|
|
+ background: var(--antd-color-primary-opacity-10);
|
|
|
+ border: 1px solid var(--antd-color-primary);
|
|
|
+ border-radius: 4px;
|
|
|
+}
|
|
|
+
|
|
|
.device-cop-value {
|
|
|
font-family: DINAlternate;
|
|
|
font-size: 24px;
|