mall-components 1.0.0
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 +128 -0
- package/build/_components-raw.css +791 -0
- package/build/_shims/antd.js +1 -0
- package/build/_shims/icons.js +1 -0
- package/build/_shims/moment.js +1 -0
- package/build/_shims/react-dom.js +1 -0
- package/build/_shims/react.js +1 -0
- package/build/adapters/DataSourceAdapter.d.ts +46 -0
- package/build/components/AdminLayout/AdminLayout.d.ts +5 -0
- package/build/components/AdminLayout/Breadcrumb.d.ts +8 -0
- package/build/components/AdminLayout/MainContent.d.ts +17 -0
- package/build/components/AdminLayout/Navbar.d.ts +10 -0
- package/build/components/AdminLayout/Sidebar.d.ts +14 -0
- package/build/components/AdminLayout/TabBar.d.ts +13 -0
- package/build/components/AdminLayout/TabPane.d.ts +4 -0
- package/build/components/AdminLayout/index.d.ts +3 -0
- package/build/components/AdminLayout/types.d.ts +42 -0
- package/build/components/CouponCard/CouponCard.d.ts +20 -0
- package/build/components/CouponCard/index.d.ts +1 -0
- package/build/components/OrderForm/OrderForm.d.ts +18 -0
- package/build/components/OrderForm/index.d.ts +1 -0
- package/build/components/OrderList/OrderList.d.ts +29 -0
- package/build/components/OrderList/index.d.ts +1 -0
- package/build/components/ProductForm/ProductForm.d.ts +18 -0
- package/build/components/ProductForm/index.d.ts +3 -0
- package/build/components/ProductList/ProductList.d.ts +47 -0
- package/build/components/ProductList/index.d.ts +3 -0
- package/build/components/PromotionCard/PromotionCard.d.ts +22 -0
- package/build/components/PromotionCard/index.d.ts +1 -0
- package/build/components/RoleCard/RoleCard.d.ts +18 -0
- package/build/components/RoleCard/index.d.ts +1 -0
- package/build/components/UserCard/UserCard.d.ts +17 -0
- package/build/components/UserCard/index.d.ts +1 -0
- package/build/entry-meta.d.ts +603 -0
- package/build/index.css +1 -0
- package/build/index.js +1 -0
- package/build/mall-components-meta.js +2563 -0
- package/build/mall-components.cdn.umd.css +1 -0
- package/build/mall-components.cdn.umd.js +8 -0
- package/build/mall-components.codesandbox.combined.js +1094 -0
- package/build/mall-components.codesandbox.css +401 -0
- package/build/mall-components.codesandbox.js +1080 -0
- package/build/mall-components.umd.css +1 -0
- package/build/mall-components.umd.js +8 -0
- package/build/meta/adminLayoutMeta.d.ts +3 -0
- package/build/meta/couponCardMeta.d.ts +128 -0
- package/build/meta/icons.d.ts +10 -0
- package/build/meta/orderFormMeta.d.ts +111 -0
- package/build/meta/orderListMeta.d.ts +170 -0
- package/build/meta/productFormMeta.d.ts +3 -0
- package/build/meta/productListMeta.d.ts +200 -0
- package/build/meta/promotionCardMeta.d.ts +129 -0
- package/build/meta/roleCardMeta.d.ts +3 -0
- package/build/meta/tabPaneMeta.d.ts +3 -0
- package/build/meta/userCardMeta.d.ts +3 -0
- package/build/meta.d.ts +605 -0
- package/build/setters/RestApiTester.d.ts +11 -0
- package/build/types/common.d.ts +17 -0
- package/build/types/marketing.d.ts +128 -0
- package/build/types/order.d.ts +174 -0
- package/build/types/permission.d.ts +101 -0
- package/build/types/product.d.ts +47 -0
- package/package.json +1 -0
- package/src/adapters/DataSourceAdapter.ts +445 -0
- package/src/components/AdminLayout/AdminLayout.scss +447 -0
- package/src/components/AdminLayout/AdminLayout.tsx +681 -0
- package/src/components/AdminLayout/Breadcrumb.tsx +60 -0
- package/src/components/AdminLayout/MainContent.tsx +54 -0
- package/src/components/AdminLayout/Navbar.tsx +76 -0
- package/src/components/AdminLayout/Sidebar.tsx +256 -0
- package/src/components/AdminLayout/TabBar.tsx +177 -0
- package/src/components/AdminLayout/TabPane.tsx +29 -0
- package/src/components/AdminLayout/index.ts +3 -0
- package/src/components/AdminLayout/types.ts +46 -0
- package/src/components/CouponCard/CouponCard.scss +55 -0
- package/src/components/CouponCard/CouponCard.tsx +687 -0
- package/src/components/CouponCard/index.ts +1 -0
- package/src/components/OrderForm/OrderForm.scss +148 -0
- package/src/components/OrderForm/OrderForm.tsx +503 -0
- package/src/components/OrderForm/index.ts +1 -0
- package/src/components/OrderList/OrderList.scss +160 -0
- package/src/components/OrderList/OrderList.tsx +885 -0
- package/src/components/OrderList/index.ts +1 -0
- package/src/components/ProductForm/ProductForm.scss +23 -0
- package/src/components/ProductForm/ProductForm.tsx +442 -0
- package/src/components/ProductForm/index.ts +3 -0
- package/src/components/ProductList/ProductList.scss +293 -0
- package/src/components/ProductList/ProductList.tsx +454 -0
- package/src/components/ProductList/index.ts +3 -0
- package/src/components/PromotionCard/PromotionCard.scss +71 -0
- package/src/components/PromotionCard/PromotionCard.tsx +579 -0
- package/src/components/PromotionCard/index.ts +1 -0
- package/src/components/RoleCard/RoleCard.scss +77 -0
- package/src/components/RoleCard/RoleCard.tsx +463 -0
- package/src/components/RoleCard/index.ts +1 -0
- package/src/components/UserCard/UserCard.scss +51 -0
- package/src/components/UserCard/UserCard.tsx +432 -0
- package/src/components/UserCard/index.ts +1 -0
- package/src/entry-components.ts +39 -0
- package/src/entry-meta.ts +23 -0
- package/src/index.scss +4 -0
- package/src/index.ts +36 -0
- package/src/index.tsx +17 -0
- package/src/meta/adminLayoutMeta.ts +154 -0
- package/src/meta/couponCardMeta.ts +287 -0
- package/src/meta/icons.ts +41 -0
- package/src/meta/orderFormMeta.ts +279 -0
- package/src/meta/orderListMeta.ts +443 -0
- package/src/meta/productFormMeta.ts +253 -0
- package/src/meta/productListMeta.ts +434 -0
- package/src/meta/promotionCardMeta.ts +276 -0
- package/src/meta/roleCardMeta.ts +142 -0
- package/src/meta/tabPaneMeta.ts +69 -0
- package/src/meta/userCardMeta.ts +128 -0
- package/src/meta.ts +25 -0
- package/src/setters/RestApiTester.tsx +219 -0
- package/src/shims/require.js +8 -0
- package/src/types/common.ts +19 -0
- package/src/types/marketing.ts +124 -0
- package/src/types/order.ts +169 -0
- package/src/types/permission.ts +102 -0
- package/src/types/product.ts +49 -0
|
@@ -0,0 +1,432 @@
|
|
|
1
|
+
import React, { useState, useEffect } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Card,
|
|
4
|
+
Button,
|
|
5
|
+
Tag,
|
|
6
|
+
Space,
|
|
7
|
+
Modal,
|
|
8
|
+
Form,
|
|
9
|
+
Input,
|
|
10
|
+
Select,
|
|
11
|
+
message,
|
|
12
|
+
Table,
|
|
13
|
+
Avatar,
|
|
14
|
+
Divider,
|
|
15
|
+
Switch,
|
|
16
|
+
} from 'antd'
|
|
17
|
+
import type { ColumnsType } from 'antd/es/table'
|
|
18
|
+
import {
|
|
19
|
+
PlusOutlined,
|
|
20
|
+
EditOutlined,
|
|
21
|
+
DeleteOutlined,
|
|
22
|
+
UserOutlined,
|
|
23
|
+
} from '@ant-design/icons'
|
|
24
|
+
import type { UmsAdmin } from '../../types/permission'
|
|
25
|
+
import { USER_STATUS, USER_STATUS_OPTIONS } from '../../types/permission'
|
|
26
|
+
import './UserCard.scss'
|
|
27
|
+
|
|
28
|
+
interface UserCardProps {
|
|
29
|
+
dataSource?: string
|
|
30
|
+
showCreateButton?: boolean
|
|
31
|
+
showFilter?: boolean
|
|
32
|
+
showStatistics?: boolean
|
|
33
|
+
onCreateUser?: (user: Partial<UmsAdmin>) => void
|
|
34
|
+
onEditUser?: (id: number, user: Partial<UmsAdmin>) => void
|
|
35
|
+
onDeleteUser?: (id: number) => void
|
|
36
|
+
onToggleStatus?: (id: number, status: number) => void
|
|
37
|
+
style?: React.CSSProperties
|
|
38
|
+
className?: string
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const UserCard: React.FC<UserCardProps> = ({
|
|
42
|
+
dataSource,
|
|
43
|
+
showCreateButton = true,
|
|
44
|
+
showFilter = true,
|
|
45
|
+
showStatistics = true,
|
|
46
|
+
onCreateUser,
|
|
47
|
+
onEditUser,
|
|
48
|
+
onDeleteUser,
|
|
49
|
+
onToggleStatus,
|
|
50
|
+
style,
|
|
51
|
+
className,
|
|
52
|
+
}) => {
|
|
53
|
+
const [loading, setLoading] = useState(false)
|
|
54
|
+
const [data, setData] = useState<UmsAdmin[]>([])
|
|
55
|
+
const [total, setTotal] = useState(0)
|
|
56
|
+
const [currentPage, setCurrentPage] = useState(1)
|
|
57
|
+
const [pageSize, setPageSize] = useState(10)
|
|
58
|
+
const [filterUsername, setFilterUsername] = useState('')
|
|
59
|
+
const [filterStatus, setFilterStatus] = useState<number>()
|
|
60
|
+
const [modalVisible, setModalVisible] = useState(false)
|
|
61
|
+
const [editingUser, setEditingUser] = useState<UmsAdmin | null>(null)
|
|
62
|
+
const [form] = Form.useForm()
|
|
63
|
+
|
|
64
|
+
const mockData: UmsAdmin[] = [
|
|
65
|
+
{
|
|
66
|
+
id: 1,
|
|
67
|
+
username: 'admin',
|
|
68
|
+
nickName: '超级管理员',
|
|
69
|
+
email: 'admin@example.com',
|
|
70
|
+
phone: '13800138000',
|
|
71
|
+
status: USER_STATUS.ENABLED,
|
|
72
|
+
createTime: '2024-01-01 10:00:00',
|
|
73
|
+
loginTime: '2024-04-02 09:30:00',
|
|
74
|
+
roleIds: [1],
|
|
75
|
+
roleNames: ['超级管理员'],
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
id: 2,
|
|
79
|
+
username: 'operator',
|
|
80
|
+
nickName: '运营人员',
|
|
81
|
+
email: 'operator@example.com',
|
|
82
|
+
phone: '13900139000',
|
|
83
|
+
status: USER_STATUS.ENABLED,
|
|
84
|
+
createTime: '2024-01-15 14:00:00',
|
|
85
|
+
loginTime: '2024-04-01 16:20:00',
|
|
86
|
+
roleIds: [2],
|
|
87
|
+
roleNames: ['运营'],
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
id: 3,
|
|
91
|
+
username: 'viewer',
|
|
92
|
+
nickName: '访客用户',
|
|
93
|
+
email: 'viewer@example.com',
|
|
94
|
+
phone: '13700137000',
|
|
95
|
+
status: USER_STATUS.DISABLED,
|
|
96
|
+
createTime: '2024-02-01 09:00:00',
|
|
97
|
+
loginTime: '2024-03-15 10:00:00',
|
|
98
|
+
roleIds: [3],
|
|
99
|
+
roleNames: ['访客'],
|
|
100
|
+
},
|
|
101
|
+
]
|
|
102
|
+
|
|
103
|
+
useEffect(() => {
|
|
104
|
+
fetchData()
|
|
105
|
+
}, [currentPage, pageSize])
|
|
106
|
+
|
|
107
|
+
const fetchData = async () => {
|
|
108
|
+
setLoading(true)
|
|
109
|
+
try {
|
|
110
|
+
await new Promise((resolve) => setTimeout(resolve, 500))
|
|
111
|
+
let filtered = [...mockData]
|
|
112
|
+
if (filterUsername) {
|
|
113
|
+
filtered = filtered.filter(
|
|
114
|
+
(item) =>
|
|
115
|
+
item.username.toLowerCase().includes(filterUsername.toLowerCase()) ||
|
|
116
|
+
item.nickName?.toLowerCase().includes(filterUsername.toLowerCase())
|
|
117
|
+
)
|
|
118
|
+
}
|
|
119
|
+
if (filterStatus !== undefined) {
|
|
120
|
+
filtered = filtered.filter((item) => item.status === filterStatus)
|
|
121
|
+
}
|
|
122
|
+
setData(filtered)
|
|
123
|
+
setTotal(filtered.length)
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error('Failed to fetch user list:', error)
|
|
126
|
+
message.error('获取用户列表失败')
|
|
127
|
+
} finally {
|
|
128
|
+
setLoading(false)
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
const handleSearch = () => {
|
|
133
|
+
setCurrentPage(1)
|
|
134
|
+
fetchData()
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
const handleReset = () => {
|
|
138
|
+
setFilterUsername('')
|
|
139
|
+
setFilterStatus(undefined)
|
|
140
|
+
setCurrentPage(1)
|
|
141
|
+
fetchData()
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
const handleCreate = () => {
|
|
145
|
+
setEditingUser(null)
|
|
146
|
+
form.resetFields()
|
|
147
|
+
setModalVisible(true)
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
const handleEdit = (record: UmsAdmin) => {
|
|
151
|
+
setEditingUser(record)
|
|
152
|
+
form.setFieldsValue(record)
|
|
153
|
+
setModalVisible(true)
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
const handleDelete = (id: number) => {
|
|
157
|
+
Modal.confirm({
|
|
158
|
+
title: '确认删除',
|
|
159
|
+
content: '确定要删除该用户吗?',
|
|
160
|
+
onOk: () => {
|
|
161
|
+
onDeleteUser?.(id)
|
|
162
|
+
message.success('删除成功')
|
|
163
|
+
fetchData()
|
|
164
|
+
},
|
|
165
|
+
})
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
const handleToggleStatus = (record: UmsAdmin) => {
|
|
169
|
+
const newStatus =
|
|
170
|
+
record.status === USER_STATUS.ENABLED ? USER_STATUS.DISABLED : USER_STATUS.ENABLED
|
|
171
|
+
onToggleStatus?.(record.id, newStatus)
|
|
172
|
+
message.success(newStatus === USER_STATUS.ENABLED ? '已启用' : '已禁用')
|
|
173
|
+
fetchData()
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
const handleSubmit = async () => {
|
|
177
|
+
try {
|
|
178
|
+
const values = await form.validateFields()
|
|
179
|
+
if (editingUser) {
|
|
180
|
+
onEditUser?.(editingUser.id, values)
|
|
181
|
+
message.success('编辑成功')
|
|
182
|
+
} else {
|
|
183
|
+
onCreateUser?.(values)
|
|
184
|
+
message.success('创建成功')
|
|
185
|
+
}
|
|
186
|
+
setModalVisible(false)
|
|
187
|
+
fetchData()
|
|
188
|
+
} catch (error) {
|
|
189
|
+
console.error('Validation failed:', error)
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
const getStatusTag = (status: number) => {
|
|
194
|
+
const statusMap: Record<number, { color: string; text: string }> = {
|
|
195
|
+
[USER_STATUS.ENABLED]: { color: 'success', text: '已启用' },
|
|
196
|
+
[USER_STATUS.DISABLED]: { color: 'default', text: '已禁用' },
|
|
197
|
+
}
|
|
198
|
+
const { color, text } = statusMap[status] || { color: 'default', text: '未知' }
|
|
199
|
+
return <Tag color={color}>{text}</Tag>
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
const columns: ColumnsType<UmsAdmin> = [
|
|
203
|
+
{
|
|
204
|
+
title: '用户信息',
|
|
205
|
+
key: 'userInfo',
|
|
206
|
+
width: 200,
|
|
207
|
+
render: (_, record) => (
|
|
208
|
+
<Space>
|
|
209
|
+
<Avatar icon={<UserOutlined />} style={{ backgroundColor: '#1890ff' }} />
|
|
210
|
+
<div>
|
|
211
|
+
<div className="user-name">{record.nickName || record.username}</div>
|
|
212
|
+
<div className="user-username">@{record.username}</div>
|
|
213
|
+
</div>
|
|
214
|
+
</Space>
|
|
215
|
+
),
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
title: '邮箱',
|
|
219
|
+
dataIndex: 'email',
|
|
220
|
+
key: 'email',
|
|
221
|
+
width: 180,
|
|
222
|
+
},
|
|
223
|
+
{
|
|
224
|
+
title: '手机号',
|
|
225
|
+
dataIndex: 'phone',
|
|
226
|
+
key: 'phone',
|
|
227
|
+
width: 130,
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
title: '角色',
|
|
231
|
+
dataIndex: 'roleNames',
|
|
232
|
+
key: 'roleNames',
|
|
233
|
+
width: 150,
|
|
234
|
+
render: (roleNames: string[]) => (
|
|
235
|
+
<Space wrap>
|
|
236
|
+
{roleNames?.map((name, index) => (
|
|
237
|
+
<Tag key={index} color="blue">
|
|
238
|
+
{name}
|
|
239
|
+
</Tag>
|
|
240
|
+
))}
|
|
241
|
+
</Space>
|
|
242
|
+
),
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
title: '状态',
|
|
246
|
+
dataIndex: 'status',
|
|
247
|
+
key: 'status',
|
|
248
|
+
width: 80,
|
|
249
|
+
render: (status: number) => getStatusTag(status),
|
|
250
|
+
},
|
|
251
|
+
{
|
|
252
|
+
title: '最后登录',
|
|
253
|
+
dataIndex: 'loginTime',
|
|
254
|
+
key: 'loginTime',
|
|
255
|
+
width: 160,
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
title: '操作',
|
|
259
|
+
key: 'action',
|
|
260
|
+
width: 180,
|
|
261
|
+
render: (_, record) => (
|
|
262
|
+
<Space>
|
|
263
|
+
<Button
|
|
264
|
+
type="link"
|
|
265
|
+
size="small"
|
|
266
|
+
icon={<EditOutlined />}
|
|
267
|
+
onClick={() => handleEdit(record)}
|
|
268
|
+
>
|
|
269
|
+
编辑
|
|
270
|
+
</Button>
|
|
271
|
+
<Button type="link" size="small" onClick={() => handleToggleStatus(record)}>
|
|
272
|
+
{record.status === USER_STATUS.ENABLED ? '禁用' : '启用'}
|
|
273
|
+
</Button>
|
|
274
|
+
<Button
|
|
275
|
+
type="link"
|
|
276
|
+
size="small"
|
|
277
|
+
danger
|
|
278
|
+
icon={<DeleteOutlined />}
|
|
279
|
+
onClick={() => handleDelete(record.id)}
|
|
280
|
+
>
|
|
281
|
+
删除
|
|
282
|
+
</Button>
|
|
283
|
+
</Space>
|
|
284
|
+
),
|
|
285
|
+
},
|
|
286
|
+
]
|
|
287
|
+
|
|
288
|
+
const statistics = {
|
|
289
|
+
totalUsers: mockData.length,
|
|
290
|
+
activeUsers: mockData.filter((u) => u.status === USER_STATUS.ENABLED).length,
|
|
291
|
+
disabledUsers: mockData.filter((u) => u.status === USER_STATUS.DISABLED).length,
|
|
292
|
+
}
|
|
293
|
+
|
|
294
|
+
return (
|
|
295
|
+
<div className={`mall-user-card ${className || ''}`} style={style}>
|
|
296
|
+
<Card>
|
|
297
|
+
{showStatistics && (
|
|
298
|
+
<div className="statistics-section">
|
|
299
|
+
<Space size="large">
|
|
300
|
+
<div className="stat-item">
|
|
301
|
+
<div className="stat-value">{statistics.totalUsers}</div>
|
|
302
|
+
<div className="stat-label">用户总数</div>
|
|
303
|
+
</div>
|
|
304
|
+
<Divider type="vertical" style={{ height: 40 }} />
|
|
305
|
+
<div className="stat-item">
|
|
306
|
+
<div className="stat-value" style={{ color: '#52c41a' }}>
|
|
307
|
+
{statistics.activeUsers}
|
|
308
|
+
</div>
|
|
309
|
+
<div className="stat-label">活跃用户</div>
|
|
310
|
+
</div>
|
|
311
|
+
<Divider type="vertical" style={{ height: 40 }} />
|
|
312
|
+
<div className="stat-item">
|
|
313
|
+
<div className="stat-value" style={{ color: '#8c8c8c' }}>
|
|
314
|
+
{statistics.disabledUsers}
|
|
315
|
+
</div>
|
|
316
|
+
<div className="stat-label">已禁用</div>
|
|
317
|
+
</div>
|
|
318
|
+
</Space>
|
|
319
|
+
</div>
|
|
320
|
+
)}
|
|
321
|
+
|
|
322
|
+
{showFilter && (
|
|
323
|
+
<div className="filter-section">
|
|
324
|
+
<Space wrap>
|
|
325
|
+
<Input
|
|
326
|
+
placeholder="用户名/昵称"
|
|
327
|
+
value={filterUsername}
|
|
328
|
+
onChange={(e) => setFilterUsername(e.target.value)}
|
|
329
|
+
style={{ width: 200 }}
|
|
330
|
+
/>
|
|
331
|
+
<Select
|
|
332
|
+
placeholder="用户状态"
|
|
333
|
+
value={filterStatus}
|
|
334
|
+
onChange={setFilterStatus}
|
|
335
|
+
style={{ width: 120 }}
|
|
336
|
+
allowClear
|
|
337
|
+
>
|
|
338
|
+
{USER_STATUS_OPTIONS.map((option) => (
|
|
339
|
+
<Select.Option key={option.value} value={option.value}>
|
|
340
|
+
{option.label}
|
|
341
|
+
</Select.Option>
|
|
342
|
+
))}
|
|
343
|
+
</Select>
|
|
344
|
+
<Button type="primary" onClick={handleSearch}>
|
|
345
|
+
查询
|
|
346
|
+
</Button>
|
|
347
|
+
<Button onClick={handleReset}>重置</Button>
|
|
348
|
+
</Space>
|
|
349
|
+
</div>
|
|
350
|
+
)}
|
|
351
|
+
|
|
352
|
+
{showCreateButton && (
|
|
353
|
+
<div className="action-section">
|
|
354
|
+
<Button type="primary" icon={<PlusOutlined />} onClick={handleCreate}>
|
|
355
|
+
创建用户
|
|
356
|
+
</Button>
|
|
357
|
+
</div>
|
|
358
|
+
)}
|
|
359
|
+
|
|
360
|
+
<Table
|
|
361
|
+
columns={columns}
|
|
362
|
+
dataSource={data}
|
|
363
|
+
rowKey="id"
|
|
364
|
+
loading={loading}
|
|
365
|
+
pagination={{
|
|
366
|
+
current: currentPage,
|
|
367
|
+
pageSize,
|
|
368
|
+
total,
|
|
369
|
+
showSizeChanger: true,
|
|
370
|
+
showQuickJumper: true,
|
|
371
|
+
showTotal: (total) => `共 ${total} 条`,
|
|
372
|
+
onChange: (page, pageSize) => {
|
|
373
|
+
setCurrentPage(page)
|
|
374
|
+
setPageSize(pageSize)
|
|
375
|
+
},
|
|
376
|
+
}}
|
|
377
|
+
/>
|
|
378
|
+
</Card>
|
|
379
|
+
|
|
380
|
+
<Modal
|
|
381
|
+
title={editingUser ? '编辑用户' : '创建用户'}
|
|
382
|
+
visible={modalVisible}
|
|
383
|
+
onOk={handleSubmit}
|
|
384
|
+
onCancel={() => setModalVisible(false)}
|
|
385
|
+
width={500}
|
|
386
|
+
>
|
|
387
|
+
<Form form={form} layout="vertical">
|
|
388
|
+
<Form.Item
|
|
389
|
+
name="username"
|
|
390
|
+
label="用户名"
|
|
391
|
+
rules={[{ required: true, message: '请输入用户名' }]}
|
|
392
|
+
>
|
|
393
|
+
<Input placeholder="请输入用户名" disabled={!!editingUser} />
|
|
394
|
+
</Form.Item>
|
|
395
|
+
<Form.Item
|
|
396
|
+
name="nickName"
|
|
397
|
+
label="昵称"
|
|
398
|
+
rules={[{ required: true, message: '请输入昵称' }]}
|
|
399
|
+
>
|
|
400
|
+
<Input placeholder="请输入昵称" />
|
|
401
|
+
</Form.Item>
|
|
402
|
+
<Form.Item
|
|
403
|
+
name="email"
|
|
404
|
+
label="邮箱"
|
|
405
|
+
rules={[
|
|
406
|
+
{ required: true, message: '请输入邮箱' },
|
|
407
|
+
{ type: 'email', message: '请输入有效的邮箱地址' },
|
|
408
|
+
]}
|
|
409
|
+
>
|
|
410
|
+
<Input placeholder="请输入邮箱" />
|
|
411
|
+
</Form.Item>
|
|
412
|
+
<Form.Item
|
|
413
|
+
name="phone"
|
|
414
|
+
label="手机号"
|
|
415
|
+
rules={[{ required: true, message: '请输入手机号' }]}
|
|
416
|
+
>
|
|
417
|
+
<Input placeholder="请输入手机号" />
|
|
418
|
+
</Form.Item>
|
|
419
|
+
<Form.Item name="status" label="状态" initialValue={USER_STATUS.ENABLED}>
|
|
420
|
+
<Switch
|
|
421
|
+
checkedChildren="启用"
|
|
422
|
+
unCheckedChildren="禁用"
|
|
423
|
+
defaultChecked
|
|
424
|
+
/>
|
|
425
|
+
</Form.Item>
|
|
426
|
+
</Form>
|
|
427
|
+
</Modal>
|
|
428
|
+
</div>
|
|
429
|
+
)
|
|
430
|
+
}
|
|
431
|
+
|
|
432
|
+
export default UserCard
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { default } from './UserCard'
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import ProductList from './components/ProductList'
|
|
2
|
+
import ProductForm from './components/ProductForm'
|
|
3
|
+
import OrderList from './components/OrderList'
|
|
4
|
+
import OrderForm from './components/OrderForm'
|
|
5
|
+
import CouponCard from './components/CouponCard'
|
|
6
|
+
import PromotionCard from './components/PromotionCard'
|
|
7
|
+
import UserCard from './components/UserCard'
|
|
8
|
+
import RoleCard from './components/RoleCard'
|
|
9
|
+
import { AdminLayout, TabPane } from './components/AdminLayout'
|
|
10
|
+
import RestApiTester from './setters/RestApiTester'
|
|
11
|
+
|
|
12
|
+
const MallComponents = {
|
|
13
|
+
ProductList,
|
|
14
|
+
ProductForm,
|
|
15
|
+
OrderList,
|
|
16
|
+
OrderForm,
|
|
17
|
+
CouponCard,
|
|
18
|
+
PromotionCard,
|
|
19
|
+
UserCard,
|
|
20
|
+
RoleCard,
|
|
21
|
+
AdminLayout,
|
|
22
|
+
TabPane,
|
|
23
|
+
RestApiTester
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default MallComponents
|
|
27
|
+
export {
|
|
28
|
+
ProductList,
|
|
29
|
+
ProductForm,
|
|
30
|
+
OrderList,
|
|
31
|
+
OrderForm,
|
|
32
|
+
CouponCard,
|
|
33
|
+
PromotionCard,
|
|
34
|
+
UserCard,
|
|
35
|
+
RoleCard,
|
|
36
|
+
AdminLayout,
|
|
37
|
+
TabPane,
|
|
38
|
+
RestApiTester
|
|
39
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import ProductListMeta from './meta/productListMeta'
|
|
2
|
+
import ProductFormMeta from './meta/productFormMeta'
|
|
3
|
+
import OrderListMeta from './meta/orderListMeta'
|
|
4
|
+
import OrderFormMeta from './meta/orderFormMeta'
|
|
5
|
+
import CouponCardMeta from './meta/couponCardMeta'
|
|
6
|
+
import PromotionCardMeta from './meta/promotionCardMeta'
|
|
7
|
+
import UserCardMeta from './meta/userCardMeta'
|
|
8
|
+
import RoleCardMeta from './meta/roleCardMeta'
|
|
9
|
+
import adminLayoutMeta from './meta/adminLayoutMeta'
|
|
10
|
+
import tabPaneMeta from './meta/tabPaneMeta'
|
|
11
|
+
|
|
12
|
+
export default [
|
|
13
|
+
ProductListMeta,
|
|
14
|
+
ProductFormMeta,
|
|
15
|
+
OrderListMeta,
|
|
16
|
+
OrderFormMeta,
|
|
17
|
+
CouponCardMeta,
|
|
18
|
+
PromotionCardMeta,
|
|
19
|
+
UserCardMeta,
|
|
20
|
+
RoleCardMeta,
|
|
21
|
+
adminLayoutMeta,
|
|
22
|
+
tabPaneMeta,
|
|
23
|
+
]
|
package/src/index.scss
ADDED
package/src/index.ts
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import ProductList from './components/ProductList'
|
|
2
|
+
import ProductForm from './components/ProductForm'
|
|
3
|
+
import OrderList from './components/OrderList'
|
|
4
|
+
import OrderForm from './components/OrderForm'
|
|
5
|
+
import CouponCard from './components/CouponCard'
|
|
6
|
+
import PromotionCard from './components/PromotionCard'
|
|
7
|
+
import UserCard from './components/UserCard'
|
|
8
|
+
import RoleCard from './components/RoleCard'
|
|
9
|
+
import { AdminLayout, TabPane } from './components/AdminLayout'
|
|
10
|
+
|
|
11
|
+
const MallComponents = {
|
|
12
|
+
ProductList,
|
|
13
|
+
ProductForm,
|
|
14
|
+
OrderList,
|
|
15
|
+
OrderForm,
|
|
16
|
+
CouponCard,
|
|
17
|
+
PromotionCard,
|
|
18
|
+
UserCard,
|
|
19
|
+
RoleCard,
|
|
20
|
+
AdminLayout,
|
|
21
|
+
TabPane,
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default MallComponents
|
|
25
|
+
export {
|
|
26
|
+
ProductList,
|
|
27
|
+
ProductForm,
|
|
28
|
+
OrderList,
|
|
29
|
+
OrderForm,
|
|
30
|
+
CouponCard,
|
|
31
|
+
PromotionCard,
|
|
32
|
+
UserCard,
|
|
33
|
+
RoleCard,
|
|
34
|
+
AdminLayout,
|
|
35
|
+
TabPane,
|
|
36
|
+
}
|
package/src/index.tsx
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import './components/ProductList'
|
|
2
|
+
import './components/ProductForm'
|
|
3
|
+
import './components/OrderList'
|
|
4
|
+
import './components/OrderForm'
|
|
5
|
+
import './components/CouponCard'
|
|
6
|
+
import './components/PromotionCard'
|
|
7
|
+
import './components/UserCard'
|
|
8
|
+
import './components/RoleCard'
|
|
9
|
+
|
|
10
|
+
export { default as ProductList } from './components/ProductList/ProductList'
|
|
11
|
+
export { default as ProductForm } from './components/ProductForm/ProductForm'
|
|
12
|
+
export { default as OrderList } from './components/OrderList/OrderList'
|
|
13
|
+
export { default as OrderForm } from './components/OrderForm/OrderForm'
|
|
14
|
+
export { default as CouponCard } from './components/CouponCard/CouponCard'
|
|
15
|
+
export { default as PromotionCard } from './components/PromotionCard/PromotionCard'
|
|
16
|
+
export { default as UserCard } from './components/UserCard/UserCard'
|
|
17
|
+
export { default as RoleCard } from './components/RoleCard/RoleCard'
|