fix: java后端接口对接,联调测试问题修改。

This commit is contained in:
tianyongbao
2026-01-15 11:34:03 +08:00
parent f5ddf1e120
commit b1bc6c174c
16 changed files with 216 additions and 126 deletions

View File

@@ -512,6 +512,7 @@
></nut-tour>
<!-- 弹出层提示 -->
<nut-toast :msg="state.msg" v-model:visible="state.show" :type="state.type" />
<nut-config-provider :theme-vars="themeVarsDialog">
<nut-dialog
v-model:visible="visControl"
class="dialog"
@@ -543,32 +544,37 @@
</nut-col>
<nut-col
:span="24"
:style="{ marginTop: '40rpx' }"
v-for="item in controlInfo.listSwitch"
:style="{
marginTop: index === 0 ? '20rpx' : '45rpx',
paddingBottom: '10rpx'
}"
v-for="(item, index) in controlInfo.listSwitch"
:key="item.id"
>
<nut-row :style="{ lineHeight: '30px' }">
<nut-col span="14">
<view class="d_c_title">{{ item.switchName }}</view>
<nut-row :style="{ lineHeight: '50rpx', alignItems: 'center' }">
<nut-col span="10">
<view class="d_c_title" :style="{ whiteSpace: 'nowrap' }">{{ item.switchName }}</view>
</nut-col>
<nut-col
span="10"
span="14"
:style="{
textAlign: 'right',
display: 'flex',
alignItems: 'center',
justifyContent: 'flex-end'
}"
>
<nut-switch
v-model="item.isOpen"
:model-value="item.isOpen === 1"
active-color="#04D98A"
@change="(value, event) => setSwitchOpen({ value, event }, item)"
/>
<view
:style="{
color: '#1589E9',
fontSize: '32rpx',
marginLeft: '10rpx',
fontSize: '28rpx',
marginLeft: '50rpx',
whiteSpace: 'nowrap'
}"
@click="setSwitch(item.id, item.switchName)"
>设置
@@ -576,9 +582,6 @@
</nut-col>
</nut-row>
</nut-col>
<nut-col :span="24">
<nut-divider class="divider" />
</nut-col>
</nut-row>
</view>
<view class="d_btn">
@@ -597,6 +600,7 @@
</view>
</view>
</nut-dialog>
</nut-config-provider>
<!-- 防误触开关提醒 -->
<nut-dialog v-model:visible="alertShow" text-align="left" pop-class="pop-class">
<template #default>
@@ -691,6 +695,13 @@ const themeVarsOther = ref({
switchInsideWidth: "14px",
switchInsideHeight: "14px",
});
// 弹窗开关样式配置,与主页面开关保持一致
const themeVarsDialog = ref({
switchWidth: "36px",
switchHeight: "21px",
switchInsideWidth: "14px",
switchInsideHeight: "14px",
});
// 图表参数
const paramsHistory = ref({
serialNum: "", // 设备序列号
@@ -807,10 +818,7 @@ function getDeviceList() {
}
// 查询塘口下设备列表
pondDeviceInfo({ id }).then((res: any) => {
console.log('塘口设备接口返回:', res);
if (res.code == 200) {
console.log('检测仪列表:', res.data.listDetector);
console.log('控制器列表:', res.data.listController);
setTimeout(() => {
if (
res.data &&
@@ -864,10 +872,9 @@ function getDeviceList() {
}
});
pondDeviceRes.value = res.data;
keepNightOpen.value = res.data.keepNightOpen;
keepNightOpen.value = res.data.keepNightOpen === 1;
doList.value = res.data.listDetector;
controlList.value = res.data.listController;
console.log('赋值后 controlList:', controlList.value);
if (res.data.listDetector && res.data.listDetector.length > 0) {
firstDoId.value = res.data.listDetector[0].id
? res.data.listDetector[0].id
@@ -935,16 +942,11 @@ function changeShow() {
// 全屏显示图表 - 跳转到单独页面
function fullscreenChart() {
console.log('🔍 设备数据结构:', pondDeviceRes.value);
console.log('🔍 当前设备ID:', doDev.value);
// 获取当前设备的 serialNum注意数据结构直接在 pondDeviceRes.value 下,没有 data 字段)
// 获取当前设备的 serialNum
const currentDevice = pondDeviceRes.value?.listDetector?.find(
(item: any) => item.id === doDev.value
);
console.log('🔍 找到的设备:', currentDevice);
if (!currentDevice) {
Taro.showToast({
title: '设备信息不存在',
@@ -953,11 +955,9 @@ function fullscreenChart() {
return;
}
// 尝试多种字段名
const serialNum = currentDevice.serialNum || currentDevice.serialNumber || currentDevice.deviceSerialNum || currentDevice.sn;
if (!serialNum) {
console.error('❗ 设备没有序列号字段,设备信息:', currentDevice);
Taro.showToast({
title: '设备序列号不存在',
icon: 'none'
@@ -965,8 +965,6 @@ function fullscreenChart() {
return;
}
console.log('✅ 跳转参数:', { serialNum, dataType: prDev.value, dayType: dayDev.value });
// 跳转到全屏图表页面
Taro.navigateTo({
url: `/components/other/chartFullscreen?serialNum=${serialNum}&dataType=${prDev.value}&dayType=${dayDev.value}`
@@ -1032,7 +1030,7 @@ function selectCharts(e) {
}
});
pondDeviceRes.value = res.data;
keepNightOpen.value = res.data.keepNightOpen;
keepNightOpen.value = res.data.keepNightOpen === 1; // 将后端的 0/1 转换为布尔值
doList.value = res.data.listDetector;
if (res.data.listDetector && res.data.listDetector.length > 0) {
firstDoId.value = res.data.listDetector[0].id
@@ -1729,19 +1727,26 @@ function setSwitchOpen({ value, event }, item: any) {
if (event) {
const data = {
id: item.id,
isOpen: value,
isOpen: value ? 1 : 0,
};
turnSwitch(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "操作成功";
state.type = "success";
// 立即更新本地状态
item.isOpen = value ? 1 : 0;
} else {
item.isOpen = !value;
state.show = true;
state.msg = res.msg || "设置失败,请重试";
state.type = "fail";
}
})
.finally(() => {
getDeviceList();
.catch((error) => {
state.show = true;
state.msg = "网络错误,请重试";
state.type = "fail";
});
}
}
@@ -1754,20 +1759,42 @@ function changeAllSwitch(e) {
content: `确认设置控制器 ${msg}`,
success: function (res) {
if (res.confirm) {
openStatus.value = e == true ? 1 : 2;
const data = {
id: props.modelValue,
isOpen: e,
isOpen: e ? 1 : 0,
};
turnPondSwitch(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "操作成功";
getDeviceList();
state.type = "success";
// 接口成功后,立即更新本地状态
openStatus.value = e == true ? 1 : 2;
// 立即更新所有控制器下的开关状态
controlList.value.forEach((controller) => {
if (controller.listSwitch && controller.listSwitch.length > 0) {
controller.listSwitch.forEach((switchItem) => {
switchItem.isOpen = e ? 1 : 0;
});
}
});
} else {
// 接口返回失败
state.show = true;
state.msg = res.msg || "设置失败,请重试";
state.type = "fail";
}
})
.finally(() => {});
.catch((error) => {
// 网络错误
state.show = true;
state.msg = "网络错误,请重试";
state.type = "fail";
});
} else if (res.cancel) {
}
},
@@ -1871,14 +1898,23 @@ function submit() {
alertShow.value = false;
const data = {
id: props.modelValue,
isOpen: keepNightOpen.value,
isOpen: keepNightOpen.value ? 1 : 0,
};
setNightProtect(data).then((res) => {
if (res.statusCode == 200) {
state.show = true;
if (res.code == 200) {
state.type = "success";
state.msg = "操作成功";
state.show = true;
// getDeviceList();
} else {
state.type = "fail";
state.msg = res.msg || "设置失败,请重试";
state.show = true;
}
}).catch((error) => {
state.type = "fail";
state.msg = "网络错误,请重试";
state.show = true;
});
}
/** -----------------method end------------------- */