# RelevanceSelect 关联选择

关联表单选择组件,支持从关联业务模型中查询和选择数据。

# 何时使用

  • 需要从其他表单/模型中选择关联数据时
  • 需要支持条件筛选的关联选择时

# 代码演示

下方示例通过 dataSource 传入静态 mock 数据(30 条工单记录),无需连接后端即可体验完整的选择交互。

离线数据模式

通过传入 dataSource prop 可以让组件完全脱离后端 API 运行,适用于文档演示、单元测试和离线环境。

# API

参数 说明 类型 默认值
value 选中的值 SingleSelectValue \| MultiSelectValue \| null null
schemaCode 当前数据模型编码 string ''
sheetCode 当前表单编码 string ''
optionSchemaCode 绑定模型编码 string ''
queryCode 查询编码 string ''
displayField 显示字段 string ''
showField 显示字段配置 string \| string[] []
mode 选择模式 FormControlType RelevanceForm(单选)
placeholder 占位文本 string '请选择'
allowClear 是否允许清空 boolean true
disabled 是否禁用 boolean false
size 尺寸 'small' \| 'middle' \| 'large' 'middle'
dataSource 静态数据源(传入后不调用 API) { columns, records, schemaName } null

# dataSource 结构

字段 说明 类型
schemaName 模型名称(显示在筛选栏标题) string
columns 列配置 Array<{ field, title, width }>
records 数据记录(需含 id 字段) any[]
const dataSource = {
  schemaName: '工单管理',
  columns: [
    { field: 'title', title: '标题', width: 180 },
    { field: 'status', title: '状态', width: 100 },
    { field: 'owner', title: '负责人', width: 100 },
  ],
  records: [
    { id: '1', title: '需求-1001', status: '进行中', owner: '张伟' },
    { id: '2', title: '缺陷-1002', status: '待处理', owner: '李芳' },
  ]
}
1
2
3
4
5
6
7
8
9
10
11
12

# 事件

事件名 说明 回调参数
change 选中值变化时回调 (value) => void

# 条件筛选

RelevanceSelect 内置了条件筛选面板,支持以下筛选类型:

筛选类型 说明 适用数据类型
Eq / NotEq 等于 / 不等于 文本、数字、日期等
Gt / Lt 大于 / 小于 数字、日期
Gte / Lte 大于等于 / 小于等于 数字、日期
Like / NotLike 包含 / 不包含 文本
IsNull / IsNotNull 为空 / 不为空 所有类型
Between / NotBetween 介于 / 不介于 数字、日期
Of / NotOf 属于 / 不属于 人员、部门