Skip to main content

The purchase table in the form can stack the input quantity of the same product.

1. Usage scenarios

In the purchase, sale and storage scenario, if you purchase multiple items at a time in the purchase table, if you fill in the purchase goods Apple 20 and Apple 30 at the same time, you want to directly display Apple 50 in inventory statement.

2. Implement functions

2.1 Configuration page

You can enter the first purchase details.

The second purchase details are the actual data after data processing, which can hide the group without being visible to users.

2.2 configuration functions

Bind to the onChange of the first subform and modify the unique identifier of the component according to the actual situation.

export function onTableChange({ value, extra }) {
const temp = {}; // 定义一个对象
for (let i in value) {
let key = value[i].selectField_lblv886b; // 判断依据,利用对象的属性不能重复进行判断。
if (temp[key]) {
temp[key].selectField_lblv886e = value[i].selectField_lblv886b;
temp[key].numberField_lblv886f += Number(value[i].numberField_lblv886d);// 进货数量相加
} else {
temp[key] = {};
temp[key].selectField_lblv886e = value[i].selectField_lblv886b;
temp[key].numberField_lblv886f = Number(value[i].numberField_lblv886d);
}
};
const newArry = [];
for (let k in temp) {
newArry.push(temp[k]);
};
this.$("tableField_lblv886g").setValue(newArry)
}

3. Achieve results

4. Try it online

This doc is generated using machine translation. Any discrepancies or differences created in the translation are not binding and have no legal effect for compliance or enforcement purposes.
Copyright © 2024钉钉(中国)信息技术有限公司和/或其关联公司浙ICP备18037475号-4