fix: 联动控制,定时开关功能修改。

This commit is contained in:
tianyongbao
2026-01-19 23:52:56 +08:00
parent d1e131f2df
commit ea95dab832
4 changed files with 265 additions and 233 deletions

View File

@@ -341,6 +341,14 @@
> >
报警设置 报警设置
</nut-button> </nut-button>
<nut-button
type="primary"
class="action-btn"
size="small"
@click="goLinkControl"
>
联动控制
</nut-button>
<nut-button <nut-button
type="primary" type="primary"
class="action-btn" class="action-btn"
@@ -373,7 +381,10 @@
<nut-col :span="24"> <nut-col :span="24">
<nut-row :gutter="10"> <nut-row :gutter="10">
<nut-col :span="4" :style="{ lineHeight: '60rpx' }"> <nut-col :span="4" :style="{ lineHeight: '60rpx' }">
<view :style="{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }">
<view class="font_32 f_weight c_22">控制器</view> <view class="font_32 f_weight c_22">控制器</view>
<view :style="{ width: '0', height: '24px', borderLeft: '2px solid #000', margin: '0 8px' }"></view>
</view>
</nut-col> </nut-col>
<nut-col <nut-col
:span="12" :span="12"
@@ -431,9 +442,9 @@
{{ item.deviceName }} {{ item.deviceName }}
<view class="error-tag" v-if="item.errorMessage">{{ item.errorMessage }}</view> <view class="error-tag" v-if="item.errorMessage">{{ item.errorMessage }}</view>
</view> </view>
<view class="controller-actions"> <!-- <view class="controller-actions">
<view @click.stop="setParamsCtr(item.id)" class="param-setting-link">参数设置</view> <view @click.stop="setParamsCtr(item.id)" class="param-setting-link">参数设置</view>
</view> </view> -->
</view> </view>
</nut-col> </nut-col>
@@ -449,12 +460,15 @@
<text class="switch-name">{{ switchItem.switchName }}</text> <text class="switch-name">{{ switchItem.switchName }}</text>
</view> </view>
<view class="switch-right"> <view class="switch-right">
<view @click.stop="setSwitchNameDialog(switchItem.id, switchItem.switchName)" class="switch-setting-link">重命名</view>
<view @click.stop="toTiming(switchItem.id)" class="switch-setting-link">定时</view>
<view @click.stop="setSwitch(switchItem.id, switchItem.switchName)" class="switch-setting-link">设置</view>
<nut-switch <nut-switch
:model-value="switchItem.isOpen === 1" :model-value="switchItem.isOpen === 1"
active-color="#04D98A" active-color="#04D98A"
@change="(value, event) => setSwitchOpen({ value, event }, switchItem)" @change="(value, event) => setSwitchOpen({ value, event }, switchItem)"
/> />
<view @click.stop="setSwitch(switchItem.id, switchItem.switchName)" class="switch-setting-link">设置</view>
</view> </view>
</view> </view>
</nut-col> </nut-col>
@@ -602,6 +616,53 @@
</template> </template>
</nut-dialog> </nut-dialog>
<!-- 开关名称修改弹窗 -->
<nut-config-provider :theme-vars="themeVarsDialog">
<nut-dialog v-model:visible="openSetNameSwitch" text-align="left" no-footer>
<view class="d_body">
<nut-row>
<nut-col :span="24">
<view class="d_title">开关名称设置</view>
</nut-col>
<nut-col :span="24">
<nut-divider class="divider" />
</nut-col>
<nut-col :span="24" class="view_f">
<view :style="{ width: '30%' }" class="font_32 c_444">名称</view>
<view :style="{ width: '70%' }">
<nut-input
v-model="switchName"
placeholder="请输入开关名称"
:border="false"
input-align="right"
clearable
max-length="20"
/>
</view>
</nut-col>
</nut-row>
</view>
<view class="d_btn">
<nut-row>
<nut-col
:span="12"
:style="{ border: '1px solid #eee', color: '#222' }"
@click="cancelSwitchName"
>
取消
</nut-col>
<nut-col
:span="12"
:style="{ border: '1px solid #eee', color: '#15BBC5' }"
@click="setNameSwitchEvent"
>
确定
</nut-col>
</nut-row>
</view>
</nut-dialog>
</nut-config-provider>
</template> </template>
<script setup lang="ts" name="PondInfo"> <script setup lang="ts" name="PondInfo">
import { IconFont, Loading, RectRight, Uploader } from "@nutui/icons-vue-taro"; import { IconFont, Loading, RectRight, Uploader } from "@nutui/icons-vue-taro";
@@ -617,7 +678,7 @@ import {
} from "@/utils/tools"; } from "@/utils/tools";
import { defineEmits } from "vue"; import { defineEmits } from "vue";
import { pondDeviceInfo } from "@/api/pond"; import { pondDeviceInfo } from "@/api/pond";
import { deviceHistory, turnPondSwitch, turnSwitch, setNightProtect } from "@/api/device"; import { deviceHistory, turnPondSwitch, turnSwitch, setNightProtect, updateSwitchName } from "@/api/device";
import { stateType } from "@/utils/types"; import { stateType } from "@/utils/types";
const pond404 = `${imgUrl}zanwurenwu.png`; const pond404 = `${imgUrl}zanwurenwu.png`;
const setting = `${imgUrl}setting.png`; const setting = `${imgUrl}setting.png`;
@@ -737,6 +798,10 @@ const controlInfo = ref<any>({
const alertShow = ref(false); const alertShow = ref(false);
const openStatus = ref(0); const openStatus = ref(0);
const keepNightOpen = ref(false); const keepNightOpen = ref(false);
// 开关名称修改相关变量
const openSetNameSwitch = ref(false);
const switchName = ref<string>('');
const switchId = ref<number>();
/** -----------------method start----------------- */ /** -----------------method start----------------- */
Taro.useDidShow(() => { Taro.useDidShow(() => {
const sysInfo = Taro.getSystemInfoSync(); const sysInfo = Taro.getSystemInfoSync();
@@ -1840,10 +1905,19 @@ function goDeviceInfo() {
return; return;
} }
// 跳转到 wqm 页面,带上 deviceInfo 参数表示跳到设备信息区域 // 根据设备类型跳转到不同页面
const deviceType = currentDevice.deviceType;
if (deviceType == 1) {
// 检测器 - 跳转到 wqm 页面
Taro.navigateTo({ Taro.navigateTo({
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=deviceInfo`, url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=deviceInfo`,
}); });
} else {
// 控制器 - 跳转到 ctr 页面
Taro.navigateTo({
url: `/home/ctr?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=deviceInfo`,
});
}
} }
// 跳转到报警设置页面(溶解氧配置) // 跳转到报警设置页面(溶解氧配置)
@@ -1859,10 +1933,19 @@ function goAlarmSettings() {
return; return;
} }
// 跳转到 wqm 页面,带上 alarmSettings 参数表示跳到溶解氧配置区域 // 根据设备类型跳转到不同页面
const deviceType = currentDevice.deviceType;
if (deviceType == 1) {
// 检测器 - 跳转到 wqm 页面
Taro.navigateTo({ Taro.navigateTo({
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=alarmSettings`, url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=alarmSettings`,
}); });
} else {
// 控制器 - 跳转到 ctr 页面
Taro.navigateTo({
url: `/home/ctr?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home&section=alarmSettings`,
});
}
} }
// 跳转到数据查询页面 // 跳转到数据查询页面
@@ -1888,11 +1971,114 @@ function goDataQuery() {
return; return;
} }
// 跳转到数据查询页面(横屏显示) // 跳转到数据查询页面
Taro.navigateTo({ Taro.navigateTo({
url: `/components/other/dataQuery?serialNum=${serialNum}&dataType=${prDev.value}&deviceName=${currentDevice.deviceName}&oxyWarnLower=${oxyWarnLower.value || ''}&tempWarnUpper=${tempWarnUpper.value || ''}&tempWarnLower=${tempWarnLower.value || ''}`, url: `/components/other/dataQuery?serialNum=${serialNum}&dataType=${prDev.value}&deviceName=${currentDevice.deviceName}&oxyWarnLower=${oxyWarnLower.value || ''}&tempWarnUpper=${tempWarnUpper.value || ''}&tempWarnLower=${tempWarnLower.value || ''}`,
}); });
} }
// 跳转到联动控制页面
function goLinkControl() {
const currentDevice = doList.value.find(
(item: any) => item.id === doDev.value
);
if (!currentDevice) {
state.show = true;
state.msg = '设备信息不存在';
state.type = 'fail';
return;
}
// 获取塘口ID
const pondId = props.modelValue;
if (!pondId) {
state.show = true;
state.msg = '塑口信息不存在';
state.type = 'fail';
return;
}
// 跳转到联动控制页面
Taro.navigateTo({
url: `/home/linkControl?id=${currentDevice.id}&pondId=${pondId}`,
});
}
// 打开开关名称修改弹窗
function setSwitchNameDialog(id: number, name: string) {
openSetNameSwitch.value = true;
switchName.value = name;
switchId.value = id;
}
// 取消开关名称修改
function cancelSwitchName() {
switchName.value = '';
switchId.value = undefined;
openSetNameSwitch.value = false;
}
// 确认修改开关名称
function setNameSwitchEvent() {
if (!switchId.value) {
state.show = true;
state.msg = '开关ID不存在';
state.type = 'fail';
return;
}
if (!switchName.value || switchName.value.trim() === '') {
state.show = true;
state.msg = '请输入开关名称';
state.type = 'fail';
return;
}
const data = {
id: switchId.value,
newName: switchName.value,
};
updateSwitchName(data).then((res) => {
if (res.code == 200) {
state.show = true;
state.msg = '设置成功';
state.type = 'success';
openSetNameSwitch.value = false;
// 更新列表中的开关名称
controlList.value.forEach((controller: any) => {
if (controller.listSwitch) {
controller.listSwitch.forEach((switchItem: any) => {
if (switchItem.id === data.id) {
switchItem.switchName = data.newName;
}
});
}
});
// 刷新设备列表
getDeviceList();
} else {
state.show = true;
state.msg = res.msg || '设置失败';
state.type = 'fail';
}
}).catch((error) => {
state.show = true;
state.msg = '网络错误,请重试';
state.type = 'fail';
});
}
// 跳转到定时页面
function toTiming(switchId: number) {
Taro.navigateTo({
url: `/home/timing?id=${switchId}`,
});
}
/** -----------------method end------------------- */ /** -----------------method end------------------- */
defineExpose({ defineExpose({
getDeviceList, getDeviceList,
@@ -2203,14 +2389,14 @@ defineExpose({
display: flex; display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
gap: 20rpx; gap: 8rpx;
padding: 0 20rpx; padding: 0 10rpx;
.action-btn { .action-btn {
flex: 0 0 auto; flex: 1;
width: 180rpx; max-width: 170rpx;
height: 70rpx; height: 70rpx;
font-size: 28rpx; font-size: 24rpx;
border-radius: 8rpx; border-radius: 8rpx;
background: linear-gradient(135deg, #09b8c2 0%, #06a0a9 100%); background: linear-gradient(135deg, #09b8c2 0%, #06a0a9 100%);
border: none; border: none;
@@ -2218,6 +2404,7 @@ defineExpose({
font-weight: 500; font-weight: 500;
box-shadow: 0 4rpx 12rpx rgba(9, 184, 194, 0.3); box-shadow: 0 4rpx 12rpx rgba(9, 184, 194, 0.3);
transition: all 0.3s ease; transition: all 0.3s ease;
padding: 0 5rpx;
&:active { &:active {
transform: scale(0.95); transform: scale(0.95);

View File

@@ -5,7 +5,8 @@
<nut-config-provider :theme-vars="themeVars"> <nut-config-provider :theme-vars="themeVars">
<view class="body"> <view class="body">
<nut-row> <nut-row>
<nut-col :span="24"> <!-- 设备信息区域 -->
<nut-col :span="24" v-if="!section || section === 'deviceInfo'">
<nut-cell class="ctr_body"> <nut-cell class="ctr_body">
<nut-row> <nut-row>
<nut-col :span="24" class="title"> 设备信息 </nut-col> <nut-col :span="24" class="title"> 设备信息 </nut-col>
@@ -68,10 +69,41 @@
</nut-cell> </nut-cell>
</nut-cell-group> </nut-cell-group>
</nut-col> </nut-col>
<!-- 盐度设置和设备校准 -->
<nut-col :span="24">
<nut-cell-group>
<nut-cell title="盐度设置" is-link @click="setSalFunc">
<template #desc>
<text class="desc"
>{{ deviceInfoRes.salinityCompensation }}</text
>
</template>
</nut-cell>
<nut-cell title="设备校准" is-link @click="toCalibration" />
</nut-cell-group>
</nut-col>
<!-- 将解除绑定按钮移到设备信息区域内 -->
<nut-col :span="24" :style="{ marginTop: '20rpx' }">
<nut-button
block
shape="square"
size="large"
color="#E22323"
:style="{
fontWeight: 'bold',
fontSize: '14px !important',
borderRadius: '10px',
}"
@click="unbind"
v-if="Uid == rootuserid"
>解除绑定</nut-button
>
</nut-col>
</nut-row> </nut-row>
</nut-cell> </nut-cell>
</nut-col> </nut-col>
<nut-col :span="24"> <!-- 开关配置区域 -->
<nut-col :span="24" v-if="!section">
<nut-cell class="ctr_body"> <nut-cell class="ctr_body">
<nut-row> <nut-row>
<!-- <nut-col :span="24" class="view_f_between"> <!-- <nut-col :span="24" class="view_f_between">
@@ -123,7 +155,8 @@
</nut-row> </nut-row>
</nut-cell> </nut-cell>
</nut-col> </nut-col>
<nut-col :span="24"> <!-- 溶解氧配置区域报警设置 -->
<nut-col :span="24" v-if="!section || section === 'alarmSettings'">
<nut-cell class="ctr_body"> <nut-cell class="ctr_body">
<nut-row> <nut-row>
<nut-col :span="24" class="view_f_between"> <nut-col :span="24" class="view_f_between">
@@ -314,128 +347,12 @@
</nut-col> </nut-col>
</nut-row> </nut-row>
</nut-cell> </nut-cell>
<nut-cell> <!-- 联动控制已隐藏 -->
<nut-row>
<nut-col
:span="24"
:style="{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}"
>
<view class="title">联动控制</view>
<view class="ils" @click="openLink">联动设置</view>
</nut-col>
<nut-col
:span="24"
v-if="deviceInfoRes.listLinkedCtr.length > 0"
>
<!-- 绘制表格 -->
<view class="m_t_15">
<view class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></view>
<view
class="table-cell"
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
联动{{ index + 1 }}
</view>
</view>
<!-- 上限行 -->
<view class="table-row">
<view class="table-cell table-label">上限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'up_' + item.id"
>
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 下限行 -->
<view class="table-row">
<view class="table-cell table-label">下限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'low_' + item.id"
>
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 开关行 -->
<view class="table-row">
<view class="table-cell table-label">开关</view>
<view
class="table-cell table-switch"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'sw_' + item.id"
>
<view class="switch-names">
<view
class="switch-name"
v-for="(sw, idx) in item.listSwitch"
:key="sw.id"
>
{{ sw.switchName }}
</view>
</view>
</view>
</view>
</view>
</view>
</nut-col>
</nut-row>
</nut-cell>
<nut-cell title="盐度设置" is-link @click="setSalFunc">
<template #desc>
<text class="desc"
>{{ deviceInfoRes.salinityCompensation }}</text
>
</template>
</nut-cell>
<nut-cell title="设备校准" is-link @click="toCalibration" />
</nut-cell-group> </nut-cell-group>
</nut-col> </nut-col>
</nut-row> </nut-row>
</nut-cell> </nut-cell>
</nut-col> </nut-col>
<!-- <nut-col :span="24" :style="{ marginBottom: '20rpx' }">
<nut-button
block
shape="square"
size="large"
color="#E22323"
plain
:style="{
fontWeight: 'bold',
fontSize: '14px !important',
borderRadius: '10px',
}"
@click="removeDev"
>移除设备</nut-button
>
</nut-col> -->
<nut-col :span="24">
<nut-button
block
shape="square"
size="large"
color="#E22323"
:style="{
fontWeight: 'bold',
fontSize: '14px !important',
borderRadius: '10px',
}"
@click="unbind"
v-if="Uid == rootuserid"
>解除绑定</nut-button
>
</nut-col>
</nut-row> </nut-row>
</view> </view>
</nut-config-provider> </nut-config-provider>
@@ -838,6 +755,7 @@ const instance = Taro.getCurrentInstance();
const id = instance.router.params.id; const id = instance.router.params.id;
const name = instance.router.params.name; const name = instance.router.params.name;
const page = instance.router.params.page; const page = instance.router.params.page;
const section = instance.router.params.section; // 获取区域参数
const r_v = `${imgUrl}r_v.png`; const r_v = `${imgUrl}r_v.png`;
// const id = 5 // const id = 5
// const name = undefined // const name = undefined

View File

@@ -126,7 +126,7 @@
</nut-row> </nut-row>
</nut-cell> </nut-cell>
</nut-col> --> </nut-col> -->
<nut-col :span="24"> <!-- <nut-col :span="24">
<nut-button <nut-button
block block
shape="square" shape="square"
@@ -141,7 +141,7 @@
@click="toTiming" @click="toTiming"
>定时</nut-button >定时</nut-button
> >
</nut-col> </nut-col> -->
</nut-row> </nut-row>
</view> </view>
</nut-config-provider> </nut-config-provider>

View File

@@ -64,6 +64,23 @@
</nut-cell> </nut-cell>
</nut-cell-group> </nut-cell-group>
</nut-col> </nut-col>
<!-- 盐度设置和设备校准 -->
<nut-col :span="24">
<nut-cell-group>
<nut-cell title="盐度设置" is-link @click="setSalFunc">
<template #desc>
<text class="desc"
>{{ deviceInfoRes.salinityCompensation }}</text
>
</template>
</nut-cell>
<nut-cell
title="设备校准"
is-link
@click="toCalibration"
/>
</nut-cell-group>
</nut-col>
<!-- 将解除绑定按钮移到设备信息区域内 --> <!-- 将解除绑定按钮移到设备信息区域内 -->
<nut-col :span="24" :style="{ marginTop: '20rpx' }"> <nut-col :span="24" :style="{ marginTop: '20rpx' }">
<nut-button <nut-button
@@ -260,97 +277,7 @@
</nut-col> </nut-col>
</nut-row> </nut-row>
</nut-cell> </nut-cell>
<nut-cell> <!-- 联动控制已隐藏 -->
<nut-row>
<nut-col
:span="24"
:style="{
display: 'flex',
alignItems: 'center',
justifyContent: 'space-between',
}"
>
<view class="title">联动控制</view>
<view class="ils" @click="openLink"
>联动设置</view
>
</nut-col>
<nut-col
:span="24"
v-if="deviceInfoRes.listLinkedCtr.length > 0"
>
<!-- 绘制表格 -->
<view class="m_t_15">
<view class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></view>
<view
class="table-cell"
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
联动{{ index + 1 }}
</view>
</view>
<!-- 上限行 -->
<view class="table-row">
<view class="table-cell table-label">上限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'up_' + item.id"
>
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 下限行 -->
<view class="table-row">
<view class="table-cell table-label">下限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'low_' + item.id"
>
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 开关行 -->
<view class="table-row">
<view class="table-cell table-label">开关</view>
<view
class="table-cell table-switch"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'sw_' + item.id"
>
<view class="switch-names">
<view
class="switch-name"
v-for="(sw, idx) in item.listSwitch"
:key="sw.id"
>
{{ sw.switchName }}
</view>
</view>
</view>
</view>
</view>
</view>
</nut-col>
</nut-row>
</nut-cell>
<nut-cell title="盐度设置" is-link @click="setSalFunc">
<template #desc>
<text class="desc"
>{{ deviceInfoRes.salinityCompensation }}</text
>
</template>
</nut-cell>
<nut-cell
title="设备校准"
is-link
@click="toCalibration"
/>
</nut-cell-group> </nut-cell-group>
</nut-col> </nut-col>
</nut-row> </nut-row>