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>

View File

@@ -92,7 +92,8 @@
<!-- <nut-tag class="tagErr font_28" v-else> 未开启联动控制 </nut-tag> -->
</view>
<view
class="font_32 c_1589E9"
class="font_28 c_1589E9"
:style="{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: '12px', margin: '0 15px' }"
@click="setParams(item.id, item.deviceName, item.deviceType)"
>参数设置</view
>
@@ -267,8 +268,11 @@
7
</view>
</view>
<view class="font_32 c_1589E9" :style="{ textAlign: 'right' }">
<view @click="changeShow">{{ setTitle }}</view>
<view :style="{ display: 'flex', alignItems: 'center', justifyContent: 'flex-end', gap: '12px', margin: '0 7px' }">
<view @click="fullscreenChart" class="zoom-btn">
放大
</view>
<view @click="changeShow" class="hide-btn">{{ setTitle }}</view>
</view>
</view>
<!-- <nut-col :span="8" class="font_32 f_weight c_222">
@@ -339,7 +343,6 @@
String(dayDev)
"
@TouchEnd="touchEnd"
type="2d"
@TouchStart="touchCandle"
@TouchMove="moveCandle"
:style="{
@@ -624,6 +627,7 @@
</view>
</template>
</nut-dialog>
</template>
<script setup lang="ts" name="PondInfo">
import { IconFont, Loading, RectRight, Uploader } from "@nutui/icons-vue-taro";
@@ -689,10 +693,10 @@ const themeVarsOther = ref({
});
// 图表参数
const paramsHistory = ref({
id: null,
StartTime: "",
EndTime: "",
dataTypeId: 1,
serialNum: "", // 设备序列号
startTime: "", // 开始时间
endTime: "", // 结束时间
intervalType: 1, // 时间间隔类型1-1天, 2-3天, 3-7天
});
// 图表数据
const chartsDatas = ref<any>({
@@ -873,6 +877,10 @@ function getDeviceList() {
: res.data.listDetector[0].id
? res.data.listDetector[0].id
: undefined;
// 初始化 serialNum
if (res.data.listDetector[0].serialNum) {
paramsHistory.value.serialNum = res.data.listDetector[0].serialNum;
}
if (doDev.value) {
if (!oxyIds.includes(doDev.value)) {
doDev.value = res.data.listDetector[0].id
@@ -908,32 +916,68 @@ function getDeviceList() {
// 选择日期
function changeDay(e) {
dayDev.value = e;
if (e > 1) {
getDaysAgo(e - 1);
} else {
// 直接传递天数getDaysAgo 会自动设置正确的 intervalType
getDaysAgo(e);
}
}
// 显隐控制器
// 显隐控制器
function changeShow() {
if (setTitle.value == "显示") {
showChart.value = !showChart.value;
if (showChart.value) {
setTitle.value = "隐藏";
// 显隐图标控制器
showChart.value = true;
// 绘制图表
setTimeout(() => {
getDaysAgo(dayDev.value);
}, 200);
} else {
setTitle.value = "显示";
showChart.value = false;
}
}
// 全屏显示图表 - 跳转到单独页面
function fullscreenChart() {
console.log('🔍 设备数据结构:', pondDeviceRes.value);
console.log('🔍 当前设备ID:', doDev.value);
// 获取当前设备的 serialNum注意数据结构直接在 pondDeviceRes.value 下,没有 data 字段)
const currentDevice = pondDeviceRes.value?.listDetector?.find(
(item: any) => item.id === doDev.value
);
console.log('🔍 找到的设备:', currentDevice);
if (!currentDevice) {
Taro.showToast({
title: '设备信息不存在',
icon: 'none'
});
return;
}
// 尝试多种字段名
const serialNum = currentDevice.serialNum || currentDevice.serialNumber || currentDevice.deviceSerialNum || currentDevice.sn;
if (!serialNum) {
console.error('❗ 设备没有序列号字段,设备信息:', currentDevice);
Taro.showToast({
title: '设备序列号不存在',
icon: 'none'
});
return;
}
console.log('✅ 跳转参数:', { serialNum, dataType: prDev.value, dayType: dayDev.value });
// 跳转到全屏图表页面
Taro.navigateTo({
url: `/components/other/chartFullscreen?serialNum=${serialNum}&dataType=${prDev.value}&dayType=${dayDev.value}`
});
}
// 切换检测指标
function selectCharts(e) {
prDev.value = e;
const id = props.modelValue;
paramsHistory.value.dataTypeId = e;
// 不再需要 dataTypeId一次查询返回所有数据
if (!id) {
return;
}
@@ -1049,397 +1093,180 @@ function changeDev(item: any) {
oxyWarnLower.value = item.oxyWarnLower;
tempWarnUpper.value = item.tempWarnUpper;
tempWarnLower.value = item.tempWarnLower;
paramsHistory.value.id = item.id;
paramsHistory.value.serialNum = item.serialNum; // 使用设备序列号
dayDev.value = 1;
getDaysAgo(1);
}
// 设备历史数据图表
function getDeviceHistory() {
loading.value = true;
paramsHistory.value.id = doDev.value;
if (!doDev.value) {
console.log('📊 开始获取历史数据,参数:', paramsHistory.value);
if (!paramsHistory.value.serialNum) {
console.error('❌ serialNum 为空,无法查询');
loading.value = false;
return;
}
deviceHistory(paramsHistory.value)
.then((res: any) => {
if (res.statusCode == 200) {
// if (res.data && res.data.length > 0) {
const result = groupByDate(processData(res.data));
const r: any = [];
Object.keys(result).forEach((res) => {
const arr = {};
arr["time"] = getRelativeDay(res);
arr["day"] = res.split("-")[1] + "-" + res.split("-")[2];
arr["info"] = result[res];
r.push(arr);
});
chartsDatas.value = {
r,
};
console.log('📥 历史数据接口返回:', res);
// 后端直接返回数组,而不是 {code: 200, data: []}
if (Array.isArray(res)) {
console.log('✅ 数据获取成功(数组格式),数据量:', res.length);
console.log('📋 数据内容:', res);
chartsDatas.value = res;
console.log('💾 chartsDatas 已赋值:', chartsDatas.value);
drawCharts(1);
// }
} else if (res.code == 200) {
// 兼容标准响应格式
console.log('✅ 数据获取成功(标准格式),数据量:', res.data?.length);
console.log('📋 数据内容:', res.data);
chartsDatas.value = res.data || [];
console.log('💾 chartsDatas 已赋值:', chartsDatas.value);
drawCharts(1);
} else {
console.error('❌ 接口返回失败:', res);
}
})
.catch((err) => {
console.error('❌ 接口请求异常:', err);
})
.finally(() => {
loading.value = false;
});
}
// 监测图表
// 监测图表 - 重构版本
function drawCharts(type) {
console.log('🎨 开始绘制图表, type:', type);
loading.value = true;
Taro.nextTick(() => {
const data = chartsDatas.value;
const dayType = dayDev.value;
const paramsType = prDev.value;
const data = chartsDatas.value; // 后端直接返回的数据数组
const paramsType = prDev.value; // 当前选中的指标类型
console.log('📊 chartsDatas.value:', data);
console.log('🎯 当前指标类型:', paramsType);
console.log('📅 天数:', dayDev.value);
if (!data || data.length === 0) {
console.error('❌ 数据为空,无法绘制图表');
loading.value = false;
return;
}
let series: any = [];
let x: any = timeX();
x7.value = generateTimeSlotsEndingToday();
let x_time_list: any = [];
let markLineData: any = 0;
let oxyMl: any = [];
let suMl: any = [];
let sdMl: any = [];
let x_time_list: any = []; // x轴时间列表
let seriesData: any = []; // y轴数据
let warnLines: any = []; // 告警线
// 根据 paramsType 选择对应的数据字段
let fieldName = '';
let seriesName = '';
if (paramsType == 1) {
fieldName = 'dissolvedOxygen';
seriesName = '溶解氧';
// 添加告警下限
if (oxyWarnLower.value) {
markLineData = [
{
value: oxyWarnLower.value,
showLabel: true,
labelOffsetX: 0,
labelOffsetY: 0,
labelAlign: "right",
labelText: "告警下限",
labelFontColor: "#666666",
labelBgColor: "#DFE8FF",
labelBgOpacity: 0.8,
},
];
warnLines = data.map(() => oxyWarnLower.value);
series.push({
name: '告警下限',
data: warnLines,
color: '#c12e34',
lineType: 'dash',
});
}
} else if (paramsType == 2) {
if (tempWarnUpper.value && tempWarnLower.value) {
markLineData = [
{
value: tempWarnUpper.value,
showLabel: true,
labelOffsetX: 0,
labelOffsetY: 0,
labelAlign: "right",
labelText: "告警上限",
labelFontColor: "#666666",
labelBgColor: "#DFE8FF",
labelBgOpacity: 0.8,
},
{
value: tempWarnLower.value,
showLabel: true,
labelOffsetX: 0,
labelOffsetY: 0,
labelAlign: "right",
labelText: "告警下限",
lineColor: "#DE4A42",
labelFontColor: "#666666",
labelBgColor: "#DFE8FF",
labelBgOpacity: 0.8,
},
];
}
}
// 时间筛选
if (dayType == 1) {
let name = "";
let arr = [];
let j = undefined;
let z = undefined;
let rows: any = [[], []];
x.forEach((time: string) => {
x_time_list.push(time.x_time);
let found_a = false;
let found_b = false;
data.r.forEach((res: any, index) => {
if (res.time == "今日") {
j = index;
}
if (res.time == "昨日") {
z = index;
}
for (const item of res.info) {
let value = Number(toDecimal(item.value, 2));
if (item.createdTime == time.time && res.time == "今日") {
if (j || j == 0) {
rows[j].push(value);
found_a = true;
}
} else if (item.createdTime == time.time && res.time == "昨日") {
if (z || z == 0) {
rows[z].push(value);
found_b = true;
}
}
}
fieldName = 'temperature';
seriesName = '水温';
// 添加告警上下限
if (tempWarnLower.value) {
warnLines = data.map(() => tempWarnLower.value);
series.push({
name: '告警下限',
data: warnLines,
color: '#c12e34',
lineType: 'dash',
});
if (!found_a && (j || j == 0)) {
rows[j].push(null);
}
if (!found_b && (z || z == 0)) {
rows[z].push(null);
}
if (oxyWarnLower.value) {
oxyMl.push(oxyWarnLower.value);
}
if (tempWarnUpper.value) {
suMl.push(tempWarnUpper.value);
}
if (tempWarnLower.value) {
sdMl.push(tempWarnLower.value);
}
const upperLines = data.map(() => tempWarnUpper.value);
series.push({
name: '告警上限',
data: upperLines,
color: '#e098c7',
lineType: 'dash',
});
if (paramsType == 1) {
name = "溶解氧";
arr = rows;
} else if (paramsType == 2) {
name = "水温";
arr = rows;
}
} else if (paramsType == 3) {
name = "饱和度";
arr = rows;
fieldName = 'saturability';
seriesName = '饱和度';
} else if (paramsType == 4) {
name = "PH";
arr = rows;
fieldName = 'ph';
seriesName = 'PH';
} else if (paramsType == 5) {
name = "盐度";
arr = rows;
fieldName = 'salinity';
seriesName = '盐度';
}
series = [
{
name: "今日" + name,
data: j || j == 0 ? arr[j] : [],
},
{
name: "昨日" + name,
lineType: "dash",
data: z || z == 0 ? arr[z] : [],
},
];
if (paramsType == 1) {
series.push({
name: "告警下限",
data: oxyMl,
color: "#c12e34",
lineType: "dash",
});
} else if (paramsType == 2) {
series.push({
name: "告警下限",
data: sdMl,
color: "#c12e34",
lineType: "dash",
});
series.push({
name: "告警上限",
data: suMl,
color: "#e098c7",
lineType: "dash",
});
}
} else if (dayType == 3) {
let name = "";
let arr = [];
let j = undefined;
let z = undefined;
let q = undefined;
let rows: any = [[], [], []];
x.forEach((time: any) => {
let found_a = false;
let found_b = false;
let found_c = false;
x_time_list.push(time.x_time);
if (oxyWarnLower.value) {
oxyMl.push(oxyWarnLower.value);
}
if (tempWarnUpper.value) {
suMl.push(tempWarnUpper.value);
}
if (tempWarnLower.value) {
sdMl.push(tempWarnLower.value);
}
data.r.forEach((res: any, index) => {
if (res.time == "今日") {
j = index;
}
if (res.time == "昨日") {
z = index;
}
if (res.time == "前日") {
q = index;
}
for (const item of res.info) {
let value = Number(toDecimal(item.value, 2));
if (item.createdTime == time.time && res.time == "今日") {
if (j || j == 0) {
rows[j].push(value);
found_a = true;
}
} else if (item.createdTime == time.time && res.time == "昨日") {
if (z || z == 0) {
rows[z].push(value);
found_b = true;
}
} else if (item.createdTime == time.time && res.time == "前日") {
if (q || q == 0) {
rows[q].push(value);
found_c = true;
}
}
}
});
if (!found_a && (j || j == 0)) {
rows[j].push(null);
}
if (!found_b && (z || z == 0)) {
rows[z].push(null);
}
if (!found_c && (q || q == 0)) {
rows[q].push(null);
}
});
if (paramsType == 1) {
name = "溶解氧";
arr = rows;
} else if (paramsType == 2) {
name = "水温";
arr = rows;
} else if (paramsType == 3) {
name = "饱和度";
arr = rows;
} else if (paramsType == 4) {
name = "PH";
arr = rows;
} else if (paramsType == 5) {
name = "盐度";
arr = rows;
}
series = [
{
name: "今日",
data: j || j == 0 ? arr[j] : [],
},
{
name: "昨日",
lineType: "dash",
data: z || z == 0 ? arr[z] : [],
},
{
name: "前日",
lineType: "dash",
data: q || q == 0 ? arr[q] : [],
},
];
if (paramsType == 1) {
series.push({
name: "告警下限",
data: oxyMl,
color: "#c12e34",
lineType: "dash",
});
} else if (paramsType == 2) {
series.push({
name: "告警下限",
data: sdMl,
color: "#c12e34",
lineType: "dash",
});
series.push({
name: "告警上限",
data: suMl,
color: "#e098c7",
lineType: "dash",
});
}
// 提取时间和数据
data.forEach((item: any, index: number) => {
console.log(`📋 处理第 ${index + 1} 条数据:`, item);
// 格式化时间2026-01-12 09:38:32.0 -> 01-12 09:38
const timeStr = item.time || item.createTime || '';
console.log(`⏰ 时间字符串:`, timeStr);
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}`;
x_time_list.push(formattedTime);
console.log(`✅ 时间格式化成功: ${formattedTime}`);
} else {
let name = "";
let arr = [];
let rows: any = [];
x7.value.forEach((time: any) => {
x_time_list.push(time.time2);
let found_a = false;
if (oxyWarnLower.value) {
oxyMl.push(oxyWarnLower.value);
}
if (tempWarnUpper.value) {
suMl.push(tempWarnUpper.value);
}
if (tempWarnLower.value) {
sdMl.push(tempWarnLower.value);
console.warn(`⚠️ 时间格式错误,跳过: ${timeStr}`);
x_time_list.push('--:--'); // 占位符
}
data.r.forEach((res: any) => {
for (const item of res.info) {
let value = Number(toDecimal(item.value, 2));
if (item.createdTime == time.time && res.day == time.time2) {
rows.push(value);
found_a = true;
}
// 提取对应字段的数据
const value = item[fieldName];
console.log(`📊 ${fieldName} 字段值:`, value);
if (value !== null && value !== undefined) {
const numValue = Number(value.toFixed(2));
seriesData.push(numValue);
console.log(`✅ 数据添加成功: ${numValue}`);
} else {
seriesData.push(null);
console.warn(`⚠️ ${fieldName} 字段为空`);
}
});
if (!found_a) {
rows.push(null);
}
console.log('⏰ x轴时间列表:', x_time_list);
console.log('📊 y轴数据列表:', seriesData);
console.log('📝 数据字段名:', fieldName);
console.log('🏷️ 系列名称:', seriesName);
// 添加主数据系列
series.unshift({
name: seriesName,
data: seriesData,
});
if (paramsType == 1) {
name = "溶解氧";
arr = rows;
} else if (paramsType == 2) {
name = "水温";
arr = rows;
} else if (paramsType == 3) {
name = "饱和度";
arr = rows;
} else if (paramsType == 4) {
name = "PH";
arr = rows;
} else if (paramsType == 5) {
name = "盐度";
arr = rows;
}
series = [
{
name: name,
data: arr,
},
];
if (paramsType == 1) {
series.push({
name: "告警下限",
data: oxyMl,
color: "#c12e34",
lineType: "dash",
});
} else if (paramsType == 2) {
series.push({
name: "告警下限",
data: sdMl,
color: "#c12e34",
lineType: "dash",
});
series.push({
name: "告警上限",
data: suMl,
color: "#e098c7",
lineType: "dash",
});
}
}
setTimeout(() => {
loading.value = false;
const ids =
"GdHQcFQYzLhfeEvZbEJnhDxJzBlbCxhE" +
String(doDev.value) +
String(prDev.value) +
String(dayDev.value);
const ids = "GdHQcFQYzLhfeEvZbEJnhDxJzBlbCxhE" + String(doDev.value) + String(prDev.value) + String(dayDev.value);
console.log('🎯 Canvas ID:', ids);
console.log('📦 准备创建图表, series:', series);
const query = Taro.createSelectorQuery();
query.select("#" + ids).boundingClientRect();
query.selectViewport().scrollOffset();
@@ -1448,10 +1275,13 @@ function drawCharts(type) {
chartConf.top = res[0] ? res[0].top : 0;
chartConf.left = res[0] ? res[0].left : 0;
}
console.log('📏 Canvas 位置:', { top: chartConf.top, left: chartConf.left });
});
if (type == 1) {
console.log('✅ 调用 createCharts');
createCharts(x_time_list, series, ids);
} else {
console.log('✅ 调用 updateCharts');
updateCharts(x_time_list, series, ids);
}
}, 200);
@@ -1503,43 +1333,69 @@ function moveCandle(e) {
e.changedTouches.unshift(tmpe);
uChartsOp.value[e.target.id].scroll(e);
}
// 创建图表
// 创建图表 - 兼容模式支持微信小程序和H5
function createCharts(x, series, ids) {
console.log('🎨 createCharts 被调用,使用旧版 Canvas 模式');
console.log(' - x轴数据:', x);
console.log(' - series数据:', series);
console.log(' - Canvas ID:', ids);
console.log(' - 当前环境:', Taro.getEnv());
Taro.nextTick(() => {
let cWidth = chartConf.cWidth;
let cHeight = chartConf.cHeight;
let pixelRatio = chartConf.pixelRatio;
const query = Taro.createSelectorQuery();
query
.select("#" + ids)
.fields({ node: true, size: true })
.exec((res) => {
if (res.length > 0 && res[0]) {
const canvas = res[0].node;
const ctx = canvas.getContext("2d");
canvas.width = res[0].width * pixelRatio;
canvas.height = res[0].height * pixelRatio;
// 判断环境
const env = Taro.getEnv();
console.log('📱 运行环境:', env);
if (env === 'WEB' || env === 'h5') {
// H5 环境需要特殊处理
console.log('🌐 H5 环境,使用 DOM 方式获取 Canvas');
setTimeout(() => {
// H5 下需要找到真实的 canvas 元素,不是 Taro 的封装组件
const canvasElement = document.querySelector(`#${ids} canvas`);
if (!canvasElement) {
console.error('❌ 未找到 Canvas 元素:', ids);
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 成功');
uChartsOp.value[ids] = new uCharts({
type: "line",
context: ctx,
canvas2d: true,
width: cWidth * pixelRatio,
height: cHeight * pixelRatio,
width: cWidth,
height: cHeight,
categories: x,
series: series,
pixelRatio: pixelRatio,
pixelRatio: 1,
dataPointShape: false,
animation: true,
background: "#FFFFFF",
color: ["#17B4B2", "#5470c6", "#fac858"],
padding: [10, 60, 0, 20],
padding: [15, 30, 35, 45],
enableScroll: false,
boundaryGap: "justify",
update: true,
legend: {
fontColor: "#222222",
itemGap: 10,
float: prDev.value == 2 || prDev.value == 1 ? "left" : "center",
position: "top",
},
dataLabel: false,
xAxis: {
@@ -1550,8 +1406,9 @@ function createCharts(x, series, ids) {
itemCount: 0,
scrollShow: false,
scrollAlign: "left",
// labelCount: dayDev.value == 7 ? 7 : 6,
labelCount: 7,
rotateLabel: true,
rotateAngle: 25,
},
yAxis: {
disableGrid: false,
@@ -1590,8 +1447,88 @@ function createCharts(x, series, ids) {
},
},
});
}
console.log('✅ H5 图表创建完成');
}, 300);
} else {
// 小程序环境
console.log('📱 小程序环境,使用 canvasId 方式');
uChartsOp.value[ids] = new uCharts({
type: "line",
canvasId: ids,
canvas2d: false,
width: cWidth * pixelRatio,
height: cHeight * pixelRatio,
categories: x,
series: series,
pixelRatio: pixelRatio,
dataPointShape: false,
animation: true,
background: "#FFFFFF",
color: ["#17B4B2", "#5470c6", "#fac858"],
padding: [15, 30, 35, 45],
enableScroll: false,
boundaryGap: "justify",
update: true,
legend: {
fontColor: "#222222",
itemGap: 10,
position: "top",
},
dataLabel: false,
xAxis: {
disableGrid: true,
axisLine: true,
type: "grid",
gridType: "dash",
itemCount: 0,
scrollShow: false,
scrollAlign: "left",
labelCount: 7,
rotateLabel: true,
rotateAngle: 25,
},
yAxis: {
disableGrid: false,
gridType: "dash",
tofix: 2,
},
extra: {
tooltip: {
showBox: true,
showArrow: true,
showCategory: true,
borderWidth: 0,
borderRadius: 0,
borderColor: "#000000",
borderOpacity: 0.7,
bgColor: "#000000",
bgOpacity: 0.7,
gridType: "solid",
dashLength: 4,
gridColor: "#CCCCCC",
boxPadding: 3,
fontSize: 13,
lineHeight: 20,
fontColor: "#FFFFFF",
legendShow: true,
legendShape: "auto",
splitLine: true,
labelBgColor: "#FFFFFF",
labelBgOpacity: 0.7,
labelFontColor: "#666666",
},
line: {
type: "curve",
width: 1,
activeType: "hollow",
},
},
});
console.log('✅ 小程序图表创建完成');
}
});
}
// 更新图表数据
@@ -1624,10 +1561,39 @@ function updateCharts(x, series, ids) {
}
// 切换日期
function getDaysAgo(days) {
const day = getStartDate(days);
paramsHistory.value.StartTime = day + " 00:00:00";
const now = new Date();
// days = 1 表示 1 天,从昨天到今天,所以往前推 1 天
// days = 3 表示 3 天,从 3 天前到今天,所以往前推 3 天
const start = new Date(now.getTime() - days * 24 * 60 * 60 * 1000);
// 格式化为 YYYY-MM-DD HH:mm:ss
paramsHistory.value.startTime = formatDateTime(start);
paramsHistory.value.endTime = formatDateTime(now);
console.log(`📅 选择 ${days} 天,时间范围: ${paramsHistory.value.startTime} ~ ${paramsHistory.value.endTime}`);
// 设置 intervalType1天->1, 3天->2, 7天->3
if (days === 1) {
paramsHistory.value.intervalType = 1;
} else if (days === 3) {
paramsHistory.value.intervalType = 2;
} else if (days === 7) {
paramsHistory.value.intervalType = 3;
}
getDeviceHistory();
}
// 格式化时间为 YYYY-MM-DD HH:mm:ss
function formatDateTime(date: Date): string {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, '0');
const day = String(date.getDate()).padStart(2, '0');
const hours = String(date.getHours()).padStart(2, '0');
const minutes = String(date.getMinutes()).padStart(2, '0');
const seconds = String(date.getSeconds()).padStart(2, '0');
return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`;
}
function getStartDate(days) {
// 获取当前日期时间
const currentDate = new Date();
@@ -1650,15 +1616,13 @@ function getStartDate(days) {
// 加载时间参数
function getNowDate() {
const now = new Date();
let year = now.getFullYear(); //得到年份
let month = now.getMonth(); //得到月份
let date = now.getDate(); //得到日期
month = month + 1;
month = month.toString().padStart(2, "0");
date = date.toString().padStart(2, "0");
let day = `${year}-${month}-${date}`;
paramsHistory.value.StartTime = day + " 00:00:00";
paramsHistory.value.EndTime = day + " 23:59:59";
const yesterday = new Date(now.getTime() - 24 * 60 * 60 * 1000); // 昨天
paramsHistory.value.startTime = formatDateTime(yesterday);
paramsHistory.value.endTime = formatDateTime(now);
paramsHistory.value.intervalType = 1; // 默认 1 天
console.log(`🕒 初始化时间: ${paramsHistory.value.startTime} ~ ${paramsHistory.value.endTime}`);
}
function groupByDate(data) {
const result = {};
@@ -2016,6 +1980,19 @@ defineExpose({
background: #09b8c2;
}
.zoom-btn {
font-size: 28px;
white-space: nowrap;
cursor: pointer;
color: #1589E9;
}
.hide-btn {
font-size: 28px;
white-space: nowrap;
color: #1589E9;
}
.gridRight {
text-align: right;
color: #1589e9;

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 class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></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"
class="table-cell"
v-for="(item, index) in deviceInfoRes.listLinkedCtr"
:key="item.id"
>
{{
item.oxyUpperOpen
? item.oxyUpperValue + "Mg/L"
: "-"
}}
联动{{ index + 1 }}
</view>
</view>
<!-- 上限行 -->
<view class="table-row">
<view class="table-cell table-label">上限</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 下限 </view>
<view
class="tableTR"
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
:key="'up_' + item.id"
>
{{
item.oxyLowerOpen
? item.oxyLowerValue + "Mg/L"
: "-"
}}
{{ item.oxyUpperOpen ? item.oxyUpperValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 下限行 -->
<view class="table-row">
<view class="table-cell table-label">下限</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 开关 </view>
<view
class="tableTR"
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
:key="'low_' + item.id"
>
<text
class="truncate"
:style="{
maxWidth: '100rpx',
textAlign: 'center',
}"
>{{ formatName(item.listSwitch) }}</text
{{ 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>
<view>
<nut-switch
v-model="item.oxyUpperOpen"
:ref="'up' + item.id"
active-color="#04D98A"
@change="
(value, event) => setUpSwitch({ value, event }, item)
"
@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>
<view>
<nut-switch
v-model="item.oxyLowerOpen"
:ref="'lo' + item.id"
active-color="#04D98A"
@change="
(value, event) => setLoSwitch({ value, event }, item)
"
@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 class="linked-table">
<!-- 表头 -->
<view class="table-row table-header">
<view class="table-cell"></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"
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
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 下限 </view>
<view
class="tableTR"
class="table-cell table-value"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
:key="'low_' + item.id"
>
{{ item.oxyLowerOpen ? item.oxyLowerValue + 'Mg/L' : '-' }}
</view>
</view>
<!-- 开关行 -->
<view class="table-row">
<view class="table-cell table-label">开关</view>
<view
style="
display: flex;
flex-direction: row;
justify-content: space-around;
"
class="tr"
>
<view class="tableTR tableTou"> 开关 </view>
<view
class="tableTR"
class="table-cell table-switch"
v-for="item in deviceInfoRes.listLinkedCtr"
:key="item.id"
:key="'sw_' + item.id"
>
<text
class="truncate"
:style="{
maxWidth: '100rpx',
textAlign: 'center',
}"
>{{ formatName(item.listSwitch) }}</text
<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' //测试环境