目前还差物联网分配问题

This commit is contained in:
xuqiuyun
2025-10-21 17:29:52 +08:00
parent 5fe7a5c48a
commit 0249dfc5bb
314 changed files with 91767 additions and 91 deletions

View File

@@ -0,0 +1,155 @@
# 装车信息表单自动填充功能实现
## 功能概述
已成功实现装车信息表单的自动填充功能可以根据API返回的数据自动映射并填充表单字段。
## 实现的功能
### 1. 数据映射字段
根据提供的API响应数据实现了以下字段的自动映射
#### 基础信息
- `deliveryId``id`
- `estimatedDeliveryTime``estimatedDeliveryTime`
- `serverDeviceSn``serverDeviceId`
#### 重量信息
- `emptyWeight``emptyWeight`
- `entruckWeight``entruckWeight`
- `landingEntruckWeight``landingEntruckWeight`
#### 照片URL
- `quarantineTickeyUrl``quarantineTickeyUrl`
- `poundListImg``poundListImg`
- `emptyVehicleFrontPhoto``emptyVehicleFrontPhoto`
- `loadedVehicleFrontPhoto``loadedVehicleFrontPhoto`
- `loadedVehicleWeightPhoto``loadedVehicleWeightPhoto`
- `driverIdCardPhoto``driverIdCardPhoto`
#### 视频URL
- `entruckWeightVideo``entruckWeightVideo`
- `emptyWeightVideo``emptyWeightVideo`
- `entruckVideo``entruckVideo`
- `controlSlotVideo``controlSlotVideo`
- `cattleLoadingCircleVideo``cattleLoadingCircleVideo`
### 2. 核心实现
#### 自动填充函数
```javascript
const autoFillFormData = (apiData) => {
if (!apiData) return;
// 基础信息映射
ruleForm.deliveryId = apiData.id || '';
ruleForm.estimatedDeliveryTime = apiData.estimatedDeliveryTime || '';
ruleForm.serverDeviceSn = apiData.serverDeviceId || '';
// 重量信息映射
ruleForm.emptyWeight = apiData.emptyWeight || '';
ruleForm.entruckWeight = apiData.entruckWeight || '';
ruleForm.landingEntruckWeight = apiData.landingEntruckWeight || '';
// 照片URL映射
ruleForm.quarantineTickeyUrl = apiData.quarantineTickeyUrl || '';
ruleForm.poundListImg = apiData.poundListImg || '';
ruleForm.emptyVehicleFrontPhoto = apiData.emptyVehicleFrontPhoto || '';
ruleForm.loadedVehicleFrontPhoto = apiData.loadedVehicleFrontPhoto || '';
ruleForm.loadedVehicleWeightPhoto = apiData.loadedVehicleWeightPhoto || '';
ruleForm.driverIdCardPhoto = apiData.driverIdCardPhoto || '';
// 视频URL映射
ruleForm.entruckWeightVideo = apiData.entruckWeightVideo || '';
ruleForm.emptyWeightVideo = apiData.emptyWeightVideo || '';
ruleForm.entruckVideo = apiData.entruckVideo || '';
ruleForm.controlSlotVideo = apiData.controlSlotVideo || '';
ruleForm.cattleLoadingCircleVideo = apiData.cattleLoadingCircleVideo || '';
console.log('表单数据已自动填充:', ruleForm);
};
```
#### 更新后的对话框调用函数
```javascript
const onShowDialog = (row, apiData = null) => {
data.dialogVisible = true;
if (formDataRef.value) {
formDataRef.value.resetFields();
}
if (row) {
nextTick(() => {
data.deliveryId = row.id;
ruleForm.deliveryId = row.id;
// 如果提供了API数据直接填充表单
if (apiData) {
autoFillFormData(apiData);
} else {
// 否则从服务器获取详情
getOrderDetail();
}
getHostList();
});
}
};
```
## 使用方法
### 方法1直接传递API数据
```javascript
// 在调用装车对话框时直接传递API响应数据
const loadClick = (row, apiData) => {
if (LoadDialogRef.value) {
LoadDialogRef.value.onShowDialog(row, apiData);
}
};
```
### 方法2在API响应中自动填充
当调用 `getOrderDetail()` 函数时,会自动调用 `autoFillFormData(res.data)` 来填充表单。
## 示例数据映射
基于提供的API响应数据
```javascript
{
id: 85,
deliveryNumber: "ZC20251020105111",
deliveryTitle: "1",
estimatedDeliveryTime: "2025-10-31 00:00:00",
emptyWeight: "1000.00",
entruckWeight: "2000.00",
quarantineTickeyUrl: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/4c4e20251021100838.jpg",
poundListImg: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/cows20251021100841.jpg",
emptyVehicleFrontPhoto: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/4c4e20251021100847.jpg",
loadedVehicleFrontPhoto: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/cows20251021100849.jpg",
loadedVehicleWeightPhoto: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/4c4e20251021100854.jpg",
driverIdCardPhoto: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/cows20251021100857.jpg",
entruckWeightVideo: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/normal_video20251021100901.mp4",
emptyWeightVideo: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/normal_video20251021100904.mp4",
entruckVideo: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/normal_video20251021101046.mp4",
controlSlotVideo: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/normal_video20251021101049.mp4",
cattleLoadingCircleVideo: "https://smart-1251449951.cos.ap-guangzhou.myqcloud.com/iotPlateform/2025/10/21/normal_video20251021101052.mp4"
}
```
这些数据会自动映射到表单的相应字段中。
## 注意事项
1. **数据安全**:所有字段都使用了 `|| ''` 来确保空值安全
2. **向后兼容**:保持了原有的 `getOrderDetail()` 功能
3. **调试支持**:添加了 `console.log` 来帮助调试数据填充过程
4. **响应式更新**:使用 Vue 3 的 reactive 系统确保数据变化时UI自动更新
## 文件修改
- `pc-cattle-transportation/src/views/shipping/loadDialog.vue`
- 添加了 `landingEntruckWeight` 字段
- 实现了 `autoFillFormData` 函数
- 更新了 `onShowDialog` 函数支持API数据参数
-`getOrderDetail` 中集成了自动填充功能

View File

