|
|
@@ -624,12 +624,30 @@ export default {
|
|
|
thickness: "",
|
|
|
id: this.list.length,
|
|
|
});
|
|
|
+ // 新增行后重新计算到货总数
|
|
|
+ this.calculateTotalReceiptQty();
|
|
|
+ },
|
|
|
+ // 计算到货总数(所有行的 到货包数 x 每包数量 总和)
|
|
|
+ calculateTotalReceiptQty() {
|
|
|
+ if (this.list.length === 0) {
|
|
|
+ this.form.receiptQty = null;
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ const total = this.list.reduce((sum, item) => {
|
|
|
+ const bagQty = parseFloat(item.bagQty) || 0;
|
|
|
+ const qty = parseFloat(item.qty) || 0;
|
|
|
+ return this.getHandleNumber(sum + bagQty * qty);
|
|
|
+ }, 0);
|
|
|
+ this.form.receiptQty = total || null;
|
|
|
},
|
|
|
/** 删除按钮操作 */
|
|
|
+ /** 删除按钮操作 */
|
|
|
handleDelete(row, $index) {
|
|
|
const { id } = row;
|
|
|
const index = this.list.findIndex((item) => item.id === id);
|
|
|
this.list.splice(index, 1);
|
|
|
+ // 删除行后重新计算到货总数
|
|
|
+ this.calculateTotalReceiptQty();
|
|
|
},
|
|
|
/** 表单重置 */
|
|
|
reset() {
|
|
|
@@ -809,36 +827,17 @@ export default {
|
|
|
// 根据到货包数 到货包数*每包数量计算到货总数
|
|
|
handleBagQtyChange(row) {
|
|
|
const { bagQty, qty } = row;
|
|
|
- if (!bagQty || !qty) {
|
|
|
- this.form.receiptQty = null;
|
|
|
- return;
|
|
|
- }
|
|
|
- this.form.receiptQty = this.getHandleNumber(bagQty * qty);
|
|
|
- if (this.form.unitCode === "Pcs") {
|
|
|
- this.form.receiptQty = this.list.reduce((acc, cur) => {
|
|
|
- acc =
|
|
|
- this.getHandleNumber(acc) +
|
|
|
- this.getHandleNumber(cur.qty * cur.bagQty);
|
|
|
- return acc;
|
|
|
- }, 0);
|
|
|
+ // 当前行计算每包数量(如果是平方米单位)
|
|
|
+ if (this.form.unitName === "平方米" && row.length && row.width) {
|
|
|
+ row.qty = this.getHandleNumber((row.width / 1000) * row.length);
|
|
|
}
|
|
|
+ // 重新计算所有行的到货总数
|
|
|
+ this.calculateTotalReceiptQty();
|
|
|
},
|
|
|
// 根据每包数量 每包数量 * 到货包数
|
|
|
handleQtyChange(row) {
|
|
|
- const { bagQty, qty } = row;
|
|
|
- if (!bagQty || !qty) {
|
|
|
- this.form.receiptQty = null;
|
|
|
- return;
|
|
|
- }
|
|
|
- this.form.receiptQty = this.getHandleNumber(bagQty * qty);
|
|
|
- if (this.form.unitCode === "Pcs") {
|
|
|
- this.form.receiptQty = this.list.reduce((acc, cur) => {
|
|
|
- acc =
|
|
|
- this.getHandleNumber(acc) +
|
|
|
- this.getHandleNumber(cur.qty * cur.bagQty);
|
|
|
- return acc;
|
|
|
- }, 0);
|
|
|
- }
|
|
|
+ // 重新计算所有行的到货总数
|
|
|
+ this.calculateTotalReceiptQty();
|
|
|
},
|
|
|
// 原单单号change事件
|
|
|
OrderNoChange(item) {
|
|
|
@@ -964,28 +963,22 @@ export default {
|
|
|
const { length } = row;
|
|
|
if (length === null || length === undefined || length === 0) {
|
|
|
row.qty = undefined;
|
|
|
+ this.calculateTotalReceiptQty(); // 重新计算总数
|
|
|
return;
|
|
|
}
|
|
|
row.qty = this.getHandleNumber((row.width / 1000) * length);
|
|
|
- this.form.receiptQty = this.list.reduce(
|
|
|
- (sum, item) =>
|
|
|
- this.getHandleNumber(sum + item.qty * parseFloat(item.bagQty)),
|
|
|
- 0
|
|
|
- );
|
|
|
+ this.calculateTotalReceiptQty(); // 重新计算总数
|
|
|
},
|
|
|
// 根据长度计算每包数量
|
|
|
lengthChange(row) {
|
|
|
const { width } = row;
|
|
|
if (width === null || width === undefined || width === 0) {
|
|
|
row.qty = undefined;
|
|
|
+ this.calculateTotalReceiptQty(); // 重新计算总数
|
|
|
return;
|
|
|
}
|
|
|
row.qty = this.getHandleNumber((width / 1000) * row.length);
|
|
|
- this.form.receiptQty = this.list.reduce(
|
|
|
- (sum, item) =>
|
|
|
- this.getHandleNumber(sum + item.qty * parseFloat(item.bagQty)),
|
|
|
- 0
|
|
|
- );
|
|
|
+ this.calculateTotalReceiptQty(); // 重新计算总数
|
|
|
},
|
|
|
// 生产日期change事件
|
|
|
produceDateChange(v) {
|