CascadeList
级联列表容器
API
ITreeContainerBaseProps
| 参数 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| key | boolean | 数据容器在页面内的唯一标识 | - |
| model | string | 模型Key | - |
| dataCondition | string | DataStore 数据源condition,若condition=""表示使用空条件进行查询 | - |
| dataParams | string | 给数据源 dataSource 携带参数。属性不需要写成表达式格式。使用对象格式的字符串,例如{ a: 1 }, 查询时会合并到查询参数search中 | - |
| dataSource | string | ((param: any) => any) | 树容器获取数据来源 key, 也可以通过一个方法返回mock数据 | - |
| title | string | 标题 | - |
| show | boolean | 是否显示 | - |
| onDataLoaded | (record: any) => void | 容器在数据获取完成后的回调 | - |
| parentField | string | 表示父级的 field key | - |
| hasChildrenField | string | 是否有children节点 field key | - |
| isLeafField | string | 是否是叶子节点 field key | - |
| iconField | string | 表示icon的 field key | - |
| searchable | boolean | 是否开启搜索 | - |
| checkedField | string | 表示是否勾选的 field key | - |
| asyncLoadChildren | boolean | 是否以同步方式加载子节点 | false |
| labelField | string | 显示的节点名称 | - |
| onSelect | string | 选中行数据触发 Action | - |
| optionFormat | (record: any) => string | 自定义节点渲染文本 | - |
| onAddRoot | (({ record }: { record: string }) => void) | string | 内置根节点新增按钮 | - |
| onAdd | (({ record }: { record: string }) => void) | string | 内置节点新增按钮 | - |
| onEdit | ({ record }: { record: { parent: any; label: string } }) => void | 内置编辑按钮 | - |
| onDelete | ({ record }: { record: any }) => void | 内置删除按钮 | - |
| orderField | string | 获取节点列表时的排序字段名称,配合order属性使用 | - |
| order | ’asc’ | ‘desc’ | 获取节点时的排序规则,配合orderField属性使用 | - |
ICascadeListProps
| 参数 | 类型 | 说明 | 默认值 |
|---|---|---|---|
| depthLimit | string | 最大深度 | - |
| dataCondition | string | 筛选条件,根据筛选条件获取树形数据 | - |
| onAdd | string | 点击 +号触发 Action | - |
| onSelect | string | 选中行数据触发 Action | - |
| columnTitles | string[] | 层级标题 | - |
| labelField | string | 显示的节点名称 | - |
| add | (({ record }: { record: { parent: any, addedNode: any } }) => void) | string | 内置节点新增按钮 | - |
| edit | (({ record }: { record: { parent: any; editedNode: string } }) => void) | string | 内置编辑按钮 | - |
| del | (({ record }: { record: { parent: any; deletedNode: any } }) => void) | string | 内置删除按钮 | - |
| draggable | boolean | 是否允许拖拽排序 | - |
| orderFlow | string | 排序 flow | - |
| orderFunc | string | 排序 function | - |
| orderParams | string | 获取需要排序节点的额外字段给 orderFlow/orderFunc | - |
| allowDrag | number[] | 配置可拖拖拽排序的层级,当 draggable=true 时默认全部层级可拖拽排序 | - |
| loadChildrenExtraField | string | 获取子节点时携带当前节点的一些额外参数,可以用逗号隔开 | - |
用法
基础用法
<View version="2" title="级联容器"> <CascadeList model="trantor_doc_Tree" parentField="parent" depthLimit="4"> <Fields> <Field name="name" /> </Fields> </CascadeList></View>注意:当前例子为0.17.x 版本
操作
<View version="2" title="级联容器"> <CascadeList model="trantor_doc_Tree" parentField="parent" depthLimit="2" onAdd="trantor_doc_Tree_create" onSelect="handlerSelect"> <Fields> <Field name="name"/> </Fields> <RecordActions> <Action key="handlerSelect" show="#{true}" label="编辑" logicFlow="trantor_doc_Tree_update" /> <Action label="删除" logicFlow="trantor_doc_Tree_delete" after="Refresh" /> </RecordActions> </CascadeList></View>注意:当前例子为0.17.x 版本
拖拽排序
拖拽排序为异步操作,需后端实现 Func/Flow 进行对数据排序。
排序 Func/Flow 实现规范
- 入参:ISortParams
- 响应:状态码 200,无需响应数据。
ISortParams - 排序接口参数
| 参数 | 类型 | 说明 |
|---|---|---|
| parentField | string | 父节点字段,等价于 CascadeList.parentField |
| parentId | string | null | 被拖拽节点的父节点 ID,用于查询所在层级所有节点进行排序 |
| id | string | 被拖拽节点 ID |
| destination | number | 目的位置,[0, n] |
| […] | any | 其他字段,可以通过 orderParams 传递,允许传递 1 个额外的节点自身的字段 |
DSL - Example
<View version="2" title="级联容器"> <CascadeList model="trantor_doc_Tree" parentField="parent" depthLimit="2"
draggable="true" # 开启拖拽排序 orderFunc="func_key" # 排序接口,也可以使用 flow orderParams="name" # 将节点的 name 字段和 ISortParams 一起提交给 func/flow,仅支持单个字段。 > <Fields> <Field name="name"/> </Fields> </CascadeList></View>后端 - Example
TO 声明
public class FrontCategoryMoveTO extends BaseModel<Long> { private static final long serialVersionUID = 7931310294022803382L;
@Field private Long destination;
@Field private String parentField;
@Field private Long parentId;}Function 接口
@Functionpublic interface MoveFrontCategoryFunc {
BooleanResult execute(FrontCategoryMoveTO frontCategoryMoveTO);}