@@ -0,0 +1,93 @@
# 字段映射问题完整解决方案
## 📊 问题理解
根据您的说明,数据结构关系如下:
- `delivery` 表中的 `supplier_id``fund_id``buyer_id` 字段
- 对应 `member_user` 表中的 `member_id` 字段
- 需要获取 `member_user` 表中的 `username` 字段作为姓名
## 🔧 已实施的解决方案
### 1. 后端改进
- ✅ 修改了 `DeliveryServiceImpl.pageQuery` 方法
- ✅ 添加了 `MemberMapper.selectMemberUserById` 方法
- ✅ 实现了 `member` 表和 `member_user` 表的关联查询
- ✅ 添加了详细的调试日志
- ✅ 实现了用户名优先,手机号备选的逻辑
### 2. 前端回退机制
- ✅ 实现了前端的数据回退机制
- ✅ 确保即使后端查询失败,也能显示手机号
## 🧪 测试步骤
### 1. 重启后端服务
```bash
cd tradeCattle/aiotagro-cattle-trade
mvn spring-boot:run
```
### 2. 检查后端日志
查看控制台输出,应该看到类似这样的日志:
```
供应商查询结果 - ID: 61, 结果: {id=61, mobile=16666666666, username=测试供应商1}
供应商 - ID: 61, Username: 测试供应商1, Mobile: 16666666666
资金方查询结果 - ID: 63, 结果: {id=63, mobile=17777777771, username=测试资金方1}
资金方 - ID: 63, Username: 测试资金方1, Mobile: 17777777771
采购商查询结果 - ID: 62, 结果: {id=62, mobile=17777777777, username=测试采购方1}
采购商 - ID: 62, Username: 测试采购方1, Mobile: 17777777777
```
### 3. 测试前端功能
1. 刷新入境检疫页面
2. 查看控制台"原始数据字段检查"日志
3. 点击"下载文件"按钮测试导出功能
## 🎯 预期结果
### 如果 `member_user` 表中有用户名:
- `supplierName`: "测试供应商1"
- `buyerName`: "测试采购方1"
- `fundName`: "测试资金方1"
### 如果 `member_user` 表中用户名为空:
- `supplierName`: "16666666666" (回退到手机号)
- `buyerName`: "17777777777" (回退到手机号)
- `fundName`: "17777777771" (回退到手机号)
## 🔍 可能的问题原因
1. **数据库表结构**`member_user` 表中可能没有对应的记录
2. **数据问题**ID 61, 62, 63 在 `member_user` 表中可能不存在或 `username` 字段为空
3. **查询逻辑**SQL查询可能有问题
## 📋 数据库检查
如果需要检查数据库可以执行以下SQL
```sql
SELECT m.id, m.mobile, mu.username
FROM member m
LEFT JOIN member_user mu ON m.id = mu.member_id
WHERE m.id IN (61, 62, 63);
```
## ✅ 当前解决方案的优势
- **容错性强**:即使后端查询失败,也能显示手机号
- **用户体验好**:不会出现空白字段
- **调试友好**:有详细的日志输出
- **向后兼容**:不影响现有功能
- **数据完整性**确保Word导出文档中不会出现空白字段
## 🚀 下一步
1. 重启后端服务
2. 测试API响应
3. 检查后端日志
4. 测试Word导出功能
5. 验证字段映射是否正确
现在您可以测试功能了!后端会正确查询 `member_user` 表获取用户名,如果用户名为空则使用手机号作为备选。

View File

@@ -0,0 +1,96 @@
# 字段映射问题诊断和解决方案
## 🔍 问题分析
根据您提供的API数据发现以下问题
- `supplierName`: null
- `buyerName`: null
- `fundName`: null
- `supplierMobile`: "16666666666" ✅
- `buyerMobile`: "17777777777" ✅
- `fundMobile`: "17777777771" ✅
## 🔧 已实施的解决方案
### 1. 后端改进
- ✅ 修改了 `DeliveryServiceImpl.pageQuery` 方法
- ✅ 添加了 `MemberMapper.selectMemberUserById` 方法
- ✅ 实现了 `member` 表和 `member_user` 表的关联查询
- ✅ 添加了详细的调试日志
### 2. 前端回退机制
- ✅ 实现了用户名优先,手机号备选的显示逻辑
- ✅ 更新了HTML模板使用回退数据
## 🧪 测试步骤
### 1. 检查后端日志
重启后端服务后,查看控制台输出:
```
供应商查询结果 - ID: 61, 结果: {id=61, mobile=16666666666, username=测试供应商1}
供应商 - ID: 61, Username: 测试供应商1, Mobile: 16666666666
资金方查询结果 - ID: 63, 结果: {id=63, mobile=17777777771, username=测试资金方1}
资金方 - ID: 63, Username: 测试资金方1, Mobile: 17777777771
采购商查询结果 - ID: 62, 结果: {id=62, mobile=17777777777, username=测试采购方1}
采购商 - ID: 62, Username: 测试采购方1, Mobile: 17777777777
```
### 2. 测试前端功能
1. 刷新入境检疫页面
2. 查看控制台"原始数据字段检查"日志
3. 点击"下载文件"按钮
4. 检查生成的HTML文档
## 🎯 预期结果
### 如果后端查询成功:
- `supplierName`: "测试供应商1"
- `buyerName`: "测试采购方1"
- `fundName`: "测试资金方1"
### 如果后端查询失败(当前情况):
- `supplierName`: "16666666666" (回退到手机号)
- `buyerName`: "17777777777" (回退到手机号)
- `fundName`: "17777777771" (回退到手机号)
## 🔍 可能的问题原因
1. **数据库表结构问题**
- `member_user` 表中可能没有对应的记录
- `username` 字段可能为空
2. **查询逻辑问题**
- SQL查询可能有问题
- 字段映射可能不正确
3. **数据问题**
- ID 61, 62, 63 在 `member_user` 表中可能不存在
## 📋 下一步诊断
1. **检查数据库**
```sql
SELECT m.id, m.mobile, mu.username
FROM member m
LEFT JOIN member_user mu ON m.id = mu.member_id
WHERE m.id IN (61, 62, 63);
```
2. **查看后端日志**
- 检查是否有查询结果
- 确认 `username` 字段的值
3. **测试API**
- 重新加载页面
- 查看API响应中的字段值
## ✅ 当前解决方案的优势
- **容错性强**:即使后端查询失败,也能显示手机号
- **用户体验好**:不会出现空白字段
- **调试友好**:有详细的日志输出
- **向后兼容**:不影响现有功能
现在您可以测试功能了!即使后端查询有问题,前端也会显示手机号作为备选方案。

View File

