neo-cmp-cli 1.12.7 → 1.12.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +204 -6
- package/dist/index2.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +1 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/{neo-bi-cmps → asset-manage-template}/README.md +65 -10
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/{neo-bi-cmps → asset-manage-template}/package.json +28 -16
- package/template/asset-manage-template/src/assets/img/chart.svg +1 -0
- package/template/asset-manage-template/src/components/README.md +3 -0
- package/template/asset-manage-template/src/components/assetManage__c/assetApi.ts +70 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetCreateModal.tsx +260 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetGrid.tsx +48 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetSidebar.tsx +74 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/AssetToolbar.tsx +79 -0
- package/template/asset-manage-template/src/components/assetManage__c/cmps/assetDisplay.tsx +72 -0
- package/template/asset-manage-template/src/components/assetManage__c/constants.ts +28 -0
- package/template/asset-manage-template/src/components/assetManage__c/index.tsx +258 -0
- package/template/asset-manage-template/src/components/assetManage__c/model.ts +75 -0
- package/template/asset-manage-template/src/components/assetManage__c/style.scss +425 -0
- package/template/asset-manage-template/src/components/assetManage__c/types.ts +60 -0
- package/template/asset-manage-template/src/components/bidList__c/cmps/BidCard.tsx +47 -0
- package/template/asset-manage-template/src/components/bidList__c/constants.ts +6 -0
- package/template/asset-manage-template/src/components/bidList__c/formatUtils.ts +14 -0
- package/template/asset-manage-template/src/components/bidList__c/index.tsx +194 -0
- package/template/asset-manage-template/src/components/bidList__c/model.ts +57 -0
- package/template/asset-manage-template/src/components/bidList__c/style.scss +179 -0
- package/template/asset-manage-template/src/components/bidList__c/types.ts +10 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/BidPackageHeader.tsx +140 -0
- package/template/asset-manage-template/src/components/bidPackage__c/cmps/PackageItemTable.tsx +148 -0
- package/template/asset-manage-template/src/components/bidPackage__c/index.tsx +394 -0
- package/template/asset-manage-template/src/components/bidPackage__c/mainTableColumns.tsx +57 -0
- package/template/asset-manage-template/src/components/bidPackage__c/model.ts +86 -0
- package/template/asset-manage-template/src/components/bidPackage__c/style.scss +256 -0
- package/template/asset-manage-template/src/components/bidPackage__c/types.ts +35 -0
- package/template/asset-manage-template/src/components/bidPackage__c/utils.ts +19 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/axiosFetcher.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/queryObjectData.ts +0 -0
- package/template/asset-manage-template/src/utils/url.ts +82 -0
- package/template/{neo-bi-cmps → asset-manage-template}/src/utils/xobjects.ts +0 -0
- package/template/{neo-bi-cmps → asset-manage-template}/tsconfig.json +1 -1
- package/template/echarts-custom-cmp-template/package.json +1 -1
- package/template/empty-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/package.json +2 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-h5-cmps/neo.config.js +34 -76
- package/template/neo-h5-cmps/package.json +7 -3
- package/template/neo-h5-cmps/src/components/entityList__c/index.tsx +0 -4
- package/template/neo-h5-cmps/src/components/entityList__c/model.ts +10 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/index.tsx +29 -17
- package/template/neo-h5-cmps/src/components/entityTabs__c/model.ts +25 -5
- package/template/neo-h5-cmps/src/components/entityTabs__c/style.scss +11 -22
- package/template/neo-h5-cmps/src/components/openChatPageBtn__c/index.tsx +3 -1
- package/template/neo-h5-cmps/src/utils/xobjects.ts +8 -3
- package/template/neo-h5-cmps/tsconfig.json +1 -1
- package/template/neo-order-cmps/package.json +2 -2
- package/template/react-custom-cmp-template/package.json +1 -1
- package/template/react-ts-custom-cmp-template/package.json +1 -1
- package/template/vue2-custom-cmp-template/package.json +1 -1
- package/template/develop/BI /351/241/271/347/233/256/345/210/206/346/236/220/346/212/245/345/221/212.md" +0 -562
- package/template/develop/ChatPage /347/273/204/344/273/266/344/275/277/347/224/250/350/257/264/346/230/216/346/226/207/346/241/243.md" +0 -507
- package/template/develop/EntityGrid Web /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -868
- package/template/develop/EntityList H5 /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -1386
- package/template/develop/GlobalSearch/347/273/204/344/273/266/345/257/271/346/257/224/345/210/206/346/236/220.md +0 -866
- package/template/develop/Neo /344/270/255/345/217/257/347/224/250 amis /347/273/204/344/273/266.md" +0 -1490
- package/template/develop/cmpEventFunctions.ts +0 -257
- package/template/develop/cmpEvents.ts +0 -864
- package/template/develop/comTree/347/224/237/346/210/220/350/277/207/347/250/213/345/210/206/346/236/220.md +0 -469
- package/template/develop/commonModules.js +0 -55
- package/template/develop/components-table.md +0 -50
- package/template/develop/neo-custom-cmp-template/README.md +0 -48
- package/template/develop/neo-custom-cmp-template/docs/README.md +0 -13
- package/template/develop/neo-custom-cmp-template/neo.config.js +0 -121
- package/template/develop/neo-custom-cmp-template/package.json +0 -63
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/README.md +0 -65
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/index.tsx +0 -180
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/model.ts +0 -50
- package/template/develop/neo-custom-cmp-template/src/components/contactCardList/style.scss +0 -260
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/README.md +0 -94
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/index.tsx +0 -252
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/model.ts +0 -56
- package/template/develop/neo-custom-cmp-template/src/components/contactForm/style.scss +0 -120
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/README.md +0 -115
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/index.tsx +0 -304
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/model.ts +0 -87
- package/template/develop/neo-custom-cmp-template/src/components/neoEntityGrid/style.scss +0 -127
- package/template/develop/neo-custom-cmp-template/src/utils/axiosFetcher.ts +0 -29
- package/template/develop/neo-custom-cmp-template/src/utils/queryObjectData.ts +0 -39
- package/template/develop/neo-custom-cmp-template/src/utils/xobjects.ts +0 -203
- package/template/develop/neo-custom-cmp-template/tsconfig.json +0 -68
- package/template/develop/neo-ui-component-h5.md +0 -105
- package/template/develop/neo-ui-component-web-xregister.md +0 -31
- package/template/develop/neo-ui-component-web.md +0 -292
- package/template/develop/neoCmps.ts +0 -7508
- package/template/develop/neoGlobalSearchInput /347/273/204/344/273/266/347/232/204/350/257/246/347/273/206/345/210/206/346/236/220/346/226/207/346/241/243.md" +0 -497
- package/template/develop/pageSchema1.json +0 -744
- package/template/develop//344/272/213/344/273/266/345/212/250/344/275/234/344/277/235/345/255/230/346/265/201/347/250/213/345/210/206/346/236/220.md +0 -390
- package/template/develop//345/215/225/345/205/203/346/265/213/350/257/225/344/275/277/347/224/250/350/257/264/346/230/216.md +0 -1139
- package/template/neo-bi-cmps/.prettierrc.js +0 -12
- package/template/neo-bi-cmps/commitlint.config.js +0 -59
- package/template/neo-bi-cmps/neo.config.js +0 -124
- package/template/neo-bi-cmps/public/css/base.css +0 -283
- package/template/neo-bi-cmps/public/scripts/app/bluebird.js +0 -6679
- package/template/neo-bi-cmps/public/template.html +0 -13
- package/template/neo-bi-cmps/src/assets/css/common.scss +0 -127
- package/template/neo-bi-cmps/src/assets/css/mixin.scss +0 -47
- package/template/neo-bi-cmps/src/assets/img/NeoCRM.jpg +0 -0
- package/template/neo-bi-cmps/src/assets/img/custom-widget.svg +0 -1
- package/template/neo-bi-cmps/src/assets/img/favicon.png +0 -0
- package/template/neo-bi-cmps/src/assets/img/table.svg +0 -1
- package/template/neo-bi-cmps/src/components/targetNumber__c/README.md +0 -100
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/configSchema.ts +0 -253
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.scss +0 -76
- package/template/neo-bi-cmps/src/components/targetNumber__c/customStyleConfig/index.tsx +0 -148
- package/template/neo-bi-cmps/src/components/targetNumber__c/index.tsx +0 -440
- package/template/neo-bi-cmps/src/components/targetNumber__c/model.ts +0 -128
- package/template/neo-bi-cmps/src/components/targetNumber__c/style.scss +0 -173
- package/template/neo-h5-cmps/src/components/simpleTable__c/README.md +0 -90
- package/template/neo-h5-cmps/src/components/simpleTable__c/index.tsx +0 -277
- package/template/neo-h5-cmps/src/components/simpleTable__c/model.ts +0 -91
- package/template/neo-h5-cmps/src/components/simpleTable__c/style.scss +0 -116
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/@types/neo-ui-common.d.ts +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/commitlint.config.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/css/base.css +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/scripts/app/bluebird.js +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/public/template.html +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/common.scss +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/AIBtn.gif +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/aiLogo.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/card-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/contact-form.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/custom-form.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/data-list.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/detail.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/map.svg +0 -0
- /package/template/{neo-bi-cmps → asset-manage-template}/src/assets/img/search.svg +0 -0
- /package/template/{develop/neo-custom-cmp-template → asset-manage-template}/src/assets/img/table.svg +0 -0
|
@@ -1,1386 +0,0 @@
|
|
|
1
|
-
# EntityList H5 组件详细分析文档
|
|
2
|
-
|
|
3
|
-
## 目录
|
|
4
|
-
|
|
5
|
-
- [组件概述](#组件概述)
|
|
6
|
-
- [核心功能](#核心功能)
|
|
7
|
-
- [组件架构](#组件架构)
|
|
8
|
-
- [主要属性说明](#主要属性说明)
|
|
9
|
-
- [生命周期方法](#生命周期方法)
|
|
10
|
-
- [核心方法详解](#核心方法详解)
|
|
11
|
-
- [使用示例](#使用示例)
|
|
12
|
-
- [扩展机制](#扩展机制)
|
|
13
|
-
- [注意事项](#注意事项)
|
|
14
|
-
- [常见问题](#常见问题)
|
|
15
|
-
|
|
16
|
-
## 组件概述
|
|
17
|
-
|
|
18
|
-
`EntityList` 是 Neo UI Component H5 端的一个核心业务组件,用于展示和管理实体数据列表。它支持多种列表类型(大列表、相关列表、Picker列表、搜索列表等),提供了完整的数据展示、筛选、排序、批量操作等功能。
|
|
19
|
-
|
|
20
|
-
### 技术栈
|
|
21
|
-
|
|
22
|
-
- **React**: 基于 React 类组件实现
|
|
23
|
-
- **MobX**: 使用 MobX 进行状态管理(通过 `@observer` 装饰器)
|
|
24
|
-
- **MobX State Tree**: Store 使用 MST 进行状态管理
|
|
25
|
-
- **amis**: 基于 amis 框架进行 UI 渲染
|
|
26
|
-
- **TypeScript**: 完整的类型定义支持
|
|
27
|
-
|
|
28
|
-
### 组件位置
|
|
29
|
-
|
|
30
|
-
```
|
|
31
|
-
packages/neo-ui-component-h5/src/components/List/EntityList/
|
|
32
|
-
├── component.tsx # 主组件实现
|
|
33
|
-
├── interface.tsx # 接口定义
|
|
34
|
-
├── constant.ts # 常量定义
|
|
35
|
-
├── styled.ts # 样式定义
|
|
36
|
-
├── store.tsx # Store 定义(在 Store/list.tsx)
|
|
37
|
-
├── utils.ts # 工具函数
|
|
38
|
-
├── nexManager.ts # Nex 1.0 扩展管理器
|
|
39
|
-
└── nex/ # Nex 2.0 扩展实现
|
|
40
|
-
```
|
|
41
|
-
|
|
42
|
-
## 核心功能
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
### 1. 多种列表类型支持
|
|
46
|
-
|
|
47
|
-
组件支持以下列表类型(通过 `tableType` 属性控制):
|
|
48
|
-
|
|
49
|
-
- **`list`**: 大列表或数据列表组件
|
|
50
|
-
- **`lookup`**: Picker 列表(用于表单关联关系选择)
|
|
51
|
-
- **`refer`**: 二级列表或相关列表组件
|
|
52
|
-
- **`search`**: 搜索结果列表
|
|
53
|
-
- **`dashboardList`**: BI 列表
|
|
54
|
-
|
|
55
|
-
### 2. 数据展示功能
|
|
56
|
-
|
|
57
|
-
- **列表视图**: 支持卡片式列表展示
|
|
58
|
-
- **SmartView 切换**: 支持多个视图切换(通过 `currencySmartView` 控制)
|
|
59
|
-
- **分页加载**: 支持下拉刷新和上拉加载更多
|
|
60
|
-
- **空状态处理**: 提供友好的空数据提示
|
|
61
|
-
- **错误处理**: 完善的错误提示和重试机制
|
|
62
|
-
|
|
63
|
-
### 3. 筛选和排序
|
|
64
|
-
|
|
65
|
-
- **筛选功能**:
|
|
66
|
-
- 支持顶部常用筛选(最多显示4个)
|
|
67
|
-
- 支持筛选抽屉(完整筛选界面)
|
|
68
|
-
- 支持扩展筛选项(`extFilterItems`)
|
|
69
|
-
- 筛选条件缓存
|
|
70
|
-
- **排序功能**:
|
|
71
|
-
- 支持多字段排序
|
|
72
|
-
- 支持升序/降序切换
|
|
73
|
-
- 不支持文本域和多选字段排序
|
|
74
|
-
|
|
75
|
-
### 4. 批量操作
|
|
76
|
-
|
|
77
|
-
- **批量选择**: 支持多选模式(最多20条)
|
|
78
|
-
- **批量操作按钮**: 支持批量编辑、删除等操作
|
|
79
|
-
- **批量操作状态管理**: 自动管理选中状态
|
|
80
|
-
|
|
81
|
-
### 5. 新建和编辑
|
|
82
|
-
|
|
83
|
-
- **新建按钮**: 支持业务类型选择
|
|
84
|
-
- **表单跳转**: 支持跳转到新建/编辑表单
|
|
85
|
-
- **相关列表新建**: 支持从详情页相关列表新建
|
|
86
|
-
|
|
87
|
-
### 6. 搜索功能
|
|
88
|
-
|
|
89
|
-
- **搜索栏**: 支持顶部搜索栏
|
|
90
|
-
- **搜索页面**: 支持跳转到搜索页面
|
|
91
|
-
- **当前页搜索**: 支持在当前页进行搜索(`isSearchAtCurrentPage`)
|
|
92
|
-
|
|
93
|
-
### 7. 汇总统计
|
|
94
|
-
|
|
95
|
-
- **汇总数据**: 支持显示汇总统计信息
|
|
96
|
-
- **汇总弹窗**: 点击汇总按钮显示详细汇总信息
|
|
97
|
-
|
|
98
|
-
### 8. 扩展机制
|
|
99
|
-
|
|
100
|
-
- **Nex 1.0**: 通过 `nexIns` 进行扩展
|
|
101
|
-
- **Nex 2.0**: 通过 `nexInsV2` 进行扩展(`nexVersion=2`)
|
|
102
|
-
- **扩展布局**: 支持在多个位置插入扩展 Schema
|
|
103
|
-
|
|
104
|
-
## 组件架构
|
|
105
|
-
|
|
106
|
-
### 组件继承关系
|
|
107
|
-
|
|
108
|
-
```typescript
|
|
109
|
-
@GridRenderer({})
|
|
110
|
-
@observer
|
|
111
|
-
export default class EntityList<T> extends React.Component<EntityListProps & T, ObjectFormState>
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
- `@GridRenderer({})`: amis 网格渲染器装饰器
|
|
115
|
-
- `@observer`: MobX 观察者装饰器,用于响应式更新
|
|
116
|
-
- 继承自 `React.Component`
|
|
117
|
-
|
|
118
|
-
### 核心实例属性
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
class EntityList {
|
|
122
|
-
private listViewStatus: any[] // 列表视图状态
|
|
123
|
-
listLoaded = false // 列表是否已加载
|
|
124
|
-
goback = false // 是否返回
|
|
125
|
-
uniqueEntity = '' // 唯一标识
|
|
126
|
-
nexIns: NexManager // Nex 1.0 扩展实例
|
|
127
|
-
nexInsV2: EntityListMaster // Nex 2.0 扩展实例
|
|
128
|
-
}
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
### Store 结构
|
|
132
|
-
|
|
133
|
-
组件依赖 `IEntityListStore`,主要包含以下状态:
|
|
134
|
-
|
|
135
|
-
- **数据状态**: `listData`, `allCount`, `hasMore`
|
|
136
|
-
- **视图状态**: `currencySmartView`, `dataListViews`, `listStatus`
|
|
137
|
-
- **筛选状态**: `filterValues`, `currencyFilter`
|
|
138
|
-
- **排序状态**: `sortItemList`, `currentSortApiKey`
|
|
139
|
-
- **加载状态**: `initConfiging`, `loadDataing`, `error`
|
|
140
|
-
- **权限状态**: `permission`
|
|
141
|
-
- **按钮配置**: `entityBtnList`, `batchBtnList`
|
|
142
|
-
|
|
143
|
-
## 主要属性说明
|
|
144
|
-
|
|
145
|
-
### 基础属性
|
|
146
|
-
|
|
147
|
-
| 属性名 | 类型 | 默认值 | 说明 |
|
|
148
|
-
|--------|------|--------|------|
|
|
149
|
-
| `tableType` | `string` | `'list'` | 列表类型:`list`/`lookup`/`refer`/`search`/`dashboardList` |
|
|
150
|
-
| `objectApiKey` | `string` | - | 实体的 ApiKey |
|
|
151
|
-
| `entityApiKey` | `string` | - | 实体的 ApiKey(与 objectApiKey 相同) |
|
|
152
|
-
| `store` | `IEntityListStore` | - | 列表的 Store 实例(必填) |
|
|
153
|
-
| `name` | `string` | - | 组件名称(必填) |
|
|
154
|
-
| `titleName` | `string` | - | 顶部标题名称 |
|
|
155
|
-
| `className` | `string` | `''` | 自定义样式类名 |
|
|
156
|
-
| `style` | `object` | - | 自定义样式对象 |
|
|
157
|
-
|
|
158
|
-
### 列表配置属性
|
|
159
|
-
|
|
160
|
-
| 属性名 | 类型 | 默认值 | 说明 |
|
|
161
|
-
|--------|------|--------|------|
|
|
162
|
-
| `isOnlyList` | `boolean` | `false` | 是否只展示列表(隐藏 smartView、filter、title) |
|
|
163
|
-
| `isComponents` | `boolean` | `false` | 是否是数据列表组件或相关列表组件 |
|
|
164
|
-
| `isNoRefresh` | `boolean` | `false` | 禁用下拉刷新和上拉加载 |
|
|
165
|
-
| `disableTopView` | `boolean` | `false` | 隐藏搜索、排序、筛选 |
|
|
166
|
-
| `disableSortFilterView` | `boolean` | `false` | 隐藏排序、筛选 |
|
|
167
|
-
| `disabledSort` | `boolean` | `false` | 不展示列表排序组件 |
|
|
168
|
-
| `disabledFilter` | `boolean` | `false` | 不展示列表过滤组件 |
|
|
169
|
-
| `disableSearch` | `boolean` | `false` | 禁用搜索功能 |
|
|
170
|
-
| `disableTitleView` | `boolean` | `false` | 隐藏筛选 |
|
|
171
|
-
|
|
172
|
-
### 数据相关属性
|
|
173
|
-
|
|
174
|
-
| 属性名 | 类型 | 默认值 | 说明 |
|
|
175
|
-
|--------|------|--------|------|
|
|
176
|
-
| `requestParams` | `object` | - | 请求参数或 URL 额外信息 |
|
|
177
|
-
| `referConditions` | `object` | - | 相关列表信息(相关列表必传) |
|
|
178
|
-
| `referData` | `object` | - | Picker 相关信息(Picker 列表必传) |
|
|
179
|
-
| `extFilterItems` | `array` | - | 配置之外的 filterItem 信息 |
|
|
180
|
-
| `selectDataFromProps` | `array` | - | 默认选中数据 `[{id: XXX}]` |
|
|
181
|
-
| `enableCache` | `boolean` | `true` | 是否启用缓存 |
|
|
182
|
-
|
|
183
|
-
### 事件回调属性
|
|
184
|
-
|
|
185
|
-
| 属性名 | 类型 | 说明 |
|
|
186
|
-
|--------|------|------|
|
|
187
|
-
| `onItemClickIntercept` | `Function` | 列表项点击事件拦截回调 |
|
|
188
|
-
| `onBottomBtnIntercept` | `Function` | 底部操作按钮扩展回调 |
|
|
189
|
-
| `onSearchDataComplete` | `Function` | 搜索接口数据完成回调 |
|
|
190
|
-
| `onLoadedDataComplete` | `Function` | 表单获取数据后事件 |
|
|
191
|
-
| `onPageComplete` | `Function` | 列表加载完成回调 |
|
|
192
|
-
| `onListComplete` | `Function` | 列表初始化完成回调 |
|
|
193
|
-
| `beforeSelectedSmartView` | `Function` | 选择 smartview 前回调 |
|
|
194
|
-
| `afterSelectedSmartView` | `Function` | 选择 smartview 后回调 |
|
|
195
|
-
| `beforeSearch` | `Function` | 搜索前回调 |
|
|
196
|
-
|
|
197
|
-
### 扩展属性
|
|
198
|
-
|
|
199
|
-
| 属性名 | 类型 | 默认值 | 说明 |
|
|
200
|
-
|--------|------|--------|------|
|
|
201
|
-
| `nexVersion` | `number` | - | 列表 Nex 的版本(1 或 2) |
|
|
202
|
-
| `extSmartViewCount` | `Function` | - | SmartViews 数量扩展点 |
|
|
203
|
-
| `extSmartViewConditions` | `array` | - | SmartViews 查询 conditions 扩展点 |
|
|
204
|
-
| `getHeaderExpand` | `Function` | - | 获取头部扩展 Schema |
|
|
205
|
-
| `expandSchemas` | `array` | - | 扩展布局 Schema 数组 |
|
|
206
|
-
|
|
207
|
-
### 其他属性
|
|
208
|
-
|
|
209
|
-
| 属性名 | 类型 | 默认值 | 说明 |
|
|
210
|
-
|--------|------|--------|------|
|
|
211
|
-
| `selectionMode` | `'single' \| 'multiple'` | - | 单选或多选状态 |
|
|
212
|
-
| `selectMaxCount` | `number` | - | 列表多选最多选择条数(默认20) |
|
|
213
|
-
| `isSearchAtCurrentPage` | `boolean` | `false` | 是否启用当页搜索 |
|
|
214
|
-
| `listType` | `1 \| 2` | `1` | 正常大列表为1,首页配置的列表为2 |
|
|
215
|
-
| `cancelBtnDisable` | `boolean` | `false` | 取消按钮是否禁用 |
|
|
216
|
-
| `filterModal` | `boolean` | `false` | 是否配置了关联筛选器 |
|
|
217
|
-
|
|
218
|
-
## 生命周期方法
|
|
219
|
-
|
|
220
|
-
### componentWillMount
|
|
221
|
-
|
|
222
|
-
```typescript
|
|
223
|
-
componentWillMount() {
|
|
224
|
-
const scoped = this.context as IScopedContext
|
|
225
|
-
scoped.registerComponent(this)
|
|
226
|
-
}
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
- **作用**: 注册组件到 amis 的 ScopedContext
|
|
230
|
-
- **时机**: 组件挂载前
|
|
231
|
-
|
|
232
|
-
### componentDidMount
|
|
233
|
-
|
|
234
|
-
```typescript
|
|
235
|
-
componentDidMount() {
|
|
236
|
-
// 1. 注册刷新列表的方法
|
|
237
|
-
this.registerFuncs()
|
|
238
|
-
|
|
239
|
-
// 2. 处理搜索逻辑
|
|
240
|
-
if (searchKey && autoSearchPage) {
|
|
241
|
-
this.onSearch(...)
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
// 3. 设置水印
|
|
245
|
-
if (waterMarkTextContent) {
|
|
246
|
-
setWaterMark(...)
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
// 4. 初始化列表视图
|
|
250
|
-
this.initListView()
|
|
251
|
-
}
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
- **作用**:
|
|
255
|
-
- 注册全局刷新方法(`refreshList_${entityApiKey}`、`refreshListPage_${entityApiKey}`)
|
|
256
|
-
- 处理自动搜索逻辑
|
|
257
|
-
- 设置水印
|
|
258
|
-
- 初始化列表视图
|
|
259
|
-
|
|
260
|
-
### componentWillReceiveProps
|
|
261
|
-
|
|
262
|
-
```typescript
|
|
263
|
-
componentWillReceiveProps(nextProps: Readonly<EntityListProps & T>, nextContext: any): void {
|
|
264
|
-
// 当 requestParams 变化时刷新列表
|
|
265
|
-
if (JSON.stringify(nextProps.requestParams) !== JSON.stringify(this.props.requestParams)) {
|
|
266
|
-
this.props.store.initConfigInfo({ requestParams: nextProps.requestParams })
|
|
267
|
-
this.props.store.refreshListData(this.props.onSearchDataComplete)
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
// 当 referData 变化时刷新列表
|
|
271
|
-
if (!isEqual(nextProps.referData, this.props.referData)) {
|
|
272
|
-
this.props.store.initConfigInfo({ referData: nextProps.referData })
|
|
273
|
-
this.props.store.refreshListData(this.props.onSearchDataComplete)
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
- **作用**: 监听 props 变化,自动刷新列表数据
|
|
279
|
-
- **触发条件**: `requestParams` 或 `referData` 发生变化
|
|
280
|
-
|
|
281
|
-
### componentDidUpdate
|
|
282
|
-
|
|
283
|
-
```typescript
|
|
284
|
-
componentDidUpdate() {
|
|
285
|
-
// 1. 触发列表完成回调
|
|
286
|
-
if (!this.listLoaded && !initConfiging && !loadDataing) {
|
|
287
|
-
this.listLoaded = true
|
|
288
|
-
onListComplete && onListComplete({ listStore: store, listContext: this.context })
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
// 2. 缓存请求参数(并行优化)
|
|
292
|
-
if (enableParOpt && pageNo === 1) {
|
|
293
|
-
cacheDataReqParams()
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
// 3. 保存布局配置(分步渲染)
|
|
297
|
-
if (enableStepRender) {
|
|
298
|
-
setTimeout(() => {
|
|
299
|
-
saveItemLayoutConfig()
|
|
300
|
-
saveItemHeight()
|
|
301
|
-
}, 200)
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
```
|
|
305
|
-
|
|
306
|
-
- **作用**:
|
|
307
|
-
- 触发列表完成回调
|
|
308
|
-
- 缓存请求参数(性能优化)
|
|
309
|
-
- 保存布局配置(分步渲染优化)
|
|
310
|
-
|
|
311
|
-
### componentWillUnmount
|
|
312
|
-
|
|
313
|
-
```typescript
|
|
314
|
-
componentWillUnmount() {
|
|
315
|
-
const scoped = this.context as IScopedContext
|
|
316
|
-
scoped.unRegisterComponent(this)
|
|
317
|
-
}
|
|
318
|
-
```
|
|
319
|
-
|
|
320
|
-
- **作用**: 从 ScopedContext 中注销组件
|
|
321
|
-
|
|
322
|
-
## 核心方法详解
|
|
323
|
-
|
|
324
|
-
### 初始化方法
|
|
325
|
-
|
|
326
|
-
#### initListView()
|
|
327
|
-
|
|
328
|
-
初始化列表视图的核心方法,负责:
|
|
329
|
-
|
|
330
|
-
1. 收集所有配置参数
|
|
331
|
-
2. 初始化 Store 配置信息
|
|
332
|
-
3. 根据 `localConfigLayout` 决定走本地配置还是网络请求
|
|
333
|
-
4. 调用 Store 的 `getEntityListInfo` 或 `initLocalConfig`
|
|
334
|
-
|
|
335
|
-
```typescript
|
|
336
|
-
initListView() {
|
|
337
|
-
// 1. 收集参数
|
|
338
|
-
const { tableType, entityApiKey, store, ... } = this.props
|
|
339
|
-
|
|
340
|
-
// 2. 判断是否启用并行优化
|
|
341
|
-
const enableParOpt = tableType === 'list' && !isComponents
|
|
342
|
-
|
|
343
|
-
// 3. 初始化 Store 配置
|
|
344
|
-
store.initConfigInfo({
|
|
345
|
-
tableType,
|
|
346
|
-
entityApiKey,
|
|
347
|
-
enableParOpt,
|
|
348
|
-
// ... 其他配置
|
|
349
|
-
})
|
|
350
|
-
|
|
351
|
-
// 4. 根据配置决定走本地还是网络
|
|
352
|
-
if (localConfigLayout) {
|
|
353
|
-
store.initLocalConfig(...)
|
|
354
|
-
} else {
|
|
355
|
-
store.getEntityListInfo(...)
|
|
356
|
-
}
|
|
357
|
-
}
|
|
358
|
-
```
|
|
359
|
-
|
|
360
|
-
#### initNexV2()
|
|
361
|
-
|
|
362
|
-
初始化 Nex 2.0 扩展实例:
|
|
363
|
-
|
|
364
|
-
```typescript
|
|
365
|
-
initNexV2() {
|
|
366
|
-
if (this.isNexV2() && !this.nexInsV2) {
|
|
367
|
-
const props = {
|
|
368
|
-
objectApiKey,
|
|
369
|
-
disableSearch,
|
|
370
|
-
dataList,
|
|
371
|
-
listViews,
|
|
372
|
-
listButton,
|
|
373
|
-
multiButton,
|
|
374
|
-
// ... 其他属性
|
|
375
|
-
}
|
|
376
|
-
const entityListIns = new EntityListMaster(props)
|
|
377
|
-
this.nexInsV2 = entityListIns
|
|
378
|
-
store.setNexInsV2(this.nexInsV2)
|
|
379
|
-
}
|
|
380
|
-
}
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### 数据刷新方法
|
|
384
|
-
|
|
385
|
-
#### refreshData()
|
|
386
|
-
|
|
387
|
-
只刷新列表数据(不重新请求配置):
|
|
388
|
-
|
|
389
|
-
```typescript
|
|
390
|
-
refreshData = () => {
|
|
391
|
-
const { store, tableType = 'list' } = this.props
|
|
392
|
-
|
|
393
|
-
// 如果是批量选中状态,切换回正常状态
|
|
394
|
-
if (tableType === 'list' && store.listStatus === ListViewStatus.MULSELECT) {
|
|
395
|
-
store.setListViewStatus(ListViewStatus.NORMAL)
|
|
396
|
-
this.closeOperationView(true)
|
|
397
|
-
}
|
|
398
|
-
|
|
399
|
-
// 刷新列表数据
|
|
400
|
-
this.props.store.refreshListData(this.props.onSearchDataComplete)
|
|
401
|
-
}
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
#### refreshPage()
|
|
405
|
-
|
|
406
|
-
刷新整个组件(重新请求配置和数据):
|
|
407
|
-
|
|
408
|
-
```typescript
|
|
409
|
-
refreshPage = () => {
|
|
410
|
-
// 1. 滚动到顶部
|
|
411
|
-
let listViewDom = this.getNeoListViewDom()
|
|
412
|
-
listViewDom && listViewDom?.neoListViewRef?.scrollTo()
|
|
413
|
-
|
|
414
|
-
// 2. 切换批量选中状态
|
|
415
|
-
if (tableType === 'list' && store.listStatus === ListViewStatus.MULSELECT) {
|
|
416
|
-
store.setListViewStatus(ListViewStatus.NORMAL)
|
|
417
|
-
this.closeOperationView(true)
|
|
418
|
-
}
|
|
419
|
-
|
|
420
|
-
// 3. 重新初始化列表
|
|
421
|
-
if (localConfigLayout) {
|
|
422
|
-
store.initLocalConfig(...)
|
|
423
|
-
} else {
|
|
424
|
-
store.getEntityListInfo(...)
|
|
425
|
-
}
|
|
426
|
-
}
|
|
427
|
-
```
|
|
428
|
-
|
|
429
|
-
### 筛选相关方法
|
|
430
|
-
|
|
431
|
-
#### onFilter()
|
|
432
|
-
|
|
433
|
-
处理筛选逻辑:
|
|
434
|
-
|
|
435
|
-
```typescript
|
|
436
|
-
onFilter = async (data, showFilters?) => {
|
|
437
|
-
const { store, onSearchDataComplete, beforeSearch } = this.props
|
|
438
|
-
|
|
439
|
-
// 1. 更新筛选值
|
|
440
|
-
store.updataFilterValues(data, showFilters, onSearchDataComplete, beforeSearch)
|
|
441
|
-
|
|
442
|
-
// 2. 获取缓存数据
|
|
443
|
-
let cacheData = await store.universalStorage('get')
|
|
444
|
-
|
|
445
|
-
// 3. 构建筛选对象
|
|
446
|
-
let filters = {
|
|
447
|
-
[store.currencySmartViewApiKey]: {
|
|
448
|
-
timestamp: Date.now(),
|
|
449
|
-
filters: showFilters ? cloneDeep(showFilters.toJSON()) : cacheData?.filters,
|
|
450
|
-
filterValues: data
|
|
451
|
-
}
|
|
452
|
-
}
|
|
453
|
-
|
|
454
|
-
// 4. 保存到缓存
|
|
455
|
-
if (!cacheData || !isEqual(cacheData.filters, filters)) {
|
|
456
|
-
await store.universalStorage('set', filters)
|
|
457
|
-
store.updateCacheFilter && store.updateCacheFilter()
|
|
458
|
-
}
|
|
459
|
-
}
|
|
460
|
-
```
|
|
461
|
-
|
|
462
|
-
#### getTopFilterJson()
|
|
463
|
-
|
|
464
|
-
获取顶部常用筛选 JSON:
|
|
465
|
-
|
|
466
|
-
```typescript
|
|
467
|
-
getTopFilterJson = () => {
|
|
468
|
-
const { store, extFilterItems } = this.props
|
|
469
|
-
const { currencyFilter, filterValues } = store
|
|
470
|
-
|
|
471
|
-
// 1. 合并扩展筛选项
|
|
472
|
-
const filters = extFilterItemsFilters.concat([...currencyFilter])
|
|
473
|
-
|
|
474
|
-
// 2. 只取前4个
|
|
475
|
-
filters.forEach((item, index) => {
|
|
476
|
-
if (index <= 3) {
|
|
477
|
-
// 3. 构建筛选项 JSON
|
|
478
|
-
filterItems.push({
|
|
479
|
-
type: 'wrapper',
|
|
480
|
-
label: label,
|
|
481
|
-
className: className,
|
|
482
|
-
body: {
|
|
483
|
-
type: 'neoAction',
|
|
484
|
-
onClick: () => {
|
|
485
|
-
// 打开筛选弹窗
|
|
486
|
-
setModalViewInfo(true, 'filter', itemData, this.getTopFilterModalJson(itemData))
|
|
487
|
-
}
|
|
488
|
-
}
|
|
489
|
-
})
|
|
490
|
-
}
|
|
491
|
-
})
|
|
492
|
-
|
|
493
|
-
return filterItems
|
|
494
|
-
}
|
|
495
|
-
```
|
|
496
|
-
|
|
497
|
-
### 排序相关方法
|
|
498
|
-
|
|
499
|
-
#### updateListBySort()
|
|
500
|
-
|
|
501
|
-
更新排序并刷新列表:
|
|
502
|
-
|
|
503
|
-
```typescript
|
|
504
|
-
updateListBySort = (newCurrentApiKey, newSortType) => {
|
|
505
|
-
const { store } = this.props
|
|
506
|
-
const { currentSortApiKey, sortItemListObs } = store
|
|
507
|
-
|
|
508
|
-
if (newSortType === undefined && newCurrentApiKey == currentSortApiKey) {
|
|
509
|
-
// 如果排序没有变化,只关闭弹窗
|
|
510
|
-
setModalViewInfo(false, modalType)
|
|
511
|
-
} else {
|
|
512
|
-
// 更新排序并刷新
|
|
513
|
-
const currentSortItem = sortItemListObs.find((element) => element.apiKey === newCurrentApiKey)
|
|
514
|
-
store.clickSortView(currentSortItem, this.props.onSearchDataComplete)
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
```
|
|
518
|
-
|
|
519
|
-
### 视图切换方法
|
|
520
|
-
|
|
521
|
-
#### updateListBySmart()
|
|
522
|
-
|
|
523
|
-
切换 SmartView 并刷新列表:
|
|
524
|
-
|
|
525
|
-
```typescript
|
|
526
|
-
updateListBySmart = (newCurrentApiKey, isRefresh: boolean, userSmartCache?) => {
|
|
527
|
-
const { store, beforeSearch } = this.props
|
|
528
|
-
const { currencySmartViewApiKey, dataListViewsObs } = store
|
|
529
|
-
|
|
530
|
-
if (newCurrentApiKey !== currencySmartViewApiKey) {
|
|
531
|
-
// 切换视图
|
|
532
|
-
const currentSmartItem = dataListViewsObs.find((element) => element.apiKey === newCurrentApiKey)
|
|
533
|
-
store.clickSmartView(
|
|
534
|
-
currentSmartItem,
|
|
535
|
-
this.props.getAllFilterItems,
|
|
536
|
-
this.props.onSearchDataComplete,
|
|
537
|
-
userSmartCache,
|
|
538
|
-
beforeSearch
|
|
539
|
-
)
|
|
540
|
-
} else {
|
|
541
|
-
// 如果视图相同,根据 isRefresh 决定是否刷新
|
|
542
|
-
if (isRefresh) {
|
|
543
|
-
store.clickSmartView(...)
|
|
544
|
-
} else {
|
|
545
|
-
setModalViewInfo(false, modalType)
|
|
546
|
-
}
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
// 更新列表视图状态
|
|
550
|
-
const neoListViewDom = this.getNeoListViewDom()
|
|
551
|
-
neoListViewDom && neoListViewDom.setMultiseriate &&
|
|
552
|
-
neoListViewDom.setMultiseriate(this.listViewStatus[viewNames.indexOf(newCurrentApiKey)])
|
|
553
|
-
}
|
|
554
|
-
```
|
|
555
|
-
|
|
556
|
-
### 批量操作方法
|
|
557
|
-
|
|
558
|
-
#### getBulkOperationBtn()
|
|
559
|
-
|
|
560
|
-
获取批量操作按钮 JSON:
|
|
561
|
-
|
|
562
|
-
```typescript
|
|
563
|
-
getBulkOperationBtn = () => {
|
|
564
|
-
const { store } = this.props
|
|
565
|
-
const { batchBtnList, listStatus } = store
|
|
566
|
-
|
|
567
|
-
if (batchBtnList.length && showBatchButton) {
|
|
568
|
-
return {
|
|
569
|
-
type: 'neoAction',
|
|
570
|
-
icon: 'files_batch_select_32',
|
|
571
|
-
visible: listStatus != ListViewStatus.MULSELECT,
|
|
572
|
-
onClick: () => {
|
|
573
|
-
// 切换到批量选择状态
|
|
574
|
-
setListViewStatus(ListViewStatus.MULSELECT)
|
|
575
|
-
},
|
|
576
|
-
drawer: {
|
|
577
|
-
// 批量操作抽屉配置
|
|
578
|
-
body: {
|
|
579
|
-
type: 'neoBulkOperation',
|
|
580
|
-
batchButtonList: batchBtnList,
|
|
581
|
-
operationFinishCallBack: (close, isUpdate) => {
|
|
582
|
-
if (isUpdate) {
|
|
583
|
-
store.refreshListData(onSearchDataComplete)
|
|
584
|
-
}
|
|
585
|
-
this.closeOperationView(close)
|
|
586
|
-
setListViewStatus(ListViewStatus.NORMAL)
|
|
587
|
-
}
|
|
588
|
-
}
|
|
589
|
-
}
|
|
590
|
-
}
|
|
591
|
-
}
|
|
592
|
-
return {}
|
|
593
|
-
}
|
|
594
|
-
```
|
|
595
|
-
|
|
596
|
-
#### updateBulkOperationState()
|
|
597
|
-
|
|
598
|
-
更新批量操作按钮状态:
|
|
599
|
-
|
|
600
|
-
```typescript
|
|
601
|
-
updateBulkOperationState = (selectDataId) => {
|
|
602
|
-
let component = this.context.getComponentByName('neo-list.list_filter_drawer.neoBulkOperation')
|
|
603
|
-
const disabled = isArray(selectDataId) && selectDataId.length > 0 ? false : true
|
|
604
|
-
if (component) {
|
|
605
|
-
component.updateDisableState(disabled)
|
|
606
|
-
}
|
|
607
|
-
}
|
|
608
|
-
```
|
|
609
|
-
|
|
610
|
-
### 搜索相关方法
|
|
611
|
-
|
|
612
|
-
#### onSearch()
|
|
613
|
-
|
|
614
|
-
打开搜索页面或搜索弹窗:
|
|
615
|
-
|
|
616
|
-
```typescript
|
|
617
|
-
onSearch = (className, tableType, listStatus, SmartViewApiKey, referData, entity, searchKey?) => {
|
|
618
|
-
if (tableType === 'lookup') {
|
|
619
|
-
// Picker 列表使用弹窗
|
|
620
|
-
NeoNavigator.openDialog({
|
|
621
|
-
ctx: this.context,
|
|
622
|
-
className: 'list-search-dialog',
|
|
623
|
-
bodySchema: [{
|
|
624
|
-
type: 'neoEntityListSearchDialog',
|
|
625
|
-
// ... 配置
|
|
626
|
-
}]
|
|
627
|
-
})
|
|
628
|
-
} else {
|
|
629
|
-
// 大列表使用路由跳转
|
|
630
|
-
const listSearchPath = '/neo/entityListSearch/:entityApiKey/:tabType'
|
|
631
|
-
NeoNavigator.openPageWithURL(
|
|
632
|
-
listSearchPath.replace(':entityApiKey', entity.apiKey).replace(':tabType', tableType),
|
|
633
|
-
{ objectApiKey: entity.apiKey, tableType },
|
|
634
|
-
{
|
|
635
|
-
// ... 参数
|
|
636
|
-
}
|
|
637
|
-
)
|
|
638
|
-
}
|
|
639
|
-
}
|
|
640
|
-
```
|
|
641
|
-
|
|
642
|
-
### 新建相关方法
|
|
643
|
-
|
|
644
|
-
#### getListOperationBtn()
|
|
645
|
-
|
|
646
|
-
获取列表操作按钮(新建按钮等):
|
|
647
|
-
|
|
648
|
-
```typescript
|
|
649
|
-
getListOperationBtn = () => {
|
|
650
|
-
const { store, entityTypes } = this.props
|
|
651
|
-
const { entityBtnList, entityTypes } = store
|
|
652
|
-
|
|
653
|
-
// 如果只有一个新建按钮
|
|
654
|
-
if (entityBtnList.length === 1 && entityBtnList[0].buttonFunType == 1) {
|
|
655
|
-
return {
|
|
656
|
-
type: 'neoAction',
|
|
657
|
-
icon: 'add_32',
|
|
658
|
-
actionType: 'actionSheet',
|
|
659
|
-
onClick: () => {
|
|
660
|
-
// 显示业务类型选择
|
|
661
|
-
return true
|
|
662
|
-
},
|
|
663
|
-
actionSheet: {
|
|
664
|
-
optionData: entityTypesVisible,
|
|
665
|
-
optionClick: (index) => {
|
|
666
|
-
// 打开新建表单
|
|
667
|
-
NeoNavigator.openEntityForm(entity.apiKey, 'create', {
|
|
668
|
-
businessType: entityTypesVisible[index].apiKey,
|
|
669
|
-
// ... 其他配置
|
|
670
|
-
})
|
|
671
|
-
}
|
|
672
|
-
}
|
|
673
|
-
}
|
|
674
|
-
}
|
|
675
|
-
|
|
676
|
-
// 如果有多个按钮,使用抽屉
|
|
677
|
-
return {
|
|
678
|
-
type: 'neoAction',
|
|
679
|
-
icon: 'more_vert_32',
|
|
680
|
-
actionType: 'drawer',
|
|
681
|
-
drawer: {
|
|
682
|
-
body: {
|
|
683
|
-
type: 'neoBulkOperation',
|
|
684
|
-
batchButtonList: entityBtnList,
|
|
685
|
-
// ... 配置
|
|
686
|
-
}
|
|
687
|
-
}
|
|
688
|
-
}
|
|
689
|
-
}
|
|
690
|
-
```
|
|
691
|
-
|
|
692
|
-
### JSON 生成方法
|
|
693
|
-
|
|
694
|
-
#### getAmisJson()
|
|
695
|
-
|
|
696
|
-
生成 amis JSON Schema:
|
|
697
|
-
|
|
698
|
-
```typescript
|
|
699
|
-
getAmisJson = () => {
|
|
700
|
-
// 1. 初始化 Nex V2
|
|
701
|
-
this.initNexV2()
|
|
702
|
-
|
|
703
|
-
// 2. 获取导航栏 JSON
|
|
704
|
-
let navTitleJson = this.getNavJson()
|
|
705
|
-
|
|
706
|
-
// 3. 构建页面 JSON
|
|
707
|
-
const listPageJson = {
|
|
708
|
-
type: 'page',
|
|
709
|
-
title: navTitleJson,
|
|
710
|
-
body: this.getListPageJson()
|
|
711
|
-
}
|
|
712
|
-
|
|
713
|
-
// 4. 如果有 BI 看板,使用 Tabs
|
|
714
|
-
if (boardInfo && !isOnlyList) {
|
|
715
|
-
return {
|
|
716
|
-
type: 'neoTabs',
|
|
717
|
-
tabs: [
|
|
718
|
-
{ title: '列表', sub: '1' },
|
|
719
|
-
{ title: '智能分析', sub: '2' }
|
|
720
|
-
],
|
|
721
|
-
tabsBody: [listPageJson, biBoardJson]
|
|
722
|
-
}
|
|
723
|
-
}
|
|
724
|
-
|
|
725
|
-
return listPageJson
|
|
726
|
-
}
|
|
727
|
-
```
|
|
728
|
-
|
|
729
|
-
#### getListPageJson()
|
|
730
|
-
|
|
731
|
-
生成列表页面 JSON:
|
|
732
|
-
|
|
733
|
-
```typescript
|
|
734
|
-
getListPageJson = () => {
|
|
735
|
-
return [
|
|
736
|
-
// 1. SmartView 底部扩展
|
|
737
|
-
this.getExpandSchema(ExpandSchemasPosition.SMARTVIEW_BOTTOM),
|
|
738
|
-
|
|
739
|
-
// 2. 搜索栏
|
|
740
|
-
!serchHide && {
|
|
741
|
-
type: 'neoEntityListSearch',
|
|
742
|
-
onSubmit: (val) => {
|
|
743
|
-
if (isSearchAtCurrentPage) {
|
|
744
|
-
updateProps({ searchKey: val })
|
|
745
|
-
refreshListData(onSearchDataComplete)
|
|
746
|
-
}
|
|
747
|
-
}
|
|
748
|
-
},
|
|
749
|
-
|
|
750
|
-
// 3. 排序筛选栏
|
|
751
|
-
{
|
|
752
|
-
type: 'neoHBox',
|
|
753
|
-
name: 'neoSmartSort',
|
|
754
|
-
body: this.getTopToolbar(),
|
|
755
|
-
visible: showTopView && !disableSortFilterView
|
|
756
|
-
},
|
|
757
|
-
|
|
758
|
-
// 4. 顶部筛选
|
|
759
|
-
{
|
|
760
|
-
type: 'neoHBox',
|
|
761
|
-
name: 'neoTopFilter',
|
|
762
|
-
body: this.getTopFilterJson(),
|
|
763
|
-
visible: showTopView && topFilterJson.length > 0
|
|
764
|
-
},
|
|
765
|
-
|
|
766
|
-
// 5. 列表视图
|
|
767
|
-
this.getListViewJson(),
|
|
768
|
-
|
|
769
|
-
// 6. 底部操作按钮
|
|
770
|
-
this.getListOperationBtn(),
|
|
771
|
-
|
|
772
|
-
// 7. 汇总合计
|
|
773
|
-
this.getSummary()
|
|
774
|
-
]
|
|
775
|
-
}
|
|
776
|
-
```
|
|
777
|
-
|
|
778
|
-
## 使用示例
|
|
779
|
-
|
|
780
|
-
### 示例 1: 基础大列表
|
|
781
|
-
|
|
782
|
-
```typescript
|
|
783
|
-
import EntityList from '@/components/List/EntityList/component'
|
|
784
|
-
import { EntityListStore } from '@/components/Store/list'
|
|
785
|
-
|
|
786
|
-
// 创建 Store 实例
|
|
787
|
-
const store = EntityListStore.create({
|
|
788
|
-
// Store 初始化配置
|
|
789
|
-
})
|
|
790
|
-
|
|
791
|
-
// 渲染组件
|
|
792
|
-
<EntityList
|
|
793
|
-
name="entityList"
|
|
794
|
-
entityApiKey="account"
|
|
795
|
-
objectApiKey="account"
|
|
796
|
-
tableType="list"
|
|
797
|
-
store={store}
|
|
798
|
-
onItemClickIntercept={(data, entity) => {
|
|
799
|
-
// 自定义点击处理
|
|
800
|
-
console.log('点击了列表项', data)
|
|
801
|
-
return false // 返回 false 继续执行默认逻辑
|
|
802
|
-
}}
|
|
803
|
-
onSearchDataComplete={(data) => {
|
|
804
|
-
// 搜索数据完成回调
|
|
805
|
-
console.log('搜索完成', data)
|
|
806
|
-
}}
|
|
807
|
-
/>
|
|
808
|
-
```
|
|
809
|
-
|
|
810
|
-
### 示例 2: Picker 列表(表单关联选择)
|
|
811
|
-
|
|
812
|
-
```typescript
|
|
813
|
-
<EntityList
|
|
814
|
-
name="entityList"
|
|
815
|
-
entityApiKey="contact"
|
|
816
|
-
objectApiKey="contact"
|
|
817
|
-
tableType="lookup"
|
|
818
|
-
store={store}
|
|
819
|
-
referData={{
|
|
820
|
-
// Picker 相关数据
|
|
821
|
-
referItemId: 'xxx',
|
|
822
|
-
referItemApiKey: 'accountId'
|
|
823
|
-
}}
|
|
824
|
-
selectionMode="multiple"
|
|
825
|
-
selectMaxCount={10}
|
|
826
|
-
onItemClickIntercept={(data, entity, isGoback) => {
|
|
827
|
-
// 选择后回调
|
|
828
|
-
console.log('选择了数据', data)
|
|
829
|
-
return false
|
|
830
|
-
}}
|
|
831
|
-
/>
|
|
832
|
-
```
|
|
833
|
-
|
|
834
|
-
### 示例 3: 相关列表(详情页)
|
|
835
|
-
|
|
836
|
-
```typescript
|
|
837
|
-
<EntityList
|
|
838
|
-
name="entityList"
|
|
839
|
-
entityApiKey="opportunity"
|
|
840
|
-
objectApiKey="opportunity"
|
|
841
|
-
tableType="refer"
|
|
842
|
-
store={store}
|
|
843
|
-
isComponents={true}
|
|
844
|
-
referConditions={[
|
|
845
|
-
{
|
|
846
|
-
apiKey: 'accountId',
|
|
847
|
-
type: 10, // IN 操作符
|
|
848
|
-
value: detailData.id
|
|
849
|
-
}
|
|
850
|
-
]}
|
|
851
|
-
detailData={detailData}
|
|
852
|
-
extendInitParams={{
|
|
853
|
-
objectId: detailData.id
|
|
854
|
-
}}
|
|
855
|
-
/>
|
|
856
|
-
```
|
|
857
|
-
|
|
858
|
-
### 示例 4: 自定义筛选和排序
|
|
859
|
-
|
|
860
|
-
```typescript
|
|
861
|
-
<EntityList
|
|
862
|
-
name="entityList"
|
|
863
|
-
entityApiKey="account"
|
|
864
|
-
objectApiKey="account"
|
|
865
|
-
tableType="list"
|
|
866
|
-
store={store}
|
|
867
|
-
// 扩展筛选项
|
|
868
|
-
extFilterItems={[
|
|
869
|
-
{
|
|
870
|
-
apiKey: 'customField',
|
|
871
|
-
label: '自定义字段',
|
|
872
|
-
itemType: 1 // 文本类型
|
|
873
|
-
}
|
|
874
|
-
]}
|
|
875
|
-
// 筛选变化监听
|
|
876
|
-
filterListener={(filterValues) => {
|
|
877
|
-
console.log('筛选值变化', filterValues)
|
|
878
|
-
}}
|
|
879
|
-
// 搜索前回调
|
|
880
|
-
beforeSearch={(params) => {
|
|
881
|
-
// 可以修改搜索参数
|
|
882
|
-
return params
|
|
883
|
-
}}
|
|
884
|
-
/>
|
|
885
|
-
```
|
|
886
|
-
|
|
887
|
-
### 示例 5: 批量操作
|
|
888
|
-
|
|
889
|
-
```typescript
|
|
890
|
-
<EntityList
|
|
891
|
-
name="entityList"
|
|
892
|
-
entityApiKey="account"
|
|
893
|
-
objectApiKey="account"
|
|
894
|
-
tableType="list"
|
|
895
|
-
store={store}
|
|
896
|
-
// 批量操作按钮点击拦截
|
|
897
|
-
bulkOperationBtnClick={(btnInfo, selectData, context) => {
|
|
898
|
-
console.log('批量操作', btnInfo, selectData)
|
|
899
|
-
// 返回 true 拦截默认逻辑,false 继续执行
|
|
900
|
-
return false
|
|
901
|
-
}}
|
|
902
|
-
// 底部按钮拦截
|
|
903
|
-
onBottomBtnIntercept={(btnInfo, context) => {
|
|
904
|
-
if (btnInfo.apiKey === 'customBtn') {
|
|
905
|
-
// 自定义处理
|
|
906
|
-
return true // 拦截
|
|
907
|
-
}
|
|
908
|
-
return false
|
|
909
|
-
}}
|
|
910
|
-
/>
|
|
911
|
-
```
|
|
912
|
-
|
|
913
|
-
### 示例 6: 当前页搜索
|
|
914
|
-
|
|
915
|
-
```typescript
|
|
916
|
-
<EntityList
|
|
917
|
-
name="entityList"
|
|
918
|
-
entityApiKey="account"
|
|
919
|
-
objectApiKey="account"
|
|
920
|
-
tableType="list"
|
|
921
|
-
store={store}
|
|
922
|
-
isSearchAtCurrentPage={true}
|
|
923
|
-
searchKey={searchKey}
|
|
924
|
-
onSearchDataComplete={(data) => {
|
|
925
|
-
console.log('搜索完成', data)
|
|
926
|
-
}}
|
|
927
|
-
/>
|
|
928
|
-
```
|
|
929
|
-
|
|
930
|
-
### 示例 7: 扩展布局
|
|
931
|
-
|
|
932
|
-
```typescript
|
|
933
|
-
<EntityList
|
|
934
|
-
name="entityList"
|
|
935
|
-
entityApiKey="account"
|
|
936
|
-
objectApiKey="account"
|
|
937
|
-
tableType="list"
|
|
938
|
-
store={store}
|
|
939
|
-
getHeaderExpand={({ store, api }) => {
|
|
940
|
-
return [
|
|
941
|
-
{
|
|
942
|
-
position: ExpandSchemasPosition.SMARTVIEW_BOTTOM,
|
|
943
|
-
schema: {
|
|
944
|
-
type: 'wrapper',
|
|
945
|
-
body: '自定义内容'
|
|
946
|
-
}
|
|
947
|
-
},
|
|
948
|
-
{
|
|
949
|
-
position: ExpandSchemasPosition.LIST_BOTTOM,
|
|
950
|
-
schema: {
|
|
951
|
-
type: 'button',
|
|
952
|
-
label: '自定义按钮',
|
|
953
|
-
onClick: () => {
|
|
954
|
-
console.log('点击了自定义按钮')
|
|
955
|
-
}
|
|
956
|
-
}
|
|
957
|
-
}
|
|
958
|
-
]
|
|
959
|
-
}}
|
|
960
|
-
/>
|
|
961
|
-
```
|
|
962
|
-
|
|
963
|
-
### 示例 8: Nex 2.0 扩展
|
|
964
|
-
|
|
965
|
-
```typescript
|
|
966
|
-
<EntityList
|
|
967
|
-
name="entityList"
|
|
968
|
-
entityApiKey="account"
|
|
969
|
-
objectApiKey="account"
|
|
970
|
-
tableType="list"
|
|
971
|
-
store={store}
|
|
972
|
-
nexVersion={2}
|
|
973
|
-
dataList={{
|
|
974
|
-
beforeFieldRender: (event) => {
|
|
975
|
-
// 字段渲染前处理
|
|
976
|
-
const { apiKey, rowData } = event.data
|
|
977
|
-
if (apiKey === 'name') {
|
|
978
|
-
// 自定义处理
|
|
979
|
-
}
|
|
980
|
-
return null
|
|
981
|
-
},
|
|
982
|
-
listItem: [
|
|
983
|
-
{
|
|
984
|
-
apiKey: 'customField',
|
|
985
|
-
label: '自定义字段'
|
|
986
|
-
}
|
|
987
|
-
]
|
|
988
|
-
}}
|
|
989
|
-
listButton={[
|
|
990
|
-
{
|
|
991
|
-
apiKey: 'customBtn',
|
|
992
|
-
label: '自定义按钮',
|
|
993
|
-
onClick: (event) => {
|
|
994
|
-
console.log('按钮点击', event)
|
|
995
|
-
}
|
|
996
|
-
}
|
|
997
|
-
]}
|
|
998
|
-
/>
|
|
999
|
-
```
|
|
1000
|
-
|
|
1001
|
-
### 示例 9: 本地配置(不请求网络)
|
|
1002
|
-
|
|
1003
|
-
```typescript
|
|
1004
|
-
<EntityList
|
|
1005
|
-
name="entityList"
|
|
1006
|
-
entityApiKey="account"
|
|
1007
|
-
objectApiKey="account"
|
|
1008
|
-
tableType="list"
|
|
1009
|
-
store={store}
|
|
1010
|
-
localConfigLayout={({ tableType, entityApiKey }) => {
|
|
1011
|
-
// 返回本地配置
|
|
1012
|
-
return {
|
|
1013
|
-
entity: {
|
|
1014
|
-
apiKey: 'account',
|
|
1015
|
-
label: '客户'
|
|
1016
|
-
},
|
|
1017
|
-
dataListViews: [
|
|
1018
|
-
{
|
|
1019
|
-
apiKey: 'default_view',
|
|
1020
|
-
label: '默认视图',
|
|
1021
|
-
config: {
|
|
1022
|
-
viewItems: [
|
|
1023
|
-
{ apiKey: 'name', label: '名称' },
|
|
1024
|
-
{ apiKey: 'phone', label: '电话' }
|
|
1025
|
-
]
|
|
1026
|
-
}
|
|
1027
|
-
}
|
|
1028
|
-
],
|
|
1029
|
-
// ... 其他配置
|
|
1030
|
-
}
|
|
1031
|
-
}}
|
|
1032
|
-
/>
|
|
1033
|
-
```
|
|
1034
|
-
|
|
1035
|
-
### 示例 10: 完整配置示例
|
|
1036
|
-
|
|
1037
|
-
```typescript
|
|
1038
|
-
import EntityList from '@/components/List/EntityList/component'
|
|
1039
|
-
import { EntityListStore } from '@/components/Store/list'
|
|
1040
|
-
import { ExpandSchemasPosition } from '@/components/List/EntityList/interface'
|
|
1041
|
-
|
|
1042
|
-
// 创建 Store
|
|
1043
|
-
const store = EntityListStore.create({
|
|
1044
|
-
// Store 配置
|
|
1045
|
-
})
|
|
1046
|
-
|
|
1047
|
-
// 渲染组件
|
|
1048
|
-
<EntityList
|
|
1049
|
-
// 基础配置
|
|
1050
|
-
name="accountList"
|
|
1051
|
-
entityApiKey="account"
|
|
1052
|
-
objectApiKey="account"
|
|
1053
|
-
tableType="list"
|
|
1054
|
-
store={store}
|
|
1055
|
-
titleName="客户列表"
|
|
1056
|
-
className="custom-list"
|
|
1057
|
-
|
|
1058
|
-
// 功能配置
|
|
1059
|
-
isSearchAtCurrentPage={false}
|
|
1060
|
-
disableTopView={false}
|
|
1061
|
-
disableSortFilterView={false}
|
|
1062
|
-
isOnlyList={false}
|
|
1063
|
-
enableCache={true}
|
|
1064
|
-
|
|
1065
|
-
// 数据配置
|
|
1066
|
-
requestParams={{
|
|
1067
|
-
searchParams: {
|
|
1068
|
-
conditions: [
|
|
1069
|
-
{ apiKey: 'status', type: 1, value: 'active' }
|
|
1070
|
-
]
|
|
1071
|
-
}
|
|
1072
|
-
}}
|
|
1073
|
-
extFilterItems={[
|
|
1074
|
-
{ apiKey: 'customField', label: '自定义字段', itemType: 1 }
|
|
1075
|
-
]}
|
|
1076
|
-
|
|
1077
|
-
// 事件回调
|
|
1078
|
-
onItemClickIntercept={(data, entity) => {
|
|
1079
|
-
console.log('点击项', data)
|
|
1080
|
-
return false
|
|
1081
|
-
}}
|
|
1082
|
-
onSearchDataComplete={(data) => {
|
|
1083
|
-
console.log('搜索完成', data)
|
|
1084
|
-
}}
|
|
1085
|
-
onPageComplete={(event) => {
|
|
1086
|
-
console.log('页面完成', event)
|
|
1087
|
-
}}
|
|
1088
|
-
beforeSearch={(params) => {
|
|
1089
|
-
// 修改搜索参数
|
|
1090
|
-
return params
|
|
1091
|
-
}}
|
|
1092
|
-
|
|
1093
|
-
// 扩展配置
|
|
1094
|
-
nexVersion={2}
|
|
1095
|
-
getHeaderExpand={({ store, api }) => {
|
|
1096
|
-
return [
|
|
1097
|
-
{
|
|
1098
|
-
position: ExpandSchemasPosition.SMARTVIEW_BOTTOM,
|
|
1099
|
-
schema: {
|
|
1100
|
-
type: 'wrapper',
|
|
1101
|
-
body: '扩展内容'
|
|
1102
|
-
}
|
|
1103
|
-
}
|
|
1104
|
-
]
|
|
1105
|
-
}}
|
|
1106
|
-
|
|
1107
|
-
// 批量操作
|
|
1108
|
-
bulkOperationBtnClick={(btnInfo, selectData, context) => {
|
|
1109
|
-
console.log('批量操作', btnInfo, selectData)
|
|
1110
|
-
return false
|
|
1111
|
-
}}
|
|
1112
|
-
|
|
1113
|
-
// 自定义按钮
|
|
1114
|
-
customOperationBtn={(entity) => {
|
|
1115
|
-
return {
|
|
1116
|
-
type: 'button',
|
|
1117
|
-
label: '自定义操作',
|
|
1118
|
-
onClick: () => {
|
|
1119
|
-
console.log('自定义操作')
|
|
1120
|
-
}
|
|
1121
|
-
}
|
|
1122
|
-
}}
|
|
1123
|
-
/>
|
|
1124
|
-
```
|
|
1125
|
-
|
|
1126
|
-
## 扩展机制
|
|
1127
|
-
|
|
1128
|
-
### Nex 1.0 扩展
|
|
1129
|
-
|
|
1130
|
-
通过 `nexIns` 进行扩展,主要扩展点:
|
|
1131
|
-
|
|
1132
|
-
1. **dataList**: 数据列表扩展
|
|
1133
|
-
- `fields`: 字段扩展
|
|
1134
|
-
- `beforeFieldRender`: 字段渲染前处理
|
|
1135
|
-
- `buttonGroup`: 按钮组扩展
|
|
1136
|
-
|
|
1137
|
-
2. **listViews**: 视图扩展
|
|
1138
|
-
- `disableSwitch`: 禁用视图切换
|
|
1139
|
-
|
|
1140
|
-
3. **listButton**: 列表按钮扩展
|
|
1141
|
-
|
|
1142
|
-
4. **multiButton**: 批量操作按钮扩展
|
|
1143
|
-
|
|
1144
|
-
### Nex 2.0 扩展
|
|
1145
|
-
|
|
1146
|
-
通过 `nexInsV2` 进行扩展(`nexVersion=2`),主要扩展点:
|
|
1147
|
-
|
|
1148
|
-
1. **dataList**:
|
|
1149
|
-
- `listItem`: 列表项字段配置
|
|
1150
|
-
- `beforeFieldRender`: 字段渲染前处理(事件形式)
|
|
1151
|
-
|
|
1152
|
-
2. **listViews**:
|
|
1153
|
-
- `disableSwitch`: 禁用视图切换
|
|
1154
|
-
|
|
1155
|
-
3. **listButton**: 列表按钮扩展(事件形式)
|
|
1156
|
-
|
|
1157
|
-
4. **multiButton**: 批量操作按钮扩展(事件形式)
|
|
1158
|
-
|
|
1159
|
-
### 扩展布局
|
|
1160
|
-
|
|
1161
|
-
通过 `getHeaderExpand` 在指定位置插入扩展 Schema:
|
|
1162
|
-
|
|
1163
|
-
```typescript
|
|
1164
|
-
enum ExpandSchemasPosition {
|
|
1165
|
-
SMARTVIEW_BOTTOM = 'smartview-bottom', // SmartView 下方
|
|
1166
|
-
SEARCHLAYOUT_BOTTOM = 'searchlayout-bottom', // 搜索栏下方
|
|
1167
|
-
FILTER_BOTTOM = 'filter-bottom', // 筛选下方
|
|
1168
|
-
LIST_BOTTOM = 'list-bottom' // 列表下方
|
|
1169
|
-
}
|
|
1170
|
-
```
|
|
1171
|
-
|
|
1172
|
-
### 扩展实例获取
|
|
1173
|
-
|
|
1174
|
-
通过 `getInstanceForNex()` 获取扩展实例:
|
|
1175
|
-
|
|
1176
|
-
```typescript
|
|
1177
|
-
const instance = this.getInstanceForNex()
|
|
1178
|
-
const dataList = instance.getComponentsByName('dataList')[0]
|
|
1179
|
-
const buttonGroup = instance.getComponentsByName('buttonGroup')[0]
|
|
1180
|
-
|
|
1181
|
-
// 调用扩展方法
|
|
1182
|
-
buttonGroup.setAttribute('actions', newActions)
|
|
1183
|
-
```
|
|
1184
|
-
|
|
1185
|
-
## 注意事项
|
|
1186
|
-
|
|
1187
|
-
### 1. Store 初始化
|
|
1188
|
-
|
|
1189
|
-
- Store 必须在组件外部创建,不能每次渲染都创建新实例
|
|
1190
|
-
- Store 需要正确初始化配置信息
|
|
1191
|
-
|
|
1192
|
-
### 2. 列表类型区分
|
|
1193
|
-
|
|
1194
|
-
- `tableType='list'` + `isComponents=false`: 大列表
|
|
1195
|
-
- `tableType='list'` + `isComponents=true`: 数据列表组件
|
|
1196
|
-
- `tableType='refer'` + `isComponents=false`: 二级列表
|
|
1197
|
-
- `tableType='refer'` + `isComponents=true`: 相关列表组件
|
|
1198
|
-
|
|
1199
|
-
### 3. 必传参数
|
|
1200
|
-
|
|
1201
|
-
- **大列表**: `entityApiKey`、`store`、`name`
|
|
1202
|
-
- **相关列表**: `referConditions`(必传)
|
|
1203
|
-
- **Picker 列表**: `referData`(必传)
|
|
1204
|
-
|
|
1205
|
-
### 4. 性能优化
|
|
1206
|
-
|
|
1207
|
-
- 启用并行优化(`enableParOpt`)可以提升大列表加载速度
|
|
1208
|
-
- 启用分步渲染(`enableStepRender`)可以优化首屏渲染
|
|
1209
|
-
- 合理使用缓存(`enableCache`)
|
|
1210
|
-
|
|
1211
|
-
### 5. 批量操作限制
|
|
1212
|
-
|
|
1213
|
-
- 批量操作最多选择 20 条数据
|
|
1214
|
-
- Picker 列表可以通过 `selectMaxCount` 自定义最大选择数
|
|
1215
|
-
|
|
1216
|
-
### 6. 筛选缓存
|
|
1217
|
-
|
|
1218
|
-
- 筛选条件会自动缓存到本地存储
|
|
1219
|
-
- 切换视图时会恢复之前的筛选条件
|
|
1220
|
-
|
|
1221
|
-
### 7. 错误处理
|
|
1222
|
-
|
|
1223
|
-
- 组件会自动处理错误并显示错误提示
|
|
1224
|
-
- 初始化错误会自动返回上一页
|
|
1225
|
-
- 搜索错误会留在当前页
|
|
1226
|
-
|
|
1227
|
-
### 8. 水印设置
|
|
1228
|
-
|
|
1229
|
-
- 如果启用了全局水印(`globalWaterMark=false`),组件会自动添加水印
|
|
1230
|
-
- 水印会添加到 `.neo-list-container` 容器上
|
|
1231
|
-
|
|
1232
|
-
## 常见问题
|
|
1233
|
-
|
|
1234
|
-
### Q1: 如何自定义列表项样式?
|
|
1235
|
-
|
|
1236
|
-
**A**: 通过 `style` 属性传入自定义样式:
|
|
1237
|
-
|
|
1238
|
-
```typescript
|
|
1239
|
-
<EntityList
|
|
1240
|
-
style={{
|
|
1241
|
-
'.a-Neo-List-View-Item-Wrapper': {
|
|
1242
|
-
margin: '0!important',
|
|
1243
|
-
padding: '10px !important'
|
|
1244
|
-
}
|
|
1245
|
-
}}
|
|
1246
|
-
/>
|
|
1247
|
-
```
|
|
1248
|
-
|
|
1249
|
-
### Q2: 如何拦截列表项点击事件?
|
|
1250
|
-
|
|
1251
|
-
**A**: 使用 `onItemClickIntercept` 回调:
|
|
1252
|
-
|
|
1253
|
-
```typescript
|
|
1254
|
-
<EntityList
|
|
1255
|
-
onItemClickIntercept={(data, entity) => {
|
|
1256
|
-
// 自定义处理逻辑
|
|
1257
|
-
// 返回 false 继续执行默认逻辑,true 拦截
|
|
1258
|
-
return false
|
|
1259
|
-
}}
|
|
1260
|
-
/>
|
|
1261
|
-
```
|
|
1262
|
-
|
|
1263
|
-
### Q3: 如何动态刷新列表数据?
|
|
1264
|
-
|
|
1265
|
-
**A**: 使用全局刷新方法:
|
|
1266
|
-
|
|
1267
|
-
```typescript
|
|
1268
|
-
// 只刷新数据
|
|
1269
|
-
window.refreshList_${entityApiKey}({ objectApiKey: entityApiKey })
|
|
1270
|
-
|
|
1271
|
-
// 刷新整个页面(重新请求配置)
|
|
1272
|
-
window.refreshListPage_${entityApiKey}({ objectApiKey: entityApiKey })
|
|
1273
|
-
```
|
|
1274
|
-
|
|
1275
|
-
### Q4: 如何自定义新建按钮?
|
|
1276
|
-
|
|
1277
|
-
**A**: 通过 `createBtn` 属性:
|
|
1278
|
-
|
|
1279
|
-
```typescript
|
|
1280
|
-
<EntityList
|
|
1281
|
-
createBtn={{
|
|
1282
|
-
label: '自定义新建',
|
|
1283
|
-
icon: 'custom-icon',
|
|
1284
|
-
onClick: () => {
|
|
1285
|
-
// 自定义逻辑
|
|
1286
|
-
}
|
|
1287
|
-
}}
|
|
1288
|
-
/>
|
|
1289
|
-
```
|
|
1290
|
-
|
|
1291
|
-
### Q5: 如何禁用某些功能?
|
|
1292
|
-
|
|
1293
|
-
**A**: 使用对应的禁用属性:
|
|
1294
|
-
|
|
1295
|
-
```typescript
|
|
1296
|
-
<EntityList
|
|
1297
|
-
disableSearch={true} // 禁用搜索
|
|
1298
|
-
disableTopView={true} // 隐藏搜索、排序、筛选
|
|
1299
|
-
disableSortFilterView={true} // 隐藏排序、筛选
|
|
1300
|
-
disabledSort={true} // 禁用排序
|
|
1301
|
-
disabledFilter={true} // 禁用筛选
|
|
1302
|
-
/>
|
|
1303
|
-
```
|
|
1304
|
-
|
|
1305
|
-
### Q6: 如何获取当前选中的数据?
|
|
1306
|
-
|
|
1307
|
-
**A**: 通过 Store 获取:
|
|
1308
|
-
|
|
1309
|
-
```typescript
|
|
1310
|
-
const selectedData = store.selectData
|
|
1311
|
-
```
|
|
1312
|
-
|
|
1313
|
-
### Q7: 如何切换 SmartView?
|
|
1314
|
-
|
|
1315
|
-
**A**: 通过 Store 方法:
|
|
1316
|
-
|
|
1317
|
-
```typescript
|
|
1318
|
-
const smartView = store.dataListViews.find(view => view.apiKey === 'targetView')
|
|
1319
|
-
store.clickSmartView(smartView, getAllFilterItems, onSearchDataComplete)
|
|
1320
|
-
```
|
|
1321
|
-
|
|
1322
|
-
### Q8: 如何添加自定义筛选项?
|
|
1323
|
-
|
|
1324
|
-
**A**: 使用 `extFilterItems`:
|
|
1325
|
-
|
|
1326
|
-
```typescript
|
|
1327
|
-
<EntityList
|
|
1328
|
-
extFilterItems={[
|
|
1329
|
-
{
|
|
1330
|
-
apiKey: 'customField',
|
|
1331
|
-
label: '自定义字段',
|
|
1332
|
-
itemType: 1, // 字段类型
|
|
1333
|
-
// ... 其他配置
|
|
1334
|
-
}
|
|
1335
|
-
]}
|
|
1336
|
-
/>
|
|
1337
|
-
```
|
|
1338
|
-
|
|
1339
|
-
### Q9: 如何处理相关列表新建?
|
|
1340
|
-
|
|
1341
|
-
**A**: 需要传入 `detailData` 和 `extendInitParams`:
|
|
1342
|
-
|
|
1343
|
-
```typescript
|
|
1344
|
-
<EntityList
|
|
1345
|
-
tableType="refer"
|
|
1346
|
-
detailData={detailData}
|
|
1347
|
-
extendInitParams={{
|
|
1348
|
-
objectId: detailData.id
|
|
1349
|
-
}}
|
|
1350
|
-
isNeedExtraParams={({ relateEntityApiKey, createEntityApikey }) => {
|
|
1351
|
-
// 判断是否需要额外参数
|
|
1352
|
-
return true
|
|
1353
|
-
}}
|
|
1354
|
-
/>
|
|
1355
|
-
```
|
|
1356
|
-
|
|
1357
|
-
### Q10: 如何使用 Nex 2.0 扩展?
|
|
1358
|
-
|
|
1359
|
-
**A**: 设置 `nexVersion=2` 并传入扩展配置:
|
|
1360
|
-
|
|
1361
|
-
```typescript
|
|
1362
|
-
<EntityList
|
|
1363
|
-
nexVersion={2}
|
|
1364
|
-
dataList={{
|
|
1365
|
-
beforeFieldRender: (event) => {
|
|
1366
|
-
// 处理逻辑
|
|
1367
|
-
},
|
|
1368
|
-
listItem: [...]
|
|
1369
|
-
}}
|
|
1370
|
-
listButton={[...]}
|
|
1371
|
-
multiButton={[...]}
|
|
1372
|
-
/>
|
|
1373
|
-
```
|
|
1374
|
-
|
|
1375
|
-
## 总结
|
|
1376
|
-
|
|
1377
|
-
`EntityList` 是一个功能强大的列表组件,提供了完整的数据展示、筛选、排序、批量操作等功能。通过合理的配置和扩展,可以满足各种业务场景的需求。在使用时需要注意:
|
|
1378
|
-
|
|
1379
|
-
1. 正确初始化 Store
|
|
1380
|
-
2. 根据业务场景选择合适的 `tableType`
|
|
1381
|
-
3. 合理使用扩展机制
|
|
1382
|
-
4. 注意性能优化配置
|
|
1383
|
-
5. 正确处理事件回调
|
|
1384
|
-
|
|
1385
|
-
更多详细信息请参考组件源码和接口定义。
|
|
1386
|
-
|