xydata-tools 1.0.41 → 1.0.43
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 +50 -256
- package/dist/assets/defaultAddPicBg.png +0 -0
- package/dist/assets/loading.png +0 -0
- package/dist/assets/uploadVideoBg.png +0 -0
- package/dist/assets/videoPlay.png +0 -0
- package/dist/components/uni-app/FilePicker.vue +697 -0
- package/dist/components/uni-app/PicPicker.vue +498 -0
- package/dist/components/uni-app/VideoPicker.vue +508 -0
- package/dist/types/uniapp.d.ts +1 -0
- package/dist/uniapp.js +21 -0
- package/package.json +12 -3
package/README.md
CHANGED
|
@@ -1,278 +1,61 @@
|
|
|
1
1
|
# 鑫义科技前端开发者工具包
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
内网文档:[http://172.16.1.254:8090/display/UX/xydata-tools](http://172.16.1.254:8090/display/UX/xydata-tools)
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
# xydata-tools 文档索引
|
|
6
|
+
|
|
6
7
|
|
|
7
|
-
|
|
8
|
-
- `sso` 模版(没有独立的登录页面,支持统一登陆):SecurityLayout、系统管理
|
|
9
|
-
- `both` 模版(有独立的登录页面,支持统一登陆): SecurityLayout、一般配合 `sso` 模板的系统管理使用
|
|
10
|
-
- 数据字典页面
|
|
11
|
-
- 组织机构页面
|
|
12
|
-
- 附件上传组件
|
|
13
|
-
- 附件下载组件
|
|
8
|
+
#### Web 端组件
|
|
14
9
|
|
|
15
|
-
|
|
10
|
+
- [附件上传组件](./docs/组件使用文档/附件上传组件.md)
|
|
16
11
|
|
|
17
|
-
|
|
12
|
+
- 支持图片、文件上传
|
|
13
|
+
- 内置文件大小、格式校验
|
|
14
|
+
- 支持预览功能
|
|
18
15
|
|
|
19
|
-
|
|
16
|
+
- [附件下载组件](./docs/组件使用文档/附件下载组件.md)
|
|
20
17
|
|
|
21
|
-
|
|
18
|
+
- 支持链接和流式文件下载
|
|
19
|
+
- 兼容原生按钮功能
|
|
22
20
|
|
|
23
|
-
|
|
24
|
-
import { registerService } from "xydata-tools";
|
|
21
|
+
- [数据字典组件](./docs/组件使用文档/数据字典.md)
|
|
25
22
|
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
- 完整的数据字典管理功能
|
|
24
|
+
- 支持分类管理
|
|
28
25
|
|
|
29
|
-
|
|
26
|
+
- [组织机构组件](./docs/组件使用文档/组织机构.md)
|
|
30
27
|
|
|
31
|
-
|
|
28
|
+
- 树形结构展示
|
|
29
|
+
- 人员管理功能
|
|
32
30
|
|
|
33
|
-
|
|
34
|
-
import React from "react";
|
|
35
|
-
import { DictionaryFront } from "xydata-tools";
|
|
31
|
+
#### uni-app 组件
|
|
36
32
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
33
|
+
- [PicPicker - 图片选择器](./docs/uniapp/PicPicker.md)
|
|
34
|
+
- [VideoPicker - 视频选择器](./docs/uniapp/VideoPicker.md)
|
|
35
|
+
- [FilePicker - 文件选择器](./docs/uniapp/FilePicker.md)
|
|
40
36
|
|
|
41
|
-
|
|
42
|
-
```
|
|
37
|
+
### 模版使用文档
|
|
43
38
|
|
|
44
|
-
|
|
39
|
+
- [AAA 模版](./docs/模版使用文档/AAA模版.md)
|
|
45
40
|
|
|
46
|
-
|
|
41
|
+
- 适用场景:有独立登录页面,不支持统一登录
|
|
42
|
+
- 包含:SecurityLayout、系统管理模块
|
|
47
43
|
|
|
48
|
-
|
|
49
|
-
import React from "react";
|
|
50
|
-
import { OrganizationFront } from "xydata-tools";
|
|
44
|
+
- [SSO 模版](./docs/模版使用文档/SSO模版.md)
|
|
51
45
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
};
|
|
46
|
+
- 适用场景:没有独立登录页面,支持统一登录
|
|
47
|
+
- 包含:SecurityLayout、系统管理模块
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
```
|
|
49
|
+
- [Both 模版](./docs/模版使用文档/Both模版.md)
|
|
58
50
|
|
|
59
|
-
|
|
51
|
+
- 适用场景:同时支持独立登录和统一登录
|
|
52
|
+
- 包含:SecurityLayout
|
|
60
53
|
|
|
61
|
-
### 附件上传组件
|
|
62
|
-
|
|
63
|
-
基于 `ProformUploadButton` 二次封装的上传组件,支持以下功能:
|
|
64
|
-
|
|
65
|
-
1. 支持单独使用或在表单内使用。
|
|
66
|
-
2. 支持上传图片、文件,可根据 `listType` 进行多种上传风格切换。
|
|
67
|
-
3. 内置文件大小、格式校验。
|
|
68
|
-
4. 内置常用请求头参数。
|
|
69
|
-
5. 内置图片预览功能(`listType` 为 `"picture"` 或 `"picture-card"` 时可用)。
|
|
70
|
-
6. 兼容所有原生组件功能。
|
|
71
|
-
|
|
72
|
-
#### 示例代码
|
|
73
|
-
|
|
74
|
-
```javascript
|
|
75
|
-
import React from "react";
|
|
76
|
-
import { UploadFile } from "xydata-tools";
|
|
77
|
-
import { Form } from "antd";
|
|
78
|
-
|
|
79
|
-
const Demo = () => {
|
|
80
|
-
const [form] = Form.useForm();
|
|
81
|
-
|
|
82
|
-
// 单独使用
|
|
83
|
-
<UploadFile
|
|
84
|
-
title="导入模板"
|
|
85
|
-
listType="text"
|
|
86
|
-
accept=".xlsx,.xls"
|
|
87
|
-
icon={<ImportOutlined />}
|
|
88
|
-
buttonOptions={{ type: "primary" }}
|
|
89
|
-
showUploadList={false}
|
|
90
|
-
onChange={({ fileList }) => {
|
|
91
|
-
// 通过监听状态为done获取最终的上传结果
|
|
92
|
-
if (fileList.every((item) => item.status === "done")) {
|
|
93
|
-
console.log(fileList );
|
|
94
|
-
}
|
|
95
|
-
}}
|
|
96
|
-
checkFile={{
|
|
97
|
-
suffixs: ["xlsx", "xls"],
|
|
98
|
-
maxSize: 1024,
|
|
99
|
-
}}
|
|
100
|
-
multiple={true}
|
|
101
|
-
/>;
|
|
102
|
-
|
|
103
|
-
// 在表单内使用
|
|
104
|
-
<Form form={form}>
|
|
105
|
-
<UploadFile form={form} name="file" label="图片上传" listType="picture-card" />
|
|
106
|
-
</Form>
|
|
107
|
-
|
|
108
|
-
// 在 FormList 内使用
|
|
109
|
-
<ProFormList {...yourProps}>
|
|
110
|
-
{(field) => {
|
|
111
|
-
return <UploadFile key={field.key} name={[field.name, "cover"]} />;
|
|
112
|
-
}}
|
|
113
|
-
</ProFormList>;
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export default Demo;
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
#### 参数说明
|
|
120
|
-
|
|
121
|
-
| 参数名 | 类型 | 描述 | 默认值 |
|
|
122
|
-
| ----------------- | -------------------- | ----------------------------------------------------------------------------------- | ------------------------------------------------- |
|
|
123
|
-
| `form` | `Antd.Form.Instance` | 表单实例 | 无 |
|
|
124
|
-
| `label` | `string` | 表单标签 | 无 |
|
|
125
|
-
| `name` | `string` | 表单字段 | 无 |
|
|
126
|
-
| `rules` | `Array[Object]` | 表单校验规则 | 无 |
|
|
127
|
-
| `accept` | `string` | 接受上传的文件类型 | 无 |
|
|
128
|
-
| `action` | `string` | 上传的地址 | `/api/${注册的服务}/file/upload/v3?type=openFile` |
|
|
129
|
-
| `max` | `string` | 最大上传数量,超过最大数量就会隐藏上传按钮 | 无 |
|
|
130
|
-
| `multiple` | `boolean` | 是否支持多选文件,开启后按住 `Ctrl` 可选择多个文件 | `false` |
|
|
131
|
-
| `icon` | `ReactNode` | `Button` 或 `Dragger` 的图标 | 无 |
|
|
132
|
-
| `title` | `ReactNode` | `Button` 或 `Dragger` 的标题 | 无 |
|
|
133
|
-
| `description` | `ReactNode` | 当 `listType` 为 `dragger` 时的描述 | 无 |
|
|
134
|
-
| `listType` | `string` | 上传列表的内建样式,支持 `text`、`picture`、`picture-card`、`dragger` | `text` |
|
|
135
|
-
| `showUploadList` | `Boolean/Object` | 是否展示文件列表,可设为对象,用于单独设定 `showPreviewIcon` 等配置 | `true` |
|
|
136
|
-
| `readonly` | `boolean` | 是否只读 | `false` |
|
|
137
|
-
| `disabled` | `boolean` | 是否禁用 | `false` |
|
|
138
|
-
| `checkFile` | `Object` | 文件校验配置,包括 `suffixs`(限制的文件格式)和 `maxSize`(文件大小限制,单位 KB) | 无 |
|
|
139
|
-
| `onChange` | `Function` | 上传文件改变时的回调,上传中、完成、失败都会调用 | 无 |
|
|
140
|
-
| `formItemOptions` | `Object` | 表单项配置,覆盖以上设置 | 无 |
|
|
141
|
-
| `uploadOptions` | `Object` | 上传配置,覆盖以上设置 | 无 |
|
|
142
|
-
| `buttonOptions` | `Object` | 上传按钮的配置,`listType` 为 `dragger` 时无效 | 默认配置了 `loading` |
|
|
143
|
-
|
|
144
|
-
---
|
|
145
|
-
|
|
146
|
-
### 附件下载组件
|
|
147
|
-
|
|
148
|
-
内置了下载功能的按钮组件,支持以下功能:
|
|
149
|
-
|
|
150
|
-
1. 支持格式为链接或流的文件下载。
|
|
151
|
-
2. 兼容原生组件功能。
|
|
152
|
-
|
|
153
|
-
#### 示例代码
|
|
154
|
-
|
|
155
|
-
```javascript
|
|
156
|
-
import React from "react";
|
|
157
|
-
import { DownloadFile } from "xydata-tools";
|
|
158
|
-
|
|
159
|
-
const Demo = () => {
|
|
160
|
-
return (
|
|
161
|
-
<DownloadFile
|
|
162
|
-
shape="round"
|
|
163
|
-
type="link"
|
|
164
|
-
queryOption={{
|
|
165
|
-
url: "/api/tb/exportTbExcel",
|
|
166
|
-
params: { peopleType: 0 },
|
|
167
|
-
customField: {
|
|
168
|
-
url: "exportFileUrl",
|
|
169
|
-
fileName: "exportFileName",
|
|
170
|
-
},
|
|
171
|
-
}}
|
|
172
|
-
/>
|
|
173
|
-
);
|
|
174
|
-
};
|
|
175
|
-
|
|
176
|
-
export default Demo;
|
|
177
|
-
```
|
|
178
|
-
|
|
179
|
-
#### 参数说明
|
|
180
|
-
|
|
181
|
-
| 参数名 | 类型 | 描述 | 默认值 |
|
|
182
|
-
| -------------------------- | -------------------- | ----------------------------------------------------------------- | -------- |
|
|
183
|
-
| `text` | `String / ReactNode` | 按钮内容 | 下载按钮 |
|
|
184
|
-
| `queryOption` | `Object` | 下载设置 | 无 |
|
|
185
|
-
| `queryOption.url` | `String` | 接口地址 | 无 |
|
|
186
|
-
| `queryOption.headers` | `Object` | 请求头 | 无 |
|
|
187
|
-
| `queryOption.method` | `String` | 请求方法,支持 `GET` 或 `POST` | 无 |
|
|
188
|
-
| `queryOption.fileName` | `String` | 文件名称 | 无 |
|
|
189
|
-
| `queryOption.params` | `Object` | 请求参数 | 无 |
|
|
190
|
-
| `queryOption.customField` | `Object` | 自定义返回接口返回的文件名和地址(适用于返回 JSON 的接口) | 无 |
|
|
191
|
-
| `queryOption.onError` | `Function` | 接口异常回调 | 无 |
|
|
192
|
-
| `queryOption.downloadType` | `String` | 下载类型,`pure` 表示传入的是下载地址(OSS 链接),而不是下载接口 | 无 |
|
|
193
|
-
| 其他 | `-` | 兼容 Antd.Button 所有原生参数 | 无 |
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
#### 配套的 提交/回显 方法
|
|
197
|
-
|
|
198
|
-
```javascript
|
|
199
|
-
|
|
200
|
-
import { getUploadFileData, setUploadFileData } from "xydata-tools";
|
|
201
|
-
|
|
202
|
-
// 获取表单数据
|
|
203
|
-
const getFieldsValue= async () => {
|
|
204
|
-
const fieldsValue = await form.validateFields();
|
|
205
|
-
const { cover } = fieldsValue;
|
|
206
|
-
const data = await getUploadFileData(cover);
|
|
207
|
-
};
|
|
208
|
-
|
|
209
|
-
// 回显表单数据
|
|
210
|
-
const renderFieldsValue = async () => {
|
|
211
|
-
const cover = [
|
|
212
|
-
{
|
|
213
|
-
name: "image.png",
|
|
214
|
-
url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png",
|
|
215
|
-
fileName:'xxx'
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
url: "https://zos.alipayobjects.com/rmsportal/jkjgkEfvpUPVyRjUImniVslZfWPnJuuZ.png",
|
|
219
|
-
},
|
|
220
|
-
];
|
|
221
|
-
const data = setUploadFileData(cover);
|
|
222
|
-
form.setFieldsValue({
|
|
223
|
-
cover: data,
|
|
224
|
-
});
|
|
225
|
-
};
|
|
226
|
-
```
|
|
227
54
|
---
|
|
228
55
|
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
#### 用户管理
|
|
232
|
-
|
|
233
|
-
```javascript
|
|
234
|
-
import React from "react";
|
|
235
|
-
import { Sso } from "xydata-tools";
|
|
236
|
-
import { connect } from "umi";
|
|
237
|
-
|
|
238
|
-
const UserPage = (props) => {
|
|
239
|
-
const { currentUser } = props;
|
|
240
|
-
return <Sso.User currentUser={currentUser} />;
|
|
241
|
-
};
|
|
242
|
-
|
|
243
|
-
export default connect(({ user }) => ({
|
|
244
|
-
currentUser: user.currentUser,
|
|
245
|
-
}))(UserPage);
|
|
246
|
-
```
|
|
247
|
-
|
|
248
|
-
#### 权限管理
|
|
249
|
-
|
|
250
|
-
```javascript
|
|
251
|
-
import React from "react";
|
|
252
|
-
import { Sso } from "xydata-tools";
|
|
253
|
-
|
|
254
|
-
const PermPage = () => {
|
|
255
|
-
return <Sso.Permission />;
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
export default PermPage;
|
|
259
|
-
```
|
|
56
|
+
## 本地开发
|
|
260
57
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
```javascript
|
|
264
|
-
<Sso.Role currentUser={currentUser} />
|
|
265
|
-
```
|
|
266
|
-
|
|
267
|
-
#### 设置权限
|
|
268
|
-
|
|
269
|
-
```javascript
|
|
270
|
-
<Sso.PermRole currentUser={currentUser} />
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
---
|
|
274
|
-
|
|
275
|
-
### 本地开发
|
|
58
|
+
react
|
|
276
59
|
|
|
277
60
|
1. 在项目根目录执行:
|
|
278
61
|
|
|
@@ -287,21 +70,32 @@ export default PermPage;
|
|
|
287
70
|
```
|
|
288
71
|
|
|
289
72
|
3. example 是一个由 `umi` 搭建的后台项目,可直接引用 `xydata-tools` 内的组件进行预览。
|
|
290
|
-
|
|
291
73
|
4. 新组件可在 `/xydata-tools/src/components` 下进行开发更新。
|
|
292
|
-
|
|
293
74
|
5. 在 src 内的修改操作将会被实时编译到 dist 文件夹中。
|
|
294
75
|
|
|
295
|
-
|
|
76
|
+
uniapp
|
|
77
|
+
|
|
78
|
+
1. 在项目根目录执行:
|
|
79
|
+
|
|
80
|
+
```bash
|
|
81
|
+
yarn dev
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
2. 在 example-uniapp 下运行
|
|
85
|
+
```bash
|
|
86
|
+
yarn link xydata-tools
|
|
87
|
+
```
|
|
88
|
+
3. 将 example-uniapp 添加到 H-Builder 中运行
|
|
89
|
+
|
|
90
|
+
打包发布:
|
|
296
91
|
|
|
297
92
|
```bash
|
|
298
93
|
npm run prepublishOnly
|
|
299
|
-
npm config set registry https://registry.npmjs.org
|
|
300
|
-
npm config set proxy false
|
|
94
|
+
npm config set registry https://registry.npmjs.org
|
|
301
95
|
npm publish -d
|
|
302
96
|
```
|
|
303
97
|
|
|
304
|
-
|
|
98
|
+
发布完成后,还原 npm 源(淘宝源):
|
|
305
99
|
|
|
306
100
|
```bash
|
|
307
101
|
npm config set registry https://registry.npmmirror.com
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|