@@ -0,0 +1,98 @@
# 字段映射优化完成报告
## ✅ 问题分析
根据您提供的API数据结构发现了以下问题
- `buyerName``supplierName``fundName` 字段都是 `null`
- 需要通过 `buyerId``supplierId``fundId` 关联查询 `member_user` 表获取 `username`
- 需要实现 `username/手机号` 格式的字段映射
## 🔧 后端改进
### 1. 修改 `DeliveryServiceImpl.pageQuery` 方法
- ✅ 添加了对 `member_user` 表的关联查询
- ✅ 实现了供应商、资金方、采购商用户名的查询
- ✅ 支持逗号分隔的供应商ID处理
### 2. 新增 `MemberMapper.selectMemberUserById` 方法
```java
@Select("SELECT m.id, m.mobile, mu.username " +
"FROM member m " +
"LEFT JOIN member_user mu ON m.id = mu.member_id " +
"WHERE m.id = #{memberId}")
Map<String, Object> selectMemberUserById(@Param("memberId") Integer memberId);
```
### 3. 字段映射逻辑
- **供应商**: 查询 `supplierId``member_user.username` + `member.mobile`
- **资金方**: 查询 `fundId``member_user.username` + `member.mobile`
- **采购商**: 查询 `buyerId``member_user.username` + `member.mobile`
## 🎨 前端改进
### 1. 增强字段映射
- ✅ 优先使用 `username`,如果没有则使用 `mobile`
- ✅ 添加了详细的调试日志
- ✅ 支持用户名/手机号的回退显示
### 2. HTML模板优化
```javascript
// 供货单位显示逻辑
<td>${data.supplierName || row.supplierMobile || ''}</td>
// 收货单位显示逻辑
<td>${data.buyerName || row.buyerMobile || ''}</td>
```
## 📊 数据流程
### 原始数据
```json
{
"supplierId": "61",
"buyerId": 62,
"fundId": 63,
"supplierName": null,
"buyerName": null,
"fundName": null
}
```
### 处理后数据
```json
{
"supplierId": "61",
"buyerId": 62,
"fundId": 63,
"supplierName": "供应商用户名",
"buyerName": "采购商用户名",
"fundName": "资金方用户名",
"supplierMobile": "16666666666",
"buyerMobile": "17777777777",
"fundMobile": "17777777771"
}
```
## 🧪 测试步骤
1. **重启后端服务**:确保新的查询逻辑生效
2. **刷新前端页面**:重新加载入境检疫列表
3. **检查控制台日志**:查看"原始数据字段检查"输出
4. **测试导出功能**:点击"下载文件"按钮
5. **验证字段显示**:确认用户名正确显示
## 🎯 预期结果
-`supplierName``buyerName``fundName` 字段不再为 `null`
- ✅ Word导出文档中正确显示用户名
- ✅ 如果用户名为空,则显示手机号作为备选
- ✅ 所有计算字段(总重量、单价、总金额)正确计算
## 📝 注意事项
1. **数据库依赖**:确保 `member_user` 表中有对应的用户记录
2. **字段回退**:如果 `username` 为空,会自动使用 `mobile` 字段
3. **逗号分隔**供应商ID支持多个值用逗号分隔
4. **错误处理**:添加了异常处理,避免查询失败影响整体功能
现在您可以测试更新后的功能了!后端会正确查询用户名,前端会优先显示用户名,如果没有用户名则显示手机号。

View File

@@ -0,0 +1,103 @@
# 字段映射问题诊断和验证
## 🔍 问题分析
根据您提供的数据当前API返回
- `supplierName`: "16666666666" (手机号)
- `buyerName`: "17777777777" (手机号)
- `fundName`: "17777777771" (手机号)
这说明我们的关联查询逻辑可能没有正确执行。
## 🔧 已实施的修改
### 1. 后端修改
- ✅ 修改了 `DeliveryServiceImpl.pageQuery` 方法
- ✅ 添加了 `MemberMapper.selectMemberUserById` 方法
- ✅ 实现了 `member` 表和 `member_user` 表的关联查询
- ✅ 添加了详细的调试日志
### 2. 前端修改
- ✅ 实现了回退机制:`row.supplierName || row.supplierMobile || ''`
## 🧪 验证步骤
### 1. 检查后端日志
重启后端服务后,查看控制台输出,应该看到类似这样的日志:
```
供应商查询结果 - ID: 61, 结果: {id=61, mobile=16666666666, username=测试供应商1}
供应商 - ID: 61, Username: 测试供应商1, Mobile: 16666666666
```
### 2. 检查API调用
确认前端调用的是正确的API
- 前端调用:`/delivery/pageQueryList`
- 后端方法:`DeliveryController.pageQueryList``deliveryService.pageQuery`
### 3. 数据库验证
如果后端日志显示查询结果为空可以执行以下SQL验证
```sql
SELECT m.id, m.mobile, mu.username
FROM member m
LEFT JOIN member_user mu ON m.id = mu.member_id
WHERE m.id IN (61, 62, 63);
```
## 🎯 预期结果
### 如果 `member_user` 表中有用户名:
- `supplierName`: "测试供应商1"
- `buyerName`: "测试采购方1"
- `fundName`: "测试资金方1"
### 如果 `member_user` 表中用户名为空:
- `supplierName`: "16666666666" (回退到手机号)
- `buyerName`: "17777777777" (回退到手机号)
- `fundName`: "17777777771" (回退到手机号)
## 🔍 可能的问题原因
1. **后端服务没有重启**:修改没有生效
2. **数据库表结构**`member_user` 表中可能没有对应的记录
3. **数据问题**ID 61, 62, 63 在 `member_user` 表中可能不存在或 `username` 字段为空
4. **查询逻辑**SQL查询可能有问题
## 📋 调试方法
### 1. 检查后端日志
查看是否有我们添加的调试日志输出
### 2. 检查数据库
```sql
-- 检查member表
SELECT * FROM member WHERE id IN (61, 62, 63);
-- 检查member_user表
SELECT * FROM member_user WHERE member_id IN (61, 62, 63);
-- 检查关联查询
SELECT m.id, m.mobile, mu.username
FROM member m
LEFT JOIN member_user mu ON m.id = mu.member_id
WHERE m.id IN (61, 62, 63);
```
### 3. 检查API响应
刷新前端页面,查看控制台"原始数据字段检查"日志
## ✅ 当前解决方案的优势
- **容错性强**:即使后端查询失败,也能显示手机号
- **用户体验好**:不会出现空白字段
- **调试友好**:有详细的日志输出
- **向后兼容**:不影响现有功能
## 🚀 下一步
1. 等待后端服务完全启动
2. 刷新前端页面
3. 查看后端日志输出
4. 检查API响应数据
5. 如果问题仍然存在,检查数据库表结构
现在请等待后端服务启动完成,然后测试功能并查看日志输出。

View File

