fix: 后台接口对接,问题修复及线上提交测试。
This commit is contained in:
@@ -55,14 +55,13 @@
|
||||
>
|
||||
{{ item.oxyUpperValue ? item.oxyUpperValue : "-" }}Mg/L
|
||||
</view>
|
||||
<nut-switch
|
||||
v-model="item.oxyUpperOpen"
|
||||
:ref="'up' + item.id"
|
||||
active-color="#04D98A"
|
||||
@change="
|
||||
(value, event) => setUpSwitch({ value, event }, item)
|
||||
"
|
||||
/>
|
||||
<view>
|
||||
<nut-switch
|
||||
v-model="item.oxyUpperOpen"
|
||||
active-color="#04D98A"
|
||||
@change="(value, event) => setUpSwitch({ value, event }, item)"
|
||||
/>
|
||||
</view>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
</nut-cell>
|
||||
@@ -85,14 +84,13 @@
|
||||
>
|
||||
{{ item.oxyLowerValue ? item.oxyLowerValue : "-" }}Mg/L
|
||||
</view>
|
||||
<nut-switch
|
||||
v-model="item.oxyLowerOpen"
|
||||
:ref="'lo' + item.id"
|
||||
active-color="#04D98A"
|
||||
@change="
|
||||
(value, event) => setLoSwitch({ value, event }, item)
|
||||
"
|
||||
/>
|
||||
<view>
|
||||
<nut-switch
|
||||
v-model="item.oxyLowerOpen"
|
||||
active-color="#04D98A"
|
||||
@change="(value, event) => setLoSwitch({ value, event }, item)"
|
||||
/>
|
||||
</view>
|
||||
</nut-col>
|
||||
</nut-row>
|
||||
</nut-cell>
|
||||
@@ -487,13 +485,6 @@ const themeVars = ref({
|
||||
cellBorderRadius: "4px",
|
||||
cellBoxShadow: "0px",
|
||||
cellPadding: "26rpx 0px",
|
||||
SwitchWidth: "112rpx",
|
||||
SwitchHeight: "56rpx",
|
||||
SwitchLineHeight: "56rpx",
|
||||
SwitchInsideHeight: "40rpx",
|
||||
SwitchInsideWidth: "40rpx",
|
||||
SwitchInsideOpenTransform: "translateX(155%)",
|
||||
SwitchInsideCloseTransform: "translateX(20%)",
|
||||
});
|
||||
const themeVars2 = ref({
|
||||
cellBoxShadow: "0px 0px 0px 0px",
|
||||
@@ -545,10 +536,18 @@ Taro.useDidShow(() => {
|
||||
// 查询联动控制
|
||||
function getLinksList() {
|
||||
linkerCtrlList({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
console.log('完整返回数据:', JSON.stringify(res, null, 2));
|
||||
if (res.code == 200) {
|
||||
if (res.data) {
|
||||
res.data.forEach((item, index) => {
|
||||
console.log(`联动控制${index + 1}完整数据:`, JSON.stringify(item, null, 2));
|
||||
item.name = "联动控制" + (index + 1);
|
||||
// 调试:查看原始数据
|
||||
console.log('原始数据:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen);
|
||||
// 将后端返回的 0/1 转换为布尔类型 - 强制设置为 true 或 false
|
||||
item.oxyUpperOpen = item.oxyUpperOpen === 1 ? true : false;
|
||||
item.oxyLowerOpen = item.oxyLowerOpen === 1 ? true : false;
|
||||
console.log('转换后:', item.oxyUpperOpen, item.oxyLowerOpen, typeof item.oxyUpperOpen);
|
||||
const switchName: any = [];
|
||||
if (item.listSwitch && item.listSwitch.length > 0) {
|
||||
item.listSwitch.forEach((r: any) => {
|
||||
@@ -559,13 +558,14 @@ function getLinksList() {
|
||||
});
|
||||
}
|
||||
linkList.value = res.data || [];
|
||||
console.log('最终linkList:', JSON.stringify(linkList.value, null, 2));
|
||||
}
|
||||
});
|
||||
}
|
||||
// 开关列表
|
||||
function getSwitchList(type = undefined,id=undefined) {
|
||||
pondSwitchList({ id: pondId }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
if (res.data.length > 0) {
|
||||
res.data.forEach((r) => {
|
||||
if (r.deviceType == 2) {
|
||||
@@ -639,7 +639,7 @@ function remove(name, id) {
|
||||
success: function (res) {
|
||||
if (res.confirm) {
|
||||
delLinkerCtrl({ id }).then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "删除成功";
|
||||
getLinksList();
|
||||
@@ -715,7 +715,7 @@ function addHandler() {
|
||||
if (params.value.id) {
|
||||
updateLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "编辑成功";
|
||||
getLinksList();
|
||||
@@ -728,7 +728,7 @@ function addHandler() {
|
||||
} else {
|
||||
addLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "添加成功";
|
||||
getLinksList();
|
||||
@@ -808,7 +808,7 @@ function setUpSwitch({ value, event }, item: any) {
|
||||
const data = {
|
||||
id: item.id,
|
||||
openType: 1,
|
||||
isOpen: item.oxyUpperOpen,
|
||||
isOpen: item.oxyUpperOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
switchParams.value = data;
|
||||
if (item.oxyUpperOpen) {
|
||||
@@ -823,7 +823,7 @@ function setLoSwitch({ value, event }, item: any) {
|
||||
const data = {
|
||||
id: item.id,
|
||||
openType: 2,
|
||||
isOpen: item.oxyLowerOpen,
|
||||
isOpen: item.oxyLowerOpen ? 1 : 0, // 布尔转数字
|
||||
};
|
||||
switchParams.value = data;
|
||||
if (item.oxyLowerOpen) {
|
||||
@@ -845,12 +845,21 @@ function setSwitchOpenNone() {
|
||||
function setSwitchOpen(data) {
|
||||
setLinkOpen(data)
|
||||
.then((res: any) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
const tag = data.isOpen ? "开启" : "关闭";
|
||||
state.msg = tag + "成功";
|
||||
// 重新加载列表以同步状态
|
||||
getLinksList();
|
||||
} else {
|
||||
// 失败时恢复开关状态
|
||||
getLinksList();
|
||||
}
|
||||
})
|
||||
.catch(() => {
|
||||
// 错误时恢复开关状态
|
||||
getLinksList();
|
||||
})
|
||||
.finally(() => {
|
||||
openAlert.value = false;
|
||||
});
|
||||
@@ -962,7 +971,7 @@ function updateOxy(item) {
|
||||
function upHandler() {
|
||||
updateLinkerCtrl(params.value)
|
||||
.then((res) => {
|
||||
if (res.statusCode == 200) {
|
||||
if (res.code == 200) {
|
||||
state.show = true;
|
||||
state.msg = "编辑成功";
|
||||
getLinksList();
|
||||
|
||||
Reference in New Issue
Block a user