neo-cmp-cli 1.12.8 → 1.12.10
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/module/neoInitByCopy.js +1 -1
- package/dist/neo/env.js +1 -1
- package/dist/package.json.js +1 -1
- package/package.json +4 -1
- package/template/antd-custom-cmp-template/package.json +1 -1
- package/template/asset-manage-template/README.md +154 -0
- package/template/asset-manage-template/docs/README.md +244 -0
- package/template/asset-manage-template/neo.config.js +60 -0
- package/template/asset-manage-template/package.json +74 -0
- 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 +36 -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/asset-manage-template/tsconfig.json +40 -0
- 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 +5 -2
- package/template/neo-custom-cmp-template/src/components/entityTable__c/index.tsx +62 -6
- package/template/neo-custom-cmp-template/src/utils/queryObjectData.ts +36 -0
- package/template/neo-custom-cmp-template/tsconfig.json +1 -2
- package/template/neo-h5-cmps/neo.config.js +1 -6
- package/template/neo-h5-cmps/package.json +7 -4
- package/template/neo-h5-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-h5-cmps/tsconfig.json +3 -4
- package/template/neo-order-cmps/package.json +2 -2
- package/template/neo-order-cmps/src/utils/queryObjectData.ts +36 -0
- package/template/neo-web-cmps/@types/neo-ui-common.d.ts +36 -0
- package/template/neo-web-cmps/neo.config.js +53 -0
- package/template/{neo-bi-cmps → neo-web-cmps}/package.json +10 -7
- package/template/neo-web-cmps/src/assets/img/AIBtn.gif +0 -0
- package/template/neo-web-cmps/src/assets/img/aiLogo.png +0 -0
- package/template/neo-web-cmps/src/assets/img/card-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/contact-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/custom-form.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/data-list.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/detail.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/map.svg +1 -0
- package/template/neo-web-cmps/src/assets/img/search.svg +1 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/index.tsx +72 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid2__c/style.scss +13 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/index.tsx +52 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/model.ts +195 -0
- package/template/neo-web-cmps/src/components/entityGrid__c/style.scss +13 -0
- package/template/neo-web-cmps/src/utils/axiosFetcher.ts +37 -0
- package/template/neo-web-cmps/src/utils/queryObjectData.ts +112 -0
- package/template/{develop/neo-custom-cmp-template → neo-web-cmps}/src/utils/xobjects.ts +28 -64
- package/template/{neo-bi-cmps → neo-web-cmps}/tsconfig.json +2 -3
- 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/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/develop//345/261/236/346/200/247/351/205/215/347/275/256/351/241/271/347/261/273/345/236/213/346/261/207/346/200/273.md +0 -558
- package/template/neo-bi-cmps/neo.config.js +0 -124
- 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/{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
- /package/template/{neo-bi-cmps → neo-web-cmps}/.prettierrc.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/README.md +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/commitlint.config.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/css/base.css +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/scripts/app/bluebird.js +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/public/template.html +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/common.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/css/mixin.scss +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/NeoCRM.jpg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/custom-widget.svg +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/favicon.png +0 -0
- /package/template/{neo-bi-cmps → neo-web-cmps}/src/assets/img/table.svg +0 -0
|
@@ -1,866 +0,0 @@
|
|
|
1
|
-
# 全局搜索组件对比分析文档
|
|
2
|
-
|
|
3
|
-
## 一、组件概述
|
|
4
|
-
|
|
5
|
-
本文档详细对比分析两个全局搜索首页组件的功能差异、使用场景和实现细节。
|
|
6
|
-
|
|
7
|
-
### 1.1 组件信息
|
|
8
|
-
|
|
9
|
-
| 项目 | 旧组件 | 新组件 |
|
|
10
|
-
|------|--------|--------|
|
|
11
|
-
| **组件名称** | GlobalSearchList | GlobalSearchListHome |
|
|
12
|
-
| **注册名称** | `GlobalSearchHome` | `neoGlobalSearchHome` |
|
|
13
|
-
| **文件路径** | `packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchHome/` | `packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/` |
|
|
14
|
-
| **组件类型** | 类组件 | 类组件 |
|
|
15
|
-
| **状态管理** | React State | React State |
|
|
16
|
-
|
|
17
|
-
### 1.2 组件定位
|
|
18
|
-
|
|
19
|
-
- **旧组件(GlobalSearchHome)**:基础版全局搜索入口,提供简单的实体列表展示和搜索跳转功能
|
|
20
|
-
- **新组件(neoGlobalSearchHome)**:增强版全局搜索入口,支持历史搜索、常用对象管理、权限控制等高级功能
|
|
21
|
-
|
|
22
|
-
---
|
|
23
|
-
|
|
24
|
-
## 二、核心功能对比
|
|
25
|
-
|
|
26
|
-
### 2.1 数据获取方式
|
|
27
|
-
|
|
28
|
-
#### 旧组件数据获取
|
|
29
|
-
|
|
30
|
-
```typescript
|
|
31
|
-
// 接口地址:entityListUrl (来自 constants)
|
|
32
|
-
getEntityList = async () => {
|
|
33
|
-
this.setState({
|
|
34
|
-
entityList: await getEntityList(this.props),
|
|
35
|
-
isLoading: false
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
```
|
|
39
|
-
|
|
40
|
-
**特点:**
|
|
41
|
-
- 获取所有可搜索的实体列表
|
|
42
|
-
- 包含动态(Feed)实体
|
|
43
|
-
- 返回数据结构包含:`objectBelongId`, `objectApiKey`, `objectLabel`, `icon`, `iconColor` 等
|
|
44
|
-
|
|
45
|
-
#### 新组件数据获取
|
|
46
|
-
|
|
47
|
-
```typescript
|
|
48
|
-
// 接口地址:/rest/data/v2.0/global_search/xobjects
|
|
49
|
-
getObjectList = async () => {
|
|
50
|
-
this.setState(
|
|
51
|
-
{
|
|
52
|
-
objectList: await getObjectList(this.props),
|
|
53
|
-
isLoading: false
|
|
54
|
-
},
|
|
55
|
-
() => {
|
|
56
|
-
this.searchRef?.focus()
|
|
57
|
-
}
|
|
58
|
-
)
|
|
59
|
-
}
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
**特点:**
|
|
63
|
-
- 获取全局搜索配置的实体列表
|
|
64
|
-
- 区分常用对象(`commonXObject: true`)和非常用对象
|
|
65
|
-
- 不包含动态实体
|
|
66
|
-
- 支持用户自定义常用对象配置
|
|
67
|
-
- 数据结构包含:`xobjectApikey`, `objectId`, `objectName`, `commonXObject` 等
|
|
68
|
-
|
|
69
|
-
### 2.2 状态管理对比
|
|
70
|
-
|
|
71
|
-
#### 旧组件状态(ObjectFormState)
|
|
72
|
-
|
|
73
|
-
```typescript
|
|
74
|
-
export interface ObjectFormState {
|
|
75
|
-
isSearched: boolean // 是否已进行搜索
|
|
76
|
-
entityList: Array<object> // 实体列表
|
|
77
|
-
isSingleEntitySearch: boolean // 是否单实体搜索模式
|
|
78
|
-
isLoading: boolean // 加载状态
|
|
79
|
-
currentEntity: object // 当前选中的实体
|
|
80
|
-
searchKey: string // 搜索关键词
|
|
81
|
-
}
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
#### 新组件状态(GlobalSearchHomeState)
|
|
85
|
-
|
|
86
|
-
```typescript
|
|
87
|
-
export interface GlobalSearchHomeState {
|
|
88
|
-
isLoading: boolean // 加载状态
|
|
89
|
-
isHistory: boolean // 是否显示历史搜索
|
|
90
|
-
searchKey: string // 搜索关键词
|
|
91
|
-
objectList: GlobalSearchXobjectProps[] // 对象列表
|
|
92
|
-
historyArr: any[] // 历史搜索记录数组
|
|
93
|
-
}
|
|
94
|
-
```
|
|
95
|
-
|
|
96
|
-
**关键差异:**
|
|
97
|
-
- 新组件增加了 `isHistory` 状态,用于控制历史搜索界面的显示
|
|
98
|
-
- 新组件增加了 `historyArr` 状态,用于存储历史搜索记录
|
|
99
|
-
- 旧组件使用 `isSingleEntitySearch` 控制单实体搜索模式,新组件通过路由参数传递
|
|
100
|
-
|
|
101
|
-
### 2.3 UI 展示逻辑对比
|
|
102
|
-
|
|
103
|
-
#### 旧组件 UI 结构
|
|
104
|
-
|
|
105
|
-
```typescript
|
|
106
|
-
page = () => {
|
|
107
|
-
return {
|
|
108
|
-
type: 'page',
|
|
109
|
-
bodyClassName: 'globalSearchContainer',
|
|
110
|
-
name: 'GlobalSearchListList',
|
|
111
|
-
body: this.state.isLoading
|
|
112
|
-
? this.searchView()
|
|
113
|
-
: [
|
|
114
|
-
this.searchView(),
|
|
115
|
-
// 如果点击了单个实体进行搜索,需要把entityList隐藏掉
|
|
116
|
-
this.state.isSingleEntitySearch ? {} : this.entityList()
|
|
117
|
-
]
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
```
|
|
121
|
-
|
|
122
|
-
**UI 特点:**
|
|
123
|
-
- 搜索栏始终显示
|
|
124
|
-
- 加载中:只显示搜索栏
|
|
125
|
-
- 加载完成:显示搜索栏 + 实体列表(单实体搜索模式下隐藏实体列表)
|
|
126
|
-
|
|
127
|
-
#### 新组件 UI 结构
|
|
128
|
-
|
|
129
|
-
```typescript
|
|
130
|
-
getJsonSchema = () => {
|
|
131
|
-
const { isHistory } = this.state
|
|
132
|
-
return {
|
|
133
|
-
type: 'page',
|
|
134
|
-
bodyClassName: 'globalSearchContainer',
|
|
135
|
-
name: 'GlobalSearchListList',
|
|
136
|
-
body: isHistory ? this.getHistorySchema() : this.getObjectViewScheam()
|
|
137
|
-
}
|
|
138
|
-
}
|
|
139
|
-
```
|
|
140
|
-
|
|
141
|
-
**UI 特点:**
|
|
142
|
-
- 搜索栏独立渲染,始终显示
|
|
143
|
-
- 根据 `isHistory` 状态切换显示内容:
|
|
144
|
-
- `true`:显示历史搜索界面(`getHistorySchema`)
|
|
145
|
-
- `false`:显示对象视图(`getObjectViewScheam`)
|
|
146
|
-
- 对象视图区分常用对象和非常用对象
|
|
147
|
-
|
|
148
|
-
### 2.4 搜索行为对比
|
|
149
|
-
|
|
150
|
-
#### 旧组件搜索流程
|
|
151
|
-
|
|
152
|
-
```typescript
|
|
153
|
-
onSubmit: (val) => {
|
|
154
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearch', {
|
|
155
|
-
searchKey: val,
|
|
156
|
-
searchEntity: this.state.currentEntity,
|
|
157
|
-
isSingleEntitySearch: this.state.isSingleEntitySearch,
|
|
158
|
-
entityList: this.state.entityList
|
|
159
|
-
})
|
|
160
|
-
}
|
|
161
|
-
```
|
|
162
|
-
|
|
163
|
-
**流程:**
|
|
164
|
-
1. 用户输入搜索关键词
|
|
165
|
-
2. 点击搜索或回车
|
|
166
|
-
3. 直接跳转到 `/neo/neoGlobalSearch` 搜索结果页
|
|
167
|
-
4. 传递搜索关键词、当前实体、是否单实体搜索、实体列表等参数
|
|
168
|
-
|
|
169
|
-
#### 新组件搜索流程
|
|
170
|
-
|
|
171
|
-
```typescript
|
|
172
|
-
onSubmit: (val) => {
|
|
173
|
-
this.setHistorySearchValueDb(val) // 保存历史搜索记录
|
|
174
|
-
this.gotoAllContentPage() // 跳转到全部内容页
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
gotoAllContentPage = () => {
|
|
178
|
-
const { searchKey, objectList } = this.state
|
|
179
|
-
const listSearchPath = '/neo/neoGlobalSearchContent'
|
|
180
|
-
NeoNavigator.openPageWithURL(listSearchPath, null, {
|
|
181
|
-
searchKey,
|
|
182
|
-
objectList
|
|
183
|
-
})
|
|
184
|
-
}
|
|
185
|
-
```
|
|
186
|
-
|
|
187
|
-
**流程:**
|
|
188
|
-
1. 用户输入搜索关键词
|
|
189
|
-
2. 点击搜索或回车
|
|
190
|
-
3. **保存历史搜索记录**到本地存储
|
|
191
|
-
4. 跳转到 `/neo/neoGlobalSearchContent` 全部内容搜索结果页
|
|
192
|
-
5. 传递搜索关键词和对象列表参数
|
|
193
|
-
|
|
194
|
-
### 2.5 单实体搜索对比
|
|
195
|
-
|
|
196
|
-
#### 旧组件单实体搜索
|
|
197
|
-
|
|
198
|
-
```typescript
|
|
199
|
-
gotoSingleEntitySearch = (item) => {
|
|
200
|
-
// 当前页面重新渲染,屏蔽实体列表组件
|
|
201
|
-
this.setState({ isSingleEntitySearch: true, currentEntity: item })
|
|
202
|
-
}
|
|
203
|
-
```
|
|
204
|
-
|
|
205
|
-
**特点:**
|
|
206
|
-
- 在当前页面切换状态,隐藏实体列表
|
|
207
|
-
- 搜索时传递单实体搜索标识和实体信息
|
|
208
|
-
|
|
209
|
-
#### 新组件单实体搜索
|
|
210
|
-
|
|
211
|
-
```typescript
|
|
212
|
-
gotoSingleEntityList = (item: GlobalSearchXobjectProps) => {
|
|
213
|
-
const { searchKey } = this.state
|
|
214
|
-
const listSearchPath = '/neo/neoGlobalSearchList'
|
|
215
|
-
NeoNavigator.openPageWithURL(listSearchPath, null, {
|
|
216
|
-
objectApiKey: item.xobjectApikey,
|
|
217
|
-
searchKey
|
|
218
|
-
})
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
|
-
**特点:**
|
|
223
|
-
- 直接跳转到单实体列表页 `/neo/neoGlobalSearchList`
|
|
224
|
-
- 传递对象 API Key 和搜索关键词
|
|
225
|
-
- 不在当前页面切换状态
|
|
226
|
-
|
|
227
|
-
---
|
|
228
|
-
|
|
229
|
-
## 三、新增功能特性
|
|
230
|
-
|
|
231
|
-
### 3.1 历史搜索功能(新组件独有)
|
|
232
|
-
|
|
233
|
-
#### 功能说明
|
|
234
|
-
|
|
235
|
-
新组件支持历史搜索记录功能,用户可以查看和快速选择之前的搜索关键词。
|
|
236
|
-
|
|
237
|
-
#### 实现细节
|
|
238
|
-
|
|
239
|
-
```typescript
|
|
240
|
-
// 历史搜索存储键名
|
|
241
|
-
const storageKey = `global_search_history__${getNeoContext('currentUser')?.id}__${
|
|
242
|
-
getNeoContext('currentTenant')?.id
|
|
243
|
-
}`
|
|
244
|
-
|
|
245
|
-
// 保存历史搜索记录
|
|
246
|
-
setHistorySearchValueDb = (val?) => {
|
|
247
|
-
let { historyArr } = this.state
|
|
248
|
-
if (val) {
|
|
249
|
-
historyArr.unshift(val) // 添加到数组开头
|
|
250
|
-
}
|
|
251
|
-
const result = Array.from(new Set(historyArr)) // 去重
|
|
252
|
-
const result2 = result.slice(0, this.historySearchCount) // 最多保存10条
|
|
253
|
-
offlineStorageService.getService().dbSet(storageKey, result2)
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
// 历史搜索界面
|
|
257
|
-
getHistorySchema = () => {
|
|
258
|
-
return {
|
|
259
|
-
type: 'wrapper',
|
|
260
|
-
body: [
|
|
261
|
-
{
|
|
262
|
-
type: 'neoSearchHistory',
|
|
263
|
-
historyType: 'global',
|
|
264
|
-
tagSchema: {
|
|
265
|
-
type: 'neoCustomTag',
|
|
266
|
-
closable: true
|
|
267
|
-
},
|
|
268
|
-
onChange: (value) => {
|
|
269
|
-
this.setState({ searchKey: value, isHistory: false })
|
|
270
|
-
this.searchRef?.focus()
|
|
271
|
-
}
|
|
272
|
-
}
|
|
273
|
-
]
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
```
|
|
277
|
-
|
|
278
|
-
**特点:**
|
|
279
|
-
- 使用 `offlineStorageService` 进行本地存储
|
|
280
|
-
- 按用户和租户隔离存储
|
|
281
|
-
- 最多保存 10 条历史记录
|
|
282
|
-
- 自动去重
|
|
283
|
-
- 支持点击历史记录快速搜索
|
|
284
|
-
|
|
285
|
-
### 3.2 常用对象设置功能(新组件独有)
|
|
286
|
-
|
|
287
|
-
#### 功能说明
|
|
288
|
-
|
|
289
|
-
新组件支持用户自定义常用对象,通过设置页面管理哪些对象显示在常用对象列表中。
|
|
290
|
-
|
|
291
|
-
#### 实现细节
|
|
292
|
-
|
|
293
|
-
```typescript
|
|
294
|
-
gotoSetting = () => {
|
|
295
|
-
const { objectList } = this.state
|
|
296
|
-
NeoNavigator.openDialog({
|
|
297
|
-
ctx: this.context,
|
|
298
|
-
bodySchema: {
|
|
299
|
-
type: 'neoGlobalSearchSetting',
|
|
300
|
-
name: 'neoGlobalSearchSetting',
|
|
301
|
-
objectList,
|
|
302
|
-
setCallback: async () => {
|
|
303
|
-
this.setState({ isLoading: true })
|
|
304
|
-
const newObjectList = await getObjectList(this.props)
|
|
305
|
-
this.setState({ objectList: newObjectList, isLoading: false })
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
})
|
|
309
|
-
}
|
|
310
|
-
```
|
|
311
|
-
|
|
312
|
-
**特点:**
|
|
313
|
-
- 通过弹窗形式打开设置页面
|
|
314
|
-
- 设置完成后自动刷新对象列表
|
|
315
|
-
- 常用对象配置持久化存储
|
|
316
|
-
|
|
317
|
-
### 3.3 权限控制功能(新组件独有)
|
|
318
|
-
|
|
319
|
-
#### 功能说明
|
|
320
|
-
|
|
321
|
-
新组件增加了全局搜索权限检查,无权限用户显示无权限提示页面。
|
|
322
|
-
|
|
323
|
-
#### 实现细节
|
|
324
|
-
|
|
325
|
-
```typescript
|
|
326
|
-
notPermission = () => {
|
|
327
|
-
const { render } = this.props
|
|
328
|
-
return render('notPermission', {
|
|
329
|
-
type: 'neoPage',
|
|
330
|
-
titleConfig: {
|
|
331
|
-
titleStrings: kiwiIntl('neo.global.search', '全局搜索'),
|
|
332
|
-
noRightBtn: true
|
|
333
|
-
},
|
|
334
|
-
containerBody: {
|
|
335
|
-
type: 'neoEmpty',
|
|
336
|
-
desc: kiwiIntl('neo.global.search.not.permission', '您没有全局搜索的权限'),
|
|
337
|
-
style: { marginTop: '100px' }
|
|
338
|
-
}
|
|
339
|
-
})
|
|
340
|
-
}
|
|
341
|
-
|
|
342
|
-
render() {
|
|
343
|
-
const globalSearchPermission = getNeoContext('globalSearchPermission')
|
|
344
|
-
if (!globalSearchPermission) {
|
|
345
|
-
return this.notPermission()
|
|
346
|
-
}
|
|
347
|
-
// ... 正常渲染逻辑
|
|
348
|
-
}
|
|
349
|
-
```
|
|
350
|
-
|
|
351
|
-
**特点:**
|
|
352
|
-
- 从 `getNeoContext` 获取权限配置
|
|
353
|
-
- 无权限时显示友好的提示页面
|
|
354
|
-
- 不影响其他功能的正常使用
|
|
355
|
-
|
|
356
|
-
### 3.4 搜索栏增强功能(新组件)
|
|
357
|
-
|
|
358
|
-
#### 功能对比
|
|
359
|
-
|
|
360
|
-
| 功能 | 旧组件 | 新组件 |
|
|
361
|
-
|------|--------|--------|
|
|
362
|
-
| 自动聚焦 | ❌ | ✅ (`autoFocus: true`) |
|
|
363
|
-
| 始终显示清除按钮 | ❌ | ✅ (`alwaysShowClear: true`) |
|
|
364
|
-
| 搜索引用 | ❌ | ✅ (`searchRef`) |
|
|
365
|
-
| 输入变化监听 | ❌ | ✅ (`onChange`) |
|
|
366
|
-
| 占位符文本 | 简单文本 | 多语言支持 |
|
|
367
|
-
|
|
368
|
-
#### 新组件搜索栏配置
|
|
369
|
-
|
|
370
|
-
```typescript
|
|
371
|
-
searchViewSchema = () => {
|
|
372
|
-
const { showCancelButton = true } = this.props
|
|
373
|
-
return {
|
|
374
|
-
type: 'neoSearchBar',
|
|
375
|
-
maxLength: 100,
|
|
376
|
-
searchRef: (ref) => {
|
|
377
|
-
this.searchRef = ref // 保存搜索框引用
|
|
378
|
-
},
|
|
379
|
-
placeholder: dayOneI18n('XdMDTextLabel.Neo.Global.Search.Placeholder', '搜索CRM数据、动态...'),
|
|
380
|
-
showCancelButton,
|
|
381
|
-
alwaysShowClear: true, // 始终显示清除按钮
|
|
382
|
-
value: this.state.searchKey,
|
|
383
|
-
autoFocus: true, // 自动聚焦
|
|
384
|
-
className: 'searchBarContainer',
|
|
385
|
-
onSubmit: (val) => {
|
|
386
|
-
this.setHistorySearchValueDb(val)
|
|
387
|
-
this.gotoAllContentPage()
|
|
388
|
-
},
|
|
389
|
-
onCancel: () => {
|
|
390
|
-
this.setState({ isHistory: true })
|
|
391
|
-
NeoNavigator.goBack()
|
|
392
|
-
},
|
|
393
|
-
onClear: () => {
|
|
394
|
-
this.setState({ searchKey: '', isHistory: true })
|
|
395
|
-
},
|
|
396
|
-
onChange: (val) => {
|
|
397
|
-
// 根据输入内容切换显示历史搜索或对象列表
|
|
398
|
-
this.setState({ searchKey: val, isHistory: NeoIsEmpty(val) ? true : false })
|
|
399
|
-
}
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
```
|
|
403
|
-
|
|
404
|
-
---
|
|
405
|
-
|
|
406
|
-
## 四、路由跳转对比
|
|
407
|
-
|
|
408
|
-
### 4.1 旧组件路由跳转
|
|
409
|
-
|
|
410
|
-
| 操作 | 目标路由 | 传递参数 |
|
|
411
|
-
|------|----------|----------|
|
|
412
|
-
| 搜索提交 | `/neo/neoGlobalSearch` | `searchKey`, `searchEntity`, `isSingleEntitySearch`, `entityList` |
|
|
413
|
-
| 取消操作 | 返回上一页 | - |
|
|
414
|
-
|
|
415
|
-
### 4.2 新组件路由跳转
|
|
416
|
-
|
|
417
|
-
| 操作 | 目标路由 | 传递参数 |
|
|
418
|
-
|------|----------|----------|
|
|
419
|
-
| 搜索提交(全部内容) | `/neo/neoGlobalSearchContent` | `searchKey`, `objectList` |
|
|
420
|
-
| 点击单实体 | `/neo/neoGlobalSearchList` | `objectApiKey`, `searchKey` |
|
|
421
|
-
| 取消操作 | 返回上一页 | - |
|
|
422
|
-
|
|
423
|
-
---
|
|
424
|
-
|
|
425
|
-
## 五、数据接口对比
|
|
426
|
-
|
|
427
|
-
### 5.1 旧组件数据接口
|
|
428
|
-
|
|
429
|
-
**获取实体列表接口:**
|
|
430
|
-
- **接口地址**:`entityListUrl`(来自 constants)
|
|
431
|
-
- **请求方法**:`GET`
|
|
432
|
-
- **返回数据结构**:
|
|
433
|
-
```typescript
|
|
434
|
-
{
|
|
435
|
-
data: {
|
|
436
|
-
data: {
|
|
437
|
-
entities: [
|
|
438
|
-
{
|
|
439
|
-
objectBelongId: string,
|
|
440
|
-
objectApiKey: string,
|
|
441
|
-
objectLabel: string,
|
|
442
|
-
objectLabel_resourceKey: string,
|
|
443
|
-
objectIconId: string,
|
|
444
|
-
// ... 其他字段
|
|
445
|
-
}
|
|
446
|
-
]
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
}
|
|
450
|
-
```
|
|
451
|
-
|
|
452
|
-
**特点:**
|
|
453
|
-
- 返回所有可搜索实体
|
|
454
|
-
- 包含动态实体(代码中手动添加)
|
|
455
|
-
- 需要额外请求获取实体图标
|
|
456
|
-
|
|
457
|
-
### 5.2 新组件数据接口
|
|
458
|
-
|
|
459
|
-
**获取对象列表接口:**
|
|
460
|
-
- **接口地址**:`/rest/data/v2.0/global_search/xobjects`
|
|
461
|
-
- **请求方法**:`GET`
|
|
462
|
-
- **返回数据结构**:
|
|
463
|
-
```typescript
|
|
464
|
-
{
|
|
465
|
-
data: {
|
|
466
|
-
data: [
|
|
467
|
-
{
|
|
468
|
-
xobjectApikey: string,
|
|
469
|
-
objectId: number,
|
|
470
|
-
objectName: string,
|
|
471
|
-
objectLabel: string,
|
|
472
|
-
objectLabelResourceKey: string,
|
|
473
|
-
objectIconId: string,
|
|
474
|
-
defaultColor: string,
|
|
475
|
-
commonXObject: boolean, // 是否常用对象
|
|
476
|
-
// ... 其他字段
|
|
477
|
-
}
|
|
478
|
-
]
|
|
479
|
-
}
|
|
480
|
-
}
|
|
481
|
-
```
|
|
482
|
-
|
|
483
|
-
**特点:**
|
|
484
|
-
- 返回全局搜索配置的对象列表
|
|
485
|
-
- 区分常用对象和非常用对象
|
|
486
|
-
- 不包含动态实体
|
|
487
|
-
- 需要额外请求获取实体图标
|
|
488
|
-
|
|
489
|
-
---
|
|
490
|
-
|
|
491
|
-
## 六、使用示例
|
|
492
|
-
|
|
493
|
-
### 6.1 旧组件使用示例
|
|
494
|
-
|
|
495
|
-
#### 基础使用
|
|
496
|
-
|
|
497
|
-
```typescript
|
|
498
|
-
// 在 Amis Schema 中使用
|
|
499
|
-
{
|
|
500
|
-
type: 'page',
|
|
501
|
-
body: [
|
|
502
|
-
{
|
|
503
|
-
type: 'GlobalSearchHome',
|
|
504
|
-
name: 'globalSearchHome'
|
|
505
|
-
}
|
|
506
|
-
]
|
|
507
|
-
}
|
|
508
|
-
```
|
|
509
|
-
|
|
510
|
-
#### 完整配置示例
|
|
511
|
-
|
|
512
|
-
```typescript
|
|
513
|
-
{
|
|
514
|
-
type: 'GlobalSearchHome',
|
|
515
|
-
name: 'globalSearchHome',
|
|
516
|
-
// 组件会自动获取实体列表
|
|
517
|
-
// 用户操作流程:
|
|
518
|
-
// 1. 显示搜索栏和实体列表
|
|
519
|
-
// 2. 用户可以选择实体进入单实体搜索模式
|
|
520
|
-
// 3. 输入搜索关键词后跳转到搜索结果页
|
|
521
|
-
}
|
|
522
|
-
```
|
|
523
|
-
|
|
524
|
-
### 6.2 新组件使用示例
|
|
525
|
-
|
|
526
|
-
#### 基础使用
|
|
527
|
-
|
|
528
|
-
```typescript
|
|
529
|
-
// 在 Amis Schema 中使用
|
|
530
|
-
{
|
|
531
|
-
type: 'page',
|
|
532
|
-
body: [
|
|
533
|
-
{
|
|
534
|
-
type: 'neoGlobalSearchHome',
|
|
535
|
-
name: 'neoGlobalSearchHome'
|
|
536
|
-
}
|
|
537
|
-
]
|
|
538
|
-
}
|
|
539
|
-
```
|
|
540
|
-
|
|
541
|
-
#### 完整配置示例
|
|
542
|
-
|
|
543
|
-
```typescript
|
|
544
|
-
{
|
|
545
|
-
type: 'neoGlobalSearchHome',
|
|
546
|
-
name: 'neoGlobalSearchHome',
|
|
547
|
-
showCancelButton: true, // 是否显示取消按钮,默认 true
|
|
548
|
-
menuList: (objectList, onCallBack) => {
|
|
549
|
-
// 自定义菜单列表渲染(可选)
|
|
550
|
-
// objectList: 对象列表
|
|
551
|
-
// onCallBack: 回调函数
|
|
552
|
-
return {
|
|
553
|
-
type: 'neoMenuGroup',
|
|
554
|
-
dataSource: objectList,
|
|
555
|
-
onItemClick: (item) => {
|
|
556
|
-
// 自定义点击处理
|
|
557
|
-
onCallBack && onCallBack(item)
|
|
558
|
-
}
|
|
559
|
-
}
|
|
560
|
-
},
|
|
561
|
-
onCallBack: (item) => {
|
|
562
|
-
// 自定义回调处理(可选)
|
|
563
|
-
console.log('点击了对象:', item)
|
|
564
|
-
}
|
|
565
|
-
}
|
|
566
|
-
```
|
|
567
|
-
|
|
568
|
-
#### 实际使用场景示例
|
|
569
|
-
|
|
570
|
-
**场景1:在导航入口使用**
|
|
571
|
-
|
|
572
|
-
```typescript
|
|
573
|
-
// GlobalSearchInput 组件中的使用
|
|
574
|
-
{
|
|
575
|
-
type: 'neoGlobalSearchInput',
|
|
576
|
-
isNewGlobal: true, // 使用新组件
|
|
577
|
-
// 当 isNewGlobal 为 true 时,跳转到 neoGlobalSearchHome
|
|
578
|
-
// 当 isNewGlobal 为 false 时,跳转到 GlobalSearchHome
|
|
579
|
-
}
|
|
580
|
-
```
|
|
581
|
-
|
|
582
|
-
**场景2:直接路由跳转**
|
|
583
|
-
|
|
584
|
-
```typescript
|
|
585
|
-
import { NeoNavigator } from 'neo-ui-common'
|
|
586
|
-
|
|
587
|
-
// 跳转到全局搜索首页
|
|
588
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearchHome')
|
|
589
|
-
```
|
|
590
|
-
|
|
591
|
-
**场景3:自定义菜单列表**
|
|
592
|
-
|
|
593
|
-
```typescript
|
|
594
|
-
{
|
|
595
|
-
type: 'neoGlobalSearchHome',
|
|
596
|
-
name: 'customGlobalSearch',
|
|
597
|
-
menuList: (objectList, onCallBack) => {
|
|
598
|
-
// 只显示前5个常用对象
|
|
599
|
-
const top5Objects = objectList.filter(item => item.commonXObject).slice(0, 5)
|
|
600
|
-
return {
|
|
601
|
-
type: 'neoMenuGroup',
|
|
602
|
-
dataSource: top5Objects,
|
|
603
|
-
onItemClick: (item) => {
|
|
604
|
-
// 自定义跳转逻辑
|
|
605
|
-
NeoNavigator.openPageWithURL('/custom/search', null, {
|
|
606
|
-
objectApiKey: item.xobjectApikey
|
|
607
|
-
})
|
|
608
|
-
}
|
|
609
|
-
}
|
|
610
|
-
}
|
|
611
|
-
}
|
|
612
|
-
```
|
|
613
|
-
|
|
614
|
-
---
|
|
615
|
-
|
|
616
|
-
## 七、迁移指南
|
|
617
|
-
|
|
618
|
-
### 7.1 从旧组件迁移到新组件
|
|
619
|
-
|
|
620
|
-
#### 步骤1:更新组件类型
|
|
621
|
-
|
|
622
|
-
```typescript
|
|
623
|
-
// 旧代码
|
|
624
|
-
{
|
|
625
|
-
type: 'GlobalSearchHome',
|
|
626
|
-
name: 'globalSearch'
|
|
627
|
-
}
|
|
628
|
-
|
|
629
|
-
// 新代码
|
|
630
|
-
{
|
|
631
|
-
type: 'neoGlobalSearchHome',
|
|
632
|
-
name: 'globalSearch'
|
|
633
|
-
}
|
|
634
|
-
```
|
|
635
|
-
|
|
636
|
-
#### 步骤2:更新路由配置
|
|
637
|
-
|
|
638
|
-
```typescript
|
|
639
|
-
// 旧代码:搜索结果页路由
|
|
640
|
-
'/neo/neoGlobalSearch'
|
|
641
|
-
|
|
642
|
-
// 新代码:全部内容搜索结果页路由
|
|
643
|
-
'/neo/neoGlobalSearchContent'
|
|
644
|
-
|
|
645
|
-
// 新代码:单实体列表搜索结果页路由
|
|
646
|
-
'/neo/neoGlobalSearchList'
|
|
647
|
-
```
|
|
648
|
-
|
|
649
|
-
#### 步骤3:更新参数传递
|
|
650
|
-
|
|
651
|
-
```typescript
|
|
652
|
-
// 旧代码:跳转时传递的参数
|
|
653
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearch', {
|
|
654
|
-
searchKey: val,
|
|
655
|
-
searchEntity: this.state.currentEntity,
|
|
656
|
-
isSingleEntitySearch: this.state.isSingleEntitySearch,
|
|
657
|
-
entityList: this.state.entityList
|
|
658
|
-
})
|
|
659
|
-
|
|
660
|
-
// 新代码:全部内容搜索
|
|
661
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearchContent', null, {
|
|
662
|
-
searchKey: val,
|
|
663
|
-
objectList: this.state.objectList
|
|
664
|
-
})
|
|
665
|
-
|
|
666
|
-
// 新代码:单实体搜索
|
|
667
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearchList', null, {
|
|
668
|
-
objectApiKey: item.xobjectApikey,
|
|
669
|
-
searchKey: val
|
|
670
|
-
})
|
|
671
|
-
```
|
|
672
|
-
|
|
673
|
-
#### 步骤4:处理权限检查
|
|
674
|
-
|
|
675
|
-
```typescript
|
|
676
|
-
// 新组件会自动检查权限,无需额外处理
|
|
677
|
-
// 但需要确保全局搜索权限配置正确
|
|
678
|
-
const globalSearchPermission = getNeoContext('globalSearchPermission')
|
|
679
|
-
```
|
|
680
|
-
|
|
681
|
-
### 7.2 兼容性处理
|
|
682
|
-
|
|
683
|
-
如果需要在同一系统中同时支持新旧组件,可以参考 `GlobalSearchInput` 组件的实现:
|
|
684
|
-
|
|
685
|
-
```typescript
|
|
686
|
-
{
|
|
687
|
-
type: 'neoGlobalSearchInput',
|
|
688
|
-
isNewGlobal: true, // 通过配置项控制使用哪个组件
|
|
689
|
-
// 当 isNewGlobal 为 true 时使用 neoGlobalSearchHome
|
|
690
|
-
// 当 isNewGlobal 为 false 时使用 GlobalSearchHome
|
|
691
|
-
}
|
|
692
|
-
```
|
|
693
|
-
|
|
694
|
-
---
|
|
695
|
-
|
|
696
|
-
## 八、功能对比总结表
|
|
697
|
-
|
|
698
|
-
| 功能特性 | 旧组件(GlobalSearchHome) | 新组件(neoGlobalSearchHome) |
|
|
699
|
-
|---------|---------------------------|-------------------------------|
|
|
700
|
-
| **基础搜索** | ✅ | ✅ |
|
|
701
|
-
| **实体列表展示** | ✅(所有实体) | ✅(常用对象) |
|
|
702
|
-
| **单实体搜索** | ✅(页面内切换) | ✅(路由跳转) |
|
|
703
|
-
| **历史搜索** | ❌ | ✅ |
|
|
704
|
-
| **常用对象设置** | ❌ | ✅ |
|
|
705
|
-
| **权限控制** | ❌ | ✅ |
|
|
706
|
-
| **搜索栏自动聚焦** | ❌ | ✅ |
|
|
707
|
-
| **搜索栏清除按钮** | ❌ | ✅(始终显示) |
|
|
708
|
-
| **输入变化监听** | ❌ | ✅ |
|
|
709
|
-
| **自定义菜单** | ❌ | ✅ |
|
|
710
|
-
| **动态实体支持** | ✅ | ❌ |
|
|
711
|
-
| **数据接口** | `entityListUrl` | `/rest/data/v2.0/global_search/xobjects` |
|
|
712
|
-
| **搜索结果路由** | `/neo/neoGlobalSearch` | `/neo/neoGlobalSearchContent`<br>`/neo/neoGlobalSearchList` |
|
|
713
|
-
| **本地存储** | ❌ | ✅(历史搜索) |
|
|
714
|
-
|
|
715
|
-
---
|
|
716
|
-
|
|
717
|
-
## 九、最佳实践建议
|
|
718
|
-
|
|
719
|
-
### 9.1 何时使用旧组件
|
|
720
|
-
|
|
721
|
-
- 需要支持动态(Feed)实体搜索的场景
|
|
722
|
-
- 简单的搜索入口需求,不需要历史搜索和设置功能
|
|
723
|
-
- 需要与旧版搜索结果页(`/neo/neoGlobalSearch`)兼容的场景
|
|
724
|
-
|
|
725
|
-
### 9.2 何时使用新组件
|
|
726
|
-
|
|
727
|
-
- **推荐使用**:新项目或需要完整搜索功能的场景
|
|
728
|
-
- 需要历史搜索功能提升用户体验
|
|
729
|
-
- 需要用户自定义常用对象
|
|
730
|
-
- 需要权限控制功能
|
|
731
|
-
- 需要更好的搜索体验(自动聚焦、输入监听等)
|
|
732
|
-
|
|
733
|
-
### 9.3 开发建议
|
|
734
|
-
|
|
735
|
-
1. **新项目**:直接使用新组件 `neoGlobalSearchHome`
|
|
736
|
-
2. **旧项目迁移**:按照迁移指南逐步迁移,注意路由和参数的变化
|
|
737
|
-
3. **兼容处理**:如需同时支持,使用配置项控制(如 `isNewGlobal`)
|
|
738
|
-
4. **权限配置**:使用新组件时确保全局搜索权限配置正确
|
|
739
|
-
5. **用户体验**:充分利用新组件的历史搜索和常用对象功能
|
|
740
|
-
|
|
741
|
-
---
|
|
742
|
-
|
|
743
|
-
## 十、相关组件和文件
|
|
744
|
-
|
|
745
|
-
### 10.1 旧组件相关文件
|
|
746
|
-
|
|
747
|
-
- **组件文件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchHome/component.tsx`
|
|
748
|
-
- **接口定义**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchHome/interface.tsx`
|
|
749
|
-
- **注册文件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchHome/index.tsx`
|
|
750
|
-
- **请求工具**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchList/requestUtils.tsx`
|
|
751
|
-
- **搜索结果页**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchResult/`
|
|
752
|
-
|
|
753
|
-
### 10.2 新组件相关文件
|
|
754
|
-
|
|
755
|
-
- **组件文件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/component.tsx`
|
|
756
|
-
- **接口定义**:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/interface.tsx`
|
|
757
|
-
- **注册文件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/index.tsx`
|
|
758
|
-
- **请求工具**:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/requestUtils.tsx`
|
|
759
|
-
- **设置组件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchSetting/`
|
|
760
|
-
- **搜索结果页**:
|
|
761
|
-
- 全部内容:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchContent/`
|
|
762
|
-
- 单实体列表:`packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSingleList/`
|
|
763
|
-
|
|
764
|
-
### 10.3 入口组件
|
|
765
|
-
|
|
766
|
-
- **搜索输入组件**:`packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchInput/component.tsx`
|
|
767
|
-
- 该组件通过 `isNewGlobal` 配置项控制使用新旧组件
|
|
768
|
-
|
|
769
|
-
---
|
|
770
|
-
|
|
771
|
-
## 十一、常见问题
|
|
772
|
-
|
|
773
|
-
### Q1: 新旧组件可以同时使用吗?
|
|
774
|
-
|
|
775
|
-
**A:** 可以。通过配置项控制,如 `GlobalSearchInput` 组件中的 `isNewGlobal` 参数。但需要注意路由和参数格式的差异。
|
|
776
|
-
|
|
777
|
-
### Q2: 如何从旧组件迁移到新组件?
|
|
778
|
-
|
|
779
|
-
**A:** 参考本文档的"迁移指南"章节,主要步骤包括:
|
|
780
|
-
1. 更新组件类型名称
|
|
781
|
-
2. 更新路由配置
|
|
782
|
-
3. 更新参数传递格式
|
|
783
|
-
4. 处理权限配置
|
|
784
|
-
|
|
785
|
-
### Q3: 新组件为什么不支持动态实体?
|
|
786
|
-
|
|
787
|
-
**A:** 新组件的设计理念是专注于业务对象搜索,动态实体的搜索可能在其他模块中单独处理。如需支持动态,可以考虑扩展新组件或使用旧组件。
|
|
788
|
-
|
|
789
|
-
### Q4: 历史搜索记录存储在哪里?
|
|
790
|
-
|
|
791
|
-
**A:** 使用 `offlineStorageService` 存储在本地数据库中,存储键名格式为:`global_search_history__{userId}__{tenantId}`,按用户和租户隔离。
|
|
792
|
-
|
|
793
|
-
### Q5: 常用对象设置如何生效?
|
|
794
|
-
|
|
795
|
-
**A:** 用户在设置页面配置常用对象后,配置会保存到后端。组件重新加载时会调用 `getObjectList` 接口获取最新的配置,其中 `commonXObject` 字段标识是否为常用对象。
|
|
796
|
-
|
|
797
|
-
---
|
|
798
|
-
|
|
799
|
-
## 十二、版本信息
|
|
800
|
-
|
|
801
|
-
- **文档创建时间**:2024年
|
|
802
|
-
- **组件版本**:
|
|
803
|
-
- 旧组件:基础版本
|
|
804
|
-
- 新组件:增强版本(支持历史搜索、设置、权限控制)
|
|
805
|
-
- **适用平台**:H5端(`neo-ui-component-h5`)
|
|
806
|
-
|
|
807
|
-
---
|
|
808
|
-
|
|
809
|
-
## 附录:代码片段参考
|
|
810
|
-
|
|
811
|
-
### A.1 旧组件核心代码片段
|
|
812
|
-
|
|
813
|
-
```typescript:packages/neo-ui-component-h5/src/components/List/GlobalSearchList/neoGlobalSearchHome/component.tsx
|
|
814
|
-
// 搜索提交处理
|
|
815
|
-
onSubmit: (val) => {
|
|
816
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearch', {
|
|
817
|
-
searchKey: val,
|
|
818
|
-
searchEntity: this.state.currentEntity,
|
|
819
|
-
isSingleEntitySearch: this.state.isSingleEntitySearch,
|
|
820
|
-
entityList: this.state.entityList
|
|
821
|
-
})
|
|
822
|
-
}
|
|
823
|
-
|
|
824
|
-
// 单实体搜索切换
|
|
825
|
-
gotoSingleEntitySearch = (item) => {
|
|
826
|
-
this.setState({ isSingleEntitySearch: true, currentEntity: item })
|
|
827
|
-
}
|
|
828
|
-
```
|
|
829
|
-
|
|
830
|
-
### A.2 新组件核心代码片段
|
|
831
|
-
|
|
832
|
-
```typescript:packages/neo-ui-component-h5/src/components/List/GlobalSearch/neoGlobalSearchHome/component.tsx
|
|
833
|
-
// 搜索提交处理(保存历史 + 跳转)
|
|
834
|
-
onSubmit: (val) => {
|
|
835
|
-
this.setHistorySearchValueDb(val)
|
|
836
|
-
this.gotoAllContentPage()
|
|
837
|
-
}
|
|
838
|
-
|
|
839
|
-
// 单实体搜索跳转
|
|
840
|
-
gotoSingleEntityList = (item: GlobalSearchXobjectProps) => {
|
|
841
|
-
const { searchKey } = this.state
|
|
842
|
-
NeoNavigator.openPageWithURL('/neo/neoGlobalSearchList', null, {
|
|
843
|
-
objectApiKey: item.xobjectApikey,
|
|
844
|
-
searchKey
|
|
845
|
-
})
|
|
846
|
-
}
|
|
847
|
-
|
|
848
|
-
// 历史搜索保存
|
|
849
|
-
setHistorySearchValueDb = (val?) => {
|
|
850
|
-
const storageKey = `global_search_history__${getNeoContext('currentUser')?.id}__${
|
|
851
|
-
getNeoContext('currentTenant')?.id
|
|
852
|
-
}`
|
|
853
|
-
let { historyArr } = this.state
|
|
854
|
-
if (val) {
|
|
855
|
-
historyArr.unshift(val)
|
|
856
|
-
}
|
|
857
|
-
const result = Array.from(new Set(historyArr))
|
|
858
|
-
const result2 = result.slice(0, this.historySearchCount)
|
|
859
|
-
offlineStorageService.getService().dbSet(storageKey, result2)
|
|
860
|
-
}
|
|
861
|
-
```
|
|
862
|
-
|
|
863
|
-
---
|
|
864
|
-
|
|
865
|
-
**文档结束**
|
|
866
|
-
|