Skip to main content

The purchase table 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. Video Display

此处为语雀视频卡片,点击链接查看:刘明帅-进货表案例(1).mp4

3. Procedure

3.1 add a subform to the purchase table to store the processed data

Add a subform named purchase details subform to the purchase table to add data. Add a subform named purchase details to merge duplicate product names and add quantity in.

Add a subform on the form editing page

The purchase details subform can be hidden so that two subforms are not found to be confusing when submitting data. Even if hidden is set, the data is still the same and will be counted.

Note: After the purchase details subform is hidden, click Advanced> data submission> Select always submit

Set purchase details subform

3.2 click the purchase details subform to add a onChange event

Create an action for a subform

3.3 add the product name and onChange added in the purchase details subform in the added quantity in event. For more information about the code, see

JS panel

Reference code:

export function onChange({ value, extra }){
var temp = {};//定义一个对象
for (var i in value) {
var key = value[i].selectField_kq7ykbt2; //判断依据,利用对象的属性不能重复进行判断。
if (temp[key]) {
temp[key] .selectField_kq7ykbt8 = value[i].selectField_kq7ykbt2;
temp[key] .numberField_kq7ykbt9 += value[i].numberField_kq7ykbt5;// 进货数量相加
} else {
temp[key] = {};
temp[key] .selectField_kq7ykbt8 = value[i].selectField_kq7ykbt2;
temp[key] .numberField_kq7ykbt9 = value[i].numberField_kq7ykbt5;
}
}
//console.log("temp[key]", temp)
var newArry = [];
for (var k in temp) {
newArry.push(temp[k]);
}
//console.log(newArry);
this.$("tableField_kq7ykbt7").setValue(newArry)
}

3.4 Add Business Association rules

Triggered when the form of the purchase table is submitted, use the UPSERT formula to insert or update data to inventory statement

Add Business Association rules

For more information about business association rules, see the following figure.

Configure the UPSERT function

4. Try it online

-------------------- Get the latest information YIDA, welcome to follow US--------------------

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