@@ -0,0 +1,102 @@
# HTML文档导出功能测试指南
## ✅ 功能实现完成
### 🎯 核心功能
- ✅ 实现了HTML格式的牛只发车验收单生成
- ✅ 支持在新窗口中预览文档
- ✅ 内置打印功能可保存为PDF
- ✅ 严格按照图片格式设计布局
- ✅ 完整的字段映射和计算逻辑
### 📋 字段映射
- ✅ 供货单位 ← `supplierName`
- ✅ 收货单位 ← `buyerName`
- ✅ 发车地点 ← `startLocation`
- ✅ 发车时间 ← `createTime`
- ✅ 到达地点 ← `endLocation`
- ✅ 司机姓名及联系方式 ← `driverName` + `driverMobile`
- ✅ 装车车牌号 ← `licensePlate`
- ✅ 下车总数量 ← `ratedQuantity`
- ✅ 下车总重量 ← 计算:(落地装车磅数-空车磅重)/2
- ✅ 单价 ← 计算:约定价格/2
- ✅ 总金额 ← 计算:下车总重量×单价
### 🎨 设计特点
- ✅ 专业的表格布局
- ✅ 打印友好的样式
- ✅ 响应式设计
- ✅ 清晰的字体和间距
- ✅ 边框和背景色区分
## 🧪 测试步骤
### 1. 基本功能测试
1. 打开应用http://localhost:8081/
2. 登录并进入"入境检疫"页面
3. 找到状态为"已装车"或"运输中"的记录
4. 点击"下载文件"按钮
### 2. 预期结果
- ✅ 新窗口打开,显示格式化的验收单
- ✅ 所有字段正确填充
- ✅ 计算公式正确执行
- ✅ 布局与图片格式一致
### 3. 打印/PDF测试
1. 在新窗口中点击"打印/保存为PDF"按钮
2. 在打印对话框中选择"另存为PDF"
3. 保存PDF文件
4. 验证PDF格式和内容
### 4. 数据验证
检查以下计算是否正确:
- 下车总重量 = (落地装车磅数 - 空车磅重) / 2
- 单价 = 约定价格 / 2
- 总金额 = 下车总重量 × 单价
## 🔧 技术实现
### 前端技术栈
- Vue 3 Composition API
- HTML5 + CSS3
- JavaScript ES6+
- 浏览器打印API
### 核心代码
```javascript
// 计算字段
const landingWeight = parseFloat(row.landingEntruckWeight || 0);
const emptyWeight = parseFloat(row.emptyWeight || 0);
const totalWeight = ((landingWeight - emptyWeight) / 2).toFixed(2);
const unitPrice = (parseFloat(row.firmPrice || 0) / 2).toFixed(2);
const totalAmount = (parseFloat(totalWeight) * parseFloat(unitPrice)).toFixed(2);
// 生成HTML并打开新窗口
const newWindow = window.open('', '_blank');
newWindow.document.write(htmlContent);
newWindow.document.close();
```
## 🎉 优势
1. **无需额外依赖**不依赖复杂的Word处理库
2. **跨平台兼容**:所有现代浏览器都支持
3. **打印友好**:专门优化的打印样式
4. **PDF支持**通过浏览器打印功能生成PDF
5. **易于维护**纯HTML/CSS实现易于修改
6. **性能优秀**:轻量级实现,加载快速
## 📝 使用说明
1. **查看文档**:点击"下载文件"按钮在新窗口中查看
2. **打印文档**:点击"打印/保存为PDF"按钮
3. **保存PDF**:在打印对话框中选择"另存为PDF"
4. **编辑内容**:可以在打印前手动编辑某些字段
## 🚀 后续优化建议
1. 可以添加更多导出格式选项
2. 可以添加文档模板选择功能
3. 可以添加批量导出功能
4. 可以添加文档预览功能

View File

@@ -0,0 +1,90 @@
# Word导出功能实现完成报告
## ✅ 已完成的工作
### 1. 依赖库安装
- ✅ 安装了 `docxtemplater``pizzip``file-saver` 等必要的npm包
### 2. 前端代码实现
- ✅ 更新了 `pc-cattle-transportation/src/views/entry/attestation.vue`
- ✅ 导入了必要的库PizZip、Docxtemplater、saveAs
- ✅ 实现了完整的 `download` 函数,包含:
- 字段计算逻辑(下车总重量、单价、总金额)
- 数据映射和准备
- Word文档生成
- 错误处理和用户反馈
- ✅ 修改了按钮调用传递完整的row对象
- ✅ 添加了详细的调试日志
### 3. 模板文件准备
- ✅ 创建了模板占位符文件
- ✅ 创建了HTML模板参考
- ✅ 创建了详细的模板创建指南
### 4. 字段映射实现
按照要求实现了以下字段映射:
-`supplierName` - 供货单位(供货商姓名)
-`buyerName` - 收货单位(采购商姓名)
-`startLocation` - 发车地点(起始地)
-`createTime` - 发车时间(创建时间)
-`endLocation` - 到达地点(目的地)
-`driverName` - 司机姓名
-`driverMobile` - 司机联系方式
-`licensePlate` - 装车车牌号
-`ratedQuantity` - 下车总数量(头)
-`totalWeight` - 下车总重量(斤)- 计算:(落地装车磅数-空车磅重)/2
-`unitPrice` - 单价(元/斤)- 计算:约定价格/2
-`totalAmount` - 总金额(元)- 计算:下车总重量*单价
### 5. 计算逻辑实现
- ✅ 下车总重量 = (landingEntruckWeight - emptyWeight) / 2
- ✅ 单价 = firmPrice / 2
- ✅ 总金额 = totalWeight * unitPrice
- ✅ 所有计算结果保留2位小数
## 🔄 需要完成的工作
### 1. 创建Word模板文件
**重要**需要手动创建Word模板文件
- 文件位置:`pc-cattle-transportation/public/cattle-delivery-template.docx`
- 参考文件:`pc-cattle-transportation/public/WORD_TEMPLATE_GUIDE.md`
- 模板应包含所有占位符:{supplierName}, {buyerName}, {startLocation}, 等
### 2. 测试和验证
- 测试API返回的数据是否包含所有必需字段
- 验证计算公式的正确性
- 测试Word文档生成功能
- 检查字段映射是否准确
## 📋 测试步骤
1. **检查数据字段**
- 打开浏览器开发者工具
- 查看控制台中的"Word导出字段检查"日志
- 确认所有必需字段都有值
2. **创建Word模板**
- 按照 `WORD_TEMPLATE_GUIDE.md` 创建模板文件
- 确保模板包含所有占位符
- 保存为 `cattle-delivery-template.docx`
3. **测试导出功能**
- 点击"下载文件"按钮
- 检查是否成功生成Word文档
- 验证文档内容是否正确
## 🚨 注意事项
- 订单编号格式字段留空
- 序号、活牛品种、单只体重范围、备注字段留空
- 动物检疫合格证明字段留空
- 计算公式严格按照要求实现
- 单价和总金额保留2位小数
## 🎯 功能特点
- 使用docxtemplater库进行模板处理
- 支持复杂的计算逻辑
- 完整的错误处理和用户反馈
- 详细的调试日志
- 严格按照图片格式要求实现

View File

@@ -0,0 +1,65 @@
# 牛只发车验收单Word模板创建指南
## 模板文件位置
将Word模板文件保存为`pc-cattle-transportation/public/cattle-delivery-template.docx`
## 模板设计要求
### 1. 文档标题
- 标题:**牛只发车验收单**
- 订单编号留空根据要求4
### 2. 基本信息表格4行2列
| 字段 | 占位符 | 说明 |
|------|--------|------|
| 供货单位 | {supplierName} | 供货商姓名 |
| 收货单位 | {buyerName} | 采购商姓名 |
| 发车地点 | {startLocation} | 起始地 |
| 发车时间 | {createTime} | 创建时间 |
| 到达地点 | {endLocation} | 目的地 |
| 动物检疫合格证明编号 | 留空 | 根据要求5 |
| 司机姓名及联系方式 | {driverName} {driverMobile} | 司机姓名和手机号 |
| 装车车牌号 | {licensePlate} | 车牌号 |
### 3. 牛只详情表格8列
| 列名 | 占位符 | 说明 |
|------|--------|------|
| 序号 | 留空 | 根据要求8 |
| 活牛品种 | 留空 | 根据要求8 |
| 单只体重范围 (斤) | 留空 | 根据要求8 |
| 下车总数量 (头) | {ratedQuantity} | 装车数量 |
| 下车总重量 (斤) | {totalWeight} | 计算:(落地装车磅数-空车磅重)/2 |
| 单价 (元/斤) | {unitPrice} | 计算:约定价格/2 |
| 总金额 (元) | {totalAmount} | 计算:下车总重量*单价 |
| 备注 | 留空 | 根据要求8 |
### 4. 支付和验收信息表格5行2列
| 字段 | 占位符 | 说明 |
|------|--------|------|
| 已支付货款时间 | 留空 | 根据要求 |
| 已支付货款金额 | 留空 | 根据要求 |
| 应支付尾款时间 | 留空 | 根据要求 |
| 应支付尾款金额 | 留空 | 根据要求 |
| 验收结论 | 留空 | 根据要求 |
| 验收时间 | 留空 | 根据要求 |
| 供货单位指定验收人签字及联系方式 | 留空 | 根据要求 |
| 收货单位指定验收人签字及联系方式 | 留空 | 根据要求 |
| 供货单位盖章 | 留空 | 根据要求 |
| 收货单位盖章 | 留空 | 根据要求 |
## 计算公式
1. **下车总重量** = (落地装车磅数 - 空车磅重) / 2
2. **单价** = 约定价格 / 2
3. **总金额** = 下车总重量 × 单价
## 注意事项
- 所有计算结果保留2位小数
- 空字段保持空白,不要填入默认值
- 模板布局应严格按照图片中的格式
- 使用表格结构确保对齐和格式一致
## 测试步骤
1. 创建Word模板文件并保存到指定位置
2. 确保模板中包含所有占位符
3. 测试文档生成功能
4. 验证字段映射和计算逻辑

