joy-admin-components 0.1.35 → 0.1.37
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 +535 -13
- package/dist/joy-admin-components.es.js +1302 -836
- package/dist/joy-admin-components.umd.js +2 -1
- package/dist/style.css +1 -1
- package/package.json +11 -6
- package/src/components/CmpIcon/index.d.ts +24 -0
- package/src/components/DownExcelTemp/index.d.ts +20 -0
- package/src/components/VxeTable/index.d.ts +23 -0
- package/src/index.d.ts +7 -0
- package/src/utils/index.d.ts +8 -69
package/README.md
CHANGED
|
@@ -1,26 +1,548 @@
|
|
|
1
1
|
# Joy Admin Components
|
|
2
2
|
|
|
3
|
-
基于
|
|
3
|
+
基于 Vue 3、Element Plus 和 VxeTable 的管理后台组件库,提供了一套完整的后台管理系统解决方案。
|
|
4
4
|
|
|
5
|
-
##
|
|
5
|
+
## 特性
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
- 基于 Vue 3 Composition API
|
|
8
|
+
- TypeScript 类型支持
|
|
9
|
+
- 开箱即用的管理后台组件
|
|
10
|
+
- 丰富的工具函数和 Hook
|
|
11
|
+
- 完整的国际化支持(中英文)
|
|
12
|
+
- VxeTable 自定义渲染器
|
|
13
|
+
- Excel 导入导出功能
|
|
14
|
+
|
|
15
|
+
## 依赖要求
|
|
16
|
+
|
|
17
|
+
- Vue 3.3.4+
|
|
18
|
+
- Element Plus 2.3.8+
|
|
19
|
+
- VxeTable 4.12.0+
|
|
20
|
+
- vue-i18n 9.10.1+
|
|
21
|
+
|
|
22
|
+
## 安装
|
|
8
23
|
|
|
9
24
|
```bash
|
|
10
25
|
npm install joy-admin-components
|
|
11
26
|
```
|
|
12
27
|
|
|
13
|
-
|
|
28
|
+
或使用 yarn:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
yarn add joy-admin-components
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
## 快速开始
|
|
35
|
+
|
|
36
|
+
### 1. 配置国际化
|
|
37
|
+
|
|
38
|
+
```js
|
|
39
|
+
// main.js
|
|
40
|
+
import { createApp } from 'vue';
|
|
41
|
+
import { createI18n } from 'vue-i18n';
|
|
42
|
+
import { setupI18n } from 'joy-admin-components';
|
|
43
|
+
import App from './App.vue';
|
|
44
|
+
|
|
45
|
+
// 创建 i18n 实例
|
|
46
|
+
const i18n = createI18n({
|
|
47
|
+
legacy: false,
|
|
48
|
+
locale: 'zh_cn',
|
|
49
|
+
fallbackLocale: 'zh_cn',
|
|
50
|
+
messages: {
|
|
51
|
+
zh_cn: {},
|
|
52
|
+
en: {}
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
// 初始化组件库的国际化
|
|
57
|
+
setupI18n(i18n);
|
|
58
|
+
|
|
59
|
+
const app = createApp(App);
|
|
60
|
+
app.use(i18n);
|
|
61
|
+
app.mount('#app');
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### 2. 注册 VxeTable 渲染器(可选)
|
|
65
|
+
|
|
66
|
+
如果需要使用 VxeTable 的自定义渲染器:
|
|
14
67
|
|
|
15
68
|
```js
|
|
16
|
-
import {
|
|
17
|
-
import ElementPlus from 'element-plus'
|
|
18
|
-
import 'element-plus/dist/index.css'
|
|
19
|
-
import JoyAdminComponents from 'joy-admin-components'
|
|
20
|
-
import App from './App.vue'
|
|
69
|
+
import { registerVxeRenderers } from 'joy-admin-components';
|
|
21
70
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
app.use(JoyAdminComponents)
|
|
25
|
-
app.mount('#app')
|
|
71
|
+
// 注册 VxeTable 渲染器
|
|
72
|
+
registerVxeRenderers();
|
|
26
73
|
```
|
|
74
|
+
|
|
75
|
+
### 3. 使用组件
|
|
76
|
+
|
|
77
|
+
组件支持按需导入:
|
|
78
|
+
|
|
79
|
+
```vue
|
|
80
|
+
<template>
|
|
81
|
+
<ListPage
|
|
82
|
+
id="userList"
|
|
83
|
+
:api="getUserList"
|
|
84
|
+
:searchForm="searchForm"
|
|
85
|
+
>
|
|
86
|
+
<vxe-column field="name" title="用户名" />
|
|
87
|
+
<vxe-column field="email" title="邮箱" />
|
|
88
|
+
</ListPage>
|
|
89
|
+
</template>
|
|
90
|
+
|
|
91
|
+
<script setup>
|
|
92
|
+
import { ListPage } from 'joy-admin-components';
|
|
93
|
+
|
|
94
|
+
const searchForm = {
|
|
95
|
+
items: [
|
|
96
|
+
{ key: 'name', type: 'input', name: '用户名', value: '' }
|
|
97
|
+
]
|
|
98
|
+
};
|
|
99
|
+
|
|
100
|
+
async function getUserList(params) {
|
|
101
|
+
// 调用 API 获取数据
|
|
102
|
+
return {
|
|
103
|
+
data: [],
|
|
104
|
+
total: 0
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
</script>
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
## 组件列表
|
|
111
|
+
|
|
112
|
+
### ListPage - 列表页面组件
|
|
113
|
+
|
|
114
|
+
一个功能完整的列表页面组件,集成了搜索、表格、分页等功能。
|
|
115
|
+
|
|
116
|
+
[ListPage](src/components/ListPage/index.vue:1)
|
|
117
|
+
|
|
118
|
+
**主要 Props:**
|
|
119
|
+
|
|
120
|
+
| 参数 | 说明 | 类型 | 必填 | 默认值 |
|
|
121
|
+
|------|------|------|------|--------|
|
|
122
|
+
| id | 表格唯一标识 | string | 是 | - |
|
|
123
|
+
| api | 获取数据的 API 函数 | Function | 否 | - |
|
|
124
|
+
| data | 静态数据(不使用 API 时) | Array | 否 | [] |
|
|
125
|
+
| searchForm | 搜索表单配置 | Object | 是 | - |
|
|
126
|
+
| immediate | 是否立即请求数据 | boolean | 否 | true |
|
|
127
|
+
| loading | 加载状态 | boolean | 否 | false |
|
|
128
|
+
|
|
129
|
+
**searchForm 配置:**
|
|
130
|
+
|
|
131
|
+
```js
|
|
132
|
+
{
|
|
133
|
+
items: [
|
|
134
|
+
{
|
|
135
|
+
key: 'field', // 字段名
|
|
136
|
+
type: 'input', // 类型:input/select/date/custom
|
|
137
|
+
name: '字段名称', // 显示名称
|
|
138
|
+
value: '', // 默认值
|
|
139
|
+
option: {} // 其他选项
|
|
140
|
+
}
|
|
141
|
+
],
|
|
142
|
+
showSearch: true, // 是否显示搜索栏
|
|
143
|
+
showPage: true, // 是否显示分页
|
|
144
|
+
showCheckBox: true, // 是否显示复选框
|
|
145
|
+
showShadow: true // 是否显示阴影
|
|
146
|
+
}
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
**插槽:**
|
|
150
|
+
|
|
151
|
+
- `search-bar-btn`: 搜索栏按钮区域
|
|
152
|
+
- `table-header-left`: 表格头部左侧区域
|
|
153
|
+
- `default`: 表格列定义
|
|
154
|
+
|
|
155
|
+
**示例:**
|
|
156
|
+
|
|
157
|
+
```vue
|
|
158
|
+
<ListPage
|
|
159
|
+
id="productList"
|
|
160
|
+
:api="getProducts"
|
|
161
|
+
:searchForm="{
|
|
162
|
+
items: [
|
|
163
|
+
{ key: 'name', type: 'input', name: '产品名称', value: '' },
|
|
164
|
+
{ key: 'status', type: 'select', name: '状态', value: '', option: {
|
|
165
|
+
options: [
|
|
166
|
+
{ label: '在售', value: 1 },
|
|
167
|
+
{ label: '下架', value: 2 }
|
|
168
|
+
]
|
|
169
|
+
}}
|
|
170
|
+
]
|
|
171
|
+
}"
|
|
172
|
+
>
|
|
173
|
+
<vxe-column field="name" title="产品名称" />
|
|
174
|
+
<vxe-column field="price" title="价格" />
|
|
175
|
+
</ListPage>
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
### SearchBar - 搜索栏组件
|
|
179
|
+
|
|
180
|
+
独立的搜索栏组件,支持多种输入类型。
|
|
181
|
+
|
|
182
|
+
[SearchBar](src/components/SearchBar/index.vue:1)
|
|
183
|
+
|
|
184
|
+
**Props:**
|
|
185
|
+
|
|
186
|
+
| 参数 | 说明 | 类型 | 必填 |
|
|
187
|
+
|------|------|------|------|
|
|
188
|
+
| form | 表单配置 | Object | 是 |
|
|
189
|
+
|
|
190
|
+
**事件:**
|
|
191
|
+
|
|
192
|
+
- `confirm`: 点击筛选按钮
|
|
193
|
+
- `reset`: 点击重置按钮
|
|
194
|
+
- `visibleChange`: 展开/收起状态变化
|
|
195
|
+
|
|
196
|
+
**表单项类型:**
|
|
197
|
+
|
|
198
|
+
- `input`: 文本输入框
|
|
199
|
+
- `select`: 下拉选择(使用 CmpDictionary)
|
|
200
|
+
- `date`: 日期选择器
|
|
201
|
+
- `custom`: 自定义渲染
|
|
202
|
+
|
|
203
|
+
**示例:**
|
|
204
|
+
|
|
205
|
+
```vue
|
|
206
|
+
<SearchBar
|
|
207
|
+
:form="{
|
|
208
|
+
items: [
|
|
209
|
+
{ key: 'keyword', type: 'input', name: '关键词', value: '' },
|
|
210
|
+
{ key: 'createTime', type: 'date', name: '创建时间', value: '', dateType: 'daterange' }
|
|
211
|
+
]
|
|
212
|
+
}"
|
|
213
|
+
@confirm="handleSearch"
|
|
214
|
+
@reset="handleReset"
|
|
215
|
+
>
|
|
216
|
+
<template #btn>
|
|
217
|
+
<el-button>自定义按钮</el-button>
|
|
218
|
+
</template>
|
|
219
|
+
</SearchBar>
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
### LayOutForm - 布局表单组件
|
|
223
|
+
|
|
224
|
+
自动布局的表单组件。
|
|
225
|
+
|
|
226
|
+
[LayOutForm](src/components/LayOutForm/index.vue:1)
|
|
227
|
+
|
|
228
|
+
### CmpDictionary - 字典选择器
|
|
229
|
+
|
|
230
|
+
支持静态选项和动态加载的选择器组件。
|
|
231
|
+
|
|
232
|
+
[CmpDictionary](src/components/CmpDictionary/index.vue:1)
|
|
233
|
+
|
|
234
|
+
### CmpIcon - 图标组件
|
|
235
|
+
|
|
236
|
+
Element Plus 图标包装组件,简化图标使用。
|
|
237
|
+
|
|
238
|
+
[CmpIcon](src/components/CmpIcon/index.vue:1)
|
|
239
|
+
|
|
240
|
+
**Props:**
|
|
241
|
+
|
|
242
|
+
| 参数 | 说明 | 类型 | 必填 |
|
|
243
|
+
|------|------|------|------|
|
|
244
|
+
| name | 图标名称 | string | 是 |
|
|
245
|
+
|
|
246
|
+
**示例:**
|
|
247
|
+
|
|
248
|
+
```vue
|
|
249
|
+
<template>
|
|
250
|
+
<CmpIcon name="Edit" />
|
|
251
|
+
<CmpIcon name="Delete" />
|
|
252
|
+
<CmpIcon name="Search" />
|
|
253
|
+
</template>
|
|
254
|
+
|
|
255
|
+
<script setup>
|
|
256
|
+
import { CmpIcon } from 'joy-admin-components';
|
|
257
|
+
</script>
|
|
258
|
+
```
|
|
259
|
+
|
|
260
|
+
### ConfrimButton - 确认按钮
|
|
261
|
+
|
|
262
|
+
带二次确认的操作按钮。
|
|
263
|
+
|
|
264
|
+
[ConfrimButton](src/components/ConfrimButton/index.vue:1)
|
|
265
|
+
|
|
266
|
+
### ImportButton - 导入按钮
|
|
267
|
+
|
|
268
|
+
Excel 文件导入按钮。
|
|
269
|
+
|
|
270
|
+
[ImportButton](src/components/ImportButton/index.vue:1)
|
|
271
|
+
|
|
272
|
+
### DownExcelTemp - 下载模板按钮
|
|
273
|
+
|
|
274
|
+
Excel 模板下载按钮。
|
|
275
|
+
|
|
276
|
+
[DownExcelTemp](src/components/DownExcelTemp/index.vue:1)
|
|
277
|
+
|
|
278
|
+
## 工具函数
|
|
279
|
+
|
|
280
|
+
### 验证工具
|
|
281
|
+
|
|
282
|
+
```js
|
|
283
|
+
import { creatValidator } from 'joy-admin-components';
|
|
284
|
+
|
|
285
|
+
// 创建表单验证器
|
|
286
|
+
const validator = creatValidator(rules);
|
|
287
|
+
```
|
|
288
|
+
|
|
289
|
+
### 加密工具
|
|
290
|
+
|
|
291
|
+
```js
|
|
292
|
+
import { crypto } from 'joy-admin-components';
|
|
293
|
+
|
|
294
|
+
// 使用加密功能
|
|
295
|
+
const encrypted = crypto.encrypt(data);
|
|
296
|
+
const decrypted = crypto.decrypt(encrypted);
|
|
297
|
+
```
|
|
298
|
+
|
|
299
|
+
### Excel 工具
|
|
300
|
+
|
|
301
|
+
```js
|
|
302
|
+
import { importExcel, exportExcel } from 'joy-admin-components';
|
|
303
|
+
|
|
304
|
+
// 导入 Excel
|
|
305
|
+
const data = await importExcel(file);
|
|
306
|
+
|
|
307
|
+
// 导出 Excel
|
|
308
|
+
exportExcel(data, 'filename.xlsx');
|
|
309
|
+
```
|
|
310
|
+
|
|
311
|
+
### 通用工具函数
|
|
312
|
+
|
|
313
|
+
```js
|
|
314
|
+
import {
|
|
315
|
+
sleep, // 延迟执行
|
|
316
|
+
_toRaw, // 转换为原始对象
|
|
317
|
+
arrayToTree, // 数组转树形结构
|
|
318
|
+
stringToArray, // 字符串转数组
|
|
319
|
+
StatusMap, // 状态映射类
|
|
320
|
+
arrToStatusMap, // 数组转状态映射
|
|
321
|
+
stripHtmlTags, // 移除 HTML 标签
|
|
322
|
+
unicode2Str, // Unicode 转字符串
|
|
323
|
+
checkFileSize, // 检查文件大小
|
|
324
|
+
createListPageId, // 创建列表页 ID
|
|
325
|
+
createImportFields, // 创建导入字段配置
|
|
326
|
+
getValueBykey // 根据 key 获取值
|
|
327
|
+
} from 'joy-admin-components';
|
|
328
|
+
```
|
|
329
|
+
|
|
330
|
+
### Hook 函数
|
|
331
|
+
|
|
332
|
+
```js
|
|
333
|
+
import {
|
|
334
|
+
useRequest, // 请求 Hook
|
|
335
|
+
useDatePicker, // 日期选择器 Hook
|
|
336
|
+
_typeOf, // 类型判断
|
|
337
|
+
useI18nReState, // 国际化响应式状态
|
|
338
|
+
getLocaleValue, // 获取本地化值
|
|
339
|
+
useState, // Vuex state Hook
|
|
340
|
+
useGetters, // Vuex getters Hook
|
|
341
|
+
useActions // Vuex actions Hook
|
|
342
|
+
} from 'joy-admin-components';
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
## VxeTable 渲染器
|
|
346
|
+
|
|
347
|
+
`registerVxeRenderers` 提供了 5 种常用的 VxeTable 自定义渲染器,简化数据展示逻辑。
|
|
348
|
+
|
|
349
|
+
### 注册渲染器
|
|
350
|
+
|
|
351
|
+
在应用入口文件中注册:
|
|
352
|
+
|
|
353
|
+
```js
|
|
354
|
+
import { registerVxeRenderers } from 'joy-admin-components';
|
|
355
|
+
|
|
356
|
+
// 注册 VxeTable 渲染器
|
|
357
|
+
registerVxeRenderers();
|
|
358
|
+
```
|
|
359
|
+
|
|
360
|
+
### 内置渲染器
|
|
361
|
+
|
|
362
|
+
| 渲染器 | 说明 | 使用场景 |
|
|
363
|
+
|--------|------|----------|
|
|
364
|
+
| **Enum** | 枚举值渲染器 | 状态、类型等枚举数据,支持彩色标签 |
|
|
365
|
+
| **InputNumber** | 数字输入渲染器 | 表格内直接编辑数字 |
|
|
366
|
+
| **TrueFalse** | 布尔值渲染器 | 是/否、真/假等布尔值,自动国际化 |
|
|
367
|
+
| **I18n** | 国际化渲染器 | 根据语言环境自动切换字段 |
|
|
368
|
+
| **Link** | 跳转链接渲染器 | 可点击跳转的链接,支持多个链接 |
|
|
369
|
+
|
|
370
|
+
### 详细文档
|
|
371
|
+
|
|
372
|
+
每个渲染器的详细参数、配置选项和高级用法,请查看:
|
|
373
|
+
|
|
374
|
+
📖 [VxeTable 渲染器完整文档](registerVxeRenderers.md)
|
|
375
|
+
|
|
376
|
+
## 国际化
|
|
377
|
+
|
|
378
|
+
组件库内置完整的国际化支持,详细使用说明请查看:[国际化文档](README-i18n.md)
|
|
379
|
+
|
|
380
|
+
**快速配置:**
|
|
381
|
+
|
|
382
|
+
```js
|
|
383
|
+
import { createI18n } from 'vue-i18n';
|
|
384
|
+
import { setupI18n } from 'joy-admin-components';
|
|
385
|
+
|
|
386
|
+
const i18n = createI18n({
|
|
387
|
+
legacy: false,
|
|
388
|
+
locale: 'zh_cn',
|
|
389
|
+
messages: { zh_cn: {}, en: {} }
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
setupI18n(i18n);
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**切换语言:**
|
|
396
|
+
|
|
397
|
+
```js
|
|
398
|
+
import { useI18n } from 'vue-i18n';
|
|
399
|
+
|
|
400
|
+
const { locale } = useI18n();
|
|
401
|
+
locale.value = 'en'; // 切换为英文
|
|
402
|
+
```
|
|
403
|
+
|
|
404
|
+
## TypeScript 支持
|
|
405
|
+
|
|
406
|
+
所有组件和函数都包含 TypeScript 类型定义:
|
|
407
|
+
|
|
408
|
+
```ts
|
|
409
|
+
import type { SearchFormConfig } from 'joy-admin-components';
|
|
410
|
+
|
|
411
|
+
const searchForm: SearchFormConfig = {
|
|
412
|
+
items: [
|
|
413
|
+
{ key: 'name', type: 'input', name: '名称', value: '' }
|
|
414
|
+
]
|
|
415
|
+
};
|
|
416
|
+
```
|
|
417
|
+
|
|
418
|
+
## 完整示例
|
|
419
|
+
|
|
420
|
+
```vue
|
|
421
|
+
<template>
|
|
422
|
+
<div class="page">
|
|
423
|
+
<ListPage
|
|
424
|
+
id="userManagement"
|
|
425
|
+
:api="getUserList"
|
|
426
|
+
:searchForm="searchForm"
|
|
427
|
+
@selection-change="handleSelectionChange"
|
|
428
|
+
>
|
|
429
|
+
<template #search-bar-btn>
|
|
430
|
+
<el-button type="primary" @click="handleAdd">新增用户</el-button>
|
|
431
|
+
<ImportButton :api="importUsers" @success="refresh" />
|
|
432
|
+
<DownExcelTemp :template="userTemplate" />
|
|
433
|
+
</template>
|
|
434
|
+
|
|
435
|
+
<vxe-column field="id" title="ID" width="80" />
|
|
436
|
+
|
|
437
|
+
<vxe-column
|
|
438
|
+
field="name"
|
|
439
|
+
title="用户名"
|
|
440
|
+
cell-render="I18n"
|
|
441
|
+
:cell-render-data="{ fieldEn: 'nameEn' }"
|
|
442
|
+
/>
|
|
443
|
+
|
|
444
|
+
<vxe-column
|
|
445
|
+
field="status"
|
|
446
|
+
title="状态"
|
|
447
|
+
cell-render="Enum"
|
|
448
|
+
:cell-render-data="{ enum: statusEnum }"
|
|
449
|
+
/>
|
|
450
|
+
|
|
451
|
+
<vxe-column
|
|
452
|
+
field="isActive"
|
|
453
|
+
title="是否激活"
|
|
454
|
+
cell-render="TrueFalse"
|
|
455
|
+
/>
|
|
456
|
+
|
|
457
|
+
<vxe-column title="操作" width="150">
|
|
458
|
+
<template #default="{ row }">
|
|
459
|
+
<el-button text @click="handleEdit(row)">编辑</el-button>
|
|
460
|
+
<ConfrimButton
|
|
461
|
+
text
|
|
462
|
+
type="danger"
|
|
463
|
+
@confirm="handleDelete(row.id)"
|
|
464
|
+
>
|
|
465
|
+
删除
|
|
466
|
+
</ConfrimButton>
|
|
467
|
+
</template>
|
|
468
|
+
</vxe-column>
|
|
469
|
+
</ListPage>
|
|
470
|
+
</div>
|
|
471
|
+
</template>
|
|
472
|
+
|
|
473
|
+
<script setup>
|
|
474
|
+
import {
|
|
475
|
+
ListPage,
|
|
476
|
+
ImportButton,
|
|
477
|
+
DownExcelTemp,
|
|
478
|
+
ConfrimButton,
|
|
479
|
+
registerVxeRenderers
|
|
480
|
+
} from 'joy-admin-components';
|
|
481
|
+
import { ref } from 'vue';
|
|
482
|
+
|
|
483
|
+
// 注册 VxeTable 渲染器
|
|
484
|
+
registerVxeRenderers();
|
|
485
|
+
|
|
486
|
+
// 搜索表单配置
|
|
487
|
+
const searchForm = {
|
|
488
|
+
items: [
|
|
489
|
+
{ key: 'name', type: 'input', name: '用户名', value: '' },
|
|
490
|
+
{ key: 'status', type: 'select', name: '状态', value: '', option: {
|
|
491
|
+
options: [
|
|
492
|
+
{ label: '启用', value: 1 },
|
|
493
|
+
{ label: '禁用', value: 2 }
|
|
494
|
+
]
|
|
495
|
+
}},
|
|
496
|
+
{ key: 'createTime', type: 'date', name: '创建时间', value: '', dateType: 'daterange' }
|
|
497
|
+
]
|
|
498
|
+
};
|
|
499
|
+
|
|
500
|
+
// 状态枚举
|
|
501
|
+
const statusEnum = {
|
|
502
|
+
getName: (value) => ({ 1: '启用', 2: '禁用' }[value] || '-'),
|
|
503
|
+
getTag: (value) => ({ 1: 'success', 2: 'danger' }[value] || 'info')
|
|
504
|
+
};
|
|
505
|
+
|
|
506
|
+
// API 函数
|
|
507
|
+
async function getUserList(params) {
|
|
508
|
+
const response = await fetch('/api/users', {
|
|
509
|
+
method: 'POST',
|
|
510
|
+
body: JSON.stringify(params)
|
|
511
|
+
});
|
|
512
|
+
return response.json();
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
// 事件处理
|
|
516
|
+
function handleSelectionChange(selection) {
|
|
517
|
+
console.log('选中的数据:', selection);
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
function handleAdd() {
|
|
521
|
+
// 新增用户逻辑
|
|
522
|
+
}
|
|
523
|
+
|
|
524
|
+
function handleEdit(row) {
|
|
525
|
+
// 编辑用户逻辑
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
function handleDelete(id) {
|
|
529
|
+
// 删除用户逻辑
|
|
530
|
+
}
|
|
531
|
+
</script>
|
|
532
|
+
```
|
|
533
|
+
|
|
534
|
+
## 浏览器支持
|
|
535
|
+
|
|
536
|
+
- Chrome >= 87
|
|
537
|
+
- Firefox >= 78
|
|
538
|
+
- Safari >= 14
|
|
539
|
+
- Edge >= 88
|
|
540
|
+
|
|
541
|
+
## 更多文档
|
|
542
|
+
|
|
543
|
+
- [国际化使用说明](README-i18n.md)
|
|
544
|
+
- [VxeTable 渲染器文档](docs/registerVxeRenderers.md)
|
|
545
|
+
|
|
546
|
+
## License
|
|
547
|
+
|
|
548
|
+
MIT
|