Skip to main content

Subform click add a serial number component plus one

1. Case Background

In some specific scenarios, the serial number in the subform cannot be used directly. We want to fill the serial number of the subform into the components in the subform and use it in other places, for example, for business association rules or formulas, see the following examples.

2. Achieve results

💡Enter the sequence number in the subform into the component in the subform

3. Implementation steps

3.1 create a form

Path: Enter the created application> upper left corner of the page + sign> Create form

Create a form

Form component configuration

Drag a single-line text component into the subform as the storage of serial numbers, and other components are added according to their own needs.

Component configuration

3.2 Action binding and JS configuration

3.2.1 action binding

Create an action onAddClick click add, click delete, and click copy, and bind an action at the same time.

Create onAddClick action

Bind onAddClick actions

3.2.2 JS panel configuration

Note: Copy the code and modify the unique identifier.

onAddClick in-action code configuration

Sample code:

  export function onAddClick(newGroupId){
let value = this.$('子表单唯一标识').getValue()
let arr = [];
value.map((val, index) => {
let yd = {
'序号组件唯一标识': index + 1,
'子表单其他组件唯一标识': val.子表单其他组件唯一标识
}
arr.push(yd)
})
console.log(arr)
this.$('子表单唯一标识').setValue(arr)

4. Effect demonstration

Perform the following operations to achieve the following results:

  1. Click Add to add a serial number
  2. Delete data and add a correction sequence number

5. 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