|
@@ -0,0 +1,167 @@
|
|
1
|
+import { EllipsisOutlined, PlusOutlined } from '@ant-design/icons';
|
|
2
|
+import { ProTable, TableDropdown } from '@ant-design/pro-components';
|
|
3
|
+import { Button, Dropdown, Menu, Space, Tag } from 'antd';
|
|
4
|
+import { useRef } from 'react';
|
|
5
|
+import Page from '@/components/page';
|
|
6
|
+
|
|
7
|
+// import request from 'umi-request';
|
|
8
|
+const columns = [
|
|
9
|
+ {
|
|
10
|
+ dataIndex: 'index',
|
|
11
|
+ valueType: 'indexBorder',
|
|
12
|
+ width: 48,
|
|
13
|
+ },
|
|
14
|
+ {
|
|
15
|
+ title: '标题',
|
|
16
|
+ dataIndex: 'title',
|
|
17
|
+ copyable: true,
|
|
18
|
+ ellipsis: true,
|
|
19
|
+ tip: '标题过长会自动收缩',
|
|
20
|
+ formItemProps: {
|
|
21
|
+ rules: [
|
|
22
|
+ {
|
|
23
|
+ required: true,
|
|
24
|
+ message: '此项为必填项',
|
|
25
|
+ },
|
|
26
|
+ ],
|
|
27
|
+ },
|
|
28
|
+ },
|
|
29
|
+ {
|
|
30
|
+ disable: true,
|
|
31
|
+ title: '状态',
|
|
32
|
+ dataIndex: 'state',
|
|
33
|
+ filters: true,
|
|
34
|
+ onFilter: true,
|
|
35
|
+ ellipsis: true,
|
|
36
|
+ valueType: 'select',
|
|
37
|
+ valueEnum: {
|
|
38
|
+ all: { text: '超长'.repeat(50) },
|
|
39
|
+ open: {
|
|
40
|
+ text: '未解决',
|
|
41
|
+ status: 'Error',
|
|
42
|
+ },
|
|
43
|
+ closed: {
|
|
44
|
+ text: '已解决',
|
|
45
|
+ status: 'Success',
|
|
46
|
+ disabled: true,
|
|
47
|
+ },
|
|
48
|
+ processing: {
|
|
49
|
+ text: '解决中',
|
|
50
|
+ status: 'Processing',
|
|
51
|
+ },
|
|
52
|
+ },
|
|
53
|
+ },
|
|
54
|
+ {
|
|
55
|
+ disable: true,
|
|
56
|
+ title: '标签',
|
|
57
|
+ dataIndex: 'labels',
|
|
58
|
+ search: false,
|
|
59
|
+ renderFormItem: (_, { defaultRender }) => {
|
|
60
|
+ return defaultRender(_);
|
|
61
|
+ },
|
|
62
|
+ render: (_, record) => (<Space>
|
|
63
|
+ {record.labels.map(({ name, color }) => (<Tag color={color} key={name}>
|
|
64
|
+ {name}
|
|
65
|
+ </Tag>))}
|
|
66
|
+ </Space>),
|
|
67
|
+ },
|
|
68
|
+ {
|
|
69
|
+ title: '创建时间',
|
|
70
|
+ key: 'showTime',
|
|
71
|
+ dataIndex: 'created_at',
|
|
72
|
+ valueType: 'date',
|
|
73
|
+ sorter: true,
|
|
74
|
+ hideInSearch: true,
|
|
75
|
+ },
|
|
76
|
+ {
|
|
77
|
+ title: '创建时间',
|
|
78
|
+ dataIndex: 'created_at',
|
|
79
|
+ valueType: 'dateRange',
|
|
80
|
+ hideInTable: true,
|
|
81
|
+ search: {
|
|
82
|
+ transform: (value) => {
|
|
83
|
+ return {
|
|
84
|
+ startTime: value[0],
|
|
85
|
+ endTime: value[1],
|
|
86
|
+ };
|
|
87
|
+ },
|
|
88
|
+ },
|
|
89
|
+ },
|
|
90
|
+ {
|
|
91
|
+ title: '操作',
|
|
92
|
+ valueType: 'option',
|
|
93
|
+ key: 'option',
|
|
94
|
+ render: (text, record, _, action) => [
|
|
95
|
+ <a key="editable" onClick={() => {
|
|
96
|
+ var _a;
|
|
97
|
+ (_a = action === null || action === void 0 ? void 0 : action.startEditable) === null || _a === void 0 ? void 0 : _a.call(action, record.id);
|
|
98
|
+ }}>
|
|
99
|
+ 编辑
|
|
100
|
+ </a>,
|
|
101
|
+ <a href={record.url} target="_blank" rel="noopener noreferrer" key="view">
|
|
102
|
+ 查看
|
|
103
|
+ </a>,
|
|
104
|
+ <TableDropdown key="actionGroup" onSelect={() => action === null || action === void 0 ? void 0 : action.reload()} menus={[
|
|
105
|
+ { key: 'copy', name: '复制' },
|
|
106
|
+ { key: 'delete', name: '删除' },
|
|
107
|
+ ]}/>,
|
|
108
|
+ ],
|
|
109
|
+ },
|
|
110
|
+];
|
|
111
|
+const menu = (<Menu items={[
|
|
112
|
+ {
|
|
113
|
+ label: '1st item',
|
|
114
|
+ key: '1',
|
|
115
|
+ },
|
|
116
|
+ {
|
|
117
|
+ label: '2nd item',
|
|
118
|
+ key: '1',
|
|
119
|
+ },
|
|
120
|
+ {
|
|
121
|
+ label: '3rd item',
|
|
122
|
+ key: '1',
|
|
123
|
+ },
|
|
124
|
+ ]}/>);
|
|
125
|
+export default () => {
|
|
126
|
+ const actionRef = useRef();
|
|
127
|
+ return (<Page><ProTable columns={columns} actionRef={actionRef} cardBordered request={async (params = {}, sort, filter) => {
|
|
128
|
+ console.log(sort, filter);
|
|
129
|
+ // return request('https://proapi.azurewebsites.net/github/issues', {
|
|
130
|
+ // params,
|
|
131
|
+ // });
|
|
132
|
+ }} editable={{
|
|
133
|
+ type: 'multiple',
|
|
134
|
+ }} columnsState={{
|
|
135
|
+ persistenceKey: 'pro-table-singe-demos',
|
|
136
|
+ persistenceType: 'localStorage',
|
|
137
|
+ onChange(value) {
|
|
138
|
+ console.log('value: ', value);
|
|
139
|
+ },
|
|
140
|
+ }} rowKey="id" search={{
|
|
141
|
+ labelWidth: 'auto',
|
|
142
|
+ }} options={{
|
|
143
|
+ setting: {
|
|
144
|
+ listsHeight: 400,
|
|
145
|
+ },
|
|
146
|
+ }} form={{
|
|
147
|
+ // 由于配置了 transform,提交的参与与定义的不同这里需要转化一下
|
|
148
|
+ syncToUrl: (values, type) => {
|
|
149
|
+ if (type === 'get') {
|
|
150
|
+ return Object.assign(Object.assign({}, values), { created_at: [values.startTime, values.endTime] });
|
|
151
|
+ }
|
|
152
|
+ return values;
|
|
153
|
+ },
|
|
154
|
+ }} pagination={{
|
|
155
|
+ pageSize: 5,
|
|
156
|
+ onChange: (page) => console.log(page),
|
|
157
|
+ }} dateFormatter="string" headerTitle="高级表格" toolBarRender={() => [
|
|
158
|
+ <Button key="button" icon={<PlusOutlined />} type="primary">
|
|
159
|
+ 新建
|
|
160
|
+ </Button>,
|
|
161
|
+ <Dropdown key="menu" overlay={menu}>
|
|
162
|
+ <Button>
|
|
163
|
+ <EllipsisOutlined />
|
|
164
|
+ </Button>
|
|
165
|
+ </Dropdown>,
|
|
166
|
+ ]}/></Page>);
|
|
167
|
+};
|