123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387 |
- <script setup lang="ts">
- import { computed, ref, watch } from 'vue';
- import { useRouter } from 'vue-router';
- 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 { DeviceType } from '../device-work-status/device-card';
- import type { EquipmentDetailsItem } from '@/types';
- interface Props {
- info?: EquipmentDetailsItem;
- }
- 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(() => {
- const { isLocale, isAuto, isDisable } = getDeviceStatus();
- return isLocale || isAuto || isDisable;
- });
- const startStopTip = computed(() => {
- const { isLocale, isAuto, isDisable } = getDeviceStatus();
- const tips: string[] = [];
- if (isLocale) {
- tips.push(t('realTimeMonitor.startStopControlTipLocal'));
- }
- if (isAuto) {
- tips.push(t('realTimeMonitor.startStopControlTipAuto'));
- }
- if (isDisable) {
- tips.push(t('realTimeMonitor.startStopControlTipDisable'));
- }
- let tipText = '';
- tips.forEach((item, index) => {
- tipText += `${index + 1}. ${item};\n`;
- });
- 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);
- },
- });
- };
- const router = useRouter();
- const goDevWorkStatus = () => {
- if (!props.info?.deviceQueryVo) {
- return;
- }
- const { id, groupId, deviceType } = props.info.deviceQueryVo;
- router.push({
- path: `/ai-smart-ctrl/device-group/${groupId}`,
- query: {
- tab: 'deviceWorkStatus',
- deviceId: id,
- deviceType,
- r: Date.now(),
- },
- });
- };
- defineExpose({
- showView,
- hideView,
- });
- </script>
- <template>
- <AModal
- v-model:open="visible"
- wrap-class-name="hvac-modal"
- :closable="false"
- :centered="true"
- :width="460"
- :footer="null"
- >
- <template #title>
- <div class="dev-ctrl-modal-header">
- <span>{{ info?.deviceQueryVo.deviceName }}</span>
- <span class="dev-ctrl-modal-operate" @click="goDevWorkStatus">
- {{ $t('common.viewMore') }}
- <SvgIcon name="right" />
- </span>
- </div>
- </template>
- <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>
- <span class="dev-ctrl-modal-operate" @click="$emit('openDevBatchExe')">
- {{ $t('common.batchExecution') }}
- <SvgIcon name="right" />
- </span>
- </div>
- <div class="dev-ctrl-modal-item">
- <span>{{ $t('realTimeMonitor.enableDisable') }}</span>
- <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
- :checked="deviceRealTimeData.manualAutoStatus"
- :checked-value="1"
- :un-checked-value="0"
- @click="handleAutoManualSwitch"
- />
- </div>
- <div class="dev-ctrl-modal-item">
- <span>{{ $t('realTimeMonitor.startStopControl') }}</span>
- <span class="dev-ctrl-modal-start-stop-right">
- <ATooltip overlay-class-name="hvac-tooltip">
- <template #title>{{ startStopTip }}</template>
- <SvgIcon v-show="disableStartStopCtrl" name="info-cirlce-o" />
- </ATooltip>
- <ASwitch
- :checked="deviceRealTimeData.startStopOrder"
- :checked-value="1"
- :un-checked-value="0"
- :disabled="disableStartStopCtrl"
- @click="handleStartStopSwitch"
- />
- </span>
- </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>
- <style lang="scss" scoped>
- .dev-ctrl-modal-header {
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .dev-ctrl-modal-item {
- display: flex;
- align-items: center;
- justify-content: space-between;
- line-height: 24px;
- > span {
- &:first-child {
- color: var(--antd-color-text-secondary);
- }
- &:last-child {
- color: var(--antd-color-text);
- }
- }
- > span.dev-ctrl-modal-operate {
- color: var(--antd-color-primary);
- }
- & + & {
- margin-top: 16px;
- }
- }
- .dev-ctrl-modal-separator {
- margin-block: 16px;
- border: 1px solid #e4e7ed;
- }
- .dev-ctrl-modal-operate {
- display: flex;
- align-items: center;
- font-size: 14px;
- font-weight: 500;
- color: var(--antd-color-primary);
- cursor: pointer;
- i {
- margin-left: 8px;
- font-size: 12px;
- }
- }
- .dev-ctrl-modal-start-stop-right {
- display: flex;
- align-items: center;
- i {
- margin-right: 8px;
- font-size: 12px;
- color: #999;
- }
- }
- .dev-ctrl-chiller-input {
- width: 120px;
- }
- </style>
|