The serial number is automatically generated when the product is put into storage.
1. Use background
Many users use forms to design the purchase, sale, storage, and warehousing scenarios. In order to improve the efficiency of data entry and define uniqueness for a product, a unique serial number of the product needs to be automatically generated after the product is entered.So, how do we set the serial number to be automatically generated when the product is put into storage? For more information, see this document.
2. Video tutorial
To be added, please look forward...
3. Procedure
Prepare three form pages: Check in table, intermediate table, and inventory statement 」.
3.1 Step 1: Create an intermediate table
The serial number of the item in the inbound form.
Procedure:
a. Create a form named intermediate table 」.
B. On the edit page, add four single-line text components named "product name", "product category", "product serial number" and "whether to check out.
c. Click save.
(The operation effect is shown in Figure 3.1-1)
Figure 3.1-1 intermediate table
3.2 Step 2: Create a Inventory statement
Used to store the inventory quantity in the inbound form.
Procedure:
a. Create a form named inventory statement 」.
B. On the edit page, add a single-line text component named "product name" and two numerical components named "inventory" and "price.
c. Click save.
(The operation effect is shown in Figure 3.2-1)
Figure 3.2-1 inventory statement
3.3 Step 3: create a database table
The warehousing table requires three detailed components, namely "warehousing products" ,"warehousing details" and "warehousing Product Details" (as shown in Figure 3.3-1).
Figure 3.3-1 display effect of warehousing table
3.3.1 List of inbound products
The "Inbound product" list is used to fill in the inbound information and assign the serial number generated by the product name and quantity to the "Inbound product details" list.
If you have the same product name in the list, you need to configure to merge the same product name into a row and add the quantity. For more information, see the direct link of the document.👉The purchase table can stack the input quantity of the same product.
Procedure:
a. Add components named "product name" ,"product category" ,"public int count" and "inbound price" to the list.
B. Bind in the scheduleonchange
Action (as shown in figure 3.3.1-1).
c. Copy the code to the pop-up JS panel and change the unique identifier of the component (as shown in figure 3.3.1-2).
Figure 3.3.1-1 binding onchange
Figure 3.3.1-2 change the unique identifier of a field
The following code can be directly copied to the JS panel,Note: replace the unique identifier of the component according to Figure 3.3-3.
export function onChange({ value, extra }) {
var temp = {};//定义一个对象
for (var i in value) {
var key = value[i].selectField_kv7wpr8r; //判断依据,利用对象的属性不能重复进行判断。
if (temp[key]) {
temp[key].selectField_kv9b415z = value[i].selectField_kv7wpr8r;//商品名称
temp[key].textField_kva9eafg = value[i].textField_kv7wpr8s;//商品种类
temp[key].numberField_kv9b4161 += value[i].numberField_kv8vck0g;// 价格相加
temp[key].numberField_kv9b4162 += value[i].numberField_kv7wpr8v;// 数量相加
} else {
temp[key] = {};//同上
temp[key].selectField_kv9b415z = value[i].selectField_kv7wpr8r;
temp[key].textField_kva9eafg = value[i].textField_kv7wpr8s;
temp[key].numberField_kv9b4161 = value[i].numberField_kv8vck0g;
temp[key].numberField_kv9b4162 = value[i].numberField_kv7wpr8v;
}
}
var newArry = [];
for (var k in temp) {
newArry.push(temp[k]);
}
this.$("tableField_kv9b4163").setValue(newArry)
}
3.3.2 detailed list of warehousing details
The inbound details list is used as an intermediate table to store information such as the same product name in the inbound product list and pass the value to inventory statement 」.
Implementation idea: when the value changes, call the data in the "intermediate table" to obtain the latest serial number of the selected data in the "product name" so that the serial number does not increase repeatedly.
(1) add remote data sources
Procedure:
a. Click Add> quickly create a remote API
B. Name the remote data sourcegetDatas
, and enter the request address and change the AppType of the request address/dingtalk/web/APP_EFGOUXOHRUAZ3IWPNGCZ/v1/form/searchFormDatas.json
(As shown in figure 3.3.2-1)
c. Disable automatic loading.
Figure 3.3.2-1 add a remote data source
(2) bind onchange2 actions in the schedule
Procedure:
a. Add components named "product name" ,"product category" ,"public int count" and "inbound price" to the list.
B. Bind the onchange action in the inbound details list, namedonchange2
.
c. Copy the code to the pop-up JS panel and replace the unique identifier and formUuid (as shown in figure 3.3.2-2).
Figure 3.3.2-2 binding onchange2 action
The following code can be directly copied in the JS panel,Note: replace formUuid with the unique identifier of the component.
export function onChange2({ value, extra }){
const tabArr = this.$("tableField_kv9b4163").getValue();//获取「入库详情」明细表数据
const tab2Arr = [];//存放「入库商品明细」所需的数据
const tab2obj = {};
for (let i = 0; i < tabArr.length; i++) {//循环获取「入库详情」明细表内的数据
//调用数据源 getDatas ,请求参数为「入库详情」明细表中的商品名称,查询中间表的商品名称。
const obj = { "textField_kv95f3o6": tabArr[i].selectField_kv9b415z }
let params = {
"formUuid": "FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5",
"searchFieldJson": JSON.stringify(obj)
}
this.dataSourceMap.getDatas.load(params).then((response) => {
if (response.data[0]) {
const arr = response.data[0].formData.textField_kv95f3oa;//取到最新一条数据
const num = parseInt(arr.split("-")[1]);//截取序列号的数字
for (let j = 0; j < tabArr[i].numberField_kv9b4161; j++) {
//赋值商品名称
tab2obj.textField_kv7wpr8y = tabArr[i].selectField_kv9b415z;
//赋值商品种类
tab2obj.textField_kv7wpr8z = tabArr[i].textField_kva9eafg;
//赋值商品序列号
tab2obj.textField_kv7wpr90 = `${tabArr[i].selectField_kv9b415z}-${ j + num + 1}`;
tab2Arr.push({ ...tab2obj })
}
//给「入库商品明细」明细表赋值
this.$("tableField_kv7wpr8x").setValue(tab2Arr);
}else{
for (let j = 0; j < tabArr[i].numberField_kv9b4161; j++) {
//赋值商品名称
tab2obj.textField_kv7wpr8y = tabArr[i].selectField_kv9b415z;
//赋值商品种类
tab2obj.textField_kv7wpr8z = tabArr[i].textField_kva9eafg;
//赋值商品序列号
tab2obj.textField_kv7wpr90 = `${tabArr[i].selectField_kv9b415z}-${j}`;
tab2Arr.push({ ...tab2obj })
}
//给「入库商品明细」明细表赋值
this.$("tableField_kv7wpr8x").setValue(tab2Arr);
}
})
}
}
3.3.3 details of incoming goods
The product details list is used to store the product name, category, and corresponding serial number, and pass the value to the intermediate table 」.
Procedure:
a. Add components named "product name" ,"product category" and "serial number" to the list respectively.
B. Set the maximum number of entries (as shown in figure 3.3.3-1). The maximum number of entries in the experience edition is 50. For more information, click👉Maximum number of entries allowed
Figure 3.3.3-1 set the maximum number of entries
3.4 Step 4: Configure form settings
Configure form checksum and Business Association rules in the inbound table (as shown in Figure 3.4-1).
3.4-1 form settings
3.4.1 formula verification
In order to prevent the serial number entry deviation when the public int count exceeds 500, verify and configure the form submission (as shown in figure 3.4.1-1).
Figure 3.4.1-1 configuration formula verification
The following code can be copied directly into the submit verification formula,Note: You need to replace the inbound product. Public int count field.
{"text":"IF(GT(SUM(入库商品.入库数量),500),TRUE(),FALSE())","marks":[{"from":{"line":0,"ch":10,"sticky":null},"to":{"line":0,"ch":21,"sticky":null},"value":"numberField_kv8vck0g","invalid":false}],"isCmData":true}
3.4.2 business association rules
Configure business association rules to update intermediate tables and inventory statement (as shown in figure 3.4.2-1).
Figure 3.4.2-1 Business Association rules
(1) update intermediate tables
Figure 3.4.2-2 update intermediate tables
The following code can be copied directly into the formula,Note: all form fields need to be replaced.
{"text":"UPSERT(中间表,EQ(中间表.商品序列号,入库商品明细.序列号),\"\",中间表.商品名称,入库商品明细.商品名称,中间表.商品种类,入库商品明细.商品种类,中间表.商品序列号,入库商品明细.序列号,中间表.是否出库,\"否\")","marks":[{"from":{"line":0,"ch":7,"sticky":null},"to":{"line":0,"ch":12,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/","invalid":false},{"from":{"line":0,"ch":16,"sticky":null},"to":{"line":0,"ch":27,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv95f3oa","invalid":false},{"from":{"line":0,"ch":28,"sticky":null},"to":{"line":0,"ch":40,"sticky":null},"value":"textField_kv7wpr90","invalid":false},{"from":{"line":0,"ch":45,"sticky":null},"to":{"line":0,"ch":55,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv95f3o6","invalid":false},{"from":{"line":0,"ch":56,"sticky":null},"to":{"line":0,"ch":69,"sticky":null},"value":"textField_kv7wpr8y","invalid":false},{"from":{"line":0,"ch":70,"sticky":null},"to":{"line":0,"ch":80,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv95f3o7","invalid":false},{"from":{"line":0,"ch":81,"sticky":null},"to":{"line":0,"ch":94,"sticky":null},"value":"textField_kv7wpr8z","invalid":false},{"from":{"line":0,"ch":95,"sticky":null},"to":{"line":0,"ch":106,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv95f3oa","invalid":false},{"from":{"line":0,"ch":107,"sticky":null},"to":{"line":0,"ch":119,"sticky":null},"value":"textField_kv7wpr90","invalid":false},{"from":{"line":0,"ch":120,"sticky":null},"to":{"line":0,"ch":130,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv96zpec","invalid":false}],"isCmData":true}
(2) update inventory statement
Figure 3.4.2-3 update inventory statement
The following code can be copied directly into the formula,Note: all form fields need to be replaced.
{"text":"UPSERT(库存表,EQ(库存表.商品名称,入库详情.商品名称),\"\",库存表.商品名称,入库详情.商品名称,库存表.库存,库存表.库存+入库详情.入库数量,库存表.价格,库存表.价格+入库详情.入库价格)","marks":[{"from":{"line":0,"ch":7,"sticky":null},"to":{"line":0,"ch":12,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/","invalid":false},{"from":{"line":0,"ch":16,"sticky":null},"to":{"line":0,"ch":26,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/textField_kv9bosnv","invalid":false},{"from":{"line":0,"ch":27,"sticky":null},"to":{"line":0,"ch":38,"sticky":null},"value":"selectField_kv9b415z","invalid":false},{"from":{"line":0,"ch":43,"sticky":null},"to":{"line":0,"ch":53,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/textField_kv9bosnv","invalid":false},{"from":{"line":0,"ch":54,"sticky":null},"to":{"line":0,"ch":65,"sticky":null},"value":"selectField_kv9b415z","invalid":false},{"from":{"line":0,"ch":66,"sticky":null},"to":{"line":0,"ch":74,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9bosnz","invalid":false},{"from":{"line":0,"ch":75,"sticky":null},"to":{"line":0,"ch":83,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9bosnz","invalid":false},{"from":{"line":0,"ch":84,"sticky":null},"to":{"line":0,"ch":95,"sticky":null},"value":"numberField_kv9b4161","invalid":false},{"from":{"line":0,"ch":96,"sticky":null},"to":{"line":0,"ch":104,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9boso1","invalid":false},{"from":{"line":0,"ch":105,"sticky":null},"to":{"line":0,"ch":113,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9boso1","invalid":false},{"from":{"line":0,"ch":114,"sticky":null},"to":{"line":0,"ch":125,"sticky":null},"value":"numberField_kv9b4162","invalid":false}],"isCmData":true}
4. Effect demonstration
Figure 4-1 shows the effect of warehousing tables.
Figure 4-2 middle table effect demonstration
Figure 4-3 inventory statement effect demonstration
YIDA in order to better optimize the content and quality of YIDA user manual, it takes you 3-5 minutes to fill in the document feedback questionnaire. The document feedback questionnaire is submitted anonymously, and the questionnaire information is only used for YIDA document experience feedback collection. Thank you for your support for YIDA!
-------------------- Get the latest information YIDA, welcome to follow US--------------------