|
@@ -1863,9 +1863,19 @@
|
|
|
validateForm(callback) {
|
|
validateForm(callback) {
|
|
|
//开始表单校验
|
|
//开始表单校验
|
|
|
this.$refs.form.validate((valid, obj) => {
|
|
this.$refs.form.validate((valid, obj) => {
|
|
|
- // 找出所有发货数量超过订单剩余数量的产品
|
|
|
|
|
- const exceededItems = this.form.datasource.filter(
|
|
|
|
|
- (item) => Number(item.totalCount) > item.notGenerateSendCount
|
|
|
|
|
|
|
+ // 同一订单产品可能拆成多条发货明细,删除明细后只按当前有效行汇总校验。
|
|
|
|
|
+ const groups = this.form.datasource.reduce((result, item) => {
|
|
|
|
|
+ const key = item.orderProductId
|
|
|
|
|
+ ? `order:${item.orderProductId}`
|
|
|
|
|
+ : `product:${item.productCode}|${item.batchNo || ''}|${item.colorKey || ''}|${item.modelType || ''}`;
|
|
|
|
|
+ const group = result[key] || { totalCount: 0, remainingCount: Number(item.notGenerateSendCount) || 0, productCode: item.productCode };
|
|
|
|
|
+ group.totalCount += Number(item.totalCount) || 0;
|
|
|
|
|
+ group.remainingCount = Math.max(group.remainingCount, Number(item.notGenerateSendCount) || 0);
|
|
|
|
|
+ result[key] = group;
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }, {});
|
|
|
|
|
+ const exceededItems = Object.values(groups).filter(
|
|
|
|
|
+ (item) => item.totalCount > item.remainingCount
|
|
|
);
|
|
);
|
|
|
// 退货单退货不校验数量,实物赔偿无法计算
|
|
// 退货单退货不校验数量,实物赔偿无法计算
|
|
|
if (
|
|
if (
|
|
@@ -1878,9 +1888,8 @@
|
|
|
.map((item) => item.productCode)
|
|
.map((item) => item.productCode)
|
|
|
.join('、');
|
|
.join('、');
|
|
|
this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
|
|
this.$message.warning(`${productNames} 的发货数量大于订单剩余数量`);
|
|
|
- if (this.isTotalCount == 1) {
|
|
|
|
|
- callback(false);
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ callback(false);
|
|
|
|
|
+ return;
|
|
|
}
|
|
}
|
|
|
if (obj) {
|
|
if (obj) {
|
|
|
let messages = Object.keys(obj).map((key) => obj[key][0]);
|
|
let messages = Object.keys(obj).map((key) => obj[key][0]);
|