fix: 页面设置错误时,给出提示信息。

This commit is contained in:
tianyongbao
2026-01-20 00:21:44 +08:00
parent 1816d21e40
commit fb6d80f000
4 changed files with 265 additions and 0 deletions

View File

@@ -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();
});
}
}

View File

@@ -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;

View File

@@ -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();
});
}
}

View File

@@ -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();
});
}
}