@zat-design/sisyphus-react 3.13.19-beta.12 → 3.13.19-beta.13
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 +207 -77
- package/es/ProEnum/index.js +12 -22
- package/lib/ProEnum/index.js +11 -21
- package/package.json +1 -1
package/README.md
CHANGED
@@ -1,70 +1,205 @@
|
|
1
|
-
|
1
|
+
# 西西弗 (Sisyphus) React 组件库项目指导
|
2
2
|
|
3
|
-
##
|
3
|
+
## 项目概述
|
4
4
|
|
5
|
-
|
5
|
+
**西西弗 (Sisyphus) React 组件库** 是一个基于 Ant Design 4.x 的企业级 React UI 组件库,专为业务系统快速开发而设计。项目名称源自希腊神话中的西西弗斯,象征着持续不断的努力和迭代优化。
|
6
6
|
|
7
|
-
|
7
|
+
- **项目名称**: @zat-design/sisyphus-react
|
8
|
+
- **官方文档**: https://procomponents.zhongan.tech
|
9
|
+
- **许可证**: MIT
|
8
10
|
|
9
|
-
|
11
|
+
## 技术栈架构
|
10
12
|
|
11
|
-
|
12
|
-
|
13
|
-
|
13
|
+
### 核心技术栈
|
14
|
+
- **前端框架**: React 17/18
|
15
|
+
- **UI 基础库**: Ant Design 4.24.16
|
16
|
+
- **开发语言**: TypeScript 4.9.5
|
17
|
+
- **构建工具**: Father Build + Dumi
|
18
|
+
- **测试框架**: Jest + React Testing Library
|
19
|
+
- **样式方案**: Less + CSS Modules
|
14
20
|
|
15
|
-
|
16
|
-
|
17
|
-
|
21
|
+
### 开发工具链
|
22
|
+
- **文档生成**: Dumi 1.x
|
23
|
+
- **代码规范**: ESLint + Prettier + Stylelint
|
24
|
+
- **提交规范**: Husky + Commitlint
|
25
|
+
- **包管理**: npm/yarn
|
26
|
+
- **CI/CD**: GitHub Actions
|
18
27
|
|
19
|
-
###
|
28
|
+
### 关键依赖
|
29
|
+
- **状态管理**: React Hooks (ahooks 3.8.4)
|
30
|
+
- **拖拽排序**: @dnd-kit 系列
|
31
|
+
- **工具库**: lodash, moment, big.js
|
32
|
+
- **图标**: @ant-design/icons
|
33
|
+
- **水印**: @pansy/react-watermark
|
20
34
|
|
21
|
-
|
35
|
+
## 项目架构
|
22
36
|
|
37
|
+
### 目录结构
|
23
38
|
```
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
39
|
+
xk-sisyphus-web/
|
40
|
+
├── src/ # 源代码目录
|
41
|
+
│ ├── ProForm/ # 表单组件
|
42
|
+
│ ├── ProTable/ # 表格组件
|
43
|
+
│ ├── ProLayout/ # 布局组件
|
44
|
+
│ ├── ProSelect/ # 选择器组件
|
45
|
+
│ ├── ProEnum/ # 枚举组件
|
46
|
+
│ ├── ProUpload/ # 上传组件
|
47
|
+
│ ├── ProDrawerForm/ # 抽屉表单
|
48
|
+
│ ├── ProEditTable/ # 可编辑表格
|
49
|
+
│ ├── ProIcon/ # 图标组件
|
50
|
+
│ ├── ProWaterMark/ # 水印组件
|
51
|
+
│ ├── ProThemeTools/ # 主题工具
|
52
|
+
│ ├── locale/ # 国际化文件
|
53
|
+
│ ├── utils/ # 工具函数
|
54
|
+
│ └── index.ts # 主入口文件
|
55
|
+
├── docs/ # 文档目录
|
56
|
+
│ ├── 组件/ # 组件文档
|
57
|
+
│ ├── 文档/ # 使用文档
|
58
|
+
│ ├── 官方模板/ # 模板示例
|
59
|
+
│ ├── 登录组件/ # 登录组件文档
|
60
|
+
│ ├── 通用函数/ # 工具函数文档
|
61
|
+
│ └── 更新日志/ # 版本更新记录
|
62
|
+
├── tests/ # 测试文件
|
63
|
+
├── lib/ # ES5 构建输出
|
64
|
+
├── es/ # ES6 构建输出
|
65
|
+
└── dist/ # UMD 构建输出
|
33
66
|
```
|
34
67
|
|
35
|
-
|
36
|
-
|
68
|
+
### 组件分类
|
69
|
+
|
70
|
+
#### 1. 布局组件
|
71
|
+
- **ProLayout**: 页面布局框架
|
72
|
+
- **ProStep**: 步骤条组件
|
73
|
+
- **ProTabs**: 标签页组件
|
74
|
+
|
75
|
+
#### 2. 数据展示
|
76
|
+
- **ProTable**: 高级表格(支持搜索、分页、排序等)
|
77
|
+
- **ProTooltip**: 文字提示
|
78
|
+
- **ProViewer**: 文件预览器
|
79
|
+
|
80
|
+
#### 3. 数据录入
|
81
|
+
- **ProForm**: 高级表单(配置化表单生成)
|
82
|
+
- **ProEditTable**: 可编辑表格
|
83
|
+
- **ProDrawerForm**: 抽屉表单
|
84
|
+
- **ProEditLabel**: 可编辑标签
|
85
|
+
- **ProSelect**: 高级选择器
|
86
|
+
- **ProEnum**: 枚举选择器
|
87
|
+
- **ProUpload**: 文件上传
|
88
|
+
|
89
|
+
#### 4. 通用组件
|
90
|
+
- **ProIcon**: 图标组件
|
91
|
+
- **ProDownload**: 文件下载
|
92
|
+
- **ProWaterMark**: 水印组件
|
93
|
+
- **ProConfigProvider**: 全局配置
|
94
|
+
- **FormsProvider**: 表单提供者
|
95
|
+
- **ProThemeTools**: 主题定制工具
|
96
|
+
- **ProAction**: 操作按钮组
|
97
|
+
|
98
|
+
## 功能特性
|
99
|
+
|
100
|
+
### 核心特性
|
101
|
+
1. **配置化开发**: 通过 JSON 配置即可生成复杂的表单和表格
|
102
|
+
2. **类型安全**: 完整的 TypeScript 类型定义
|
103
|
+
3. **主题定制**: 支持动态主题切换和自定义主题
|
104
|
+
4. **国际化**: 支持中英文双语
|
105
|
+
5. **按需加载**: 支持 babel-plugin-import 按需引入
|
106
|
+
6. **响应式设计**: 适配不同屏幕尺寸
|
107
|
+
|
108
|
+
### 高级功能
|
109
|
+
1. **ProEnum**: 支持频繁枚举请求优化,提供缓存机制
|
110
|
+
2. **ProTable**: 内置搜索、分页、排序、导出等功能
|
111
|
+
3. **ProForm**: 支持动态表单项、联动校验、自定义组件
|
112
|
+
4. **ProEditTable**: 支持行内编辑、批量操作
|
113
|
+
5. **ProThemeTools**: 可视化主题编辑器
|
114
|
+
6. **ProWaterMark**: 自定义水印保护
|
115
|
+
|
116
|
+
## 构建配置
|
117
|
+
|
118
|
+
### 构建输出
|
119
|
+
- **lib/**: ES5 + CommonJS 格式,用于服务端渲染和旧版本兼容
|
120
|
+
- **es/**: ES6 + ES Modules 格式,用于现代构建工具的 tree-shaking
|
121
|
+
- **dist/**: UMD 格式,用于直接在浏览器中引用
|
122
|
+
|
123
|
+
### 构建脚本
|
124
|
+
```bash
|
125
|
+
# 完整构建
|
126
|
+
npm run build
|
127
|
+
|
128
|
+
# 分别构建
|
129
|
+
npm run build-lib # ES5 + CJS
|
130
|
+
npm run build-es # ES6 + ESM
|
131
|
+
npm run build-dist # UMD
|
132
|
+
|
133
|
+
# 开发调试
|
134
|
+
npm start # 启动文档开发服务器
|
135
|
+
|
136
|
+
# 代码检查
|
137
|
+
npm run lint # 运行所有检查
|
138
|
+
npm run tsc # TypeScript 类型检查
|
37
139
|
```
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
140
|
+
|
141
|
+
### 测试配置
|
142
|
+
- **测试框架**: Jest + @testing-library/react
|
143
|
+
- **覆盖率要求**: 80% (branches, functions, lines, statements)
|
144
|
+
- **测试环境**: jsdom
|
145
|
+
- **Mock 配置**: 样式文件、图片资源、外部依赖
|
146
|
+
|
147
|
+
## 开发规范
|
148
|
+
|
149
|
+
### 代码规范
|
150
|
+
- **ESLint**: 基于 za/typescript-react 规范
|
151
|
+
- **Prettier**: 统一代码格式化
|
152
|
+
- **Stylelint**: Less/CSS 代码规范
|
153
|
+
- **Commitlint**: 提交信息规范 (Conventional Commits)
|
154
|
+
|
155
|
+
### 组件开发规范
|
156
|
+
1. **目录结构**: 每个组件独立目录,包含 index.tsx、propsType.ts、demos/、__tests__/
|
157
|
+
2. **类型定义**: 完整的 TypeScript 接口定义
|
158
|
+
3. **文档编写**: 使用 Dumi 编写组件文档和示例
|
159
|
+
4. **测试覆盖**: 每个组件需要单元测试
|
160
|
+
5. **样式隔离**: 使用 Less 模块化开发
|
161
|
+
|
162
|
+
### 版本发布
|
163
|
+
```bash
|
164
|
+
# Beta 版本发布
|
165
|
+
npm run release:beta
|
166
|
+
|
167
|
+
# 正式版本发布
|
168
|
+
npm run release
|
169
|
+
|
170
|
+
# 内网发布
|
171
|
+
npm publish --registry https://npm.zhonganinfo.com
|
58
172
|
```
|
59
173
|
|
60
|
-
|
174
|
+
## 浏览器兼容性
|
175
|
+
- **现代浏览器**: Chrome, Firefox, Safari, Edge (最新两个版本)
|
61
176
|
|
62
|
-
|
177
|
+
## 业务集成
|
63
178
|
|
179
|
+
### 安装使用
|
180
|
+
```bash
|
181
|
+
npm install @zat-design/sisyphus-react --save
|
64
182
|
```
|
183
|
+
|
184
|
+
### 按需加载配置
|
185
|
+
```javascript
|
186
|
+
// babel.config.js
|
187
|
+
[
|
188
|
+
'babel-plugin-import',
|
189
|
+
{
|
190
|
+
libraryName: '@zat-design/sisyphus-react',
|
191
|
+
camel2DashComponentName: false,
|
192
|
+
libraryDirectory: 'es',
|
193
|
+
style: false,
|
194
|
+
},
|
195
|
+
'@zat-design/sisyphus-react'
|
196
|
+
]
|
197
|
+
```
|
198
|
+
|
199
|
+
### 基础使用
|
200
|
+
```tsx
|
65
201
|
import React from 'react';
|
66
|
-
import {
|
67
|
-
import { ProForm } from '@zat-design/sisyphus-react';
|
202
|
+
import { ProForm, ProTable } from '@zat-design/sisyphus-react';
|
68
203
|
|
69
204
|
const App = () => {
|
70
205
|
return (
|
@@ -75,43 +210,38 @@ const App = () => {
|
|
75
210
|
label: '姓名',
|
76
211
|
name: 'name',
|
77
212
|
rules: [{ required: true, message: '请输入姓名!' }],
|
78
|
-
}
|
213
|
+
}
|
214
|
+
]}
|
79
215
|
/>
|
80
216
|
);
|
81
217
|
};
|
82
|
-
|
83
|
-
render(<App />, document.getElementById('root'));
|
84
218
|
```
|
85
219
|
|
86
|
-
|
87
|
-
|
88
|
-
### 组件库打包发布
|
89
|
-
|
90
|
-
1. build:types 生成类型文件
|
91
|
-
2. build:es 生产 es6 代码文件 module 指向该文件
|
92
|
-
3. build:lib 生产 es5 代码文件 main 指向该文件
|
93
|
-
4. release: "yarn build:types & yarn build:es && yarn build:lib && npm publish" 打包 3 个文件进行发布
|
94
|
-
5. 执行 yarn build 成功
|
95
|
-
6. 执行 yarn release
|
96
|
-
|
97
|
-
### 发布
|
98
|
-
|
99
|
-
npm publish --registry https://registry.npmjs.org --access=public
|
100
|
-
|
101
|
-
### 发布内网库
|
220
|
+
## 扩展和定制
|
102
221
|
|
103
|
-
|
222
|
+
### 主题定制
|
223
|
+
通过 ProThemeTools 组件或 Less 变量覆盖实现主题定制:
|
224
|
+
```less
|
225
|
+
@ant-prefix: ant;
|
226
|
+
@border-radius-base: 4px;
|
104
227
|
```
|
105
|
-
"publishConfig": {
|
106
|
-
"registry": "https://npm.zhonganinfo.com"
|
107
|
-
},
|
108
|
-
```
|
109
|
-
2. 之后使用 `npm publish` 发布, 如果提示登录使用域账号登录
|
110
228
|
|
229
|
+
### 组件扩展
|
230
|
+
如果现有组件无法满足业务需求,可以:
|
231
|
+
1. 联系组件库维护团队进行功能扩展
|
232
|
+
2. 基于现有组件进行二次封装
|
233
|
+
3. 复制源码进行本地化修改
|
111
234
|
|
112
|
-
|
235
|
+
## 维护和支持
|
113
236
|
|
114
|
-
|
115
|
-
|
116
|
-
|
237
|
+
### 开发团队
|
238
|
+
- 基于中安科技内部需求开发
|
239
|
+
- 遵循企业级组件库最佳实践
|
240
|
+
- 持续迭代优化,保持技术先进性
|
241
|
+
|
242
|
+
### 技术支持
|
243
|
+
- 官方文档:完整的 API 文档和使用示例
|
244
|
+
- 在线预览:实时查看组件效果和代码
|
245
|
+
- 版本管理:详细的更新日志和迁移指南
|
117
246
|
|
247
|
+
这个组件库为企业级 React 应用提供了完整的 UI 组件解决方案,通过配置化的方式大大提升了开发效率,同时保持了良好的可维护性和扩展性。
|
package/es/ProEnum/index.js
CHANGED
@@ -10,7 +10,7 @@ import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
|
|
10
10
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
11
11
|
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
12
12
|
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps", "isView"],
|
13
|
-
_excluded2 = ["fieldNames", "clear", "
|
13
|
+
_excluded2 = ["fieldNames", "clear", "cacheKey", "showCodeName"];
|
14
14
|
import { useDeepCompareEffect, useRequest as useRequestFunc } from 'ahooks';
|
15
15
|
import React, { useState, useEffect, useMemo } from 'react';
|
16
16
|
import { cloneDeep, isFunction, isString, isArray, omit, isNumber } from 'lodash';
|
@@ -19,7 +19,7 @@ import { useProConfig } from "../ProConfigProvider";
|
|
19
19
|
import ProEnumTag from "./components/Tag";
|
20
20
|
import ProEnumGroup from "./components/Group";
|
21
21
|
import Container from "../ProForm/components/Container";
|
22
|
-
import { isObject
|
22
|
+
import { isObject } from "./utils";
|
23
23
|
import getEnumLabel from "./utils/getEnumLabel";
|
24
24
|
import useEnum from "./hooks/useEnum";
|
25
25
|
import locale from "../locale";
|
@@ -50,19 +50,10 @@ var ProEnum = props => {
|
|
50
50
|
fieldNames = _ref2.fieldNames,
|
51
51
|
_ref2$clear = _ref2.clear,
|
52
52
|
clear = _ref2$clear === void 0 ? true : _ref2$clear,
|
53
|
-
_ref2$storage = _ref2.storage,
|
54
|
-
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage,
|
55
53
|
_ref2$cacheKey = _ref2.cacheKey,
|
56
54
|
cacheKey = _ref2$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref2$cacheKey,
|
57
55
|
showCodeName = _ref2.showCodeName,
|
58
|
-
configUseRequest = _ref2.useRequest,
|
59
|
-
configTransformResponse = _ref2.transformResponse,
|
60
56
|
resProps = _objectWithoutProperties(_ref2, _excluded2);
|
61
|
-
|
62
|
-
// 优先使用props中的配置,如果没有则使用全局配置
|
63
|
-
var finalUseRequest = useRequest || configUseRequest;
|
64
|
-
var finalTransformResponse = transformResponse || configTransformResponse;
|
65
|
-
var cacheData = getEnumData(storage, cacheKey);
|
66
57
|
var _isView = isView !== undefined && isView !== null ? isView : (_otherProps$isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView) !== null && _otherProps$isView !== void 0 ? _otherProps$isView : configIsView;
|
67
58
|
enumProps.showCodeName = (_enumProps$showCodeNa = enumProps.showCodeName) !== null && _enumProps$showCodeNa !== void 0 ? _enumProps$showCodeNa : showCodeName;
|
68
59
|
var label = 'label';
|
@@ -89,7 +80,7 @@ var ProEnum = props => {
|
|
89
80
|
}
|
90
81
|
|
91
82
|
// 这种时候优先级最高、完全走自定义
|
92
|
-
if (
|
83
|
+
if (useRequest !== null && useRequest !== void 0 && useRequest.service && props.fieldNames) {
|
93
84
|
var _props$fieldNames5, _props$fieldNames6;
|
94
85
|
if ((_props$fieldNames5 = props.fieldNames) !== null && _props$fieldNames5 !== void 0 && _props$fieldNames5.label) label = props.fieldNames.label;
|
95
86
|
if ((_props$fieldNames6 = props.fieldNames) !== null && _props$fieldNames6 !== void 0 && _props$fieldNames6.value) fieldValue = props.fieldNames.value;
|
@@ -97,13 +88,13 @@ var ProEnum = props => {
|
|
97
88
|
var _useProConfig = useProConfig('ProEnum'),
|
98
89
|
_useProConfig$dics = _useProConfig.dics,
|
99
90
|
dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
|
100
|
-
var _useRequestFunc = useRequestFunc(
|
91
|
+
var _useRequestFunc = useRequestFunc(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, _objectSpread(_objectSpread({
|
101
92
|
manual: true,
|
102
93
|
cacheTime: -1
|
103
|
-
},
|
94
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
104
95
|
onSuccess: res => {
|
105
|
-
if (
|
106
|
-
var responseData =
|
96
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
97
|
+
var responseData = transformResponse(res);
|
107
98
|
if (typeof responseData !== 'object') {
|
108
99
|
var _locale$ProEnum;
|
109
100
|
return _message.error((_locale$ProEnum = locale.ProEnum) === null || _locale$ProEnum === void 0 ? void 0 : _locale$ProEnum.errorMessage);
|
@@ -135,14 +126,13 @@ var ProEnum = props => {
|
|
135
126
|
|
136
127
|
// 自定义请求
|
137
128
|
useDeepCompareEffect(() => {
|
138
|
-
var _ref3 = (
|
129
|
+
var _ref3 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
139
130
|
defaultParams = _ref3.defaultParams;
|
140
131
|
var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
141
|
-
|
142
|
-
if (finalUseRequest !== null && finalUseRequest !== void 0 && finalUseRequest.service && (!Object.keys(cacheData).length || cacheData !== null && cacheData !== void 0 && cacheData.data && !Object.keys(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data).length)) {
|
132
|
+
if (useRequest !== null && useRequest !== void 0 && useRequest.service) {
|
143
133
|
run(params);
|
144
134
|
}
|
145
|
-
}, [
|
135
|
+
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
|
146
136
|
var enumLists = useMemo(() => {
|
147
137
|
var lists = [];
|
148
138
|
if (isString(code)) {
|
@@ -161,8 +151,8 @@ var ProEnum = props => {
|
|
161
151
|
// 优先使用组件内部自己传入的数据源或者请求得到的数据
|
162
152
|
list = cloneDeep(dataList && dataList.length ? dataList : enumLists);
|
163
153
|
// 对数据进行一系列的过滤等操作
|
164
|
-
if (!(
|
165
|
-
list =
|
154
|
+
if (!(useRequest !== null && useRequest !== void 0 && useRequest.service) && transformResponse) {
|
155
|
+
list = transformResponse(list);
|
166
156
|
if (!Array.isArray(list)) {
|
167
157
|
var _locale$ProEnum3;
|
168
158
|
console.error((_locale$ProEnum3 = locale.ProEnum) === null || _locale$ProEnum3 === void 0 ? void 0 : _locale$ProEnum3.errorArrayMessage);
|
package/lib/ProEnum/index.js
CHANGED
@@ -33,7 +33,7 @@ require("./style/index.less");
|
|
33
33
|
var _useFieldProps2 = require("../ProForm/utils/useFieldProps");
|
34
34
|
var _jsxRuntime = require("react/jsx-runtime");
|
35
35
|
var _excluded = ["code", "type", "dataSource", "useRequest", "value", "component", "onChange", "transformResponse", "otherProps", "isView"],
|
36
|
-
_excluded2 = ["fieldNames", "clear", "
|
36
|
+
_excluded2 = ["fieldNames", "clear", "cacheKey", "showCodeName"];
|
37
37
|
var ProEnum = props => {
|
38
38
|
var _otherProps$isView, _enumProps$showCodeNa;
|
39
39
|
var code = props.code,
|
@@ -57,19 +57,10 @@ var ProEnum = props => {
|
|
57
57
|
fieldNames = _ref2.fieldNames,
|
58
58
|
_ref2$clear = _ref2.clear,
|
59
59
|
clear = _ref2$clear === void 0 ? true : _ref2$clear,
|
60
|
-
_ref2$storage = _ref2.storage,
|
61
|
-
storage = _ref2$storage === void 0 ? 'localStorage' : _ref2$storage,
|
62
60
|
_ref2$cacheKey = _ref2.cacheKey,
|
63
61
|
cacheKey = _ref2$cacheKey === void 0 ? 'zat-design-pro-component-cacheKey' : _ref2$cacheKey,
|
64
62
|
showCodeName = _ref2.showCodeName,
|
65
|
-
configUseRequest = _ref2.useRequest,
|
66
|
-
configTransformResponse = _ref2.transformResponse,
|
67
63
|
resProps = (0, _objectWithoutProperties2.default)(_ref2, _excluded2);
|
68
|
-
|
69
|
-
// 优先使用props中的配置,如果没有则使用全局配置
|
70
|
-
var finalUseRequest = useRequest || configUseRequest;
|
71
|
-
var finalTransformResponse = transformResponse || configTransformResponse;
|
72
|
-
var cacheData = (0, _utils.getEnumData)(storage, cacheKey);
|
73
64
|
var _isView = isView !== undefined && isView !== null ? isView : (_otherProps$isView = otherProps === null || otherProps === void 0 ? void 0 : otherProps.isView) !== null && _otherProps$isView !== void 0 ? _otherProps$isView : configIsView;
|
74
65
|
enumProps.showCodeName = (_enumProps$showCodeNa = enumProps.showCodeName) !== null && _enumProps$showCodeNa !== void 0 ? _enumProps$showCodeNa : showCodeName;
|
75
66
|
var label = 'label';
|
@@ -96,7 +87,7 @@ var ProEnum = props => {
|
|
96
87
|
}
|
97
88
|
|
98
89
|
// 这种时候优先级最高、完全走自定义
|
99
|
-
if (
|
90
|
+
if (useRequest !== null && useRequest !== void 0 && useRequest.service && props.fieldNames) {
|
100
91
|
var _props$fieldNames5, _props$fieldNames6;
|
101
92
|
if ((_props$fieldNames5 = props.fieldNames) !== null && _props$fieldNames5 !== void 0 && _props$fieldNames5.label) label = props.fieldNames.label;
|
102
93
|
if ((_props$fieldNames6 = props.fieldNames) !== null && _props$fieldNames6 !== void 0 && _props$fieldNames6.value) fieldValue = props.fieldNames.value;
|
@@ -104,13 +95,13 @@ var ProEnum = props => {
|
|
104
95
|
var _useProConfig = (0, _ProConfigProvider.useProConfig)('ProEnum'),
|
105
96
|
_useProConfig$dics = _useProConfig.dics,
|
106
97
|
dics = _useProConfig$dics === void 0 ? {} : _useProConfig$dics;
|
107
|
-
var _useRequestFunc = (0, _ahooks.useRequest)(
|
98
|
+
var _useRequestFunc = (0, _ahooks.useRequest)(useRequest === null || useRequest === void 0 ? void 0 : useRequest.service, (0, _objectSpread2.default)((0, _objectSpread2.default)({
|
108
99
|
manual: true,
|
109
100
|
cacheTime: -1
|
110
|
-
},
|
101
|
+
}, useRequest === null || useRequest === void 0 ? void 0 : useRequest.options), {}, {
|
111
102
|
onSuccess: res => {
|
112
|
-
if (
|
113
|
-
var responseData =
|
103
|
+
if (transformResponse && typeof transformResponse === 'function') {
|
104
|
+
var responseData = transformResponse(res);
|
114
105
|
if (typeof responseData !== 'object') {
|
115
106
|
var _locale$ProEnum;
|
116
107
|
return _message2.default.error((_locale$ProEnum = _locale.default.ProEnum) === null || _locale$ProEnum === void 0 ? void 0 : _locale$ProEnum.errorMessage);
|
@@ -142,14 +133,13 @@ var ProEnum = props => {
|
|
142
133
|
|
143
134
|
// 自定义请求
|
144
135
|
(0, _ahooks.useDeepCompareEffect)(() => {
|
145
|
-
var _ref3 = (
|
136
|
+
var _ref3 = (useRequest === null || useRequest === void 0 ? void 0 : useRequest.options) || {},
|
146
137
|
defaultParams = _ref3.defaultParams;
|
147
138
|
var params = Array.isArray(defaultParams) ? defaultParams === null || defaultParams === void 0 ? void 0 : defaultParams[0] : defaultParams || {};
|
148
|
-
|
149
|
-
if (finalUseRequest !== null && finalUseRequest !== void 0 && finalUseRequest.service && (!Object.keys(cacheData).length || cacheData !== null && cacheData !== void 0 && cacheData.data && !Object.keys(cacheData === null || cacheData === void 0 ? void 0 : cacheData.data).length)) {
|
139
|
+
if (useRequest !== null && useRequest !== void 0 && useRequest.service) {
|
150
140
|
run(params);
|
151
141
|
}
|
152
|
-
}, [
|
142
|
+
}, [useRequest === null || useRequest === void 0 ? void 0 : useRequest.options]);
|
153
143
|
var enumLists = (0, _react.useMemo)(() => {
|
154
144
|
var lists = [];
|
155
145
|
if ((0, _lodash.isString)(code)) {
|
@@ -168,8 +158,8 @@ var ProEnum = props => {
|
|
168
158
|
// 优先使用组件内部自己传入的数据源或者请求得到的数据
|
169
159
|
list = (0, _lodash.cloneDeep)(dataList && dataList.length ? dataList : enumLists);
|
170
160
|
// 对数据进行一系列的过滤等操作
|
171
|
-
if (!(
|
172
|
-
list =
|
161
|
+
if (!(useRequest !== null && useRequest !== void 0 && useRequest.service) && transformResponse) {
|
162
|
+
list = transformResponse(list);
|
173
163
|
if (!Array.isArray(list)) {
|
174
164
|
var _locale$ProEnum3;
|
175
165
|
console.error((_locale$ProEnum3 = _locale.default.ProEnum) === null || _locale$ProEnum3 === void 0 ? void 0 : _locale$ProEnum3.errorArrayMessage);
|