From fb6d80f00048d3a9a36bce2b14474e48bffbaf10 Mon Sep 17 00:00:00 2001 From: tianyongbao Date: Tue, 20 Jan 2026 00:21:44 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A1=B5=E9=9D=A2=E8=AE=BE=E7=BD=AE?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E6=97=B6=EF=BC=8C=E7=BB=99=E5=87=BA=E6=8F=90?= =?UTF-8?q?=E7=A4=BA=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/home/ctr.vue | 104 +++++++++++++++++++++++++++++++++++++++ src/home/linkControl.vue | 45 +++++++++++++++++ src/home/switch.vue | 44 +++++++++++++++++ src/home/wqm.vue | 72 +++++++++++++++++++++++++++ 4 files changed, 265 insertions(+) diff --git a/src/home/ctr.vue b/src/home/ctr.vue index 098f46a..8bec9e8 100644 --- a/src/home/ctr.vue +++ b/src/home/ctr.vue @@ -943,8 +943,16 @@ function confirm({ selectedValue, selectedOptions }) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } }) + .catch((error) => { + console.error('[绑定塘口] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }) .finally(() => { showPond.value = false; }); @@ -966,7 +974,16 @@ function changeO2(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -982,7 +999,16 @@ function changeTem(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -1008,7 +1034,14 @@ function setOxyEvent() { state.msg = "设置成功"; deviceInfoRes.value.oxyWarnLower = oxy.value; openSetOxy.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧阈值设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } const setNameEventD = debounce(setNameEvent, 300); @@ -1023,7 +1056,14 @@ function setNameEvent() { state.msg = "设置成功"; deviceInfoRes.value.deviceName = deviceName.value; openSetName.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[设备名称设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } function setTemp() { @@ -1045,7 +1085,14 @@ function setTempEvent() { deviceInfoRes.value.tempWarnUpper = tempUp.value; deviceInfoRes.value.tempWarnLower = tempLower.value; openSetTemp.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度阈值设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } @@ -1083,7 +1130,14 @@ function setNameSwitchEvent() { r.switchName = data.newName; } }); + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[开关名称设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } function cancelSwitchName() { @@ -1126,7 +1180,14 @@ function setSalinity() { state.msg = "设置成功"; deviceInfoRes.value.salinityCompensation = salinity.value; openSalinity.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[盐度设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } //跳转校准页面 @@ -1169,7 +1230,16 @@ function changeTemDis(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度免打扰] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -1189,7 +1259,16 @@ function changeIsOxygenUsed(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧机开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -1205,8 +1284,15 @@ function setTypeEvent() { deviceInfoRes.value.inputVoltage = voltageType.value; openSetType.value = false; } else { + state.show = true; + state.msg = res.msg || "设置失败"; voltageType.value = deviceInfoRes.value.inputVoltage; } + }).catch((error) => { + console.error('[输入端接线方式] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + voltageType.value = deviceInfoRes.value.inputVoltage; }); } function changeV(value, event) { @@ -1219,7 +1305,16 @@ function changeV(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[电压告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -1237,7 +1332,16 @@ function changeOxyDis(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧免打扰] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } diff --git a/src/home/linkControl.vue b/src/home/linkControl.vue index 03967fa..e13d1f7 100644 --- a/src/home/linkControl.vue +++ b/src/home/linkControl.vue @@ -480,6 +480,18 @@ const pond404 = `${imgUrl}zanwurenwu.png`; const instance = Taro.getCurrentInstance(); const id = instance.router.params.id; const pondId = instance.router.params.pondId; + +// 调试日志:检查参数 +console.log('[linkControl] 路由参数:', { id, pondId }); + +if (!id) { + console.error('[linkControl] 警告: 设备ID为空'); +} + +if (!pondId) { + console.error('[linkControl] 警告: 塘口ID为空'); +} + // const pondId = 12; const themeVars = ref({ cellBorderRadius: "4px", @@ -564,6 +576,15 @@ function getLinksList() { } // 开关列表 function getSwitchList(type = undefined,id=undefined) { + console.log('[getSwitchList] 查询参数:', { pondId, type, id }); + + if (!pondId) { + console.error('[getSwitchList] 错误: pondId为空,无法查询开关列表'); + state.show = true; + state.msg = '塑口信息不存在,请返回重试'; + return; + } + pondSwitchList({ id: pondId }).then((res) => { if (res.code == 200) { if (res.data.length > 0) { @@ -720,8 +741,16 @@ function addHandler() { state.msg = "编辑成功"; getLinksList(); return; + } else { + state.show = true; + state.msg = res.msg || "编辑失败"; } }) + .catch((error) => { + console.error('[addHandler] 编辑失败:', error); + state.show = true; + state.msg = "网络错误,编辑失败"; + }) .finally(() => { oncancelUp(); }); @@ -733,8 +762,16 @@ function addHandler() { state.msg = "添加成功"; getLinksList(); return; + } else { + state.show = true; + state.msg = res.msg || "添加失败"; } }) + .catch((error) => { + console.error('[addHandler] 添加失败:', error); + state.show = true; + state.msg = "网络错误,添加失败"; + }) .finally(() => { oncancel(); }); @@ -976,8 +1013,16 @@ function upHandler() { state.msg = "编辑成功"; getLinksList(); return; + } else { + state.show = true; + state.msg = res.msg || "编辑失败"; } }) + .catch((error) => { + console.error('[upHandler] 编辑失败:', error); + state.show = true; + state.msg = "网络错误,编辑失败"; + }) .finally(() => { oncancelUp(); openOxyD.value = false; diff --git a/src/home/switch.vue b/src/home/switch.vue index 9f3d43c..fcb1e38 100644 --- a/src/home/switch.vue +++ b/src/home/switch.vue @@ -433,8 +433,16 @@ function confirm({ selectedValue, selectedOptions }) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } }) + .catch((error) => { + console.error('[绑定塘口] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }) .finally(() => { showPond.value = false; }); @@ -460,7 +468,14 @@ function setVEvent() { state.msg = "设置成功"; switchInfoRes.value.rateElectricValue = V.value; openSetV.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[额定电流设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } // 接电配置 @@ -483,7 +498,14 @@ function setTypeEvent() { state.msg = "设置成功"; switchInfoRes.value.connectVoltageType = voltageType.value; openSetType.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[接线方式设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } // 切换图表日期 @@ -513,7 +535,18 @@ function changeV(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; + // 失败时恢复开关状态 + getSwitchInfo(); } + }).catch((error) => { + console.error('[电压告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + // 失败时恢复开关状态 + getSwitchInfo(); }); } } @@ -527,7 +560,18 @@ function changeE(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; + // 失败时恢复开关状态 + getSwitchInfo(); } + }).catch((error) => { + console.error('[电流告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + // 失败时恢复开关状态 + getSwitchInfo(); }); } } diff --git a/src/home/wqm.vue b/src/home/wqm.vue index fc20a68..f7c79d5 100644 --- a/src/home/wqm.vue +++ b/src/home/wqm.vue @@ -785,8 +785,16 @@ console.log(selectedValue) if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } }) + .catch((error) => { + console.error('[绑定塘口] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }) .finally(() => { showPond.value = false; }); @@ -810,7 +818,16 @@ function changeO2(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -828,7 +845,16 @@ function changeTem(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度告警开关] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -865,7 +891,14 @@ function setOxyEvent() { state.msg = "设置成功"; deviceInfoRes.value.oxyWarnLower = oxy.value; openSetOxy.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧阈值设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } const setNameEventD = debounce(setNameEvent, 300); @@ -881,7 +914,14 @@ function setNameEvent() { openSetName.value = false; // 重新加载设备信息 getDevInfo(); + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[设备名称设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } function setTemp() { @@ -920,7 +960,14 @@ function setTempEvent() { deviceInfoRes.value.tempWarnUpper = tempUp.value; deviceInfoRes.value.tempWarnLower = tempLower.value; openSetTemp.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度阈值设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } // 溶解氧告警 @@ -959,7 +1006,14 @@ function setSalinity() { state.msg = "设置成功"; deviceInfoRes.value.salinityCompensation = salinity.value; openSalinity.value = false; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[盐度设置] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; }); } //跳转校准页面 @@ -981,7 +1035,16 @@ function changeOxyDis(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[溶解氧免打扰] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } } @@ -1000,7 +1063,16 @@ function changeTemDis(value, event) { if (res.code == 200) { state.show = true; state.msg = "设置成功"; + } else { + state.show = true; + state.msg = res.msg || "设置失败"; } + }).catch((error) => { + console.error('[温度免打扰] 失败:', error); + state.show = true; + state.msg = "网络错误,设置失败"; + }).finally(() => { + getDevInfo(); }); } }