|
@@ -1,37 +1,57 @@
|
|
|
<script setup lang="ts">
|
|
|
-import { computed } from 'vue';
|
|
|
+import { computed, ref, watch } from 'vue';
|
|
|
+import { Modal } from 'ant-design-vue';
|
|
|
|
|
|
import SvgIcon from '@/components/SvgIcon.vue';
|
|
|
+import { useRequest } from '@/hooks/request';
|
|
|
import { useViewVisible } from '@/hooks/view-visible';
|
|
|
import { t } from '@/i18n';
|
|
|
+import { getGroupModuleDevData, updateGroupModuleDevData } from '@/api';
|
|
|
+import { waitTime } from '@/utils';
|
|
|
+import { DevParamChillerUnit, DevParamCoolingPump, DevParamCoolingTower } from '@/constants/device-params';
|
|
|
|
|
|
-import type { DeviceType } from '../device-work-status/device-card';
|
|
|
+import { DeviceType } from '../device-work-status/device-card';
|
|
|
+
|
|
|
+import type { EquipmentDetailsItem } from '@/types';
|
|
|
|
|
|
interface Props {
|
|
|
- title?: string;
|
|
|
- deviceType?: DeviceType;
|
|
|
+ info?: EquipmentDetailsItem;
|
|
|
}
|
|
|
|
|
|
-defineProps<Props>();
|
|
|
+const props = defineProps<Props>();
|
|
|
|
|
|
defineEmits<{
|
|
|
openDevBatchExe: [];
|
|
|
}>();
|
|
|
|
|
|
const { visible, showView, hideView } = useViewVisible();
|
|
|
+const { isLoading, handleRequest } = useRequest();
|
|
|
+const deviceRealTimeData = ref<Record<string, number | string | undefined>>({});
|
|
|
+
|
|
|
+const deviceType = computed(() => {
|
|
|
+ return props.info?.deviceQueryVo.deviceType;
|
|
|
+});
|
|
|
|
|
|
const disableStartStopCtrl = computed(() => {
|
|
|
- return true;
|
|
|
+ const { isLocale, isAuto, isDisable } = getDeviceStatus();
|
|
|
+ return isLocale || isAuto || isDisable;
|
|
|
});
|
|
|
|
|
|
const startStopTip = computed(() => {
|
|
|
+ const { isLocale, isAuto, isDisable } = getDeviceStatus();
|
|
|
const tips: string[] = [];
|
|
|
|
|
|
- tips.push(
|
|
|
- t('realTimeMonitor.startStopControlTipLocal'),
|
|
|
- t('realTimeMonitor.startStopControlTipAuto'),
|
|
|
- t('realTimeMonitor.startStopControlTipDisable'),
|
|
|
- );
|
|
|
+ if (isLocale) {
|
|
|
+ tips.push(t('realTimeMonitor.startStopControlTipLocal'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isAuto) {
|
|
|
+ tips.push(t('realTimeMonitor.startStopControlTipAuto'));
|
|
|
+ }
|
|
|
+
|
|
|
+ if (isDisable) {
|
|
|
+ tips.push(t('realTimeMonitor.startStopControlTipDisable'));
|
|
|
+ }
|
|
|
|
|
|
let tipText = '';
|
|
|
|
|
@@ -42,6 +62,110 @@ const startStopTip = computed(() => {
|
|
|
return tipText;
|
|
|
});
|
|
|
|
|
|
+const getDeviceStatus = () => {
|
|
|
+ const { localRemoteStatus, manualAutoStatus, disableEnableStatus } = deviceRealTimeData.value;
|
|
|
+
|
|
|
+ return {
|
|
|
+ isLocale: localRemoteStatus === '本地',
|
|
|
+ isAuto: manualAutoStatus === 1,
|
|
|
+ isDisable: disableEnableStatus === 0,
|
|
|
+ };
|
|
|
+};
|
|
|
+
|
|
|
+watch(visible, () => {
|
|
|
+ if (visible.value) {
|
|
|
+ getDeviceData();
|
|
|
+ } else {
|
|
|
+ deviceRealTimeData.value = {};
|
|
|
+ }
|
|
|
+});
|
|
|
+
|
|
|
+const getDeviceData = () => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ if (!props.info?.deviceQueryVo) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const { id, deviceType } = props.info.deviceQueryVo;
|
|
|
+ const data = await getGroupModuleDevData(id, deviceType);
|
|
|
+
|
|
|
+ data.dataList.forEach((item) => {
|
|
|
+ deviceRealTimeData.value[item.dataCode] = item.value;
|
|
|
+ });
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const updateDeviceData = (paramCode: string, value?: string | number | null) => {
|
|
|
+ handleRequest(async () => {
|
|
|
+ if (!props.info?.deviceQueryVo) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ const { id } = props.info.deviceQueryVo;
|
|
|
+
|
|
|
+ try {
|
|
|
+ if (value !== undefined && value !== null) {
|
|
|
+ await updateGroupModuleDevData(id, paramCode, value);
|
|
|
+ }
|
|
|
+ // eslint-disable-next-line no-useless-catch
|
|
|
+ } catch (err) {
|
|
|
+ throw err;
|
|
|
+ } finally {
|
|
|
+ await waitTime();
|
|
|
+ getDeviceData();
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleDisableEnableSwitch = () => {
|
|
|
+ const { disableEnableStatus } = deviceRealTimeData.value;
|
|
|
+ const title = disableEnableStatus ? t('common.disable') : t('common.enable');
|
|
|
+ const value = disableEnableStatus ? 0 : 1;
|
|
|
+
|
|
|
+ Modal.confirm({
|
|
|
+ title: t('realTimeMonitor.confirmSwitchToMode', { mode: title }),
|
|
|
+ closable: true,
|
|
|
+ centered: true,
|
|
|
+ onOk() {
|
|
|
+ updateDeviceData('disableEnableStatus', value);
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleAutoManualSwitch = () => {
|
|
|
+ const { manualAutoStatus } = deviceRealTimeData.value;
|
|
|
+ const title = manualAutoStatus ? t('common.manual') : t('common.automatic');
|
|
|
+ const content = manualAutoStatus
|
|
|
+ ? t('realTimeMonitor.confirmSwitchToManualTip')
|
|
|
+ : t('realTimeMonitor.confirmSwitchToAutoTip');
|
|
|
+ const value = manualAutoStatus ? 0 : 1;
|
|
|
+
|
|
|
+ Modal.confirm({
|
|
|
+ title: t('realTimeMonitor.confirmSwitchToMode', { mode: title }),
|
|
|
+ content,
|
|
|
+ closable: true,
|
|
|
+ centered: true,
|
|
|
+ onOk() {
|
|
|
+ updateDeviceData('manualAutoStatus', value);
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
+const handleStartStopSwitch = () => {
|
|
|
+ const { startStopOrder } = deviceRealTimeData.value;
|
|
|
+ const title = startStopOrder ? t('common.confirmClose') : t('common.confirmOpen');
|
|
|
+ const value = startStopOrder ? 0 : 1;
|
|
|
+
|
|
|
+ Modal.confirm({
|
|
|
+ title: title + props.info?.deviceQueryVo.deviceName,
|
|
|
+ closable: true,
|
|
|
+ centered: true,
|
|
|
+ onOk() {
|
|
|
+ updateDeviceData('startStopOrder', value);
|
|
|
+ },
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
defineExpose({
|
|
|
showView,
|
|
|
hideView,
|
|
@@ -59,37 +183,55 @@ defineExpose({
|
|
|
>
|
|
|
<template #title>
|
|
|
<div class="dev-ctrl-modal-header">
|
|
|
- <span>{{ '三期-1#冷水主机' }}</span>
|
|
|
+ <span>{{ info?.deviceQueryVo.deviceName }}</span>
|
|
|
<span class="dev-ctrl-modal-operate">
|
|
|
{{ $t('common.viewMore') }}
|
|
|
<SvgIcon name="right" />
|
|
|
</span>
|
|
|
</div>
|
|
|
</template>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.chilledWaterOutletTemperature') }}</span>
|
|
|
- <span>{{ '11.6' }}℃</span>
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.loadRate') }}</span>
|
|
|
- <span>{{ '70.3' }}%</span>
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.activePower') }}</span>
|
|
|
- <span>{{ '102' }}kw</span>
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.localRemoteStatus') }}</span>
|
|
|
- <span>{{ '远程' }}</span>
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.activePower') }}</span>
|
|
|
- <span>{{ '10.99' }}kw</span>
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.runningTime') }}</span>
|
|
|
- <span>{{ '100009.92' }}{{ $t('common.hour') }}</span>
|
|
|
- </div>
|
|
|
+ <template v-if="deviceType === DeviceType.冷水主机">
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.chilledWaterOutletTemperature') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamChillerUnit.冷冻水出水温度] ?? '-' }}℃</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.loadRate') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamChillerUnit.负载率] ?? '-' }}%</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.activePower') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamChillerUnit.有功功率] ?? '-' }}kw</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-if="deviceType === DeviceType.冷却塔">
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.localRemoteStatus') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingTower.本地远程状态] ?? '-' }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.activePower') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingTower.有功功率] ?? '-' }}kw</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.runningTime') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingTower.运行时间] ?? '-' }}{{ $t('common.hour') }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <template v-if="deviceType === DeviceType.冷冻泵 || deviceType === DeviceType.冷却泵">
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.localRemoteStatus') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingPump.本地远程状态] ?? '-' }}</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.activePower') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingPump.有功功率] ?? '-' }}kw</span>
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.runningTime') }}</span>
|
|
|
+ <span>{{ deviceRealTimeData[DevParamCoolingPump.运行时间] ?? '-' }}{{ $t('common.hour') }}</span>
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
<div class="dev-ctrl-modal-separator"></div>
|
|
|
<div class="dev-ctrl-modal-item">
|
|
|
<span></span>
|
|
@@ -100,11 +242,21 @@ defineExpose({
|
|
|
</div>
|
|
|
<div class="dev-ctrl-modal-item">
|
|
|
<span>{{ $t('realTimeMonitor.enableDisable') }}</span>
|
|
|
- <ASwitch />
|
|
|
+ <ASwitch
|
|
|
+ :checked="deviceRealTimeData.disableEnableStatus"
|
|
|
+ :checked-value="1"
|
|
|
+ :un-checked-value="0"
|
|
|
+ @click="handleDisableEnableSwitch"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="dev-ctrl-modal-item">
|
|
|
<span>{{ $t('realTimeMonitor.autoManual') }}</span>
|
|
|
- <ASwitch />
|
|
|
+ <ASwitch
|
|
|
+ :checked="deviceRealTimeData.manualAutoStatus"
|
|
|
+ :checked-value="1"
|
|
|
+ :un-checked-value="0"
|
|
|
+ @click="handleAutoManualSwitch"
|
|
|
+ />
|
|
|
</div>
|
|
|
<div class="dev-ctrl-modal-item">
|
|
|
<span>{{ $t('realTimeMonitor.startStopControl') }}</span>
|
|
@@ -113,17 +265,36 @@ defineExpose({
|
|
|
<template #title>{{ startStopTip }}</template>
|
|
|
<SvgIcon v-show="disableStartStopCtrl" name="info-cirlce-o" />
|
|
|
</ATooltip>
|
|
|
- <ASwitch :disabled="disableStartStopCtrl" />
|
|
|
+ <ASwitch
|
|
|
+ :checked="deviceRealTimeData.startStopOrder"
|
|
|
+ :checked-value="1"
|
|
|
+ :un-checked-value="0"
|
|
|
+ :disabled="disableStartStopCtrl"
|
|
|
+ @click="handleStartStopSwitch"
|
|
|
+ />
|
|
|
</span>
|
|
|
</div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.chilledWaterOutletSetValue') }}</span>
|
|
|
- <AInputNumber class="dev-ctrl-chiller-input" :controls="false" />
|
|
|
- </div>
|
|
|
- <div class="dev-ctrl-modal-item">
|
|
|
- <span>{{ $t('realTimeMonitor.loadRateLimitSetValue') }}</span>
|
|
|
- <AInputNumber class="dev-ctrl-chiller-input" :controls="false" />
|
|
|
- </div>
|
|
|
+ <template v-if="deviceType === DeviceType.冷水主机">
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.chilledWaterOutletSetValue') }}</span>
|
|
|
+ <AInputNumber
|
|
|
+ class="dev-ctrl-chiller-input"
|
|
|
+ v-model:value="deviceRealTimeData[DevParamChillerUnit.冷冻水出水温度设定值]"
|
|
|
+ :controls="false"
|
|
|
+ @change="updateDeviceData(DevParamChillerUnit.冷冻水出水温度设定值, $event)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ <div class="dev-ctrl-modal-item">
|
|
|
+ <span>{{ $t('realTimeMonitor.loadRateLimitSetValue') }}</span>
|
|
|
+ <AInputNumber
|
|
|
+ class="dev-ctrl-chiller-input"
|
|
|
+ v-model:value="deviceRealTimeData[DevParamChillerUnit.负载率限制设定值]"
|
|
|
+ :controls="false"
|
|
|
+ @change="updateDeviceData(DevParamChillerUnit.负载率限制设定值, $event)"
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+ </template>
|
|
|
+ <ASpin v-if="isLoading" class="center-loading" :spinning="true" />
|
|
|
</AModal>
|
|
|
</template>
|
|
|
|