基本完成,修复细节
This commit is contained in:
@@ -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();
|
||||
});
|
||||
|
||||
@@ -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';
|
||||
};
|
||||
|
||||
365
pc-cattle-transportation/src/views/entry/devices.vue
Normal file
365
pc-cattle-transportation/src/views/entry/devices.vue
Normal 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>
|
||||
|
||||
Reference in New Issue
Block a user