Subform

Description:
  • 子表单相关工具方法
Source:
子表单相关工具方法

Classes

Subform

Methods

(async, static) associateForm2Subform(context, formType, assocaiteFieldId, localSubformId, formInstIdField, fieldMaps, isDataFromSubform, remoteSubformId, options)

Description:
  • 将关联表单的数据填充到本表单的子表上
Source:
Example
export function onAssocciateFormChange() {
  // 将关联表单对应的表单值填充到本表单子表中
  associateForm2Subform(
    this,
    "form",
    "associationFormField_lrimaemr",
    "tableField_xxxxxx",
    "textField_xxxxxx",
    [{from: "textField_xxxxxx", to: "textField_xxxxxx", type: "string" }],
    false,
    { keepOldData: true }
  );
}
Parameters:
Name Type Description
context object this上下文
formType "form" | "process" 表单类型
assocaiteFieldId string 关联表单组件唯一标识
localSubformId string 本表单子表唯一标识
formInstIdField string 子表中用于存储关联表单实例Id的字段,用于判断子表数据应该删除还是新增
fieldMaps Array.<module:Subform~FieldMapItem> 字段填充映射
isDataFromSubform boolean 填充数据是否来自关联表单的子表
remoteSubformId string 关联表单子表ID
options module:Subform~AF2SubformOption 扩展配置

(static) sum2Main(context, tableFieldId, fieldInSubform, fieldInMainform, dataType, option)

Description:
  • 子表字段汇总到主表
Source:
Example
export function onSubformChange() {
  // tableField_xyz子表中的 textField_123 字段将被汇总到主表 textField_abc 字段。
  sum2Main(this, "tableField_xyz", "textField_123", "textField_abc", "string", { appendMode: true });
}
Parameters:
Name Type Description
context Object this上下文
tableFieldId string 子表唯一标识
fieldInSubform string 要汇总到主表的子表字段
fieldInMainform string 要汇总到的主表字段
dataType "string" | "number" | "dpt" | "employee" 字段数据类型,默认为string类型
option module:Subform~SumOption 扩展选项

(inner) resolveFieldMaps(formData, fieldMaps, mainFormData) → {Object}

Description:
  • 处理字段映射,组装并返回新的表单数据对象
Source:
Parameters:
Name Type Description
formData Object 来源表单数据,如果来源为关联表单子表则为子表数据项目
fieldMaps Array.<module:Subform~FieldMapItem> 字段映射定义
mainFormData Object 主表数据,如果来源是关联表单子表则该字段传主表数据,否则传null
Returns:
新的表单数据对象
Type
Object

Type Definitions

AF2SubformOption

Description:
  • AF2SubformOption 配置类型定义
Source:
Properties:
Name Type Description
keepOldData string 是否保留非关联表单填充的旧数据,默认为true
AF2SubformOption 配置类型定义
Type:
  • Object

FieldMapItem

Description:
  • FieldMap配置类型定义
Source:
Properties:
Name Type Description
from string 源字段
to string 填充字段
type "string" | "number" | "employee" | "dpt" 字段数据类型
multiSelect boolean 是否多选字段,type为employee时有用
FieldMap配置类型定义
Type:
  • Object

SubformSetDatasOption

Description:
  • setDatas 方法 option 参数类型定义
Source:
Properties:
Name Type Description
doNotValidate boolean 是否阻止自动校验,默认为 false
formatted boolean 是否已经格式化,默认为 false
triggerChange boolean 是否触发组件值变化事件,默认为 true
setDatas 方法 option 参数类型定义
Type:
  • Object

SubformSummaryOption

Description:
  • summary 方法 option 参数类型定义
Source:
Properties:
Name Type Description
ignoreEmpty boolean 是否跳过空数据,默认为true
ignoreDuplicate boolean 是否跳过重复数据,默认为true
filter function 一个数据过滤函数,接受子表行数据作为参数,返回falsy值跳过当前行
summary 方法 option 参数类型定义
Type:
  • Object

SumOption

Description:
  • sum2Main option 参数类型定义
Source:
Properties:
Name Type Description
ignoreEmpty boolean 是否跳过空数据,默认为true
ignoreDuplicate boolean 是否跳过重复数据,默认为true
appendMode boolean 追加模式,数据追加到主表字段上,而不是覆盖,默认为false
filter function 一个数据过滤函数,接受子表行数据作为参数,返回falsy值跳过当前行
separator string 当数据类型为string时的分隔符,默认为半角逗号","
decimalPlaces number 当数据类型为number时,结果四舍五入到几位小数,默认不做舍入,可能存在浮点数精度问题
sum2Main option 参数类型定义
Type:
  • Object