基本完成v1.0
This commit is contained in:
@@ -856,8 +856,7 @@ const buildSubmitData = () => {
|
||||
}
|
||||
});
|
||||
|
||||
console.log('[buildSubmitData] 最终提交数据(已处理undefined):', data);
|
||||
|
||||
|
||||
return data;
|
||||
};
|
||||
|
||||
@@ -874,9 +873,7 @@ const open = async (editData = null) => {
|
||||
loadOrderList()
|
||||
]);
|
||||
|
||||
console.log('[OPEN-DIALOG] 所有下拉列表加载完成');
|
||||
console.log('[OPEN-DIALOG] 车辆列表:', vehicleOptions.value);
|
||||
|
||||
|
||||
// 如果传入了编辑数据,则填充表单
|
||||
if (editData) {
|
||||
fillFormWithEditData(editData);
|
||||
@@ -885,8 +882,7 @@ const open = async (editData = null) => {
|
||||
|
||||
// 填充编辑数据到表单
|
||||
const fillFormWithEditData = (editData) => {
|
||||
console.log('[EDIT-FILL] 开始填充编辑数据:', editData);
|
||||
|
||||
|
||||
// editData 包含两个部分:
|
||||
// 1. editData.delivery - 运单基本信息
|
||||
// 2. editData 的根级字段 - supplierId, buyerId, eartagIds, collarIds, serverIds
|
||||
@@ -899,13 +895,10 @@ const fillFormWithEditData = (editData) => {
|
||||
// 发货方和采购方:优先使用根级的 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) {
|
||||
@@ -918,17 +911,17 @@ const fillFormWithEditData = (editData) => {
|
||||
// 设备信息:从根级读取
|
||||
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);
|
||||
|
||||
}
|
||||
|
||||
// 地址和坐标
|
||||
@@ -972,7 +965,7 @@ const fillFormWithEditData = (editData) => {
|
||||
// 保存编辑的ID,用于区分是新增还是编辑
|
||||
formData.editId = delivery.id;
|
||||
|
||||
console.log('[EDIT-FILL] 表单数据已填充:', formData);
|
||||
|
||||
ElMessage.success('已加载运单数据');
|
||||
};
|
||||
|
||||
@@ -1109,8 +1102,7 @@ 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) {
|
||||
@@ -1128,15 +1120,15 @@ const handleDriverChange = (driverId) => {
|
||||
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('[司机选择] 司机已清除');
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1195,7 +1187,7 @@ const updateSelectedDevicesDeliveryId = async (deliveryId) => {
|
||||
});
|
||||
}
|
||||
|
||||
console.log(`成功更新 ${devicesToUpdate.length} 个设备的delivery_id和car_number: ${formData.plateNumber}`);
|
||||
|
||||
} catch (error) {
|
||||
console.error('更新设备delivery_id和car_number失败:', error);
|
||||
// 不阻止流程,只记录错误
|
||||
@@ -1222,15 +1214,13 @@ const handleSubmit = () => {
|
||||
console.group('[CREATE-DELIVERY] 提交前检查');
|
||||
try {
|
||||
const formSnapshot = JSON.parse(JSON.stringify(formData));
|
||||
console.log('表单快照 formData:', formSnapshot);
|
||||
console.log('地图坐标校验: startLon/startLat/endLon/endLat =', formData.startLon, formData.startLat, formData.endLon, formData.endLat);
|
||||
console.log('Token 是否存在:', !!userStore.$state.token);
|
||||
|
||||
} catch (e) {
|
||||
console.warn('表单快照序列化失败:', e);
|
||||
}
|
||||
|
||||
const submitData = buildSubmitData();
|
||||
console.log('最终请求体 payload:', submitData);
|
||||
|
||||
console.table(Object.keys(submitData).map(k => ({ key: k, type: typeof submitData[k], value: Array.isArray(submitData[k]) ? `Array(len=${submitData[k].length})` : submitData[k] })));
|
||||
if (submitData.eartagIds && submitData.eartagIds.some(v => typeof v === 'string')) {
|
||||
console.warn('eartagIds 仍包含字符串,将被后端拒绝:', submitData.eartagIds);
|
||||
@@ -1244,17 +1234,17 @@ const handleSubmit = () => {
|
||||
// 判断是编辑还是新增
|
||||
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) {
|
||||
@@ -1324,10 +1314,10 @@ const handleStartMarkerDrag = (e) => {
|
||||
|
||||
// 打开起点地图并处理地址搜索
|
||||
const openStartLocationMap = () => {
|
||||
console.log('openStartLocationMap 被调用');
|
||||
|
||||
// 如果输入框有地址,先进行地理编码
|
||||
if (formData.startLocation && formData.startLocation.trim()) {
|
||||
console.log('搜索起点地址:', formData.startLocation);
|
||||
|
||||
// 先打开地图对话框,让地图组件加载
|
||||
showStartLocationMap.value = true;
|
||||
|
||||
@@ -1339,31 +1329,31 @@ const openStartLocationMap = () => {
|
||||
const geocoder = new window.BMap.Geocoder();
|
||||
geocoder.getPoint(formData.startLocation, (point) => {
|
||||
if (point) {
|
||||
console.log('找到起点坐标:', point.lng, point.lat);
|
||||
|
||||
// 搜索到坐标,更新地图中心点和标记
|
||||
formData.startLon = point.lng;
|
||||
formData.startLat = point.lat;
|
||||
// 更新地图中心点
|
||||
ElMessage.success('已定位到该地址');
|
||||
} else {
|
||||
console.log('未找到起点地址');
|
||||
|
||||
ElMessage.warning('未找到该地址,请在地图上手动选择');
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
console.log('未输入起点地址,直接打开地图');
|
||||
|
||||
showStartLocationMap.value = true;
|
||||
}
|
||||
};
|
||||
|
||||
// 打开目的地地图并处理地址搜索
|
||||
const openEndLocationMap = () => {
|
||||
console.log('openEndLocationMap 被调用');
|
||||
|
||||
// 如果输入框有地址,先进行地理编码
|
||||
if (formData.endLocation && formData.endLocation.trim()) {
|
||||
console.log('搜索目的地地址:', formData.endLocation);
|
||||
|
||||
// 先打开地图对话框,让地图组件加载
|
||||
showEndLocationMap.value = true;
|
||||
|
||||
@@ -1373,21 +1363,21 @@ const openEndLocationMap = () => {
|
||||
const geocoder = new window.BMap.Geocoder();
|
||||
geocoder.getPoint(formData.endLocation, (point) => {
|
||||
if (point) {
|
||||
console.log('找到目的地坐标:', point.lng, point.lat);
|
||||
|
||||
// 搜索到坐标,更新地图中心点和标记
|
||||
formData.endLon = point.lng;
|
||||
formData.endLat = point.lat;
|
||||
// 更新地图中心点
|
||||
ElMessage.success('已定位到该地址');
|
||||
} else {
|
||||
console.log('未找到目的地地址');
|
||||
|
||||
ElMessage.warning('未找到该地址,请在地图上手动选择');
|
||||
}
|
||||
});
|
||||
}
|
||||
}, 500);
|
||||
} else {
|
||||
console.log('未输入目的地地址,直接打开地图');
|
||||
|
||||
showEndLocationMap.value = true;
|
||||
}
|
||||
};
|
||||
@@ -1428,7 +1418,7 @@ const makeUploadSuccessSetter = (key) => (response) => {
|
||||
const url = resolveUploadUrl(response);
|
||||
if (response?.code === 200 && url) {
|
||||
formData[key] = url;
|
||||
console.log(`[UPLOAD] ${key} =`, url);
|
||||
|
||||
ElMessage.success('上传成功');
|
||||
} else {
|
||||
console.warn(`[UPLOAD] 未识别的响应结构:`, response);
|
||||
|
||||
Reference in New Issue
Block a user