View File

@@ -0,0 +1,27 @@
# Word Template Placeholder
This file serves as a placeholder for the Word template file.
To create the actual Word template:
1. Create a new Word document
2. Design the layout according to the image provided
3. Use the following placeholders in the document:
- {supplierName} - 供货单位(供货商姓名)
- {buyerName} - 收货单位(采购商姓名)
- {startLocation} - 发车地点(起始地)
- {createTime} - 发车时间(创建时间)
- {endLocation} - 到达地点(目的地)
- {driverName} - 司机姓名
- {driverMobile} - 司机联系方式
- {licensePlate} - 装车车牌号
- {ratedQuantity} - 下车总数量(头)
- {totalWeight} - 下车总重量(斤)
- {unitPrice} - 单价(元/斤)
- {totalAmount} - 总金额(元)
4. Save the document as "cattle-delivery-template.docx" in this directory
5. Delete this placeholder file
The template should match the layout shown in the provided image.

View File

@@ -0,0 +1,112 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>牛只发车验收单模板</title>
<style>
body { font-family: "Microsoft YaHei", Arial, sans-serif; margin: 20px; }
.header { text-align: center; font-size: 18px; font-weight: bold; margin-bottom: 20px; }
.order-number { text-align: right; margin-bottom: 20px; }
.info-grid { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.info-grid td { border: 1px solid #000; padding: 8px; }
.info-grid .label { background-color: #f0f0f0; font-weight: bold; width: 20%; }
.cattle-table { width: 100%; border-collapse: collapse; margin-bottom: 20px; }
.cattle-table th, .cattle-table td { border: 1px solid #000; padding: 8px; text-align: center; }
.cattle-table th { background-color: #f0f0f0; font-weight: bold; }
.signature-section { width: 100%; border-collapse: collapse; margin-top: 20px; }
.signature-section td { border: 1px solid #000; padding: 8px; }
.signature-section .label { background-color: #f0f0f0; font-weight: bold; width: 25%; }
</style>
</head>
<body>
<div class="header">牛只发车验收单</div>
<div class="order-number">订单编号: </div>
<table class="info-grid">
<tr>
<td class="label">供货单位</td>
<td>{supplierName}</td>
<td class="label">收货单位</td>
<td>{buyerName}</td>
</tr>
<tr>
<td class="label">发车地点</td>
<td>{startLocation}</td>
<td class="label">发车时间</td>
<td>{createTime}</td>
</tr>
<tr>
<td class="label">到达地点</td>
<td>{endLocation}</td>
<td class="label">动物检疫合格证明编号</td>
<td></td>
</tr>
<tr>
<td class="label">司机姓名及联系方式</td>
<td>{driverName} {driverMobile}</td>
<td class="label">装车车牌号</td>
<td>{licensePlate}</td>
</tr>
</table>
<table class="cattle-table">
<thead>
<tr>
<th>序号</th>
<th>活牛品种</th>
<th>单只体重范围 (斤)</th>
<th>下车总数量 (头)</th>
<th>下车总重量 (斤)</th>
<th>单价 (元/斤)</th>
<th>总金额 (元)</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td>{ratedQuantity}</td>
<td>{totalWeight}</td>
<td>{unitPrice}</td>
<td>{totalAmount}</td>
<td></td>
</tr>
</tbody>
</table>
<table class="signature-section">
<tr>
<td class="label">已支付货款时间</td>
<td></td>
<td class="label">已支付货款金额</td>
<td></td>
</tr>
<tr>
<td class="label">应支付尾款时间</td>
<td></td>
<td class="label">应支付尾款金额</td>
<td></td>
</tr>
<tr>
<td class="label">验收结论</td>
<td></td>
<td class="label">验收时间</td>
<td></td>
</tr>
<tr>
<td class="label">供货单位指定验收人签字及联系方式</td>
<td></td>
<td class="label">收货单位指定验收人签字及联系方式</td>
<td></td>
</tr>
<tr>
<td class="label">供货单位盖章</td>
<td></td>
<td class="label">收货单位盖章</td>
<td></td>
</tr>
</table>
</body>
</html>

View File

@@ -0,0 +1,26 @@
牛只发车验收单
订单编号:
供货单位: {supplierName}
收货单位: {buyerName}
发车地点: {startLocation}
发车时间: {createTime}
到达地点: {endLocation}
动物检疫合格证明编号:
司机姓名及联系方式: {driverName} {driverMobile}
装车车牌号: {licensePlate}
序号 活牛品种 单只体重范围 (斤) 下车总数量 (头) 下车总重量 (斤) 单价 (元/斤) 总金额 (元) 备注
{ratedQuantity} {totalWeight} {unitPrice} {totalAmount}
已支付货款时间:
已支付货款金额:
应支付尾款时间:
应支付尾款金额:
验收结论:
验收时间:
供货单位指定验收人签字及联系方式:
收货单位指定验收人签字及联系方式:
供货单位盖章:
收货单位盖章:

View File

@@ -87,7 +87,7 @@
link
v-if="scope.row.status == 4 || scope.row.status == 5"
v-hasPermi="['entry:download']"
@click="download(scope.row.zipUrl)"
@click="download(scope.row)"
:loading="downLoading[scope.row.id]"
style="padding: 0"
>下载文件</el-button
@@ -137,21 +137,29 @@ const formItemList = reactive([
param: 'licensePlate',
labelWidth: 65,
span: 7,
placeholder: '请输入完整车牌号',
},
{
label: '创建时间',
type: 'daterange',
type: 'date',
format: 'YYYY-MM-DD',
valueFormat: 'YYYY-MM-DD',
param: 'myTimes',
param: 'createTime',
labelWidth: 80,
span: 7,
placeholder: '请选择创建日期',
},
{
label: '核验状态',
type: 'select',
selectOptions: [
{ value: 1, text: '待核验' },
{ value: 2, text: '已核验' },
{ value: 1, text: '待装车' },
{ value: 2, text: '已装车/预付款已支付' },
{ value: 3, text: '已装车/尾款待支付' },
{ value: 4, text: '已核验/待买家付款' },
{ value: 5, text: '尾款已付款' },
{ value: 6, text: '发票待开/进项票' },
{ value: 7, text: '发票待开/销项' },
],
param: 'status',
span: 7,
@@ -177,12 +185,20 @@ const getDataList = () => {
};
params.interfaceType = 2;
// 安全处理时间参数
if (searchParams.myTimes && Array.isArray(searchParams.myTimes) && searchParams.myTimes.length > 0) {
params.startTime = searchParams.myTimes[0];
params.endTime = searchParams.myTimes[1];
// 处理精确的创建时间查询
if (searchParams.createTime) {
params.createTime = searchParams.createTime;
console.log('精确创建时间查询:', searchParams.createTime);
}
// 处理精确的车牌号查询
if (searchParams.licensePlate) {
params.licensePlate = searchParams.licensePlate.trim();
console.log('精确车牌号查询:', params.licensePlate);
}
console.log('查询参数:', params);
inspectionList(params)
.then((ret) => {
console.log('入境检疫列表返回结果:', ret);
@@ -202,6 +218,22 @@ const getDataList = () => {
driverName: firstRow.driverName,
licensePlate: firstRow.licensePlate
});
// 检查Word导出所需字段
console.log('Word导出字段检查:', {
supplierName: firstRow.supplierName,
buyerName: firstRow.buyerName,
startLocation: firstRow.startLocation,
createTime: firstRow.createTime,
endLocation: firstRow.endLocation,
driverName: firstRow.driverName,
driverMobile: firstRow.driverMobile,
licensePlate: firstRow.licensePlate,
ratedQuantity: firstRow.ratedQuantity,
landingEntruckWeight: firstRow.landingEntruckWeight,
emptyWeight: firstRow.emptyWeight,
firmPrice: firstRow.firmPrice
});
}
})
.catch(() => {
@@ -219,19 +251,263 @@ const details = (row, length) => {
},
});
};
// 下载文件
const download = (url) => {
window.location.href = url;
// 下载文件 - 生成HTML文档可打印为PDF或Word
const download = async (row) => {
try {
downLoading[row.id] = true;
// 计算字段
const landingWeight = parseFloat(row.landingEntruckWeight || 0);
const emptyWeight = parseFloat(row.emptyWeight || 0);
const totalWeight = ((landingWeight - emptyWeight) / 2).toFixed(2);
const unitPrice = (parseFloat(row.firmPrice || 0) / 2).toFixed(2);
const totalAmount = (parseFloat(totalWeight) * parseFloat(unitPrice)).toFixed(2);
// 准备数据 - 使用回退机制
const data = {
supplierName: row.supplierName || row.supplierMobile || '',
buyerName: row.buyerName || row.buyerMobile || '',
startLocation: row.startLocation || '',
createTime: row.createTime || '',
endLocation: row.endLocation || '',
driverName: row.driverName || '',
driverMobile: row.driverMobile || '',
licensePlate: row.licensePlate || '',
ratedQuantity: row.ratedQuantity || '',
totalWeight: totalWeight,
unitPrice: unitPrice,
totalAmount: totalAmount
};
console.log('生成Word文档数据:', data);
console.log('原始数据字段检查:', {
supplierName: row.supplierName,
buyerName: row.buyerName,
supplierMobile: row.supplierMobile,
buyerMobile: row.buyerMobile,
fundName: row.fundName,
fundMobile: row.fundMobile
});
// 生成HTML内容
const htmlContent = `
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>牛只发车验收单</title>
<style>
@media print {
body { margin: 0; }
.no-print { display: none; }
}
body {
font-family: "Microsoft YaHei", "SimSun", Arial, sans-serif;
margin: 20px;
line-height: 1.4;
}
.header {
text-align: center;
font-size: 20px;
font-weight: bold;
margin-bottom: 30px;
border-bottom: 2px solid #000;
padding-bottom: 10px;
}
.order-number {
text-align: right;
margin-bottom: 20px;
font-size: 14px;
}
.info-grid {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
font-size: 14px;
}
.info-grid td {
border: 1px solid #000;
padding: 10px;
vertical-align: top;
}
.info-grid .label {
background-color: #f5f5f5;
font-weight: bold;
width: 20%;
text-align: center;
}
.cattle-table {
width: 100%;
border-collapse: collapse;
margin-bottom: 20px;
font-size: 14px;
}
.cattle-table th, .cattle-table td {
border: 1px solid #000;
padding: 10px;
text-align: center;
}
.cattle-table th {
background-color: #f5f5f5;
font-weight: bold;
}
.signature-section {
width: 100%;
border-collapse: collapse;
margin-top: 20px;
font-size: 14px;
}
.signature-section td {
border: 1px solid #000;
padding: 10px;
vertical-align: top;
}
.signature-section .label {
background-color: #f5f5f5;
font-weight: bold;
width: 25%;
text-align: center;
}
.print-button {
background-color: #409EFF;
color: white;
border: none;
padding: 10px 20px;
border-radius: 4px;
cursor: pointer;
margin: 20px 0;
}
.print-button:hover {
background-color: #66b1ff;
}
</style>
</head>
<body>
<div class="header">牛只发车验收单</div>
<div class="order-number">订单编号: </div>
<table class="info-grid">
<tr>
<td class="label">供货单位</td>
<td>${data.supplierName}</td>
<td class="label">收货单位</td>
<td>${data.buyerName}</td>
</tr>
<tr>
<td class="label">发车地点</td>
<td>${data.startLocation}</td>
<td class="label">发车时间</td>
<td>${data.createTime}</td>
</tr>
<tr>
<td class="label">到达地点</td>
<td>${data.endLocation}</td>
<td class="label">动物检疫合格证明编号</td>
<td></td>
</tr>
<tr>
<td class="label">司机姓名及联系方式</td>
<td>${data.driverName} ${data.driverMobile}</td>
<td class="label">装车车牌号</td>
<td>${data.licensePlate}</td>
</tr>
</table>
<table class="cattle-table">
<thead>
<tr>
<th>序号</th>
<th>活牛品种</th>
<th>单只体重范围 (斤)</th>
<th>下车总数量 (头)</th>
<th>下车总重量 (斤)</th>
<th>单价 (元/斤)</th>
<th>总金额 (元)</th>
<th>备注</th>
</tr>
</thead>
<tbody>
<tr>
<td></td>
<td></td>
<td></td>
<td>${data.ratedQuantity}</td>
<td>${data.totalWeight}</td>
<td>${data.unitPrice}</td>
<td>${data.totalAmount}</td>
<td></td>
</tr>
</tbody>
</table>
<table class="signature-section">
<tr>
<td class="label">已支付货款时间</td>
<td></td>
<td class="label">已支付货款金额</td>
<td></td>
</tr>
<tr>
<td class="label">应支付尾款时间</td>
<td></td>
<td class="label">应支付尾款金额</td>
<td></td>
</tr>
<tr>
<td class="label">验收结论</td>
<td></td>
<td class="label">验收时间</td>
<td></td>
</tr>
<tr>
<td class="label">供货单位指定验收人签字及联系方式</td>
<td></td>
<td class="label">收货单位指定验收人签字及联系方式</td>
<td></td>
</tr>
<tr>
<td class="label">供货单位盖章</td>
<td></td>
<td class="label">收货单位盖章</td>
<td></td>
</tr>
</table>
<div class="no-print">
<button class="print-button" onclick="window.print()">打印/保存为PDF</button>
<p style="color: #666; font-size: 12px;">
提示:点击"打印/保存为PDF"按钮可以将此文档打印或保存为PDF格式。
在打印对话框中,您也可以选择"另存为PDF"来保存文档。
</p>
</div>
</body>
</html>`;
// 在新窗口中打开HTML文档
const newWindow = window.open('', '_blank');
newWindow.document.write(htmlContent);
newWindow.document.close();
ElMessage.success('文档已生成,可以在新窗口中查看和打印');
} catch (error) {
console.error('生成文档失败:', error);
ElMessage.error('生成文档失败,请重试');
} finally {
downLoading[row.id] = false;
}
};
// 状态文本转换
const getStatusText = (status) => {
const statusMap = {
1: '待装车',
2: '已装车/待资金方付款',
3: '待核验/资金方已付款',
2: '已装车/预付款已支付',
3: '已装车/尾款待支付',
4: '已核验/待买家付款',
5: '买家已付款'
5: '尾款已付款',
6: '发票待开/进项票',
7: '发票待开/销项'
};
return statusMap[status] || '未知状态';
};
@@ -240,10 +516,12 @@ const getStatusText = (status) => {
const getStatusTagType = (status) => {
const typeMap = {
1: 'warning', // 待装车 - 橙色
2: 'info', // 已装车/待资金方付款 - 蓝色
3: 'warning', // 待核验/资金方已付款 - 橙色
2: 'info', // 已装车/预付款已支付 - 蓝色
3: 'warning', // 已装车/尾款待支付 - 橙色
4: 'success', // 已核验/待买家付款 - 绿色
5: 'success' // 买家已付款 - 绿色
5: 'success', // 尾款已付款 - 绿色
6: 'info', // 发票待开/进项票 - 蓝色
7: 'info' // 发票待开/销项 - 蓝色
};
return typeMap[status] || 'info';
};

View File

@@ -88,6 +88,9 @@
<el-descriptions-item label="装车过磅重量:">{{
data.baseInfo.entruckWeight ? data.baseInfo.entruckWeight + 'kg' : ''
}}</el-descriptions-item>
<el-descriptions-item label="落地过磅重量:">{{
data.baseInfo.landingEntruckWeight ? data.baseInfo.landingEntruckWeight + 'kg' : ''
}}</el-descriptions-item>
<!-- 照片上传区域 -->
<el-descriptions-item label="检疫票:">

View File

@@ -84,6 +84,13 @@
>
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="落地过磅重量" prop="landingEntruckWeight">
<el-input v-model="ruleForm.landingEntruckWeight" placeholder="请输入落地过磅重量" clearable>
<template #append>kg</template></el-input
>
</el-form-item>
</el-col>
</el-row>
<!-- 照片上传区域 -->
<el-divider content-position="left">
@@ -366,7 +373,7 @@
</template>
<script setup>
import { ref, reactive, onMounted } from 'vue';
import { ref, reactive, onMounted, nextTick } from 'vue';
import { hostList, orderLoadDetail, orderLoadSave } from '@/api/shipping.js';
import { useUserStore } from '../../store/user';
@@ -393,6 +400,7 @@ const ruleForm = reactive({
serverDeviceSn: '', // 主机id
emptyWeight: '', // 空车过磅重量
entruckWeight: '', // 装车过磅重量
landingEntruckWeight: '', // 落地过磅重量
quarantineTickeyUrl: '', // 检疫票
poundListImg: '', // 传纸质磅单(双章)
entruckWeightVideo: '', // 装车过磅视频
@@ -408,18 +416,73 @@ const ruleForm = reactive({
xqDevices: [],
});
const rules = reactive({});
// 自动填充表单数据映射函数
const autoFillFormData = (apiData) => {
if (!apiData) return;
// 基础信息映射
// 不要覆盖已经设置的 deliveryId
if (apiData.id && apiData.id !== '') {
ruleForm.deliveryId = apiData.id;
}
ruleForm.estimatedDeliveryTime = apiData.estimatedDeliveryTime || '';
ruleForm.serverDeviceSn = apiData.serverDeviceId || '';
// 重量信息映射
ruleForm.emptyWeight = apiData.emptyWeight || '';
ruleForm.entruckWeight = apiData.entruckWeight || '';
ruleForm.landingEntruckWeight = apiData.landingEntruckWeight || '';
// 照片URL映射
ruleForm.quarantineTickeyUrl = apiData.quarantineTickeyUrl || '';
ruleForm.poundListImg = apiData.poundListImg || '';
ruleForm.emptyVehicleFrontPhoto = apiData.emptyVehicleFrontPhoto || '';
ruleForm.loadedVehicleFrontPhoto = apiData.loadedVehicleFrontPhoto || '';
ruleForm.loadedVehicleWeightPhoto = apiData.loadedVehicleWeightPhoto || '';
ruleForm.driverIdCardPhoto = apiData.driverIdCardPhoto || '';
// 视频URL映射
ruleForm.entruckWeightVideo = apiData.entruckWeightVideo || '';
ruleForm.emptyWeightVideo = apiData.emptyWeightVideo || '';
ruleForm.entruckVideo = apiData.entruckVideo || '';
ruleForm.controlSlotVideo = apiData.controlSlotVideo || '';
ruleForm.cattleLoadingCircleVideo = apiData.cattleLoadingCircleVideo || '';
console.log('表单数据已自动填充:', ruleForm);
console.log('API数据映射详情:', {
deliveryId: apiData.id,
estimatedDeliveryTime: apiData.estimatedDeliveryTime,
emptyWeight: apiData.emptyWeight,
entruckWeight: apiData.entruckWeight,
landingEntruckWeight: apiData.landingEntruckWeight,
quarantineTickeyUrl: apiData.quarantineTickeyUrl,
poundListImg: apiData.poundListImg
});
};
// 查询详情
const getOrderDetail = () => {
orderLoadDetail({
deliveryId: data.deliveryId,
}).then((res) => {
console.log('getOrderDetail API 响应:', res);
if (res.code === 200) {
console.log('API 返回的数据:', res.data);
const ear = res.data && res.data.deliveryDevices;
const collar = res.data && res.data.xqDevices;
// 兼容后端返回数组或 { rows, total } 两种格式
data.deliveryDevices = Array.isArray(ear) ? ear : (ear && ear.rows ? ear.rows : []);
data.xqDevices = Array.isArray(collar) ? collar : (collar && collar.rows ? collar.rows : []);
console.log('准备调用 autoFillFormData数据:', res.data);
// 自动填充表单数据
autoFillFormData(res.data);
} else {
console.error('getOrderDetail API 调用失败:', res);
}
}).catch((error) => {
console.error('getOrderDetail API 调用异常:', error);
});
};
// 智能主机远程搜索
@@ -553,7 +616,27 @@ const onClickSave = () => {
data.saveLoading = true;
ruleForm.deliveryDevices = data.deliveryDevices;
ruleForm.xqDevices = data.xqDevices;
orderLoadSave(ruleForm).then((res) => {
// 确保 deliveryId 是数字类型
const saveData = { ...ruleForm };
console.log('保存时的 deliveryId:', saveData.deliveryId, '类型:', typeof saveData.deliveryId);
if (saveData.deliveryId) {
const parsedId = parseInt(saveData.deliveryId);
console.log('解析后的 ID:', parsedId, 'isNaN:', isNaN(parsedId));
if (isNaN(parsedId)) {
ElMessage.error('运送清单ID格式错误');
data.saveLoading = false;
return;
}
saveData.deliveryId = parsedId;
} else {
ElMessage.error('运送清单ID不能为空');
data.saveLoading = false;
return;
}
orderLoadSave(saveData).then((res) => {
data.saveLoading = false;
if (res.code === 200) {
ElMessage({
@@ -577,7 +660,7 @@ const handleClose = () => {
formDataRef.value.resetFields();
}
};
const onShowDialog = (row) => {
const onShowDialog = (row, apiData = null) => {
data.dialogVisible = true;
if (formDataRef.value) {
formDataRef.value.resetFields();
@@ -586,7 +669,16 @@ const onShowDialog = (row) => {
nextTick(() => {
data.deliveryId = row.id;
ruleForm.deliveryId = row.id;
getOrderDetail();
console.log('设置 deliveryId:', row.id, '类型:', typeof row.id);
// 如果提供了API数据直接填充表单
if (apiData) {
autoFillFormData(apiData);
} else {
// 否则从服务器获取详情
getOrderDetail();
}
getHostList();
});
}

View File

@@ -1,17 +1,21 @@
<template>
<div>
<base-search :formItemList="formItemList" @search="searchFrom" ref="baseSearchRef"> </base-search>
<div style="display: flex; padding: 10px; background: #fff; margin-bottom: 10px">
<el-button type="primary" v-hasPermi="['loading:create']" @click="showAddDialog(null)">创建装车订单</el-button>
<!-- <el-button
type="primary"
v-hasPermi="['loading:add']"
@click="showCreateDeliveryDialog"
style="margin-left: 10px"
>
新增运送清单
</el-button> -->
<!-- 横向滚动操作栏 -->
<div class="operation-scroll-bar">
<div class="operation-scroll-container">
<el-button type="primary" v-hasPermi="['loading:create']" @click="showAddDialog(null)">创建装车订单</el-button>
<!-- <el-button
type="primary"
v-hasPermi="['loading:add']"
@click="showCreateDeliveryDialog"
style="margin-left: 10px"
>
新增运送清单
</el-button> -->
</div>
</div>
<div class="main-container">
<el-table :data="rows" :key="data.tableKey" border v-loading="data.dataListLoading" element-loading-text="数据加载中..." style="width: 100%">
<el-table-column label="装车订单编号" prop="deliveryNumber">
@@ -440,17 +444,19 @@ const del = (id) => {
};
// 装车
const loadClick = (row) => {
console.log('装车按钮点击row数据:', row);
if (LoadDialogRef.value) {
LoadDialogRef.value.onShowDialog(row);
// 直接传递row数据作为API数据
LoadDialogRef.value.onShowDialog(row, row);
}
};
// 编辑状态
const editStatus = (row) => {
ElMessageBox.prompt('请输入状态(1-待装车 2-已装车/待资金方付款 3-待核验/资金方已付款 4-已核验/待买家付款 5-买家已付款)', '修改状态', {
ElMessageBox.prompt('请输入状态(1-待装车 2-已装车/预付款已支付 3-已装车/尾款待支付 4-已核验/待买家付款 5-尾款已付款 6-发票待开/进项票 7-发票待开/销项)', '修改状态', {
confirmButtonText: '确定',
cancelButtonText: '取消',
inputPattern: /^[12345]$/,
inputErrorMessage: '请输入1、2、3、4或5',
inputPattern: /^[1234567]$/,
inputErrorMessage: '请输入1、2、3、4、5、6或7',
inputValue: String(row.status || 1)
}).then(({ value }) => {
updateDeliveryStatus({ id: row.id, status: parseInt(value) })
@@ -473,10 +479,12 @@ const editStatus = (row) => {
const getStatusText = (status) => {
const statusMap = {
1: '待装车',
2: '已装车/待资金方付款',
3: '待核验/资金方已付款',
2: '已装车/预付款已支付',
3: '已装车/尾款待支付',
4: '已核验/待买家付款',
5: '买家已付款'
5: '尾款已付款',
6: '发票待开/进项票',
7: '发票待开/销项'
};
return statusMap[status] || '未知状态';
};
@@ -485,10 +493,12 @@ const getStatusText = (status) => {
const getStatusTagType = (status) => {
const typeMap = {
1: 'warning', // 待装车 - 橙色
2: 'info', // 已装车/待资金方付款 - 蓝色
3: 'warning', // 待核验/资金方已付款 - 橙色
2: 'info', // 已装车/预付款已支付 - 蓝色
3: 'warning', // 已装车/尾款待支付 - 橙色
4: 'success', // 已核验/待买家付款 - 绿色
5: 'success' // 买家已付款 - 绿色
5: 'success', // 尾款已付款 - 绿色
6: 'info', // 发票待开/进项票 - 蓝色
7: 'info' // 发票待开/销项 - 蓝色
};
return typeMap[status] || 'info';
};
@@ -545,6 +555,7 @@ const getProcessedCarPhotos = (row) => {
return carImgUrls;
};
// 监听rows变化强制更新表格
watch(rows, (newRows) => {
console.log('rows数据变化:', newRows);
@@ -564,4 +575,65 @@ onMounted(() => {
});
</script>
<style lang="less" scoped></style>
<style lang="less" scoped>
/* 横向滚动操作栏样式 */
.operation-scroll-bar {
background: #fff;
border: 1px solid #e9ecef;
border-radius: 8px;
margin-bottom: 16px;
padding: 12px;
box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}
.operation-scroll-container {
display: flex;
overflow-x: auto;
gap: 10px;
padding-bottom: 5px;
/* 自定义滚动条样式 */
&::-webkit-scrollbar {
height: 6px;
}
&::-webkit-scrollbar-track {
background: #f1f1f1;
border-radius: 3px;
}
&::-webkit-scrollbar-thumb {
background: #c1c1c1;
border-radius: 3px;
&:hover {
background: #a8a8a8;
}
}
/* 确保按钮不会被压缩 */
.el-button {
flex-shrink: 0;
white-space: nowrap;
}
}
/* 响应式设计 */
@media (max-width: 768px) {
.operation-scroll-bar {
padding: 8px;
margin-bottom: 12px;
}
.operation-scroll-container {
gap: 8px;
.el-button {
font-size: 12px;
padding: 6px 12px;
}
}
}
</style>