The serial number is automatically taken out of the warehouse.
1. Use background
Many users will use forms to design the purchase, sale, storage, and warehousing scenarios. In order to improve the efficiency of data entry and define uniqueness for products, you can refer 「The serial number is automatically generated when the product is put into storage.The unique serial number of the product is automatically generated after the product is entered.So, how can we set the serial number to be automatically removed when the product is out of stock? For more information, see this document.
2. Procedure
Prepare three form pages: outbound process, intermediate table, and inventory statement 」.
2.1 Step 1: Create an intermediate table
Stores the product name, category, and serial number of the product. Subsequent outbound data is obtained from the intermediate table.
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 2.1-1)
Figure 2.1-1 intermediate table
2.2 Step 2: Create a Inventory statement
The inventory quantity used to store items.
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 2.2-1)
Figure 2.2-1 inventory statement
2.3 Step 3: Create the outbound process
The outbound process requires three detailed components, namely "outbound products" ,"outbound details" and "Outbound Product Details" (as shown in Figure 2.3-1).
Figure 2.3-1 display effect of outbound process
2.3.1 List of outbound products
The outbound product list is used to fill in outbound information and assign the serial number generated by the product name and quantity to the outbound product 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" ,"outbound quantity" and "inventory quantity" to the list respectively.
B. "product name" is set to associate other forms with the product name in the intermediate table (as shown in Figure 2.3.1-1).
c. Manually enter "outbound quantity" and set "inventory quantity" to read-only and data linkage, and link the inventory corresponding to the product name in "inventory Statement" (as shown in Figure 2.3.1-2).
B. Bind in the scheduleonchange
Action (as shown in Figure 2.3.1-3).
c. Copy the code to the pop-up JS panel and change the unique identifier of the component (as shown in Figure 2.3.1-4).
Figure 2.3.1-1 product name setting options
Figure 2.3.1-2 inventory quantity setting linkage
Figure 2.3.1-3 details binding onchange actions
Figure 2.3.1-4 detail JS code
The following code can be directly copied to the JS panel,Note: replace the unique identifier of the component according to Figure 2.3.1-4.
export function onChange({ value, extra }){
var temp = {};//定义一个对象
for (var i in value) {
var key = value[i].selectField_kvbycvt4; //判断依据,利用对象的属性不能重复进行判断。
if (temp[key]) {
temp[key].selectField_kvbycvt5 = value[i].selectField_kvbycvt4;
temp[key].numberField_kvbycvt1 += value[i].numberField_kvbycvst;// 出库数量相加
temp[key].numberField_kvg98dzj = value[i].numberField_kvbycvss;
} else {
temp[key] = {};
temp[key].selectField_kvbycvt5 = value[i].selectField_kvbycvt4;
temp[key].numberField_kvbycvt1 = value[i].numberField_kvbycvst;
temp[key].numberField_kvg98dzj = value[i].numberField_kvbycvss;
}
}
var newArry = [];
for (var k in temp) {
newArry.push(temp[k]);
}
this.$("tableField_kvbycvt3").setValue(newArry)
}
2.3.2 List of outbound details
The outbound details list is used as an intermediate table to store information such as the same product name in the outbound product list, and set rules to change the inventory in inventory statement.
Implementation idea: when the value changes, call the data in the "intermediate table" to obtain the serial number of the corresponding number of the selected data in the "product name.
(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 2.3.2-1)
c. Disable automatic loading.
Figure 2.3.2-1 add a remote data source
(2) bind onchange2 actions in the schedule
Procedure:
a. Add components named "product name" ,"outbound quantity" and "inventory quantity" to the list respectively.
B. Bind onchange actions to the outbound details list, namedonchange2
(As shown in Figure 2.3.2-2).
c. Copy the code to the pop-up JS panel and replace the unique identifier and formUuid (as shown in Figure 2.3.2-3).
Figure 3.3.2-2 binding onchange2 action
Figure 3.3.2-2 change unique identification, etc.
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 }){
var arr = [];
const tabArr = this.$("tableField_kvbycvt3").getValue();
const tab2Arr = [];//存储「出库商品明细」明细表数据
const tab2obj = {};//存储「出库商品明细」明细表数据
for (let i = 0; i < tabArr.length; i++) {//循环获取「出库详情」明细表中数据
if (tabArr[i].selectField_kvbycvt5 && tabArr[i].numberField_kvbycvt1){//如果「出库详情」中商品名称和数量不为空执行
const obj = { "textField_kv95f3o6": tabArr[i].selectField_kvbycvt5, "textField_kv96zpec": "否" }//定义中间表查询参数
let params = {
"formUuid": "FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5",
"pageSize":100,
"searchFieldJson": JSON.stringify(obj)
}
let that = this;
this.dataSourceMap.getDatas.load(params).then((response) => {//调用接口获取中间表内符合条件的数据
if (tabArr[i].numberField_kvbycvt1 <= 100) {//如果数据不超过100条执行
if (response.data[0]) {
const res = response.data;
for (let j = 0; j < tabArr[i].numberField_kvbycvt1; j++) {//循环将数据放入到存储「出库商品明细」定义的对象里
tab2obj.textField_kvbycvsl = res[j].formData.textField_kv95f3o6;//获取「中间表」的商品名称放入
tab2obj.textField_kvbycvsn = res[j].formData.textField_kv95f3oa;//获取「中间表」的序列号放入
tab2Arr.push({ ...tab2obj })
}
}
} else {//数据超过100条执行
for (let k = 0; k < Math.ceil(tabArr[i].numberField_kvbycvt1 / 100); k++) {
//判定循环 条数/100 向上取整的次数,用做循环次数和 currentPage 参数值
setTimeout(() => {
const obj = { "textField_kv95f3o6": tabArr[i].selectField_kvbycvt5, "textField_kv96zpec": "否" }
let params = {
formUuid: "FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5",
"searchFieldJson": JSON.stringify(obj),
pageSize: 100,
currentPage: k + 1,
};
that.dataSourceMap.getDatas.load(params).then(res => {
res.data.map(item => {
arr.push({ ...item.formData })
})
if (k +1 == Math.ceil(tabArr[i].numberField_kvbycvt1 / 100)){
//如果循环到最后一次,将数据循环放入到存储「出库商品明细」定义的对象里
for (let j = 0; j < tabArr[i].numberField_kvbycvt1; j++) {
tab2obj.textField_kvbycvsl = arr[j].textField_kv95f3o6;
tab2obj.textField_kvbycvsn = arr[j].textField_kv95f3oa;
tab2Arr.push({ ...tab2obj })
}
}
})
}, 1000 * k)
};
}
})
}
this.$("tableField_kvbycvsk").setValue(tab2Arr);
}
}
2.3.3 outbound product details
The outbound 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 2.3.3-1). The maximum number of entries in the experience edition is 50. For more information, click👉Maximum number of entries allowed
Figure 2.3.3-1 set the maximum number of entries
2.4 Step 4: Configure process design
Configure verification rules and business association rules in the outbound process (as shown in Figure 2.4-1).
2.4-1 process global settings
2.4.1 verification rules
a. In order to prevent the input deviation of serial numbers when the outbound number exceeds 500, verify and configure the start node (as shown in Figure 2.4.1-1).
B. Prevent the outbound quantity in the list from exceeding the inventory quantity, and perform blocking verification (as shown in Figure 2.4.1-1).
Figure 2.4.1-1 configure verification rules
The following code can be copied directly into the verification rule formula,Note: all form fields need to be replaced.
{"text":"IF(GT(SUM(出库详情.出库数量),500),TRUE(),FALSE())","marks":[{"from":{"line":0,"ch":10,"sticky":null},"to":{"line":0,"ch":21,"sticky":null},"value":"numberField_kvbycvt1","invalid":false}],"isCmData":true}
{"text":"GT(出库详情.出库数量,出库详情.库存数量)","marks":[{"from":{"line":0,"ch":3,"sticky":null},"to":{"line":0,"ch":14,"sticky":null},"value":"numberField_kvbycvt1","invalid":false},{"from":{"line":0,"ch":15,"sticky":null},"to":{"line":0,"ch":26,"sticky":null},"value":"numberField_kvg98dzj","invalid":false}],"isCmData":true}
2.4.2 associated operations
a. Configure the association operation when the end node agrees to change the "check out" field in the "intermediate table" to prevent the serial number from being repeatedly selected next time (as shown in Figure 2.4.2-1).
B. Configure the associated operation when the end node agrees to change the inventory field in inventory statement (as shown in Figure 2.4.2-1).
Figure 2.4.2-1 configure associated operations
The following code can be directly copied into the associated operation formula,Note: all form fields need to be replaced.
{"text":"UPDATE(中间表,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_kvbycvsn","invalid":false},{"from":{"line":0,"ch":45,"sticky":null},"to":{"line":0,"ch":55,"sticky":null},"value":"FORM-QQ866JB12STULJFWW45WJGSGSPYR191IE59VK5/textField_kv96zpec","invalid":false}],"isCmData":true}
{"text":"UPDATE(库存表,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_kvbycvt5","invalid":false},{"from":{"line":0,"ch":43,"sticky":null},"to":{"line":0,"ch":51,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9bosnz","invalid":false},{"from":{"line":0,"ch":52,"sticky":null},"to":{"line":0,"ch":60,"sticky":null},"value":"FORM-JNB661B13YTURX5KW87XHQF0W1OW17GIOB9VK0/numberField_kv9bosnz","invalid":false},{"from":{"line":0,"ch":61,"sticky":null},"to":{"line":0,"ch":72,"sticky":null},"value":"numberField_kvbycvt1","invalid":false}],"isCmData":true}
3. Achieve results
Figure 3-1 demonstration of the outbound process
Figure 3-2 middle table effect demonstration
Figure 3-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!
-------------------- Welcome to follow US--------------------