完善小细节

This commit is contained in:
xuqiuyun
2025-10-24 17:32:42 +08:00
parent ecccd025d1
commit a40ce28318
73 changed files with 7238 additions and 114 deletions

View File

@@ -29,7 +29,7 @@
<el-descriptions-item label="送达目的地:">{{ data.baseInfo.endLocation || '-' }}</el-descriptions-item>
<el-descriptions-item label="预计送达时间:">{{ data.baseInfo.estimatedDeliveryTime || '-' }}</el-descriptions-item>
<el-descriptions-item label="创建时间:">{{ data.baseInfo.createTime || '' }}</el-descriptions-item>
<el-descriptions-item label="登记设备数量:">{{ data.baseInfo.registeredJbqCount || '-' }} </el-descriptions-item>
<el-descriptions-item label="登记设备数量:">{{ totalRegisteredDevices }} </el-descriptions-item>
<el-descriptions-item label="状态:">
<el-tag :type="data.baseInfo.status === 2 ? 'success' : 'warning'">{{ getStatusText(data.baseInfo.status) }}</el-tag>
</el-descriptions-item>
@@ -64,7 +64,7 @@
<span class="red">{{ item.warningTypeDesc }}</span>
</el-descriptions-item>
<el-descriptions-item label="预警时间:">{{ item.warningTime || '--' }}</el-descriptions-item>
<el-descriptions-item label="智能耳标数:"> {{ data.baseInfo.registeredJbqCount || '--' }} </el-descriptions-item>
<el-descriptions-item label="智能耳标数:"> {{ totalRegisteredDevices }} </el-descriptions-item>
<el-descriptions-item label="车内盘点数量:"> {{ item.inventoryJbqCount || '--' }} </el-descriptions-item>
</template>
<template v-if="item.warningType == 3">
@@ -214,12 +214,12 @@
</el-descriptions-item>
</el-descriptions>
</div>
<!-- <div class="ear-box">
<div class="ear-box">
<div class="title">智能主机</div>
<el-table
:data="data.collarRows"
:data="data.hostRows"
border
v-loading="data.collarDataListLoading"
v-loading="data.hostDataListLoading"
element-loading-text="数据加载中..."
style="width: 100%"
>
@@ -238,23 +238,13 @@
</el-table-column>
<el-table-column label="操作" prop="">
<template #default="scope">
<el-button link type="primary" @click="collarLogClick(scope.row)">日志</el-button>
<el-button link type="primary" @click="collarTrackClick(scope.row)">运动轨迹</el-button>
<el-button link type="primary" @click="hostLogClick(scope.row)">日志</el-button>
<el-button link type="primary" @click="hostTrackClick(scope.row)">运动轨迹</el-button>
<el-button link type="primary" @click="hostLocationClick(scope.row)">定位</el-button>
</template>
</el-table-column>
</el-table>
<el-descriptions :column="1">
<el-descriptions-item label="主机编号:">
{{ data.serverIds }}
<el-button type="primary" style="margin-left: 20px" size="small" @click="locationClick(item)" v-if="data.serverIds"
>查看主机定位</el-button
>
<el-button type="primary" style="margin-left: 20px" size="small" @click="trackClick(data.serverIds)" v-if="data.serverIds"
>查看运动轨迹</el-button
>
</el-descriptions-item>
</el-descriptions>
</div> -->
</div>
<div class="ear-box">
<div class="title">智能项圈</div>
<el-table
@@ -271,8 +261,8 @@
<el-table-column label="步数" prop="steps">
<template #default="scope"> {{ scope.row.steps || scope.row.walkSteps || '-' }}</template>
</el-table-column>
<el-table-column label="设备温度" prop="temperature">
<template #default="scope"> {{ scope.row.temperature || scope.row.deviceTemp || '-' }} </template>
<el-table-column label="设备温度" prop="deviceTemp">
<template #default="scope"> {{ scope.row.deviceTemp || scope.row.temperature || '-' }} </template>
</el-table-column>
<el-table-column label="数据最后更新时间" prop="time">
<template #default="scope"> {{ scope.row.time || scope.row.updateTime || scope.row.createTime || '-' }}</template>
@@ -295,8 +285,9 @@
<div class="title">智能耳标</div>
<el-table :data="data.rows" border v-loading="data.dataListLoading" element-loading-text="数据加载中..." style="width: 100%">
<el-table-column label="智能耳标编号" prop="deviceId"></el-table-column>
<el-table-column label="设备电量" prop="deviceVoltage">
<template #default="scope"> {{ scope.row.deviceVoltage || scope.row.battery || '-' }}% </template>
<el-table-column label="设备电量" prop="battery">
<template #default="scope"> {{ scope.row.battery || scope.row.deviceVoltage || '-' }}% </template>
</el-table-column>
<el-table-column label="步数" prop="walkSteps">
<template #default="scope"> {{ scope.row.walkSteps || scope.row.steps || '-' }}</template>
@@ -310,6 +301,7 @@
<el-table-column label="操作" prop="">
<template #default="scope">
<el-button link type="primary" @click="earLogClick(scope.row)">日志</el-button>
<el-button link type="primary" @click="earTrackClick(scope.row)">运动轨迹</el-button>
</template>
</el-table-column>
</el-table>
@@ -440,7 +432,7 @@
<!-- 项圈日志 -->
<el-dialog v-model="data.collarDialogVisible" title="设备日志" style="width: 900px; padding-bottom: 20px">
<el-table :data="data.collarLogRows" border v-loading="data.logListLoading" element-loading-text="数据加载中..." style="width: 100%">
<el-table-column label="智能项圈编号" prop="sn"></el-table-column>
<el-table-column label="智能项圈编号" prop="deviceId"></el-table-column>
<el-table-column label="设备电量" prop="battery">
<template #default="scope"> {{ scope.row.battery || scope.row.deviceVoltage || '-' }}% </template>
</el-table-column>
@@ -466,16 +458,42 @@
@pagination="getCollarLogList"
/>
</el-dialog>
<!-- 智能主机日志 -->
<el-dialog v-model="data.hostLogDialogVisible" title="智能主机日志" style="width: 900px; padding-bottom: 20px">
<el-table :data="data.hostLogRows" border v-loading="data.logListLoading" element-loading-text="数据加载中..." style="width: 100%">
<el-table-column label="智能主机编号" prop="deviceId"></el-table-column>
<el-table-column label="设备电量" prop="deviceVoltage">
<template #default="scope"> {{ scope.row.deviceVoltage || scope.row.battery || '-' }}% </template>
</el-table-column>
<el-table-column label="步数" prop="walkSteps">
<template #default="scope"> {{ scope.row.walkSteps || scope.row.steps || '-' }}</template>
</el-table-column>
<el-table-column label="设备温度" prop="deviceTemp">
<template #default="scope"> {{ scope.row.deviceTemp || scope.row.temperature || '-' }} </template>
</el-table-column>
<el-table-column label="小时时间" prop="hourTime" width="200">
<template #default="scope"> {{ scope.row.hourTime || '-' }}</template>
</el-table-column>
<el-table-column label="数据最后更新时间" prop="updateTime" width="200">
<template #default="scope"> {{ scope.row.updateTime || scope.row.createTime || '-' }}</template>
</el-table-column>
<el-table-column label="操作" prop="">
<template #default="scope">
<el-button link type="primary" @click="hostLocationClick(scope.row)">定位</el-button>
</template>
</el-table-column>
</el-table>
</el-dialog>
<TrackDialog ref="TrackDialogRef" />
</section>
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ref, reactive, onMounted, computed } from 'vue';
import { useRoute } from 'vue-router';
import { ElMessage } from 'element-plus';
import { earList, hostLocation, hostTrack, waybillDetail, collarList, collarLogList, earLogList, testDeliveryDevices, pageDeviceList } from '@/api/abroad.js';
import { earList, hostLocation, hostTrack, waybillDetail, collarList, collarLogList, earLogList, testDeliveryDevices, pageDeviceList, getEarTagLogs, getCollarLogs, getHostLogs, getEarTagTrajectory, getCollarTrajectory, getHostTrajectory } from '@/api/abroad.js';
import startIcon from '../../assets/images/qi.png';
import endIcon from '../../assets/images/zhong.png';
import TrackDialog from '../hardware/trackDialog.vue';
@@ -536,11 +554,18 @@ const data = reactive({
earLogRows: [],
earLogDialogVisible: false,
collarDialogVisible: false,
hostLogDialogVisible: false,
earLogTotal: 0,
collarLogRows: [],
collarLogTotal: 0,
hostLogRows: [],
hostLogTotal: 0,
deviceId: '', // 耳标编号
sn: '', // 项圈编号
// 智能主机相关
hostDataListLoading: false,
hostRows: [],
hostTotal: 0,
});
const form = reactive({
pageNum: 1,
@@ -593,13 +618,15 @@ const getDetail = () => {
.catch(() => {});
};
// 获取智能主机信息
const getHostDeviceInfo = () => {
// 智能主机列表查询
const getHostList = () => {
if (!route.query.id) {
console.warn('=== 警告deliveryId为空跳过主机设备查询');
console.warn('=== 警告deliveryId为空跳过主机列表查询');
data.hostDataListLoading = false;
return;
}
data.hostDataListLoading = true;
pageDeviceList({
pageNum: 1,
pageSize: 100, // 获取所有主机设备
@@ -608,10 +635,14 @@ const getHostDeviceInfo = () => {
})
.then((res) => {
console.log('=== 主机设备API返回结果:', res);
data.hostDataListLoading = false;
if (res.code === 200) {
console.log('=== 主机设备数据:', res.data);
// 新API返回的是数组格式过滤出智能主机设备
const hostDevices = res.data.filter(device => device.deviceType === 1 || device.deviceType === '1');
data.hostRows = hostDevices || [];
data.hostTotal = hostDevices.length || 0;
if (hostDevices.length > 0) {
// 如果有主机设备,取第一个作为主要主机
data.serverIds = hostDevices[0].deviceId || hostDevices[0].sn || '';
@@ -619,17 +650,31 @@ const getHostDeviceInfo = () => {
} else {
data.serverIds = '';
}
console.log('=== 设置后的hostRows:', data.hostRows);
console.log('=== 设置后的hostTotal:', data.hostTotal);
} else {
console.warn('获取主机设备信息失败:', res.msg);
data.hostRows = [];
data.hostTotal = 0;
data.serverIds = '';
}
})
.catch((err) => {
console.error('获取主机设备信息异常:', err);
data.hostDataListLoading = false;
data.hostRows = [];
data.hostTotal = 0;
data.serverIds = '';
});
};
// 获取智能主机信息(保留原有功能)
const getHostDeviceInfo = () => {
// 现在直接调用getHostList来获取主机信息
getHostList();
};
// 查看主机定位
const locationClick = (item) => {
getHostLocation(item);
@@ -728,10 +773,72 @@ const getEarList = () => {
});
};
const earLogClick = (row) => {
console.log('=== 智能耳标日志点击 ===');
console.log('设备信息:', row);
data.deviceId = row.deviceId || row.sn || '';
data.earLogDialogVisible = true;
getEarLogList();
// 调用新的API获取60分钟间隔的日志数据
getEarTagLogs({
deviceId: data.deviceId,
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能耳标日志API返回结果:', res);
if (res.code === 200) {
// 新API返回的是按60分钟分组的日志数据
data.earLogRows = res.data || [];
data.earLogTotal = res.data.length || 0;
console.log('=== 设置后的earLogRows:', data.earLogRows);
console.log('=== 设置后的earLogTotal:', data.earLogTotal);
} else {
ElMessage.error(res.msg || '获取智能耳标日志失败');
data.earLogRows = [];
data.earLogTotal = 0;
}
}).catch((error) => {
console.error('获取智能耳标日志异常:', error);
ElMessage.error('获取智能耳标日志失败');
data.earLogRows = [];
data.earLogTotal = 0;
});
};
// 智能耳标运动轨迹
const earTrackClick = (row) => {
console.log('=== 智能耳标运动轨迹点击 ===');
console.log('设备信息:', row);
// 调用新的API获取60分钟间隔的轨迹数据
getEarTagTrajectory({
deviceId: row.deviceId || row.sn || '',
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能耳标轨迹API返回结果:', res);
if (res.code === 200 && res.data && res.data.length > 0) {
// 新API返回的是按60分钟分组的轨迹点数据
const trajectoryPoints = res.data;
console.log('=== 轨迹点数据:', trajectoryPoints);
// 使用TrackDialog显示轨迹
if (TrackDialogRef.value) {
const info = {
deliveryId: route.query.id,
deviceId: row.deviceId || row.sn || '',
type: 'order',
trajectoryPoints: trajectoryPoints // 传递轨迹点数据
};
TrackDialogRef.value.onShowTrackDialog(info);
}
} else {
ElMessage.warning('该设备暂无运动轨迹数据');
}
}).catch((error) => {
console.error('获取智能耳标轨迹异常:', error);
ElMessage.error('获取智能耳标运动轨迹失败');
});
};
// 智能项圈列表查询
const getCollarList = () => {
if (!route.query.id) {
@@ -769,9 +876,35 @@ const getCollarList = () => {
});
};
const collarLogClick = (row) => {
console.log('=== 智能项圈日志点击 ===');
console.log('设备信息:', row);
data.sn = row.sn || row.deviceId || '';
data.collarDialogVisible = true;
getCollarLogList();
// 调用新的API获取60分钟间隔的日志数据
getCollarLogs({
deviceId: data.sn,
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能项圈日志API返回结果:', res);
if (res.code === 200) {
// 新API返回的是按60分钟分组的日志数据
data.collarLogRows = res.data || [];
data.collarLogTotal = res.data.length || 0;
console.log('=== 设置后的collarLogRows:', data.collarLogRows);
console.log('=== 设置后的collarLogTotal:', data.collarLogTotal);
} else {
ElMessage.error(res.msg || '获取智能项圈日志失败');
data.collarLogRows = [];
data.collarLogTotal = 0;
}
}).catch((error) => {
console.error('获取智能项圈日志异常:', error);
ElMessage.error('获取智能项圈日志失败');
data.collarLogRows = [];
data.collarLogTotal = 0;
});
};
const handler = ({ BMap, map }) => {
// 自动获取展示的比例
@@ -855,16 +988,123 @@ const getCollarLogList = () => {
};
// 查看运动轨迹
const collarTrackClick = (row) => {
if (TrackDialogRef.value) {
const info = {
deliveryId: route.query.id,
deviceId: row.sn || row.deviceId || '',
type: 'order',
};
TrackDialogRef.value.onShowTrackDialog(info);
}
console.log('=== 智能项圈运动轨迹点击 ===');
console.log('设备信息:', row);
// 调用新的API获取60分钟间隔的轨迹数据
getCollarTrajectory({
deviceId: row.sn || row.deviceId || '',
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能项圈轨迹API返回结果:', res);
if (res.code === 200 && res.data && res.data.length > 0) {
// 新API返回的是按60分钟分组的轨迹点数据
const trajectoryPoints = res.data;
console.log('=== 轨迹点数据:', trajectoryPoints);
// 使用TrackDialog显示轨迹
if (TrackDialogRef.value) {
const info = {
deliveryId: route.query.id,
deviceId: row.sn || row.deviceId || '',
type: 'order',
trajectoryPoints: trajectoryPoints // 传递轨迹点数据
};
TrackDialogRef.value.onShowTrackDialog(info);
}
} else {
ElMessage.warning('该设备暂无运动轨迹数据');
}
}).catch((error) => {
console.error('获取智能项圈轨迹异常:', error);
ElMessage.error('获取智能项圈运动轨迹失败');
});
};
// 智能主机操作函数
const hostLogClick = (row) => {
console.log('=== 智能主机日志点击 ===');
console.log('设备信息:', row);
data.deviceId = row.deviceId || row.sn || '';
data.hostLogDialogVisible = true;
// 调用新的API获取60分钟间隔的日志数据
getHostLogs({
deviceId: data.deviceId,
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能主机日志API返回结果:', res);
if (res.code === 200) {
// 新API返回的是按60分钟分组的日志数据
data.hostLogRows = res.data || [];
data.hostLogTotal = res.data.length || 0;
console.log('=== 设置后的hostLogRows:', data.hostLogRows);
console.log('=== 设置后的hostLogTotal:', data.hostLogTotal);
} else {
ElMessage.error(res.msg || '获取智能主机日志失败');
data.hostLogRows = [];
data.hostLogTotal = 0;
}
}).catch((error) => {
console.error('获取智能主机日志异常:', error);
ElMessage.error('获取智能主机日志失败');
data.hostLogRows = [];
data.hostLogTotal = 0;
});
};
const hostTrackClick = (row) => {
console.log('=== 智能主机运动轨迹点击 ===');
console.log('设备信息:', row);
// 调用新的API获取60分钟间隔的轨迹数据
getHostTrajectory({
deviceId: row.deviceId || row.sn || '',
deliveryId: parseInt(route.query.id)
}).then((res) => {
console.log('=== 智能主机轨迹API返回结果:', res);
if (res.code === 200 && res.data && res.data.length > 0) {
// 新API返回的是按60分钟分组的轨迹点数据
const trajectoryPoints = res.data;
console.log('=== 轨迹点数据:', trajectoryPoints);
// 使用TrackDialog显示轨迹
if (TrackDialogRef.value) {
const info = {
deliveryId: route.query.id,
deviceId: row.deviceId || row.sn || '',
type: 'order',
trajectoryPoints: trajectoryPoints // 传递轨迹点数据
};
TrackDialogRef.value.onShowTrackDialog(info);
}
} else {
ElMessage.warning('该设备暂无运动轨迹数据');
}
}).catch((error) => {
console.error('获取智能主机轨迹异常:', error);
ElMessage.error('获取智能主机运动轨迹失败');
});
};
const hostLocationClick = (row) => {
data.center.lng = row.longitude;
data.center.lat = row.latitude;
data.updateTime = row.updateTime || row.createTime || '';
data.dialogVisible = true;
};
// 状态文本转换
// 计算所有绑定设备的总数
const totalRegisteredDevices = computed(() => {
const hostCount = data.hostTotal || 0;
const earCount = data.total || 0;
const collarCount = data.collarTotal || 0;
const total = hostCount + earCount + collarCount;
console.log('=== 计算设备总数 - 主机:', hostCount, '耳标:', earCount, '项圈:', collarCount, '总计:', total);
return total;
});
const getStatusText = (status) => {
const statusMap = {
1: '待装车',
@@ -901,6 +1141,7 @@ onMounted(() => {
});
getDetail(); // 查详情
getHostList(); // 主机列表查询
getEarList(); // 耳标列表查询
getCollarList(); // 项圈类别查询
});