1
1
import { list , save , del } from '@/services/api/table' ;
2
2
import { PlusOutlined } from '@ant-design/icons' ;
3
3
import type { ActionType , ProColumns } from '@ant-design/pro-components' ;
4
- import { ModalForm , PageContainer , ProFormText , ProFormTextArea , } from '@ant-design/pro-components' ;
4
+ import { ModalForm , PageContainer , ProFormSelect , ProFormText , ProTable } from '@ant-design/pro-components' ;
5
5
import { Button , Form , message , Popconfirm } from 'antd' ;
6
6
import { MyTable } from 'coding-components' ;
7
7
import React , { useRef , useState } from 'react' ;
@@ -48,17 +48,43 @@ const TablePage: React.FC = () => {
48
48
{
49
49
title : "编号" ,
50
50
dataIndex : 'id' ,
51
+ sorter : true ,
51
52
search : false ,
52
53
} ,
53
54
{
54
55
title : "服务名称" ,
55
56
dataIndex : 'name' ,
57
+ sorter : true ,
56
58
} ,
57
59
{
58
60
title : "地址" ,
59
61
dataIndex : 'url' ,
60
62
search : false ,
61
63
} ,
64
+ {
65
+ title : "状态" ,
66
+ dataIndex : 'state' ,
67
+ filters : [
68
+ {
69
+ text : '禁用' ,
70
+ value : 0 ,
71
+ } ,
72
+ {
73
+ text : '启用' ,
74
+ value : 1 ,
75
+ } ,
76
+ ] ,
77
+ valueEnum : {
78
+ 0 : {
79
+ text : '禁用' ,
80
+ status : 'Error'
81
+ } ,
82
+ 1 : {
83
+ text : '启用' ,
84
+ status : 'Success'
85
+ } ,
86
+ } ,
87
+ } ,
62
88
{
63
89
title : "操作" ,
64
90
dataIndex : 'option' ,
@@ -112,7 +138,12 @@ const TablePage: React.FC = () => {
112
138
</ Button > ,
113
139
] }
114
140
request = { async ( params , sort , filter ) => {
115
- const res = await list ( params ) ;
141
+ console . log ( params , sort , filter ) ;
142
+ const res = await list ( {
143
+ ...params ,
144
+ sort : Buffer . from ( JSON . stringify ( sort ) ) . toString ( 'base64' ) ,
145
+ filter : Buffer . from ( JSON . stringify ( filter ) ) . toString ( 'base64' ) ,
146
+ } ) ;
116
147
return {
117
148
data : res . data . list ,
118
149
success : res . success ,
@@ -126,6 +157,9 @@ const TablePage: React.FC = () => {
126
157
< ModalForm
127
158
title = "新建规则"
128
159
form = { form }
160
+ initialValues = { {
161
+ state : 1 ,
162
+ } }
129
163
modalProps = { {
130
164
destroyOnClose : true ,
131
165
onCancel : ( ) => {
@@ -149,6 +183,7 @@ const TablePage: React.FC = () => {
149
183
name = "id"
150
184
/>
151
185
< ProFormText
186
+ label = "服务名称"
152
187
placeholder = "请输入服务名称"
153
188
rules = { [
154
189
{
@@ -158,7 +193,8 @@ const TablePage: React.FC = () => {
158
193
] }
159
194
name = "name"
160
195
/>
161
- < ProFormTextArea
196
+ < ProFormText
197
+ label = "服务地址"
162
198
rules = { [
163
199
{
164
200
required : true ,
@@ -167,6 +203,28 @@ const TablePage: React.FC = () => {
167
203
] }
168
204
placeholder = "请输入服务地址"
169
205
name = "url" />
206
+
207
+ < ProFormSelect
208
+ label = "服务状态"
209
+ placeholder = "请输入服务状态"
210
+ rules = { [
211
+ {
212
+ required : true ,
213
+ message : "请输入服务状态" ,
214
+ } ,
215
+ ] }
216
+ options = { [
217
+ {
218
+ label : '启用' ,
219
+ value : 1 ,
220
+ } ,
221
+ {
222
+ label : '禁用' ,
223
+ value : 0 ,
224
+ } ,
225
+ ] }
226
+ name = "state"
227
+ />
170
228
</ ModalForm >
171
229
172
230
</ PageContainer >
0 commit comments