fix: 后台接口对接,问题修复及线上提交测试。

This commit is contained in:
tianyongbao
2026-01-14 08:29:38 +08:00
parent 6d1a6ded2d
commit f5ddf1e120
16 changed files with 1316 additions and 810 deletions

1
components.d.ts vendored
View File

@@ -7,6 +7,7 @@ export {}
declare module 'vue' {
export interface GlobalComponents {
ChartFullscreen: typeof import('./src/components/other/chartFullscreen.vue')['default']
CustomNavigationBar: typeof import('./src/components/custom-navigation-bar/index.vue')['default']
Fish: typeof import('./src/components/other/fish.vue')['default']
NutBadge: typeof import('@nutui/nutui-taro')['Badge']

View File

@@ -31,7 +31,6 @@ const API_PATHS = {
},
// 获取短信验证码
SMS_CODE: {
v1: '/resource/sms/code',
v2: '/resource/sms/code',
},
// 微信手机号登录
@@ -50,23 +49,19 @@ const API_PATHS = {
HOME: {
// 塘口列表模式1
POND_LIST: {
v1: '/fishery/pond/list',
v2: '/fishery/pond/list_mode1',
},
// 塘口列表模式2
POND_LIST_MODE2: {
v1: '/api/pond/list_mode2',
v2: '/fishery/pond/list/mode2',
v2: '/fishery/pond/list_mode2',
},
// 公告列表
NOTICE_LIST: {
v1: '/api/sys-notice/notice_list',
v2: '/fishery/notice/list',
v2: '/system/notice/list',
},
// 即将到期设备列表
DEVICE_DEAD: {
v1: '/api/device/list_device_dead',
v2: '/fishery/device/expiring',
v2: '/fishery/device/list_device_dead',
},
// 获取设备票据
DEVICE_TICKET: {
@@ -99,12 +94,10 @@ const API_PATHS = {
},
// 塘口下设备信息
DEVICE_INFO: {
v1: '/api/pond/pond_device_info',
v2: '/fishery/pond/devices',
},
// 将设备及开关绑定到塘口
BIND_DEVICE: {
v1: '/api/pond/select_device_switch',
v2: '/fishery/pond/bind/device',
},
// 夜间防误触
@@ -118,42 +111,34 @@ const API_PATHS = {
DEVICE: {
// 设备列表
LIST_ALL: {
v1: '/api/device/list_all_device',
v2: '/fishery/device/list_all_device',
},
// 设备详情
INFO: {
v1: '/api/device/one_device_info',
v2: '/fishery/device/info',
v2: '/fishery/device/one_device_info',
},
// 解除绑定
UNBIND: {
v1: '/api/device/break_pond',
v2: '/fishery/device/unbind',
v2: '/fishery/device/break_pond',
},
// 设备图表数据
HISTORY: {
v1: '/api/device/data_history',
v2: '/fishery/device/history',
v2: '/td/device/getHistoryData',
},
// 修改设备名称
UPDATE_NAME: {
v1: '/api/device/update_name',
v2: '/fishery/device/name',
v2: '/fishery/device/update_name',
},
// 修改设备关联塘口
UPDATE_POND: {
v1: '/api/device/update_pond',
v2: '/fishery/device/pond',
v2: '/fishery/pond/update_pond',
},
// 修改设备接电方式
UPDATE_VOLTAGE: {
v1: '/api/device/update_voltage_type',
v2: '/fishery/device/voltage',
v2: '/iot/device/voltage_type',
},
// 删除设备
DELETE: {
v1: '/api/device/delete',
v2: '/fishery/device',
},
// 扫描设备编码
@@ -167,13 +152,11 @@ const API_PATHS = {
},
// 盐度设置
SET_SALINITY: {
v1: '/api/device/detector_salinitycompensation',
v2: '/fishery/device/salinity',
v2: '/iot/device/salinity-compensation',
},
// 设备校准
CALIBRATE: {
v1: '/api/device/detector_calibrate',
v2: '/fishery/device/calibrate',
v2: '/iot/device/calibrate',
},
// 添加水质检测仪
ADD_DETECTOR: {
@@ -181,38 +164,31 @@ const API_PATHS = {
},
// 设置溶解氧/水温告警
SET_WARN_CALL: {
v1: '/api/device/set_oxy_warn_call',
v2: '/fishery/device/warn/call',
v2: '/fishery/device/set_oxy_warn_call',
},
// 设置溶解氧上下限
SET_OXY_WARN: {
v1: '/api/device/set_oxy_warn_value',
v2: '/fishery/device/warn/oxy',
v2: '/fishery/device/set_oxy_warn_value',
},
// 设置温度上下限
SET_TEMP_WARN: {
v1: '/api/device/set_temp_warn_value',
v2: '/fishery/device/warn/temp',
v2: '/fishery/device/set_temp_warn_value',
},
// 溶解氧饱和度
GET_SATURABILITY: {
v1: '/api/device/get_saturability',
v2: '/fishery/device/saturability',
v2: '/fishery/device/get_saturability',
},
// 添加控制一体机
ADD_CONTROLLER: {
v1: '/api/device/add_device_controller',
v2: '/iot/device/add_device_controller',
},
// 启停溶解氧
SET_OXY_OPEN: {
v1: '/api/device/set_controller_oxy_open',
v2: '/fishery/device/oxy/switch',
v2: '/fishery/device/set_controller_oxy_open',
},
// 电压告警开关
VOLTAGE_CHECK: {
v1: '/api/device/voltage_check_open',
v2: '/fishery/device/voltage/check',
v2: '/fishery/device/voltage_check_open',
},
},
@@ -220,28 +196,23 @@ const API_PATHS = {
LINKED_CTRL: {
// 设备控制器列表
LIST: {
v1: '/api/linked-ctrl/fetch',
v2: '/fishery/linked-ctrl/list',
v2: '/fishery/linkedCtrl/fetch',
},
// 添加联动控制
ADD: {
v1: '/api/linked-ctrl/add',
v2: '/fishery/linked-ctrl',
v2: '/fishery/linkedCtrl/add',
},
// 修改联动控制
UPDATE: {
v1: '/api/linked-ctrl/update',
v2: '/fishery/linked-ctrl',
v2: '/fishery/linkedCtrl/update',
},
// 删除联动控制
DELETE: {
v1: '/api/linked-ctrl/delete',
v2: '/fishery/linked-ctrl',
v2: '/fishery/linkedCtrl',
},
// 设置联动控制上下限开关
SET_OPEN: {
v1: '/api/linked-ctrl/set_open',
v2: '/fishery/linked-ctrl/switch',
v2: '/fishery/linkedCtrl/set_open',
},
},
@@ -249,48 +220,39 @@ const API_PATHS = {
SWITCH: {
// 开关列表
POND_LIST: {
v1: '/api/device-switch/get_pond_switch',
v2: '/fishery/switch/list',
v2: '/fishery/deviceSwitch/get_pond_switch',
},
// 开关详情
INFO: {
v1: '/api/device-switch/one_switch_info',
v2: '/fishery/switch/info',
v2: '/fishery/deviceSwitch/one_switch_info',
},
// 修改开关名称
UPDATE_NAME: {
v1: '/api/device-switch/update_name',
v2: '/fishery/switch/name',
v2: '/fishery/deviceSwitch/update_name',
},
// 修改关联塘口
UPDATE_POND: {
v1: '/api/device-switch/update_pond',
v2: '/fishery/switch/pond',
v2: '/iot/switch/update_pond',
},
// 修改接线方式
UPDATE_VOLTAGE: {
v1: '/api/device-switch/update_voltage_type',
v2: '/fishery/switch/voltage',
v2: '/iot/switch/update_voltage_type',
},
// 单个开关启停
TURN: {
v1: '/api/device-switch/turn_switch',
v2: '/fishery/switch/turn',
v2: '/iot/switch/turn_switch',
},
// 所有开关启停
TURN_POND: {
v1: '/api/device-switch/turn_pond_switch',
v2: '/fishery/switch/turn/all',
v2: '/iot/switch/turn_pond_switch',
},
// 电流告警开关
ELECTRIC_CHECK: {
v1: '/api/device-switch/electric_check_open',
v2: '/fishery/switch/electric/check',
v2: '/fishery/deviceSwitch/electric_check_open',
},
// 电流告警设置
ELECTRIC_SET: {
v1: '/api/device-switch/electric_set',
v2: '/fishery/switch/electric/set',
v2: '/iot/switch/electric_set',
},
},

View File

@@ -1,5 +1,6 @@
import httpService from '@/utils/request'
import API from './config'
import Taro from '@tarojs/taro'
/** 设备相关接口---------------------------------------- */
// 设备列表
@@ -8,27 +9,31 @@ export function allDeviceList(params) {
}
// 设备详情
export function deviceInfo(data){
return httpService.post(API.DEVICE.INFO(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.INFO()}?rootUserId=${userId}`, {data})
}
// 解除绑定
export function deviceUnbind(data){
return httpService.post(API.DEVICE.UNBIND(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.UNBIND()}?rootUserId=${userId}`, {data})
}
// 将设备及开关绑定到塘口
export function bandDeviceToPond(data){
return httpService.put(API.POND.BIND_DEVICE(), {data})
}
// 设备图表数据
export function deviceHistory(data){
return httpService.post(API.DEVICE.HISTORY(), {data})
export function deviceHistory(params){
return httpService.get(API.DEVICE.HISTORY(), {params})
}
// 修改设备名称
export function deviceUpdateName(data){
return httpService.put(API.DEVICE.UPDATE_NAME(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.UPDATE_NAME()}?rootUserId=${userId}`, {data})
}
// 修改设备关联塘口
export function deviceUpdatePond(data){
return httpService.put(API.DEVICE.UPDATE_POND(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.UPDATE_POND()}?rootUserId=${userId}`, {data})
}
// 修改设备接电方式
export function deviceUpdateV(data){
@@ -36,7 +41,8 @@ export function deviceUpdateV(data){
}
// 删除设备
export function deviceDel(data){
return httpService.delete(API.DEVICE.DELETE(), {data})
// 后端需要 /{ids} 路径参数,传入 ID 数组
return httpService.delete(`${API.DEVICE.DELETE()}/${data.id}`)
}
// 扫描设备编码
export function deviceScan(params){
@@ -61,15 +67,18 @@ export function addDeviceDetector(data) {
}
// 设置溶解氧/水温告警
export function setWarnCall(data){
return httpService.post(API.DEVICE.SET_WARN_CALL(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.post(`${API.DEVICE.SET_WARN_CALL()}?rootUserId=${userId}`, {data})
}
// 设置溶解氧上下限
export function setOxyWarn(data){
return httpService.put(API.DEVICE.SET_OXY_WARN(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_OXY_WARN()}?rootUserId=${userId}`, {data})
}
// 设置温度上下限
export function setTempWarn(data){
return httpService.put(API.DEVICE.SET_TEMP_WARN(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_TEMP_WARN()}?rootUserId=${userId}`, {data})
}
// 溶解氧饱和度
export function getSaturability(data){
@@ -82,7 +91,8 @@ export function addDeviceController(data) {
}
// 启停溶解氧
export function setOxyOpen(data){
return httpService.put(API.DEVICE.SET_OXY_OPEN(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.SET_OXY_OPEN()}?rootUserId=${userId}`, {data})
}
/** 联动控制------------------------------------- */
// 设备控制器列表
@@ -99,7 +109,9 @@ export function updateLinkerCtrl(data){
}
// 删除联动控制
export function delLinkerCtrl(data){
return httpService.delete(API.LINKED_CTRL.DELETE(), {data})
const userId = Taro.getStorageSync('UserId');
// 后端需要 /{ids} 路径参数
return httpService.delete(`${API.LINKED_CTRL.DELETE()}/${data.id}?rootUserId=${userId}`)
}
// 设置联动控制上下限开关
export function setLinkOpen(data){
@@ -137,7 +149,8 @@ export function turnPondSwitch(data){
// 电压告警开关 开启或关闭
export function voltageCheckOpen(data){
return httpService.put(API.DEVICE.VOLTAGE_CHECK(), {data})
const userId = Taro.getStorageSync('UserId');
return httpService.put(`${API.DEVICE.VOLTAGE_CHECK()}?rootUserId=${userId}`, {data})
}
// 电流告警开关 开启或关闭
export function electricCheckOpen(data){

View File

@@ -14,7 +14,12 @@ export function getPond1() {
// 塘口模式2
export function getPond2(){
return httpService.get(API.HOME.POND_LIST_MODE2())
const userId = Taro.getStorageSync("UserId");
return httpService.get(API.HOME.POND_LIST_MODE2(), {
params: {
rootUserId: userId || undefined
}
});
}
// 公告列表
@@ -24,7 +29,12 @@ export function noticeList(){
// 即将到期设备列表
export function deviceDead(){
return httpService.get(API.HOME.DEVICE_DEAD())
const userId = Taro.getStorageSync("UserId");
return httpService.get(API.HOME.DEVICE_DEAD(), {
params: {
rootUserId: userId || undefined
}
});
}
// 获取设备票据

View File

@@ -5,6 +5,7 @@ export default defineAppConfig({
'pages/main/home',
'pages/msg/index',
'pages/main/my',
'components/other/chartFullscreen',
],
requiredPrivateInfos: [
"getLocation", "chooseLocation"

View File

@@ -0,0 +1,5 @@
export default definePageConfig({
navigationBarTitleText: '曲线图',
navigationStyle: 'custom',
enablePullDownRefresh: false,
})

View File

@@ -0,0 +1,388 @@
<template>
<view class="chart-fullscreen-page">
<!-- 顶部标题栏 -->
<view class="header">
<view class="back-btn" @click="goBack">
<text class="icon"></text>
</view>
<view class="title">{{ chartTitle }}</view>
</view>
<!-- 时间选择 -->
<view class="time-selector">
<view
class="time-item"
:class="{ active: dayType === 1 }"
@click="changeDay(1)"
>
1
</view>
<view
class="time-item"
:class="{ active: dayType === 3 }"
@click="changeDay(3)"
>
3
</view>
<view
class="time-item"
:class="{ active: dayType === 7 }"
@click="changeDay(7)"
>
7
</view>
</view>
<!-- 图表容器 -->
<view class="chart-container">
<canvas
class="chart-canvas"
canvas-id="fullscreen-chart"
id="fullscreen-chart"
></canvas>
</view>
</view>
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted } from 'vue';
import Taro from '@tarojs/taro';
import { deviceHistory } from '@/api/device';
import { formatDateMin } from '@/utils/tools';
import uCharts from '@/utils/js-sdk/u-charts/u-charts.js';
const dayType = ref(1);
const chartTitle = ref('溶解氧曲线图');
const chartData = ref<any[]>([]);
let chartInstance: any = null;
// 接收的参数
const serialNum = ref('');
const dataType = ref(1); // 1-溶解氧, 2-水温, 3-饱和度, 4-PH, 5-盐度
onMounted(() => {
// 获取页面参数
const instance = Taro.getCurrentInstance();
const params = instance.router?.params || {};
serialNum.value = params.serialNum || '';
dataType.value = Number(params.dataType) || 1;
dayType.value = Number(params.dayType) || 1;
// 设置标题
const titles = ['', '溶解氧曲线图', '水温曲线图', '饱和度曲线图', 'PH曲线图', '盐度曲线图'];
chartTitle.value = titles[dataType.value] || '曲线图';
// 初始化图表
setTimeout(() => {
initChart();
}, 500);
});
onUnmounted(() => {
if (chartInstance) {
chartInstance = null;
}
});
// 初始化图表
function initChart() {
// 横屏后的尺寸计算:
// 页面宽度 = 屏幕高度100vh
// 页面高度 = 屏幕宽度100vw
// header(50px) + time-selector(50px) = 100px
const screenWidth = window.innerWidth; // 屏幕宽度
const screenHeight = window.innerHeight; // 屏幕高度
// 横屏后:
const cWidth = screenHeight - 40; // 页面宽度(100vh) - padding
const cHeight = screenWidth - 120; // 页面高度(100vw) - header - time-selector - padding
console.log('📊 横屏图表尺寸计算:', {
屏幕宽: screenWidth,
屏幕高: screenHeight,
图表宽: cWidth,
图表高: cHeight
});
// 加载数据
loadChartData(cWidth, cHeight, 1);
}
// 返回上一页
function goBack() {
Taro.navigateBack();
}
// 返回首页
function goHome() {
Taro.switchTab({
url: '/pages/main/home'
});
}
// 切换天数
function changeDay(day: number) {
dayType.value = day;
// 重新计算尺寸
const screenWidth = window.innerWidth;
const screenHeight = window.innerHeight;
const cWidth = screenHeight - 40;
const cHeight = screenWidth - 120;
loadChartData(cWidth, cHeight, 1);
}
// 加载图表数据
function loadChartData(cWidth: number, cHeight: number, pixelRatio: number) {
if (!serialNum.value) return;
const now = new Date();
const start = new Date(now.getTime() - dayType.value * 24 * 60 * 60 * 1000);
const params = {
serialNum: serialNum.value,
startTime: formatDateMin(start),
endTime: formatDateMin(now),
intervalType: dayType.value === 1 ? 1 : dayType.value === 3 ? 2 : 3,
};
Taro.showLoading({ title: '加载中...' });
deviceHistory(params).then((res: any) => {
Taro.hideLoading();
if (Array.isArray(res)) {
chartData.value = res;
} else if (res.code == 200) {
chartData.value = res.data || [];
}
// 绘制图表
drawChart(cWidth, cHeight, pixelRatio);
}).catch(() => {
Taro.hideLoading();
});
}
// 绘制图表
function drawChart(cWidth: number, cHeight: number, pixelRatio: number) {
if (!chartData.value || chartData.value.length === 0) {
console.log('❌ 数据为空');
return;
}
const fieldMap: any = {
1: 'dissolvedOxygen',
2: 'temperature',
3: 'saturability',
4: 'ph',
5: 'salinity',
};
const nameMap: any = {
1: '溶解氧',
2: '水温',
3: '饱和度',
4: 'PH',
5: '盐度',
};
const fieldName = fieldMap[dataType.value] || 'dissolvedOxygen';
const seriesName = nameMap[dataType.value] || '溶解氧';
const xAxisData: string[] = [];
const seriesData: number[] = [];
chartData.value.forEach((item: any) => {
const timeStr = item.time || item.createTime || '';
const timeParts = timeStr.split(' ');
if (timeParts.length > 1) {
const datePart = timeParts[0]; // YYYY-MM-DD
const timePart = timeParts[1]; // HH:mm:ss.0
// 提取 MM-DD HH:mm
const dateMatch = datePart.match(/\d{4}-(\d{2})-(\d{2})/);
const monthDay = dateMatch ? `${dateMatch[1]}-${dateMatch[2]}` : '';
const hourMin = timePart.substring(0, 5); // HH:mm
const formattedTime = `${monthDay} ${hourMin}`;
xAxisData.push(formattedTime);
}
const value = item[fieldName];
seriesData.push(value !== null && value !== undefined ? Number(value) : 0);
});
// H5 环境,延迟获取 Canvas 确保 DOM 渲染完成
setTimeout(() => {
// Taro 在 H5 下会在容器内部生成 <canvas> 标签
const canvasElement = document.querySelector('#fullscreen-chart canvas') as HTMLCanvasElement;
if (!canvasElement) {
console.error('❌ Canvas 元素未找到');
console.log('尝试查找所有 canvas...');
const allCanvas = document.querySelectorAll('canvas');
console.log('页面中所有 canvas:', allCanvas);
return;
}
console.log('✅ 找到 Canvas 元素:', canvasElement);
const ctx = canvasElement.getContext('2d');
if (!ctx) {
console.error('❌ 无法获取 Canvas Context');
return;
}
console.log('✅ 获取 Context 成功');
chartInstance = new uCharts({
type: 'line',
context: ctx,
width: cWidth,
height: cHeight,
categories: xAxisData,
series: [
{
name: seriesName,
data: seriesData,
}
],
pixelRatio: 1,
dataPointShape: false,
animation: true,
background: '#FFFFFF',
color: ['#1890FF'],
padding: [15, 30, 35, 45],
enableScroll: false,
boundaryGap: 'justify',
legend: {
show: false
},
dataLabel: false,
xAxis: {
disableGrid: true,
axisLine: true,
type: 'grid',
gridType: 'dash',
itemCount: 0,
scrollShow: false,
scrollAlign: 'left',
labelCount: 10,
rotateLabel: true,
rotateAngle: 25,
},
yAxis: {
disableGrid: false,
gridType: 'dash',
tofix: 2,
},
extra: {
line: {
type: 'curve',
width: 2,
activeType: 'hollow',
linearType: 'custom',
},
},
});
console.log('✅ 图表绘制完成');
}, 300);
}
</script>
<style scoped lang="scss">
.chart-fullscreen-page {
position: fixed;
top: 50%;
left: 50%;
width: 100vh; // 横屏后的宽度 = 屏幕高度
height: 100vw; // 横屏后的高度 = 屏幕宽度
transform: translate(-50%, -50%) rotate(90deg);
background: #fff;
display: flex;
flex-direction: column;
z-index: 9999;
}
.header {
height: 50px;
background: #fff;
display: flex;
align-items: center;
justify-content: space-between;
padding: 0 15px;
border-bottom: 1px solid #eee;
flex-shrink: 0;
.back-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
.icon {
font-size: 28px;
color: #333;
}
}
.title {
font-size: 28px;
font-weight: 600;
color: #333;
}
.home-btn {
width: 40px;
height: 40px;
display: flex;
align-items: center;
justify-content: center;
.home-icon {
font-size: 24px;
}
}
}
.time-selector {
display: flex;
justify-content: center;
align-items: center;
padding: 10px;
gap: 12px;
background: #fff;
flex-shrink: 0;
height: 50px;
.time-item {
padding: 8px 24px;
background: #f5f5f5;
border-radius: 6px;
font-size: 24px;
color: #666;
&.active {
background: #1890FF;
color: #fff;
}
}
}
.chart-container {
flex: 1;
position: relative;
background: #fff;
padding: 10px;
.chart-canvas {
width: 100%;
height: 100%;
}
}
</style>

File diff suppressed because it is too large Load Diff

View File

@@ -285,7 +285,7 @@ function getBhd(){
};
getSaturability(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
const bhd = Number(res.data);
saturability.value = bhd
}

View File

@@ -333,70 +333,58 @@
>
<!-- 绘制表格 -->
<view class="m_t_15">
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 上限 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
{{
item.oxyUpperOpen
? item.oxyUpperValue + "Mg/L"
: "-"
}}
</view>
</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 下限 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
{{
item.oxyLowerOpen
? item.oxyLowerValue + "Mg/L"
: "-"
}}
</view>
</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 开关 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
<text
class="truncate"
:style="{
maxWidth: '100rpx',
textAlign: 'center',
}"
>{{ formatName(item.listSwitch) }}</text
<view class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></view>
<view
class="table-cell"
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
联动{{ index + 1 }}
</view>
</view>
<!-- 上限行 -->
<view class="table-row">
<view class="table-cell table-label">上限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'up_' + item.id"
>
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 下限行 -->
<view class="table-row">
<view class="table-cell table-label">下限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'low_' + item.id"
>
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 开关行 -->
<view class="table-row">
<view class="table-cell table-label">开关</view>
<view
class="table-cell table-switch"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'sw_' + item.id"
>
<view class="switch-names">
<view
class="switch-name"
v-for="(sw, idx) in item.listSwitch"
:key="sw.id"
>
{{ sw.switchName }}
</view>
</view>
</view>
</view>
</view>
</view>
@@ -941,7 +929,7 @@ Taro.useDidShow(() => {
// 查询塘口列表
function getPondList() {
getPond2().then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
const arr = [{ id: 0, pondName: "无" }];
res.data.forEach((r) => {
arr.push({ id: r.id, pondName: r.pondName });
@@ -953,9 +941,18 @@ function getPondList() {
// 设备详情
function getDevInfo() {
deviceInfo({ id }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
res.data.bindTime = formatDate(new Date(res.data.bindTime));
res.data.deadTime = formatDate(new Date(res.data.deadTime));
// 将后端返回的 0/1 转换为布尔值
res.data.isOxygenUsed = res.data.isOxygenUsed === 1;
res.data.oxyWarnTelOpen = res.data.oxyWarnTelOpen === 1;
res.data.oxyWarnTelNoDis = res.data.oxyWarnTelNoDis === 1;
res.data.tempWarnTelOpen = res.data.tempWarnTelOpen === 1;
res.data.tempWarnTelNoDis = res.data.tempWarnTelNoDis === 1;
res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1;
deviceInfoRes.value = res.data;
pondId.value = res.data.pondInfo ? [res.data.pondInfo.id] : [0];
voltageType.value = res.data.inputVoltage;
@@ -980,7 +977,7 @@ function unbind() {
success: function (res) {
if (res.confirm) {
deviceDel({ id }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "解绑成功";
setTimeout(() => {
@@ -1025,7 +1022,7 @@ function confirm({ selectedValue, selectedOptions }) {
};
deviceUpdatePond(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1044,10 +1041,11 @@ function changeO2(value, event) {
const data = {
deviceId: id,
type: 1,
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0,
isNoDisturb: deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1059,10 +1057,11 @@ function changeTem(value, event) {
const data = {
deviceId: id,
type: 2,
isOpen: deviceInfoRes.value.tempWarnTelOpen,
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0,
isNoDisturb: deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1086,7 +1085,7 @@ function setOxyEvent() {
oxyWarnLower: oxy.value,
};
setOxyWarn(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.oxyWarnLower = oxy.value;
@@ -1101,7 +1100,7 @@ function setNameEvent() {
newName: deviceName.value,
};
deviceUpdateName(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.deviceName = deviceName.value;
@@ -1122,7 +1121,7 @@ function setTempEvent() {
tempWarnUpper: tempUp.value,
};
setTempWarn(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.tempWarnUpper = tempUp.value;
@@ -1156,7 +1155,7 @@ function setNameSwitchEvent() {
newName: switchName.value,
};
updateSwitchName(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
openSetNameSwitch.value = false;
@@ -1204,9 +1203,10 @@ function setSalinity() {
salinityCompensation: salinity.value,
};
setSal(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.salinityCompensation = salinity.value;
openSalinity.value = false;
}
});
@@ -1222,7 +1222,7 @@ function removeDev() {
success: function (res) {
if (res.confirm) {
deviceUnbind({ id }).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
// alertRes.value = true
state.show = true;
state.msg = "移除成功";
@@ -1242,13 +1242,13 @@ function changeTemDis(value, event) {
const data = {
deviceId: id,
type: 2,
isOpen: deviceInfoRes.value.tempWarnTelOpen,
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0,
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
? deviceInfoRes.value.tempWarnTelNoDis
: false,
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0)
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1265,10 +1265,10 @@ function changeIsOxygenUsed(value, event) {
if (event) {
const data = {
id: id,
isOpen: deviceInfoRes.value.isOxygenUsed,
isOpen: deviceInfoRes.value.isOxygenUsed ? 1 : 0,
};
setOxyOpen(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1277,11 +1277,11 @@ function changeIsOxygenUsed(value, event) {
}
function setTypeEvent() {
const data = {
id: Number(id),
id: id,
voltageType: voltageType.value,
};
deviceUpdateV(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.inputVoltage = voltageType.value;
@@ -1295,10 +1295,10 @@ function changeV(value, event) {
if (event) {
const data = {
id: id,
isOpen: deviceInfoRes.value.voltageWarnOpen,
isOpen: deviceInfoRes.value.voltageWarnOpen ? 1 : 0,
};
voltageCheckOpen(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1310,13 +1310,13 @@ function changeOxyDis(value, event) {
const data = {
deviceId: id,
type: 1,
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0,
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
? deviceInfoRes.value.oxyWarnTelNoDis
: false,
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0)
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1448,4 +1448,82 @@ function changeOxyDis(value, event) {
color: #17b4b2;
font-size: 28px;
}
/* 联动控制表格优化样式 */
.linked-table {
width: 100%;
border-radius: 8px;
overflow: hidden;
background: #fff;
}
.table-row {
display: flex;
border-bottom: 1px solid #f0f0f0;
&:last-child {
border-bottom: none;
}
}
.table-header {
background: #f8f8f8;
font-weight: bold;
.table-cell {
color: #666;
font-size: 26rpx;
}
}
.table-cell {
flex: 1;
padding: 20rpx 10rpx;
text-align: center;
border-right: 1px solid #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
min-height: 80rpx;
&:last-child {
border-right: none;
}
}
.table-label {
flex: 0 0 100rpx;
background: #fafafa;
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.table-value {
color: #17b4b2;
font-size: 28rpx;
font-weight: 500;
}
.table-switch {
padding: 10rpx;
}
.switch-names {
display: flex;
flex-direction: column;
gap: 8rpx;
width: 100%;
}
.switch-name {
font-size: 24rpx;
color: #17b4b2;
padding: 6rpx 10rpx;
background: #f5f5f5;
border-radius: 4rpx;
line-height: 1.4;
word-break: break-all;
text-align: center;
}
</style>

View File

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

View File

@@ -325,7 +325,7 @@ import Taro from "@tarojs/taro";
import { imgUrl } from "@/utils/imgUrl";
const r_v = `${imgUrl}r_v.png`;
const instance = Taro.getCurrentInstance();
const id = Number(instance.router.params.id);
const id = (instance.router.params.id);
// const id = 21;
const name = instance.router.params.name;
Taro.setNavigationBarTitle({
@@ -393,7 +393,7 @@ Taro.useDidShow(() => {
// 查询塘口列表
function getPondList() {
getPond2().then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
const arr = [{ id: 0, pondName: "无" }];
res.data.forEach((r) => {
arr.push({ id: r.id, pondName: r.pondName });
@@ -405,7 +405,11 @@ function getPondList() {
// 开关详情
function getSwitchInfo() {
switchInfo({ id }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
// 将后端返回的 0/1 转换为布尔值
res.data.voltageWarnOpen = res.data.voltageWarnOpen === 1;
res.data.electricWarnOpen = res.data.electricWarnOpen === 1;
switchInfoRes.value = res.data;
pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : [];
voltageType.value = res.data.connectVoltageType ? res.data.connectVoltageType : 1;
@@ -426,7 +430,7 @@ function confirm({ selectedValue, selectedOptions }) {
};
updateSwitchPond(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -451,7 +455,7 @@ function setVEvent() {
electric: Number(V.value),
};
electricSet(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
switchInfoRes.value.rateElectricValue = V.value;
@@ -474,7 +478,7 @@ function setTypeEvent() {
voltageType: voltageType.value,
};
updateSwitchType(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
switchInfoRes.value.connectVoltageType = voltageType.value;
@@ -503,10 +507,10 @@ function changeV(value, event) {
if (event) {
const data = {
id: id,
isOpen: switchInfoRes.value.voltageWarnOpen,
isOpen: switchInfoRes.value.voltageWarnOpen ? 1 : 0, // 布尔转数字
};
voltageCheckOpen(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -517,10 +521,10 @@ function changeE(value, event) {
if (event) {
const data = {
id: id,
isOpen: switchInfoRes.value.electricWarnOpen,
isOpen: switchInfoRes.value.electricWarnOpen ? 1 : 0, // 布尔转数字
};
electricCheckOpen(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}

View File

@@ -261,62 +261,58 @@
>
<!-- 绘制表格 -->
<view class="m_t_15">
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 上限 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
{{ item.oxyUpperOpen?item.oxyUpperValue+'Mg/L':'-' }}
</view>
</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 下限 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
{{ item.oxyLowerOpen?item.oxyLowerValue+'Mg/L':'-' }}
</view>
</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 开关 </view>
<view
class="tableTR"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
<text
class="truncate"
:style="{
maxWidth: '100rpx',
textAlign: 'center',
}"
>{{ formatName(item.listSwitch) }}</text
<view class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></view>
<view
class="table-cell"
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
联动{{ index + 1 }}
</view>
</view>
<!-- 上限行 -->
<view class="table-row">
<view class="table-cell table-label">上限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'up_' + item.id"
>
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 下限行 -->
<view class="table-row">
<view class="table-cell table-label">下限</view>
<view
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'low_' + item.id"
>
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 开关行 -->
<view class="table-row">
<view class="table-cell table-label">开关</view>
<view
class="table-cell table-switch"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="'sw_' + item.id"
>
<view class="switch-names">
<view
class="switch-name"
v-for="(sw, idx) in item.listSwitch"
:key="sw.id"
>
{{ sw.switchName }}
</view>
</view>
</view>
</view>
</view>
</view>
@@ -773,7 +769,7 @@ Taro.useDidShow(() => {
// 查询塘口列表
function getPondList() {
getPond2().then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
const arr = [{ id: 0, pondName: "无" }];
res.data.forEach(r=>{
arr.push({id:r.id,pondName:r.pondName})
@@ -785,9 +781,17 @@ function getPondList() {
// 设备详情
function getDevInfo() {
deviceInfo({ id }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
res.data.bindTime = formatDate(new Date(res.data.bindTime));
res.data.deadTime = formatDate(new Date(res.data.deadTime));
// 将数字类型转为布尔类型
res.data.oxyWarnTelOpen = !!res.data.oxyWarnTelOpen;
res.data.oxyWarnTelNoDis = !!res.data.oxyWarnTelNoDis;
res.data.tempWarnTelOpen = !!res.data.tempWarnTelOpen;
res.data.tempWarnTelNoDis = !!res.data.tempWarnTelNoDis;
res.data.isOxygenUsed = !!res.data.isOxygenUsed;
deviceInfoRes.value = res.data;
pondId.value = res.data.pondInfo ? [Number(res.data.pondInfo.id)] : [0];
}
@@ -814,7 +818,7 @@ function unbind() {
if (res.confirm) {
b_isLoading.value = true
deviceDel({ id }).then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "解绑成功";
setTimeout(() => {
@@ -864,7 +868,7 @@ console.log(selectedValue)
};
deviceUpdatePond(data)
.then((res: any) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -883,13 +887,13 @@ function changeO2(value, event) {
const data = {
deviceId: id,
type: 1,
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
? deviceInfoRes.value.oxyWarnTelNoDis
: false,
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -901,13 +905,13 @@ function changeTem(value, event) {
const data = {
deviceId: id,
type: 2,
isOpen: deviceInfoRes.value.tempWarnTelOpen,
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
? deviceInfoRes.value.tempWarnTelNoDis
: false,
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -942,7 +946,7 @@ function setOxyEvent() {
oxyWarnLower: oxy.value,
};
setOxyWarn(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.oxyWarnLower = oxy.value;
@@ -957,11 +961,12 @@ function setNameEvent() {
newName: deviceName.value,
};
deviceUpdateName(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.deviceName = deviceName.value;
openSetName.value = false;
// 重新加载设备信息
getDevInfo();
}
});
}
@@ -995,7 +1000,7 @@ function setTempEvent() {
tempWarnUpper: tempUp.value,
};
setTempWarn(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.tempWarnUpper = tempUp.value;
@@ -1035,7 +1040,7 @@ function setSalinity() {
salinityCompensation: salinity.value ? Number(salinity.value) : 0,
};
setSal(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
deviceInfoRes.value.salinityCompensation = salinity.value;
@@ -1053,13 +1058,13 @@ function changeOxyDis(value, event) {
const data = {
deviceId: id,
type: 1,
isOpen: deviceInfoRes.value.oxyWarnTelOpen,
isOpen: deviceInfoRes.value.oxyWarnTelOpen ? 1 : 0, // 布尔转数字
isNoDisturb: deviceInfoRes.value.oxyWarnTelOpen
? deviceInfoRes.value.oxyWarnTelNoDis
: false,
? (deviceInfoRes.value.oxyWarnTelNoDis ? 1 : 0) // 布尔转数字
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
@@ -1072,46 +1077,19 @@ function changeTemDis(value, event) {
const data = {
deviceId: id,
type: 2,
isOpen: deviceInfoRes.value.tempWarnTelOpen,
isOpen: deviceInfoRes.value.tempWarnTelOpen ? 1 : 0, // 布尔转数字
isNoDisturb: deviceInfoRes.value.tempWarnTelOpen
? deviceInfoRes.value.tempWarnTelNoDis
: false,
? (deviceInfoRes.value.tempWarnTelNoDis ? 1 : 0) // 布尔转数字
: 0,
};
setWarnCall(data).then((res) => {
if (res.statusCode == 200) {
if (res.code == 200) {
state.show = true;
state.msg = "设置成功";
}
});
}
}
// 移除设备
function removeDev() {
Taro.showModal({
title: "提示",
content:
"移除后会将设备从塘口移除,并和塘口内的其他设备解除关联关系。确认移除该设备?",
success: function (res) {
if (res.confirm) {
r_isLoading.value = true
deviceUnbind({ id }).then((res) => {
if (res.statusCode == 200) {
// alertRes.value = true
state.show = true;
state.msg = "移除成功";
deviceInfoRes.value.pondInfo = {
id: 0,
pondName: "请绑定塘口",
};
}
}).finally(() => {
r_isLoading.value = false
})
} else if (res.cancel) {
}
},
});
}
// 返回上一页
function onGoBack() {
Taro.navigateBack({ delta: 1 });
@@ -1248,4 +1226,82 @@ function onblur() {
color: #17b4b2;
font-size: 28px;
}
/* 联动控制表格优化样式 */
.linked-table {
width: 100%;
border-radius: 8px;
overflow: hidden;
background: #fff;
}
.table-row {
display: flex;
border-bottom: 1px solid #f0f0f0;
&:last-child {
border-bottom: none;
}
}
.table-header {
background: #f8f8f8;
font-weight: bold;
.table-cell {
color: #666;
font-size: 26rpx;
}
}
.table-cell {
flex: 1;
padding: 20rpx 10rpx;
text-align: center;
border-right: 1px solid #f0f0f0;
display: flex;
align-items: center;
justify-content: center;
min-height: 80rpx;
&:last-child {
border-right: none;
}
}
.table-label {
flex: 0 0 100rpx;
background: #fafafa;
font-size: 28rpx;
color: #333;
font-weight: 500;
}
.table-value {
color: #17b4b2;
font-size: 28rpx;
font-weight: 500;
}
.table-switch {
padding: 10rpx;
}
.switch-names {
display: flex;
flex-direction: column;
gap: 8rpx;
width: 100%;
}
.switch-name {
font-size: 24rpx;
color: #17b4b2;
padding: 6rpx 10rpx;
background: #f5f5f5;
border-radius: 4rpx;
line-height: 1.4;
word-break: break-all;
text-align: center;
}
</style>

View File

@@ -397,8 +397,9 @@ function getPayItem() {
}
// 设备列表
function getDeviceList() {
allDeviceList({ type: 1 }).then((res: any) => {
if (res.statusCode == 200) {
const userId = Taro.getStorageSync("UserId");
allDeviceList({ type: 1,rootUserId:userId }).then((res: any) => {
if (res.code == 200) {
res.data.forEach((item: any) => {
const deadDay = daysBeforeToday(formatDate(new Date(item.deadTime)));
item.deadDay = deadDay

View File

@@ -504,16 +504,16 @@
<nut-tab-pane
v-for="(item, index) in noticeRows"
:key="index"
:title="`${item.title}`"
:title="`${item.noticeTitle}`"
:pane-key="index"
>
<nut-row>
<nut-col :span="24" :style="{ height: '200px' }">
{{ item.content }}
<view v-html="item.noticeContent"></view>
</nut-col>
<nut-col :span="24">
<view :style="{ textAlign: 'right' }"
>发布时间{{ formatDateString(item.createdTime, "yyyy-mm-dd") }}</view
>发布时间{{ formatDateString(item.createTime, "yyyy-mm-dd") }}</view
>
<!-- <div>有效期至{{formatDateMin(item.deadTime)}}</div> -->
</nut-col>
@@ -768,17 +768,17 @@ function getNotice(openType = 0) {
noticeList().then((res) => {
if (res.code == 200) {
const nList: any = [];
noticeRows.value = res.data.sort(sortByField("priority", false));
noticeRows.value = res.rows.sort(sortByField("priority", false));
if (noticeRows.value.length > 0) {
noticeRows.value.forEach((item: AnalyserOptions) => {
const content: string = `${item.title}${item.content}`;
const content: string = `${item.noticeTitle}${item.noticeContent}`;
nList.push(content);
});
if (openType == 0) {
notice.value = nList[0];
if (store.getNoticeRead == 0) {
noticeOpen.value = true;
} else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) {
} else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) {
noticeOpen.value = true;
} else {
noticeOpen.value = false;
@@ -1222,9 +1222,9 @@ function closeNotice() {
noticeOpen.value = false;
if (noticeRows.value.length > 0) {
if (store.getNoticeRead == 0) {
store.updateNoticeRead(noticeRows.value[0]["createdTime"]);
} else if (store.getNoticeRead != noticeRows.value[0]["createdTime"]) {
store.updateNoticeRead(noticeRows.value[0]["createdTime"]);
store.updateNoticeRead(noticeRows.value[0]["createTime"]);
} else if (store.getNoticeRead != noticeRows.value[0]["createTime"]) {
store.updateNoticeRead(noticeRows.value[0]["createTime"]);
}
} else {
store.updateNoticeRead(0);

View File

@@ -8,7 +8,8 @@ const timeOutSeconds = 10000;
const getBaseUrl = () => {
let BASE_URL = ''
if (process.env.TARO_ENV === 'h5') {
BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
BASE_URL = 'https://www.qdintc.com/fishery-api' // 线上调试后端
// BASE_URL = 'http://127.0.0.1:8080' // 本地调试后端地址
} else {
BASE_URL = 'https://api.yuceyun.cn' //填写你的请求域名
// BASE_URL = 'https://dev.yuceyun.cn' //测试环境