|
|
|
@ -105,6 +105,7 @@ Page({ |
|
|
|
distance: '', |
|
|
|
weight: '', |
|
|
|
volume: '', |
|
|
|
quantity: '', |
|
|
|
waitTime: '40', |
|
|
|
|
|
|
|
// 车型信息
|
|
|
|
@ -189,14 +190,21 @@ Page({ |
|
|
|
// 从重量规格中提取数字
|
|
|
|
const weightMatch = firstSpec.weightSpec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
const weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsInfo.quantity) || 1; |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (firstSpec.weightSpec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsInfo.quantity) || 1; |
|
|
|
weight = (weightPerUnit * quantity) / 2; // 换算为公斤
|
|
|
|
} |
|
|
|
} |
|
|
|
// 计算体积
|
|
|
|
if (goodsInfo.producting && (goodsInfo.quantity || firstSpec.soldQuantity)) { |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsInfo.quantity) || 1; |
|
|
|
if (goodsInfo.producting && (goodsInfo.quantity || firstSpec.quantity)) { |
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsInfo.quantity) || 1; |
|
|
|
volume = this.calculateVolumeFromPackaging({ ...goodsInfo, quantity: quantity }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -219,6 +227,9 @@ Page({ |
|
|
|
// 生成格式化后的规格列表(用于 picker 显示)
|
|
|
|
const formattedSpecList = specList.map((item, index) => item.weightSpec || '规格' + (index + 1)); |
|
|
|
|
|
|
|
// 获取第一个规格的件数
|
|
|
|
const firstSpecQuantity = firstSpec ? (parseInt(firstSpec.soldQuantity) || parseInt(goodsInfo.quantity) || 1) : 1; |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
selectedGoods: goodsInfo, |
|
|
|
specList: specList, |
|
|
|
@ -226,7 +237,7 @@ Page({ |
|
|
|
selectedSpecIndex: selectedSpecIndex, |
|
|
|
'goodsInfo.weight': weight, |
|
|
|
'goodsInfo.volume': volume, |
|
|
|
'goodsInfo.quantity': goodsInfo.quantity || 1, |
|
|
|
'goodsInfo.quantity': firstSpecQuantity, |
|
|
|
weight: weight, // 同步到运输参数的重量输入框
|
|
|
|
volume: volume // 同步到运输参数的体积输入框
|
|
|
|
}); |
|
|
|
@ -274,14 +285,21 @@ Page({ |
|
|
|
// 从重量规格中提取数字
|
|
|
|
const weightMatch = firstSpec.weightSpec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
const weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsData.quantity) || 1; |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (firstSpec.weightSpec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsData.quantity) || 1; |
|
|
|
weight = (weightPerUnit * quantity) / 2; // 换算为公斤
|
|
|
|
} |
|
|
|
} |
|
|
|
// 计算体积
|
|
|
|
if (goodsData.producting && (goodsData.quantity || firstSpec.soldQuantity)) { |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsData.quantity) || 1; |
|
|
|
if (goodsData.producting && (goodsData.quantity || firstSpec.quantity)) { |
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsData.quantity) || 1; |
|
|
|
volume = this.calculateVolumeFromPackaging({ ...goodsData, quantity: quantity }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -304,6 +322,10 @@ Page({ |
|
|
|
// 生成格式化后的规格列表(用于 picker 显示)
|
|
|
|
const formattedSpecList = specList.map((item, index) => item.weightSpec || '规格' + (index + 1)); |
|
|
|
|
|
|
|
// 获取第一个规格的件数
|
|
|
|
const firstSpec = specList.length > 0 ? specList[0] : null; |
|
|
|
const firstSpecQuantity = firstSpec ? (parseInt(firstSpec.soldQuantity) || parseInt(goodsData.quantity) || 1) : (parseInt(goodsData.quantity) || 1); |
|
|
|
|
|
|
|
this.setData({ |
|
|
|
selectedGoods: goodsData, |
|
|
|
specList: specList, |
|
|
|
@ -311,9 +333,10 @@ Page({ |
|
|
|
selectedSpecIndex: selectedSpecIndex, |
|
|
|
'goodsInfo.weight': weight, |
|
|
|
'goodsInfo.volume': volume, |
|
|
|
'goodsInfo.quantity': goodsData.quantity || 1, |
|
|
|
'goodsInfo.quantity': firstSpecQuantity, |
|
|
|
weight: weight, // 同步到运输参数的重量输入框
|
|
|
|
volume: volume // 同步到运输参数的体积输入框
|
|
|
|
volume: volume, // 同步到运输参数的体积输入框
|
|
|
|
quantity: firstSpecQuantity // 同步到运输参数的件数输入框
|
|
|
|
}); |
|
|
|
|
|
|
|
// 自动匹配车型和车长
|
|
|
|
@ -417,14 +440,21 @@ Page({ |
|
|
|
// 从重量规格中提取数字
|
|
|
|
const weightMatch = firstSpec.weightSpec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
const weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsItem.quantity) || 1; |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (firstSpec.weightSpec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsItem.quantity) || 1; |
|
|
|
weight = (weightPerUnit * quantity) / 2; // 换算为公斤
|
|
|
|
} |
|
|
|
} |
|
|
|
// 计算体积
|
|
|
|
if (goodsItem.producting && (goodsItem.quantity || firstSpec.soldQuantity)) { |
|
|
|
const quantity = parseInt(firstSpec.soldQuantity || goodsItem.quantity) || 1; |
|
|
|
if (goodsItem.producting && (goodsItem.quantity || firstSpec.quantity)) { |
|
|
|
const quantity = parseInt(firstSpec.quantity || goodsItem.quantity) || 1; |
|
|
|
volume = this.calculateVolumeFromPackaging({ ...goodsItem, quantity: quantity }); |
|
|
|
} |
|
|
|
} |
|
|
|
@ -444,14 +474,20 @@ Page({ |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
// 获取第一个规格的件数
|
|
|
|
const firstSpec = specList.length > 0 ? specList[0] : null; |
|
|
|
const firstSpecQuantity = firstSpec ? (parseInt(firstSpec.soldQuantity) || parseInt(goodsItem.quantity) || 1) : 1; |
|
|
|
|
|
|
|
// 生成格式化后的规格列表(用于 picker 显示)
|
|
|
|
const formattedSpecList = specList.map((item, index) => item.weightSpec || '规格' + (index + 1)); |
|
|
|
|
|
|
|
// 设置规格列表
|
|
|
|
// 设置规格列表和件数
|
|
|
|
this.setData({ |
|
|
|
specList: specList, |
|
|
|
formattedSpecList: formattedSpecList, |
|
|
|
selectedSpecIndex: selectedSpecIndex |
|
|
|
selectedSpecIndex: selectedSpecIndex, |
|
|
|
'goodsInfo.quantity': firstSpecQuantity, |
|
|
|
quantity: firstSpecQuantity // 同步到运输参数的件数输入框
|
|
|
|
}); |
|
|
|
|
|
|
|
// 自动匹配车型和车长
|
|
|
|
@ -472,7 +508,14 @@ Page({ |
|
|
|
// 从规格字符串中提取数字
|
|
|
|
const weightMatch = spec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
const weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (spec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
// 计算总重量:重量(斤) * 件数 / 2(换算为公斤)
|
|
|
|
const totalWeight = (weightPerUnit * quantity) / 2; |
|
|
|
console.log('计算得到的总重量:', totalWeight, '公斤'); |
|
|
|
@ -671,24 +714,36 @@ Page({ |
|
|
|
if (selectedSpec.weightSpec) { |
|
|
|
const weightMatch = selectedSpec.weightSpec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
const weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
const quantity = parseInt(selectedSpec.soldQuantity || this.data.goodsInfo.quantity) || 1; |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (selectedSpec.weightSpec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
const quantity = parseInt(selectedSpec.quantity || this.data.goodsInfo.quantity) || 1; |
|
|
|
weight = (weightPerUnit * quantity) / 2; // 换算为公斤
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 计算体积
|
|
|
|
if (this.data.selectedGoods.producting && (this.data.goodsInfo.quantity || selectedSpec.soldQuantity)) { |
|
|
|
const quantity = parseInt(selectedSpec.soldQuantity || this.data.goodsInfo.quantity) || 1; |
|
|
|
if (this.data.selectedGoods.producting && (this.data.goodsInfo.quantity || selectedSpec.quantity)) { |
|
|
|
const quantity = parseInt(selectedSpec.quantity || this.data.goodsInfo.quantity) || 1; |
|
|
|
volume = this.calculateVolumeFromPackaging({ ...this.data.selectedGoods, quantity: quantity }); |
|
|
|
} |
|
|
|
|
|
|
|
// 更新重量和体积
|
|
|
|
// 获取当前规格的件数
|
|
|
|
const specQuantity = parseInt(selectedSpec.quantity || this.data.goodsInfo.quantity) || 1; |
|
|
|
|
|
|
|
// 更新重量、体积和件数
|
|
|
|
this.setData({ |
|
|
|
'goodsInfo.weight': weight, |
|
|
|
'goodsInfo.volume': volume, |
|
|
|
'goodsInfo.quantity': specQuantity, |
|
|
|
weight: weight, // 同步到运输参数的重量输入框
|
|
|
|
volume: volume // 同步到运输参数的体积输入框
|
|
|
|
volume: volume, // 同步到运输参数的体积输入框
|
|
|
|
quantity: specQuantity // 同步到运输参数的件数输入框
|
|
|
|
}); |
|
|
|
|
|
|
|
// 自动匹配车型和车长
|
|
|
|
@ -1514,6 +1569,58 @@ Page({ |
|
|
|
this.autoMatchVehicle(this.data.weight, volume); |
|
|
|
}, |
|
|
|
|
|
|
|
// 件数输入处理
|
|
|
|
bindQuantityInput: function(e) { |
|
|
|
const quantity = e.detail.value; |
|
|
|
this.setData({ quantity: quantity }); |
|
|
|
|
|
|
|
// 如果有选中的规格,重新计算重量和体积
|
|
|
|
if (this.data.specList.length > 0 && this.data.selectedSpecIndex >= 0) { |
|
|
|
const selectedSpec = this.data.specList[this.data.selectedSpecIndex]; |
|
|
|
if (selectedSpec) { |
|
|
|
let weight = ''; |
|
|
|
let volume = ''; |
|
|
|
|
|
|
|
// 从规格中提取重量
|
|
|
|
if (selectedSpec.weightSpec) { |
|
|
|
const weightMatch = selectedSpec.weightSpec.match(/(\d+(?:\.\d+)?)/); |
|
|
|
if (weightMatch && weightMatch.length > 1) { |
|
|
|
let weightPerUnit = parseFloat(weightMatch[1]); |
|
|
|
|
|
|
|
// 如果是净重,需要加上5斤的箱托重量
|
|
|
|
if (selectedSpec.weightSpec.includes('净重')) { |
|
|
|
weightPerUnit += 5; |
|
|
|
console.log('净重加上箱托重量后:', weightPerUnit, '斤'); |
|
|
|
} |
|
|
|
|
|
|
|
const qty = parseInt(quantity) || 1; |
|
|
|
weight = (weightPerUnit * qty) / 2; // 换算为公斤
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 计算体积
|
|
|
|
if (this.data.selectedGoods.producting && quantity) { |
|
|
|
const qty = parseInt(quantity) || 1; |
|
|
|
volume = this.calculateVolumeFromPackaging({ ...this.data.selectedGoods, quantity: qty }); |
|
|
|
} |
|
|
|
|
|
|
|
// 更新重量和体积
|
|
|
|
this.setData({ |
|
|
|
'goodsInfo.weight': weight, |
|
|
|
'goodsInfo.volume': volume, |
|
|
|
'goodsInfo.quantity': quantity, |
|
|
|
weight: weight, // 同步到运输参数的重量输入框
|
|
|
|
volume: volume // 同步到运输参数的体积输入框
|
|
|
|
}); |
|
|
|
|
|
|
|
// 自动匹配车型和车长
|
|
|
|
if (weight && volume) { |
|
|
|
this.autoMatchVehicle(weight, volume); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
// 根据重量和体积自动匹配车型和车长
|
|
|
|
autoMatchVehicle: function(weight, volume) { |
|
|
|
const weightNum = parseFloat(weight) || 0; |
|
|
|
|