基本完成,修复细节

This commit is contained in:
xuqiuyun
2025-10-29 17:33:32 +08:00
parent 6c86963418
commit d1d0b62184
37 changed files with 5133 additions and 236 deletions

View File

@@ -263,4 +263,40 @@ export function orderGetDetail(id) {
url: `/order/detail?id=${id}`,
method: 'GET',
});
}
// ==================== 运送清单管理新增 API ====================
// 逻辑删除运送清单
export function deleteDeliveryLogic(id) {
return request({
url: `/delivery/deleteLogic?id=${id}`,
method: 'POST',
});
}
// 打包运送清单文件(图片、视频、信息)
export function downloadDeliveryPackage(id) {
return request({
url: `/delivery/downloadPackage?id=${id}`,
method: 'GET',
responseType: 'blob', // 重要:用于下载文件
});
}
// 获取运送清单详情(用于编辑)
export function getDeliveryDetail(id) {
return request({
url: `/delivery/detail?id=${id}`,
method: 'GET',
});
}
// 更新运送清单信息
export function updateDeliveryInfo(data) {
return request({
url: '/delivery/updateDeliveryInfo',
method: 'POST',
data,
});
}

View File

@@ -26,7 +26,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/entry/details',
path: 'details', // ✅ 修复:使用相对路径
name: 'details',
meta: {
title: '详情',
@@ -35,6 +35,16 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
component: () => import('~/views/entry/details.vue'),
},
{
path: 'devices', // ✅ 修复:使用相对路径
name: 'devices',
meta: {
title: '设备管理',
keepAlive: true,
requireAuth: true,
},
component: () => import('~/views/entry/devices.vue'),
},
],
},
// 系统管理路由
@@ -48,7 +58,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/system/post',
path: 'post', // ✅ 修复:使用相对路径
name: 'Post',
meta: {
title: '岗位管理',
@@ -58,7 +68,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/system/post.vue'),
},
{
path: '/system/staff',
path: 'staff', // ✅ 修复:使用相对路径
name: 'Staff',
meta: {
title: '员工管理',
@@ -68,7 +78,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/system/staff.vue'),
},
{
path: '/system/tenant',
path: 'tenant', // ✅ 修复:使用相对路径
name: 'Tenant',
meta: {
title: '租户管理',
@@ -90,7 +100,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/permission/menu',
path: 'menu', // ✅ 修复:使用相对路径
name: 'MenuPermission',
meta: {
title: '菜单权限管理',
@@ -100,7 +110,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/permission/menuPermission.vue'),
},
{
path: '/permission/operation',
path: 'operation', // ✅ 修复:使用相对路径
name: 'OperationPermission',
meta: {
title: '操作权限管理',
@@ -122,7 +132,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/hardware/collar',
path: 'collar', // ✅ 修复:使用相对路径
name: 'Collar',
meta: {
title: '智能项圈',
@@ -132,7 +142,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/hardware/collar.vue'),
},
{
path: '/hardware/eartag',
path: 'eartag', // ✅ 修复:使用相对路径
name: 'Eartag',
meta: {
title: '智能耳标',
@@ -142,7 +152,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/hardware/eartag.vue'),
},
{
path: '/hardware/host',
path: 'host', // ✅ 修复:使用相对路径
name: 'Host',
meta: {
title: '智能主机',
@@ -164,7 +174,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/userManage/user',
path: 'user', // ✅ 修复:使用相对路径
name: 'UserManage',
meta: {
title: '用户管理',
@@ -174,7 +184,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/userManage/user.vue'),
},
{
path: '/userManage/driver',
path: 'driver', // ✅ 修复:使用相对路径
name: 'DriverManage',
meta: {
title: '司机管理',
@@ -184,7 +194,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
component: () => import('~/views/userManage/driver.vue'),
},
{
path: '/userManage/vehicle',
path: 'vehicle', // ✅ 修复:使用相对路径
name: 'VehicleManage',
meta: {
title: '车辆管理',
@@ -206,7 +216,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/earlywarning/earlywarninglist',
path: 'earlywarninglist', // ✅ 修复:使用相对路径
name: 'EarlyWarningList',
meta: {
title: '早期预警列表',
@@ -228,7 +238,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
},
children: [
{
path: '/shipping/loadingOrder',
path: 'loadingOrder', // ✅ 修复:使用相对路径
name: 'LoadingOrder',
meta: {
title: '装车订单',
@@ -240,7 +250,7 @@ export const constantRoutes: Array<RouteRecordRaw> = [
{
path: '/shipping/shippinglist',
path: 'shippinglist', // ✅ 修复:使用相对路径
name: 'ShippingList',
meta: {
title: '运送清单',

View File

@@ -78,20 +78,15 @@
<el-table-column label="司机姓名" prop="driverName"> </el-table-column>
<el-table-column label="创建时间" prop="createTime"></el-table-column>
<el-table-column label="创建人" prop="createByName"></el-table-column>
<el-table-column label="操作" width="194">
<el-table-column label="操作" width="350">
<template #default="scope">
<div class="table_column_operation">
<a v-hasPermi="['entry:view']" @click="details(scope.row, scope.row.warningTypeList ? scope.row.warningTypeList.length : 0)">详情</a>
<el-button
type="primary"
link
v-if="scope.row.status == 4 || scope.row.status == 5"
v-hasPermi="['entry:download']"
@click="download(scope.row)"
:loading="downLoading[scope.row.id]"
style="padding: 0"
>下载文件</el-button
>
<el-button type="primary" link @click="details(scope.row, scope.row.warningTypeList ? scope.row.warningTypeList.length : 0)" v-hasPermi="['entry:view']">详情</el-button>
<el-button type="primary" link @click="viewDevices(scope.row)" v-hasPermi="['entry:device']">查看设备</el-button>
<el-button type="warning" link @click="editDelivery(scope.row)" v-hasPermi="['entry:edit']">编辑</el-button>
<el-button type="success" link @click="updateStatus(scope.row)" v-hasPermi="['entry:status']">修改状态</el-button>
<el-button type="info" link @click="downloadPackage(scope.row)" :loading="downLoading[scope.row.id]" v-hasPermi="['entry:download']">打包文件</el-button>
<el-button type="danger" link @click="deleteDelivery(scope.row)" v-hasPermi="['entry:delete']">删除</el-button>
</div>
</template>
</el-table-column>
@@ -101,18 +96,25 @@
</el-table>
<pagination v-model:limit="form.pageSize" v-model:page="form.pageNum" :total="data.total" @pagination="getDataList" />
</div>
<!-- 编辑对话框 -->
<createDeliveryDialog ref="editDialogRef" @success="getDataList" />
</div>
</template>
<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import baseSearch from '@/components/common/searchCustom/index.vue';
import createDeliveryDialog from '@/views/shipping/createDeliveryDialog.vue';
import { inspectionList, downloadZip, pageDeviceList } from '@/api/abroad.js';
import { updateDeliveryStatus, deleteDeliveryLogic, downloadDeliveryPackage, getDeliveryDetail } from '@/api/shipping.js';
const router = useRouter();
const route = useRoute();
const baseSearchRef = ref();
const editDialogRef = ref();
const dataListLoading = ref(false);
const downLoading = reactive({});
const form = reactive({
@@ -154,13 +156,9 @@ const formItemList = reactive([
label: '核验状态',
type: 'select',
selectOptions: [
{ value: 1, text: '待装车' },
{ value: 2, text: '已装车/预付款已支付' },
{ value: 3, text: '已装车/尾款待支付' },
{ value: 4, text: '已核验/待买家付款' },
{ value: 5, text: '尾款已付款' },
{ value: 6, text: '发票待开/进项票' },
{ value: 7, text: '发票待开/销项' },
{ value: 1, text: '准备中' },
{ value: 2, text: '运输中' },
{ value: 3, text: '已结束' },
],
param: 'status',
span: 7,
@@ -570,13 +568,9 @@ const download = async (row) => {
// 状态文本转换
const getStatusText = (status) => {
const statusMap = {
1: '待装车',
2: '已装车/预付款已支付',
3: '已装车/尾款待支付',
4: '已核验/待买家付款',
5: '尾款已付款',
6: '发票待开/进项票',
7: '发票待开/销项'
1: '准备中',
2: '运输中',
3: '已结束'
};
return statusMap[status] || '未知状态';
};
@@ -584,17 +578,155 @@ const getStatusText = (status) => {
// 状态标签类型
const getStatusTagType = (status) => {
const typeMap = {
1: 'warning', // 待装车 -
2: 'info', // 已装车/预付款已支付 -
3: 'warning', // 已装车/尾款待支付 -
4: 'success', // 已核验/待买家付款 - 绿色
5: 'success', // 尾款已付款 - 绿色
6: 'info', // 发票待开/进项票 - 蓝色
7: 'info' // 发票待开/销项 - 蓝色
1: 'info', // 准备中 -
2: 'warning', // 运输中 -
3: 'success' // 已结束 - 绿
};
return typeMap[status] || 'info';
};
// ==================== 新增功能方法 ====================
// 查看设备
const viewDevices = (row) => {
router.push({
path: '/entry/devices',
query: {
deliveryId: row.id,
deliveryNumber: row.deliveryNumber
}
});
};
// 编辑运送清单
const editDelivery = async (row) => {
try {
console.log('[EDIT-DELIVERY] 准备编辑运送清单, ID:', row.id);
// 检查编辑对话框组件是否已加载
if (!editDialogRef.value || !editDialogRef.value.open) {
ElMessage.warning('编辑功能暂不可用,请刷新页面重试');
return;
}
// 调用 detail 接口获取完整数据(包含 supplierId, buyerId, 设备信息等)
const detailRes = await getDeliveryDetail(row.id);
console.log('[EDIT-DELIVERY] 获取到详情数据:', detailRes);
if (detailRes.code === 200 && detailRes.data) {
// 传入完整的 detail 数据给 open() 方法
editDialogRef.value.open(detailRes.data);
} else {
ElMessage.error('获取运单详情失败:' + (detailRes.msg || '未知错误'));
}
} catch (error) {
console.error('[EDIT-DELIVERY] 打开编辑对话框失败:', error);
ElMessage.error('打开编辑对话框失败,请重试');
}
};
// 修改状态
const updateStatus = (row) => {
const statusOptions = [
{ value: 1, label: '准备中' },
{ value: 2, label: '运输中' },
{ value: 3, label: '已结束' }
];
const currentStatus = statusOptions.find(opt => opt.value === row.status)?.label || '未知';
ElMessageBox.confirm(
`当前状态:${currentStatus}。请选择要修改的状态:\n1 - 准备中\n2 - 运输中\n3 - 已结束`,
'修改状态',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
inputPattern: /^[1-3]$/,
inputErrorMessage: '请输入 1-3 之间的数字',
showInput: true,
inputPlaceholder: '请输入新状态对应的数字1/2/3',
inputValue: String(row.status)
}
).then(async ({ value }) => {
const newStatus = parseInt(value);
if (newStatus && newStatus >= 1 && newStatus <= 3) {
try {
const res = await updateDeliveryStatus({
id: row.id,
status: newStatus
});
if (res.code === 200) {
ElMessage.success(`状态已修改为:${statusOptions.find(opt => opt.value === newStatus)?.label}`);
getDataList();
} else {
ElMessage.error(res.msg || '状态修改失败');
}
} catch (error) {
console.error('修改状态失败:', error);
ElMessage.error('状态修改失败,请重试');
}
} else {
ElMessage.error('无效的状态值');
}
}).catch(() => {
ElMessage.info('已取消');
});
};
// 删除运送清单(逻辑删除)
const deleteDelivery = (row) => {
ElMessageBox.confirm(`确定要删除运单号为 ${row.deliveryNumber} 的运送清单吗?`, '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}).then(async () => {
try {
const res = await deleteDeliveryLogic(row.id);
if (res.code === 200) {
ElMessage.success('删除成功');
getDataList();
} else {
ElMessage.error(res.msg || '删除失败');
}
} catch (error) {
console.error('删除运送清单失败:', error);
ElMessage.error('删除失败,请重试');
}
}).catch(() => {
ElMessage.info('已取消删除');
});
};
// 打包文件
const downloadPackage = async (row) => {
try {
downLoading[row.id] = true;
ElMessage.info('正在打包文件,请稍候...');
// 调用后端API打包文件包含图片、视频和信息
const res = await downloadDeliveryPackage(row.id);
// 创建下载链接
const blob = new Blob([res], { type: 'application/zip' });
const url = window.URL.createObjectURL(blob);
const link = document.createElement('a');
link.href = url;
link.download = `运送清单_${row.deliveryNumber}_${new Date().getTime()}.zip`;
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
window.URL.revokeObjectURL(url);
ElMessage.success('文件打包成功');
} catch (error) {
console.error('打包文件失败:', error);
ElMessage.error('打包文件失败,请重试');
} finally {
downLoading[row.id] = false;
}
};
onMounted(() => {
getDataList();
});

View File

@@ -20,9 +20,9 @@
<div class="title">基础信息</div>
<el-descriptions :column="4">
<el-descriptions-item label="运单号:">{{ data.baseInfo.deliveryNumber || '-' }}</el-descriptions-item>
<el-descriptions-item label="订单标题:">{{ data.baseInfo.deliveryTitle || '-' }}</el-descriptions-item>
<el-descriptions-item label="资金方:">{{ data.baseInfo.fundName || '-' }}</el-descriptions-item>
<el-descriptions-item label="采购商:">{{ data.baseInfo.buyerName || '-' }}</el-descriptions-item>
<el-descriptions-item label="方:">{{ data.baseInfo.supplierName || '-' }}</el-descriptions-item>
<el-descriptions-item label="买方:">{{ data.baseInfo.buyerName || '-' }}</el-descriptions-item>
<el-descriptions-item label="车牌号:">{{ data.baseInfo.licensePlate || '-' }}</el-descriptions-item>
<el-descriptions-item label="司机姓名:">{{ data.baseInfo.driverName || '-' }}</el-descriptions-item>
<el-descriptions-item label="起始地:">{{ data.baseInfo.startLocation || '-' }}</el-descriptions-item>
@@ -166,6 +166,32 @@
</span>
</el-descriptions-item>
<!-- 到地相关照片 -->
<el-descriptions-item label="到地纸质磅单:">
<span style="vertical-align: top">
<el-image
v-if="data.baseInfo.destinationPoundListImg"
style="width: 50px; height: 50px; margin-right: 10px"
:src="data.baseInfo.destinationPoundListImg ? data.baseInfo.destinationPoundListImg : ''"
fit="cover"
:preview-src-list="[data.baseInfo.destinationPoundListImg] ? [data.baseInfo.destinationPoundListImg] : []"
preview-teleported
/>
</span>
</el-descriptions-item>
<el-descriptions-item label="到地车辆过重磅车头照片:">
<span style="vertical-align: top">
<el-image
v-if="data.baseInfo.destinationVehicleFrontPhoto"
style="width: 50px; height: 50px; margin-right: 10px"
:src="data.baseInfo.destinationVehicleFrontPhoto ? data.baseInfo.destinationVehicleFrontPhoto : ''"
fit="cover"
:preview-src-list="[data.baseInfo.destinationVehicleFrontPhoto] ? [data.baseInfo.destinationVehicleFrontPhoto] : []"
preview-teleported
/>
</span>
</el-descriptions-item>
<!-- 视频上传区域 -->
<el-descriptions-item label="空车过磅视频(含车牌、地磅数):">
<span style="vertical-align: top" v-if="data.baseInfo.emptyWeightVideo">
@@ -212,6 +238,24 @@
/>
</span>
</el-descriptions-item>
<el-descriptions-item label="卸牛视频:">
<span style="vertical-align: top" v-if="data.baseInfo.unloadCattleVideo">
<video
style="height: 250px; width: auto; border-radius: 5px; margin-left: 60px"
controls
:src="data.baseInfo.unloadCattleVideo"
/>
</span>
</el-descriptions-item>
<el-descriptions-item label="到地过磅视频:">
<span style="vertical-align: top" v-if="data.baseInfo.destinationWeightVideo">
<video
style="height: 250px; width: auto; border-radius: 5px; margin-left: 60px"
controls
:src="data.baseInfo.destinationWeightVideo"
/>
</span>
</el-descriptions-item>
</el-descriptions>
</div>
<div class="ear-box">
@@ -494,6 +538,7 @@ 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, getEarTagLogs, getCollarLogs, getHostLogs, getEarTagTrajectory, getCollarTrajectory, getHostTrajectory } from '@/api/abroad.js';
import { vehicleList } from '@/api/userManage.js';
import startIcon from '../../assets/images/qi.png';
import endIcon from '../../assets/images/zhong.png';
import TrackDialog from '../hardware/trackDialog.vue';
@@ -525,6 +570,12 @@ const data = reactive({
quarStatusDesc: '入场状态', // 根据status反显
status: '订单状态 1境外预检 2 已入境待隔离(检疫成功) 3 已入隔离场 4 隔离场出场 ',
deliverTime: '启运时间',
// 新增照片字段
destinationPoundListImg: '',
destinationVehicleFrontPhoto: '',
// 新增视频字段
unloadCattleVideo: '',
destinationWeightVideo: '',
},
warnInfo: [],
serverIds: '',
@@ -609,6 +660,11 @@ const getDetail = () => {
driverId: data.baseInfo.driverId
});
// 查询车辆照片
if (data.baseInfo.licensePlate) {
loadVehiclePhotos();
}
// 使用新的统一API获取智能主机信息
getHostDeviceInfo();
} else {
@@ -618,6 +674,16 @@ const getDetail = () => {
.catch(() => {});
};
// 查询车辆照片(从司机信息获取)
const loadVehiclePhotos = () => {
// 后端已经从delivery/driver信息中获取了车身照片无需额外前端查询
// carFrontPhoto和carBehindPhoto应该已经由后端的DeliveryServiceImpl填充
console.log('车身照片信息:', {
carFrontPhoto: data.baseInfo.carFrontPhoto,
carBehindPhoto: data.baseInfo.carBehindPhoto
});
};
// 智能主机列表查询
const getHostList = () => {
if (!route.query.id) {
@@ -1107,13 +1173,9 @@ const totalRegisteredDevices = computed(() => {
const getStatusText = (status) => {
const statusMap = {
1: '待装车',
2: '已装车/预付款已支付',
3: '已装车/尾款待支付',
4: '已核验/待买家付款',
5: '尾款已付款',
6: '发票待开/进项票',
7: '发票待开/销项'
1: '准备中',
2: '运输中',
3: '已结束'
};
return statusMap[status] || '未知状态';
};
@@ -1121,13 +1183,9 @@ const getStatusText = (status) => {
// 根据状态返回标签类型(颜色)
const getStatusType = (status) => {
const typeMap = {
1: 'info', // 待装车 - 灰色
2: 'success', // 已装车/预付款已支付 - 绿
3: 'warning', // 已装车/尾款待支付 -
4: 'warning', // 已核验/待买家付款 - 橙色
5: 'success', // 尾款已付款 - 绿色
6: 'primary', // 发票待开/进项票 - 蓝色
7: 'primary' // 发票待开/销项 - 蓝色
1: 'info', // 准备中 - 灰色
2: 'warning', // 运输中 -
3: 'success' // 已结束 - 绿
};
return typeMap[status] || 'info';
};

View File

@@ -0,0 +1,365 @@
<template>
<div class="devices-container">
<!-- 参数缺失时的友好提示 -->
<div v-if="!route.query.deliveryId" class="error-container">
<el-result
icon="warning"
title="参数缺失"
sub-title="缺少必要的参数无法加载设备列表"
>
<template #extra>
<el-button type="primary" @click="goBack">返回上一页</el-button>
</template>
</el-result>
</div>
<!-- 正常内容 -->
<div v-else>
<div class="header-info">
<el-page-header @back="goBack">
<template #content>
<div class="header-title">
<span class="text-large font-600 mr-3">
运送清单设备管理 - {{ route.query.deliveryNumber || '未知运单' }}
</span>
</div>
</template>
</el-page-header>
</div>
<!-- 设备统计 -->
<div class="statistics-box">
<el-row :gutter="20">
<el-col :span="6">
<el-card shadow="hover">
<el-statistic title="智能主机" :value="hostTotal">
<template #suffix></template>
</el-statistic>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<el-statistic title="智能耳标" :value="earTotal">
<template #suffix></template>
</el-statistic>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<el-statistic title="智能项圈" :value="collarTotal">
<template #suffix></template>
</el-statistic>
</el-card>
</el-col>
<el-col :span="6">
<el-card shadow="hover">
<el-statistic title="设备总数" :value="totalDevices">
<template #suffix></template>
</el-statistic>
</el-card>
</el-col>
</el-row>
</div>
<!-- 设备列表Tab -->
<div class="main-container">
<el-tabs v-model="activeTab" @tab-change="handleTabChange">
<!-- 智能主机 -->
<el-tab-pane label="智能主机" name="host">
<el-table v-loading="hostLoading" :data="hostList" border>
<el-table-column label="设备ID" prop="deviceId" width="200"></el-table-column>
<el-table-column label="设备SN" prop="sn" width="200"></el-table-column>
<el-table-column label="运单号" prop="deliveryNumber"></el-table-column>
<el-table-column label="绑定时间" prop="bindTime"></el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button type="danger" link @click="unbindDevice(scope.row, 1)">解绑</el-button>
</template>
</el-table-column>
<template #empty>
<div class="dataListOnEmpty">暂无数据</div>
</template>
</el-table>
</el-tab-pane>
<!-- 智能耳标 -->
<el-tab-pane label="智能耳标" name="ear">
<el-table v-loading="earLoading" :data="earList" border>
<el-table-column label="设备ID" prop="deviceId" width="200"></el-table-column>
<el-table-column label="运单号" prop="deliveryNumber"></el-table-column>
<el-table-column label="重量(kg)" prop="weight"></el-table-column>
<el-table-column label="车牌号" prop="carNumber"></el-table-column>
<el-table-column label="绑定时间" prop="bindTime"></el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button type="danger" link @click="unbindDevice(scope.row, 2)">解绑</el-button>
</template>
</el-table-column>
<template #empty>
<div class="dataListOnEmpty">暂无数据</div>
</template>
</el-table>
<pagination v-model:limit="earForm.pageSize" v-model:page="earForm.pageNum" :total="earTotal" @pagination="getEarList" />
</el-tab-pane>
<!-- 智能项圈 -->
<el-tab-pane label="智能项圈" name="collar">
<el-table v-loading="collarLoading" :data="collarList" border>
<el-table-column label="设备SN" prop="sn" width="200"></el-table-column>
<el-table-column label="设备ID" prop="deviceId" width="200"></el-table-column>
<el-table-column label="运单号" prop="deliveryNumber"></el-table-column>
<el-table-column label="车牌号" prop="carNumber"></el-table-column>
<el-table-column label="绑定时间" prop="bindTime"></el-table-column>
<el-table-column label="操作" width="150">
<template #default="scope">
<el-button type="danger" link @click="unbindDevice(scope.row, 4)">解绑</el-button>
</template>
</el-table-column>
<template #empty>
<div class="dataListOnEmpty">暂无数据</div>
</template>
</el-table>
<pagination v-model:limit="collarForm.pageSize" v-model:page="collarForm.pageNum" :total="collarTotal" @pagination="getCollarList" />
</el-tab-pane>
</el-tabs>
</div>
</div>
</div>
</template>
<script setup>
import { ref, reactive, onMounted, computed } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { ElMessage, ElMessageBox } from 'element-plus';
import { pageDeviceList } from '@/api/abroad.js';
import { unbindDevice as unbindDeviceAPI } from '@/api/shipping.js';
const route = useRoute();
const router = useRouter();
const activeTab = ref('host');
const hostLoading = ref(false);
const earLoading = ref(false);
const collarLoading = ref(false);
const hostList = ref([]);
const earList = ref([]);
const collarList = ref([]);
const hostTotal = ref(0);
const earTotal = ref(0);
const collarTotal = ref(0);
const earForm = reactive({
pageNum: 1,
pageSize: 10,
});
const collarForm = reactive({
pageNum: 1,
pageSize: 10,
});
// 计算设备总数
const totalDevices = computed(() => {
return hostTotal.value + earTotal.value + collarTotal.value;
});
// 返回上一页
const goBack = () => {
router.back();
};
// Tab切换
const handleTabChange = (tabName) => {
console.log('切换到Tab:', tabName);
};
// 获取智能主机列表
const getHostList = async () => {
if (!route.query.deliveryId) {
console.warn('deliveryId为空跳过主机列表查询');
return;
}
hostLoading.value = true;
try {
const res = await pageDeviceList({
pageNum: 1,
pageSize: 100,
deliveryId: parseInt(route.query.deliveryId),
deviceType: 1,
});
console.log('主机设备API返回:', res);
if (res.code === 200) {
const hostDevices = res.data.filter(device => device.deviceType === 1 || device.deviceType === '1');
hostList.value = hostDevices || [];
hostTotal.value = hostDevices.length || 0;
} else {
ElMessage.error(res.msg || '获取主机设备失败');
}
} catch (error) {
console.error('获取主机设备失败:', error);
ElMessage.error('获取主机设备失败');
} finally {
hostLoading.value = false;
}
};
// 获取智能耳标列表
const getEarList = async () => {
if (!route.query.deliveryId) {
console.warn('deliveryId为空跳过耳标列表查询');
return;
}
earLoading.value = true;
try {
const res = await pageDeviceList({
pageNum: earForm.pageNum,
pageSize: earForm.pageSize,
deliveryId: parseInt(route.query.deliveryId),
deviceType: 2,
});
console.log('耳标设备API返回:', res);
if (res.code === 200) {
const earDevices = res.data.filter(device => device.deviceType === 2 || device.deviceType === '2');
earList.value = earDevices || [];
earTotal.value = earDevices.length || 0;
} else {
ElMessage.error(res.msg || '获取耳标设备失败');
}
} catch (error) {
console.error('获取耳标设备失败:', error);
ElMessage.error('获取耳标设备失败');
} finally {
earLoading.value = false;
}
};
// 获取智能项圈列表
const getCollarList = async () => {
if (!route.query.deliveryId) {
console.warn('deliveryId为空跳过项圈列表查询');
return;
}
collarLoading.value = true;
try {
const res = await pageDeviceList({
pageNum: collarForm.pageNum,
pageSize: collarForm.pageSize,
deliveryId: parseInt(route.query.deliveryId),
deviceType: 4,
});
console.log('项圈设备API返回:', res);
if (res.code === 200) {
const collarDevices = res.data.filter(device => device.deviceType === 4 || device.deviceType === '4');
collarList.value = collarDevices || [];
collarTotal.value = collarDevices.length || 0;
} else {
ElMessage.error(res.msg || '获取项圈设备失败');
}
} catch (error) {
console.error('获取项圈设备失败:', error);
ElMessage.error('获取项圈设备失败');
} finally {
collarLoading.value = false;
}
};
// 解绑设备
const unbindDevice = (device, deviceType) => {
const deviceTypeName = deviceType === 1 ? '智能主机' : (deviceType === 2 ? '智能耳标' : '智能项圈');
const deviceIdDisplay = device.deviceId || device.sn;
ElMessageBox.confirm(
`确定要解绑${deviceTypeName}设备 ${deviceIdDisplay} 吗?`,
'提示',
{
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
}
).then(async () => {
try {
const res = await unbindDeviceAPI(device.deviceId || device.sn);
if (res.code === 200) {
ElMessage.success('设备解绑成功');
// 刷新对应列表
if (deviceType === 1) {
getHostList();
} else if (deviceType === 2) {
getEarList();
} else if (deviceType === 4) {
getCollarList();
}
} else {
ElMessage.error(res.msg || '设备解绑失败');
}
} catch (error) {
console.error('设备解绑失败:', error);
ElMessage.error('设备解绑失败');
}
}).catch(() => {
ElMessage.info('已取消解绑');
});
};
onMounted(() => {
console.log('设备管理页面初始化deliveryId:', route.query.deliveryId);
console.log('运单号:', route.query.deliveryNumber);
if (!route.query.deliveryId) {
console.warn('deliveryId为空无法加载设备列表');
ElMessage.error('缺少必要的参数,请从列表页面点击"查看设备"按钮进入');
return;
}
// 加载所有设备列表
getHostList();
getEarList();
getCollarList();
});
</script>
<style lang="less" scoped>
.devices-container {
padding: 20px;
}
.error-container {
padding: 50px;
text-align: center;
}
.header-info {
margin-bottom: 20px;
}
.header-title {
font-size: 18px;
font-weight: 600;
}
.statistics-box {
margin: 20px 0;
}
.main-container {
background: #fff;
padding: 20px;
border-radius: 4px;
}
.dataListOnEmpty {
padding: 50px;
text-align: center;
color: #909399;
font-size: 14px;
}
</style>

View File

@@ -1,7 +1,7 @@
<template>
<el-dialog
v-model="dialogVisible"
title="新增运送清单"
:title="formData.editId ? '编辑运送清单' : '新增运送清单'"
width="800px"
:close-on-click-modal="false"
@close="handleClose"
@@ -75,12 +75,12 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="司机姓名" prop="driverName">
<el-select v-model="formData.driverName" placeholder="请选择司机" clearable filterable style="width: 100%" @change="handleDriverChange">
<el-form-item label="司机姓名" prop="driverId">
<el-select v-model="formData.driverId" placeholder="请选择司机" clearable filterable style="width: 100%" @change="handleDriverChange">
<el-option
v-for="item in driverOptions"
:key="item.id"
:label="item.username"
:label="item.username + (item.mobile ? ' - ' + item.mobile : '')"
:value="item.id"
/>
</el-select>
@@ -559,7 +559,7 @@
v-model="formData.remark"
type="textarea"
:rows="3"
maxlength="500"
maxlength="500"
show-word-limit
placeholder="请输入备注信息(可选)"
/>
@@ -648,10 +648,12 @@ const showStartLocationMap = ref(false);
const showEndLocationMap = ref(false);
const formData = reactive({
editId: null, // 编辑时的运单ID
orderId: null,
shipper: null,
buyer: null,
plateNumber: null,
driverId: null, // 司机ID后端用
driverName: null,
driverPhone: '',
serverId: null, // Integer设备表主键ID
@@ -737,7 +739,7 @@ const rules = {
shipper: [{ required: true, message: '请选择发货方', trigger: 'change' }],
buyer: [{ required: true, message: '请选择采购方', trigger: 'change' }],
plateNumber: [{ required: true, message: '请选择车牌号', trigger: 'change' }],
driverName: [{ required: true, message: '请输入司机姓名', trigger: 'blur' }],
driverId: [{ required: true, message: '请选择司机', trigger: 'change' }],
driverPhone: [{ required: true, validator: validatePhone, trigger: 'blur' }],
estimatedDepartureTime: [{ required: true, message: '请选择预计出发时间', trigger: 'change' }],
estimatedArrivalTime: [{ required: true, validator: validateArrivalTime, trigger: 'change' }],
@@ -771,32 +773,20 @@ const collarDevices = computed(() => {
// 完善提交数据 - 只提交DeliveryCreateDto需要的字段
const buildSubmitData = () => {
// 将发货方和采购方的ID转换为名
let shipperName = '';
let buyerName = '';
if (formData.shipper) {
const shipper = supplierList.value.find(item => item.id === formData.shipper);
shipperName = shipper ? (shipper.username || shipper.mobile || shipper.name || '') : String(formData.shipper);
}
if (formData.buyer) {
const buyer = buyerList.value.find(item => item.id === formData.buyer);
buyerName = buyer ? (buyer.username || buyer.mobile || buyer.name || '') : String(formData.buyer);
}
// 将司机ID转换为名称
// 将司机ID转换为
let driverNameStr = '';
if (formData.driverName) {
const driver = driverOptions.value.find(item => item.id === formData.driverName);
driverNameStr = driver ? (driver.name || driver.mobile || driver.username || '') : String(formData.driverName);
if (formData.driverId) {
const driver = driverOptions.value.find(item => item.id === formData.driverId);
// 使用username作为司机姓名不要使用mobile
driverNameStr = driver ? (driver.username || '') : '';
}
const data = {
// 基本信息
shipper: shipperName,
buyer: buyerName,
shipperId: formData.shipper,
buyerId: formData.buyer,
plateNumber: formData.plateNumber,
driverId: formData.driverId, // 传递司机ID给后端
driverName: driverNameStr,
driverPhone: formData.driverPhone,
@@ -871,14 +861,119 @@ const buildSubmitData = () => {
return data;
};
// 打开弹窗
const open = () => {
// 打开弹窗(支持编辑模式)
const open = async (editData = null) => {
dialogVisible.value = true;
loadSupplierAndBuyerList();
loadDeviceOptions();
loadDriverList();
loadVehicleList();
loadOrderList();
// 并行加载所有下拉列表数据
await Promise.all([
loadSupplierAndBuyerList(),
loadDeviceOptions(),
loadDriverList(),
loadVehicleList(),
loadOrderList()
]);
console.log('[OPEN-DIALOG] 所有下拉列表加载完成');
console.log('[OPEN-DIALOG] 车辆列表:', vehicleOptions.value);
// 如果传入了编辑数据,则填充表单
if (editData) {
fillFormWithEditData(editData);
}
};
// 填充编辑数据到表单
const fillFormWithEditData = (editData) => {
console.log('[EDIT-FILL] 开始填充编辑数据:', editData);
// editData 包含两个部分:
// 1. editData.delivery - 运单基本信息
// 2. editData 的根级字段 - supplierId, buyerId, eartagIds, collarIds, serverIds
const delivery = editData.delivery || editData; // 兼容两种数据结构
// 基本信息
formData.orderId = delivery.orderId || null;
// 发货方和采购方:优先使用根级的 supplierId 和 buyerId
formData.shipper = editData.supplierId || (delivery.supplierId ? parseInt(delivery.supplierId) : null);
formData.buyer = editData.buyerId || delivery.buyerId || null;
console.log('[EDIT-FILL] 发货方ID:', formData.shipper, '采购方ID:', formData.buyer);
// 车牌号
formData.plateNumber = delivery.licensePlate || '';
console.log('[EDIT-FILL] 车牌号:', formData.plateNumber);
console.log('[EDIT-FILL] 当前车辆列表:', vehicleOptions.value);
// 检查车牌号是否在车辆列表中
const vehicleExists = vehicleOptions.value.find(v => v.licensePlate === formData.plateNumber);
if (!vehicleExists && formData.plateNumber) {
console.warn('[EDIT-FILL] ⚠️ 车牌号在车辆列表中不存在:', formData.plateNumber);
}
formData.driverId = delivery.driverId || null;
formData.driverPhone = delivery.driverMobile || '';
// 设备信息:从根级读取
if (editData.serverIds && editData.serverIds !== '') {
formData.serverId = editData.serverIds;
console.log('[EDIT-FILL] 主机ID:', formData.serverId);
}
if (editData.eartagIds && Array.isArray(editData.eartagIds) && editData.eartagIds.length > 0) {
formData.eartagIds = editData.eartagIds;
console.log('[EDIT-FILL] 耳标IDs:', formData.eartagIds);
}
if (editData.collarIds && Array.isArray(editData.collarIds) && editData.collarIds.length > 0) {
formData.collarIds = editData.collarIds;
console.log('[EDIT-FILL] 项圈IDs:', formData.collarIds);
}
// 地址和坐标
formData.startLocation = delivery.startLocation || '';
formData.startLat = delivery.startLat || '';
formData.startLon = delivery.startLon || '';
formData.endLocation = delivery.endLocation || '';
formData.endLat = delivery.endLat || '';
formData.endLon = delivery.endLon || '';
// 时间(需要处理)
// estimatedDeliveryTime 对应 estimatedArrivalTime
if (delivery.estimatedDeliveryTime) {
formData.estimatedArrivalTime = delivery.estimatedDeliveryTime;
}
// 重量信息
formData.emptyWeight = delivery.emptyWeight || null;
formData.entruckWeight = delivery.entruckWeight || null;
formData.landingEntruckWeight = delivery.landingEntruckWeight || null;
// 照片
formData.quarantineTickeyUrl = delivery.quarantineTickeyUrl || '';
formData.poundListImg = delivery.poundListImg || '';
formData.emptyVehicleFrontPhoto = delivery.emptyVehicleFrontPhoto || '';
formData.loadedVehicleFrontPhoto = delivery.loadedVehicleFrontPhoto || '';
formData.loadedVehicleWeightPhoto = delivery.loadedVehicleWeightPhoto || '';
formData.driverIdCardPhoto = delivery.driverIdCardPhoto || '';
formData.destinationPoundListImg = delivery.destinationPoundListImg || '';
formData.destinationVehicleFrontPhoto = delivery.destinationVehicleFrontPhoto || '';
// 视频
formData.entruckWeightVideo = delivery.entruckWeightVideo || '';
formData.emptyWeightVideo = delivery.emptyWeightVideo || '';
formData.cattleLoadingVideo = delivery.cattleLoadingVideo || '';
formData.controlSlotVideo = delivery.controlSlotVideo || '';
formData.cattleLoadingCircleVideo = delivery.cattleLoadingCircleVideo || '';
formData.unloadCattleVideo = delivery.unloadCattleVideo || '';
formData.destinationWeightVideo = delivery.destinationWeightVideo || '';
// 保存编辑的ID用于区分是新增还是编辑
formData.editId = delivery.id;
console.log('[EDIT-FILL] 表单数据已填充:', formData);
ElMessage.success('已加载运单数据');
};
// 加载供应商和采购方列表
@@ -1014,6 +1109,8 @@ const handleOrderChange = async (orderId) => {
formData.shipper = sellerId ? parseInt(sellerId) : null;
formData.buyer = buyerId ? parseInt(buyerId) : null;
console.log('[订单选择] 选中的订单ID:', orderId);
console.log('[订单选择] orderId已保存到formData.orderId:', formData.orderId);
ElMessage.success('已自动填充发货方和采购方信息');
}
} catch (error) {
@@ -1027,12 +1124,19 @@ const handleOrderChange = async (orderId) => {
// 司机选择变化时自动填充电话
const handleDriverChange = (driverId) => {
if (driverId) {
formData.driverId = driverId; // 保存司机ID用于后端查询
const driver = driverOptions.value.find(item => item.id === driverId);
if (driver && driver.mobile) {
formData.driverPhone = driver.mobile;
console.log('[司机选择] 司机ID:', driverId, ', 已自动填充手机号:', driver.mobile);
ElMessage.success('已自动填充司机手机号');
} else {
console.log('[司机选择] 司机ID:', driverId, ', 但未找到手机号');
}
} else {
formData.driverId = null;
formData.driverPhone = '';
console.log('[司机选择] 司机已清除');
}
};
@@ -1066,7 +1170,7 @@ const handleCollarChange = (ids) => {
}
};
// 更新选中设备的delivery_id
// 更新选中设备的delivery_id和car_number
const updateSelectedDevicesDeliveryId = async (deliveryId) => {
try {
const devicesToUpdate = [];
@@ -1082,17 +1186,18 @@ const updateSelectedDevicesDeliveryId = async (deliveryId) => {
devicesToUpdate.push(...formData.collarDeviceIds);
}
// 批量更新设备的delivery_id
// 批量更新设备的delivery_id和car_number
for (const deviceId of devicesToUpdate) {
await updateDeviceDeliveryId({
deviceId: deviceId,
deliveryId: deliveryId
deliveryId: deliveryId,
carNumber: formData.plateNumber // 传递车牌号
});
}
console.log(`成功更新 ${devicesToUpdate.length} 个设备的delivery_id`);
console.log(`成功更新 ${devicesToUpdate.length} 个设备的delivery_id和car_number: ${formData.plateNumber}`);
} catch (error) {
console.error('更新设备delivery_id失败:', error);
console.error('更新设备delivery_id和car_number失败:', error);
// 不阻止流程,只记录错误
}
};
@@ -1135,24 +1240,37 @@ const handleSubmit = () => {
}
console.groupEnd();
const res = await createDelivery(submitData);
console.group('[CREATE-DELIVERY] 响应日志');
let res;
// 判断是编辑还是新增
if (formData.editId) {
// 编辑模式:调用更新接口
console.log('[EDIT-DELIVERY] 编辑模式运单ID:', formData.editId);
submitData.deliveryId = formData.editId; // 添加deliveryId字段后端需要
res = await shippingApi.updateDeliveryInfo(submitData);
} else {
// 新增模式:调用创建接口
console.log('[CREATE-DELIVERY] 新增模式');
res = await createDelivery(submitData);
}
console.group(formData.editId ? '[EDIT-DELIVERY] 响应日志' : '[CREATE-DELIVERY] 响应日志');
console.log('完整响应:', res);
console.groupEnd();
if (res.code === 200) {
// 获取新创建的运送清单ID
const newDeliveryId = res.data?.id;
// 获取运送清单ID新增返回data.id编辑直接用editId
const deliveryId = formData.editId || res.data?.id;
if (newDeliveryId) {
if (deliveryId) {
// 更新设备的delivery_id
await updateSelectedDevicesDeliveryId(newDeliveryId);
await updateSelectedDevicesDeliveryId(deliveryId);
}
ElMessage.success('创建成功');
ElMessage.success(formData.editId ? '更新成功' : '创建成功');
dialogVisible.value = false;
emit('success');
} else {
ElMessage.error(res.msg || '创建失败');
ElMessage.error(res.msg || (formData.editId ? '更新失败' : '创建失败'));
}
} catch (error) {
console.group('[CREATE-DELIVERY] 异常日志');
@@ -1353,7 +1471,7 @@ const handleClose = () => {
formRef.value?.resetFields();
// 清空所有表单字段
Object.keys(formData).forEach(key => {
if (key === 'orderId') {
if (key === 'orderId' || key === 'editId') {
formData[key] = null;
} else if (typeof formData[key] === 'number') {
formData[key] = key === 'cattleCount' ? 1 : null;

View File

@@ -145,6 +145,7 @@ const getDataList = () => {
apiCall
.then((res) => {
console.log('=== API 调用成功 ===', res);
console.log('=== 原始返回数据 res.data ===', JSON.parse(JSON.stringify(res.data)));
data.dataListLoading = false;
if (res.code == 200) {
let rawData = [];
@@ -163,6 +164,9 @@ const getDataList = () => {
console.log('=== 使用 rows 格式数据 ===', { rawData, total });
}
console.log('=== rawData 原始数据数量 ===', rawData.length);
console.log('=== rawData 详细内容 ===', JSON.parse(JSON.stringify(rawData)));
// 处理数据:添加设备类型和分配状态
data.rows = rawData.map(item => {
const processedItem = { ...item };

View File

@@ -140,7 +140,6 @@ const data = reactive({
const form = reactive({
pageNum: 1,
pageSize: 10,
licensePlate: '',
});
const showAddDialog = (row) => {
@@ -170,12 +169,12 @@ const delClick = (row) => {
const getDataList = async () => {
data.dataListLoading = true;
try {
// ✅ 使用 baseSearchRef 获取搜索参数
const params = {
pageNum: form.pageNum,
pageSize: form.pageSize,
licensePlate: form.licensePlate,
...form,
...baseSearchRef.value.penetrateParams(),
};
console.log('查询参数:', params);
console.log('[VEHICLE-SEARCH] 查询参数:', params);
const res = await vehicleList(params);
console.log('查询结果:', res);