1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
| <template>
| <cl-crud ref="Crud">
| <cl-row>
| <!-- 刷新按钮 -->
| <cl-refresh-btn />
|
| <cl-flex1 />
|
| <!-- 导入 -->
| <cl-import-btn template="/用户导入模版.xlsx" :on-submit="onImpSubmit" />
|
| <!-- 导出 -->
| <cl-export-btn :columns="Table?.columns" />
| </cl-row>
|
| <cl-row>
| <!-- 表格 -->
| <cl-table ref="Table" :auto-height="false" />
| </cl-row>
|
| <cl-row>
| <cl-flex1 />
|
| <!-- 分页 -->
| <cl-pagination />
| </cl-row>
| </cl-crud>
| </template>
|
| <script lang="tsx" setup>
| import { useCrud, useTable } from '@cool-vue/crud';
| import { useDict } from '/$/dict';
| import { ElMessage } from 'element-plus';
|
| const { dict } = useDict();
|
| // crud
| const Crud = useCrud(
| {
| service: 'test'
| },
| app => {
| app.refresh({ size: 10 });
| }
| );
|
| // 表格
| const Table = useTable({
| columns: [
| {
| label: '姓名',
| prop: 'name'
| },
| {
| label: '手机号',
| prop: 'phone'
| },
| {
| label: '账号',
| prop: 'account'
| },
| {
| label: '存款(元)',
| prop: 'wages'
| },
| {
| label: '工作',
| prop: 'occupation',
| dict: dict.get('occupation')
| }
| ]
| });
|
| function onImpSubmit(data: { list: any[]; file: File }, { done, close }: any) {
| close();
| ElMessage.success(`已提交${data.list.length}条数据`);
| }
| </script>
|
|