Constructor
new Subform(context, tableFieldId)
- Description:
- 创建一个子表工具类实例
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
Parameters:
| Name | Type | Description |
|---|---|---|
context |
Object | this上下文 |
tableFieldId |
string | 子表唯一标识 |
Methods
getDatas() → {Array.<Object>}
- Description:
- 获取子表数据列表
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
const dataList = subform.getDatas(); // 等效于 this.$("tableField_xxxxxx").getValue();
Returns:
子表数据列表
- Type
- Array.<Object>
getFormGroupId(index) → {string}
- Description:
- 根据子表项索引获取formGroupId
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
subform.getFormGroupId(0); // "tfitem_1"
Parameters:
| Name | Type | Description |
|---|---|---|
index |
number | 索引下标 |
Returns:
formGroupId
- Type
- string
getFormGroupIds() → {Array.<string>}
- Description:
- 获取子表项formGroupId列表
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
subform.getFormGroupIds(); // ["tfitem_1", "tfitem_2"]
Returns:
formGroupId列表
- Type
- Array.<string>
getIndex(formGroupId) → {number}
- Description:
- 根据子表项formGroupId获取子表项索引
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
subform.getIndex("tfitem_1"); // 0
Parameters:
| Name | Type | Description |
|---|---|---|
formGroupId |
string | formGroupId |
Returns:
索引下标
- Type
- number
getInstance() → {Object}
- Description:
- 获取子表组件实例
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
const tableField = subform.getInstance(); // 等效于 this.$("tableField_xxxxxx");
tableField.getValue();
Returns:
子表组件实例
- Type
- Object
getItem(id) → {Object}
- Description:
- 获取子表单行数据
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
// 使用索引下标获取数据行
subform.getItem(0);
// 使用formGroupId获取数据行
subform.getItem("tfitem_1");
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | number | 可传入行下标或者formGroupId |
Returns:
单行子表数据
- Type
- Object
setDatas(datas, optionsopt)
- Description:
- 设置整个子表的数据
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
subform.setDatas([...datas]); // 等效于 this.$("tableField_xxxxxx").setValue([...datas]);
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
datas |
Array.<Object> | 子表数据列表 | |
options |
module:Subform~SubformSetDatasOption |
<optional> |
配置项 |
summary(fieldId, dataTypeopt, optionopt) → {Array.<any>}
- Description:
- 汇总子表中指定字段的值
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
subform.summary("textField_xxxxxx", "string", { ignoreEmpty: true, ignoreDuplicate: true });
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
fieldId |
string | 要汇总到主表的子表字段 | |
dataType |
"string" | "number" | "dpt" | "employee" |
<optional> |
字段数据类型,默认为string类型 |
option |
module:Subform~SubformSummaryOption |
<optional> |
扩展选项 |
Returns:
汇总字段值数组
- Type
- Array.<any>
updateItem(id, data)
- Description:
- 更新子表单行数据
- Source:
Example
const subform = new Subform(this, "tableField_xxxxxx");
// 使用索引下标指示更新数据行
subform.updateItem(0, { "tableField_xxxxxx": "new value" });
// 使用formGroupId指示更新数据行
subform.updateItem("tfitem_1", { "tableField_xxxxxx": "new value" });
Parameters:
| Name | Type | Description |
|---|---|---|
id |
number | string | 可传入要更新的行下标或者formGroupId |
data |
Object | 要更新的字段值对象 |