fix: 联动控制,定时开关功能修改。
This commit is contained in:
@@ -341,6 +341,14 @@
|
||||
>
|
||||
报警设置
|
||||
</nut-button>
|
||||
<nut-button
|
||||
type="primary"
|
||||
class="action-btn"
|
||||
size="small"
|
||||
@click="goLinkControl"
|
||||
>
|
||||
联动控制
|
||||
</nut-button>
|
||||
<nut-button
|
||||
type="primary"
|
||||
class="action-btn"
|
||||
@@ -373,7 +381,10 @@
|
||||
<nut-col :span="24">
|
||||
<nut-row :gutter="10">
|
||||
<nut-col :span="4" :style="{ lineHeight: '60rpx' }">
|
||||
<view class="font_32 f_weight c_22">控制器</view>
|
||||
<view :style="{ display: 'flex', alignItems: 'center', whiteSpace: 'nowrap' }">
|
||||
<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
|
||||
:span="12"
|
||||
@@ -431,9 +442,9 @@
|
||||
{{ item.deviceName }}
|
||||
<view class="error-tag" v-if="item.errorMessage">{{ item.errorMessage }}</view>
|
||||
</view>
|
||||
<view class="controller-actions">
|
||||
<!-- <view class="controller-actions">
|
||||
<view @click.stop="setParamsCtr(item.id)" class="param-setting-link">参数设置</view>
|
||||
</view>
|
||||
</view> -->
|
||||
</view>
|
||||
</nut-col>
|
||||
|
||||
@@ -449,12 +460,15 @@
|
||||
<text class="switch-name">{{ switchItem.switchName }}</text>
|
||||
</view>
|
||||
<view class="switch-right">
|
||||
<nut-switch
|
||||
|
||||
<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
|
||||
:model-value="switchItem.isOpen === 1"
|
||||
active-color="#04D98A"
|
||||
@change="(value, event) => setSwitchOpen({ value, event }, switchItem)"
|
||||
/>
|
||||
<view @click.stop="setSwitch(switchItem.id, switchItem.switchName)" class="switch-setting-link">设置</view>
|
||||
</view>
|
||||
</view>
|
||||
</nut-col>
|
||||
@@ -602,6 +616,53 @@
|
||||
</template>
|
||||
</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>
|
||||
<script setup lang="ts" name="PondInfo">
|
||||
import { IconFont, Loading, RectRight, Uploader } from "@nutui/icons-vue-taro";
|
||||
@@ -617,7 +678,7 @@ import {
|
||||
} from "@/utils/tools";
|
||||
import { defineEmits } from "vue";
|
||||
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";
|
||||
const pond404 = `${imgUrl}zanwurenwu.png`;
|
||||
const setting = `${imgUrl}setting.png`;
|
||||
@@ -737,6 +798,10 @@ const controlInfo = ref<any>({
|
||||
const alertShow = ref(false);
|
||||
const openStatus = ref(0);
|
||||
const keepNightOpen = ref(false);
|
||||
// 开关名称修改相关变量
|
||||
const openSetNameSwitch = ref(false);
|
||||
const switchName = ref<string>('');
|
||||
const switchId = ref<number>();
|
||||
/** -----------------method start----------------- */
|
||||
Taro.useDidShow(() => {
|
||||
const sysInfo = Taro.getSystemInfoSync();
|
||||
@@ -1840,10 +1905,19 @@ function goDeviceInfo() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳转到 wqm 页面,带上 deviceInfo 参数表示跳到设备信息区域
|
||||
Taro.navigateTo({
|
||||
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=deviceInfo`,
|
||||
});
|
||||
// 根据设备类型跳转到不同页面
|
||||
const deviceType = currentDevice.deviceType;
|
||||
if (deviceType == 1) {
|
||||
// 检测器 - 跳转到 wqm 页面
|
||||
Taro.navigateTo({
|
||||
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=deviceInfo`,
|
||||
});
|
||||
} else {
|
||||
// 控制器 - 跳转到 ctr 页面
|
||||
Taro.navigateTo({
|
||||
url: `/home/ctr?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=deviceInfo`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转到报警设置页面(溶解氧配置)
|
||||
@@ -1859,10 +1933,19 @@ function goAlarmSettings() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳转到 wqm 页面,带上 alarmSettings 参数表示跳到溶解氧配置区域
|
||||
Taro.navigateTo({
|
||||
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=alarmSettings`,
|
||||
});
|
||||
// 根据设备类型跳转到不同页面
|
||||
const deviceType = currentDevice.deviceType;
|
||||
if (deviceType == 1) {
|
||||
// 检测器 - 跳转到 wqm 页面
|
||||
Taro.navigateTo({
|
||||
url: `/home/wqm?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=alarmSettings`,
|
||||
});
|
||||
} else {
|
||||
// 控制器 - 跳转到 ctr 页面
|
||||
Taro.navigateTo({
|
||||
url: `/home/ctr?id=${currentDevice.id}&name=${currentDevice.deviceName}&page=home§ion=alarmSettings`,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// 跳转到数据查询页面
|
||||
@@ -1888,11 +1971,114 @@ function goDataQuery() {
|
||||
return;
|
||||
}
|
||||
|
||||
// 跳转到数据查询页面(横屏显示)
|
||||
// 跳转到数据查询页面
|
||||
Taro.navigateTo({
|
||||
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------------------- */
|
||||
defineExpose({
|
||||
getDeviceList,
|
||||
@@ -2203,14 +2389,14 @@ defineExpose({
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
gap: 20rpx;
|
||||
padding: 0 20rpx;
|
||||
gap: 8rpx;
|
||||
padding: 0 10rpx;
|
||||
|
||||
.action-btn {
|
||||
flex: 0 0 auto;
|
||||
width: 180rpx;
|
||||
flex: 1;
|
||||
max-width: 170rpx;
|
||||
height: 70rpx;
|
||||
font-size: 28rpx;
|
||||
font-size: 24rpx;
|
||||
border-radius: 8rpx;
|
||||
background: linear-gradient(135deg, #09b8c2 0%, #06a0a9 100%);
|
||||
border: none;
|
||||
@@ -2218,6 +2404,7 @@ defineExpose({
|
||||
font-weight: 500;
|
||||
box-shadow: 0 4rpx 12rpx rgba(9, 184, 194, 0.3);
|
||||
transition: all 0.3s ease;
|
||||
padding: 0 5rpx;
|
||||
|
||||
&:active {
|
||||
transform: scale(0.95);
|
||||
|
||||
Reference in New Issue
Block a user