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 @@
|
|
|
1
|
+
export { default } from './OrderList'
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
.mall-product-form {
|
|
2
|
+
.ant-card-body {
|
|
3
|
+
padding: 24px;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.ant-form-item {
|
|
7
|
+
margin-bottom: 16px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.ant-form-item-label {
|
|
11
|
+
label {
|
|
12
|
+
font-weight: 500;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.ant-input-number {
|
|
17
|
+
width: 100%;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
.ant-select {
|
|
21
|
+
width: 100%;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -0,0 +1,442 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import { Form, Input, InputNumber, Select, Button, Card, Space, message, Switch, Divider, Row, Col, Tabs } from 'antd'
|
|
3
|
+
import type { PmsProduct } from '../../types/product'
|
|
4
|
+
import './ProductForm.scss'
|
|
5
|
+
|
|
6
|
+
interface ProductFormProps {
|
|
7
|
+
initialValues?: string | Partial<PmsProduct>
|
|
8
|
+
mode?: 'create' | 'edit' | 'view'
|
|
9
|
+
showBasicInfo?: boolean
|
|
10
|
+
showPriceInfo?: boolean
|
|
11
|
+
showStockInfo?: boolean
|
|
12
|
+
showStatusInfo?: boolean
|
|
13
|
+
showDescription?: boolean
|
|
14
|
+
onSubmit?: (values: PmsProduct) => void
|
|
15
|
+
onCancel?: () => void
|
|
16
|
+
style?: React.CSSProperties
|
|
17
|
+
className?: string
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
const ProductForm: React.FC<ProductFormProps> = ({
|
|
21
|
+
initialValues,
|
|
22
|
+
mode = 'create',
|
|
23
|
+
showBasicInfo = true,
|
|
24
|
+
showPriceInfo = true,
|
|
25
|
+
showStockInfo = true,
|
|
26
|
+
showStatusInfo = true,
|
|
27
|
+
showDescription = true,
|
|
28
|
+
onSubmit,
|
|
29
|
+
onCancel,
|
|
30
|
+
style,
|
|
31
|
+
className,
|
|
32
|
+
}) => {
|
|
33
|
+
const [form] = Form.useForm()
|
|
34
|
+
const [activeTab, setActiveTab] = useState('basic')
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
if (initialValues) {
|
|
38
|
+
let parsedValues = initialValues
|
|
39
|
+
if (typeof initialValues === 'string') {
|
|
40
|
+
try {
|
|
41
|
+
parsedValues = JSON.parse(initialValues)
|
|
42
|
+
} catch (e) {
|
|
43
|
+
console.error('Failed to parse initialValues:', e)
|
|
44
|
+
parsedValues = {}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
form.setFieldsValue(parsedValues as any)
|
|
48
|
+
}
|
|
49
|
+
}, [initialValues, form])
|
|
50
|
+
|
|
51
|
+
const handleSubmit = async () => {
|
|
52
|
+
try {
|
|
53
|
+
const values = await form.validateFields()
|
|
54
|
+
onSubmit?.(values as PmsProduct)
|
|
55
|
+
message.success('提交成功')
|
|
56
|
+
} catch (error) {
|
|
57
|
+
console.error('Validation failed:', error)
|
|
58
|
+
message.error('请检查表单填写是否正确')
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
const handleCancel = () => {
|
|
63
|
+
form.resetFields()
|
|
64
|
+
onCancel?.()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
const handleReset = () => {
|
|
68
|
+
form.resetFields()
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const getParsedInitialValues = () => {
|
|
72
|
+
if (typeof initialValues === 'string') {
|
|
73
|
+
try {
|
|
74
|
+
return JSON.parse(initialValues)
|
|
75
|
+
} catch (e) {
|
|
76
|
+
return {}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return initialValues || {}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const isViewMode = mode === 'view'
|
|
83
|
+
|
|
84
|
+
const basicInfoItems = [
|
|
85
|
+
<Row gutter={16} key="basic-row-1">
|
|
86
|
+
<Col span={12}>
|
|
87
|
+
<Form.Item
|
|
88
|
+
name="name"
|
|
89
|
+
label="商品名称"
|
|
90
|
+
rules={[{ required: true, message: '请输入商品名称' }]}
|
|
91
|
+
>
|
|
92
|
+
<Input placeholder="请输入商品名称" disabled={isViewMode} />
|
|
93
|
+
</Form.Item>
|
|
94
|
+
</Col>
|
|
95
|
+
<Col span={12}>
|
|
96
|
+
<Form.Item
|
|
97
|
+
name="productSn"
|
|
98
|
+
label="商品货号"
|
|
99
|
+
rules={[{ required: true, message: '请输入商品货号' }]}
|
|
100
|
+
>
|
|
101
|
+
<Input placeholder="请输入商品货号" disabled={isViewMode} />
|
|
102
|
+
</Form.Item>
|
|
103
|
+
</Col>
|
|
104
|
+
</Row>,
|
|
105
|
+
|
|
106
|
+
<Row gutter={16} key="basic-row-2">
|
|
107
|
+
<Col span={12}>
|
|
108
|
+
<Form.Item
|
|
109
|
+
name="brandName"
|
|
110
|
+
label="品牌名称"
|
|
111
|
+
>
|
|
112
|
+
<Input placeholder="请输入品牌名称" disabled={isViewMode} />
|
|
113
|
+
</Form.Item>
|
|
114
|
+
</Col>
|
|
115
|
+
<Col span={12}>
|
|
116
|
+
<Form.Item
|
|
117
|
+
name="productCategoryName"
|
|
118
|
+
label="商品分类"
|
|
119
|
+
>
|
|
120
|
+
<Select placeholder="请选择商品分类" disabled={isViewMode}>
|
|
121
|
+
<Select.Option value="手机">手机</Select.Option>
|
|
122
|
+
<Select.Option value="笔记本">笔记本</Select.Option>
|
|
123
|
+
<Select.Option value="平板">平板</Select.Option>
|
|
124
|
+
<Select.Option value="耳机">耳机</Select.Option>
|
|
125
|
+
<Select.Option value="手表">手表</Select.Option>
|
|
126
|
+
<Select.Option value="衣服">衣服</Select.Option>
|
|
127
|
+
<Select.Option value="鞋子">鞋子</Select.Option>
|
|
128
|
+
<Select.Option value="配饰">配饰</Select.Option>
|
|
129
|
+
<Select.Option value="数码">数码</Select.Option>
|
|
130
|
+
</Select>
|
|
131
|
+
</Form.Item>
|
|
132
|
+
</Col>
|
|
133
|
+
</Row>,
|
|
134
|
+
|
|
135
|
+
<Form.Item
|
|
136
|
+
key="pic"
|
|
137
|
+
name="pic"
|
|
138
|
+
label="商品图片"
|
|
139
|
+
>
|
|
140
|
+
<Input placeholder="请输入商品图片 URL" disabled={isViewMode} />
|
|
141
|
+
</Form.Item>,
|
|
142
|
+
|
|
143
|
+
<Row gutter={16} key="basic-row-3">
|
|
144
|
+
<Col span={12}>
|
|
145
|
+
<Form.Item
|
|
146
|
+
name="subTitle"
|
|
147
|
+
label="商品副标题"
|
|
148
|
+
>
|
|
149
|
+
<Input placeholder="请输入商品副标题" disabled={isViewMode} />
|
|
150
|
+
</Form.Item>
|
|
151
|
+
</Col>
|
|
152
|
+
<Col span={12}>
|
|
153
|
+
<Form.Item
|
|
154
|
+
name="keywords"
|
|
155
|
+
label="商品关键词"
|
|
156
|
+
>
|
|
157
|
+
<Input placeholder="多个关键词用逗号分隔" disabled={isViewMode} />
|
|
158
|
+
</Form.Item>
|
|
159
|
+
</Col>
|
|
160
|
+
</Row>,
|
|
161
|
+
]
|
|
162
|
+
|
|
163
|
+
const priceInfoItems = [
|
|
164
|
+
<Row gutter={16} key="price-row-1">
|
|
165
|
+
<Col span={12}>
|
|
166
|
+
<Form.Item
|
|
167
|
+
name="price"
|
|
168
|
+
label="商品价格"
|
|
169
|
+
rules={[{ required: true, message: '请输入商品价格' }]}
|
|
170
|
+
>
|
|
171
|
+
<InputNumber
|
|
172
|
+
placeholder="请输入商品价格"
|
|
173
|
+
style={{ width: '100%' }}
|
|
174
|
+
min={0}
|
|
175
|
+
precision={2}
|
|
176
|
+
prefix="¥"
|
|
177
|
+
disabled={isViewMode}
|
|
178
|
+
/>
|
|
179
|
+
</Form.Item>
|
|
180
|
+
</Col>
|
|
181
|
+
<Col span={12}>
|
|
182
|
+
<Form.Item
|
|
183
|
+
name="originalPrice"
|
|
184
|
+
label="原价"
|
|
185
|
+
>
|
|
186
|
+
<InputNumber
|
|
187
|
+
placeholder="请输入原价"
|
|
188
|
+
style={{ width: '100%' }}
|
|
189
|
+
min={0}
|
|
190
|
+
precision={2}
|
|
191
|
+
prefix="¥"
|
|
192
|
+
disabled={isViewMode}
|
|
193
|
+
/>
|
|
194
|
+
</Form.Item>
|
|
195
|
+
</Col>
|
|
196
|
+
</Row>,
|
|
197
|
+
|
|
198
|
+
<Row gutter={16} key="price-row-2">
|
|
199
|
+
<Col span={12}>
|
|
200
|
+
<Form.Item
|
|
201
|
+
name="promotionPrice"
|
|
202
|
+
label="促销价"
|
|
203
|
+
>
|
|
204
|
+
<InputNumber
|
|
205
|
+
placeholder="请输入促销价"
|
|
206
|
+
style={{ width: '100%' }}
|
|
207
|
+
min={0}
|
|
208
|
+
precision={2}
|
|
209
|
+
prefix="¥"
|
|
210
|
+
disabled={isViewMode}
|
|
211
|
+
/>
|
|
212
|
+
</Form.Item>
|
|
213
|
+
</Col>
|
|
214
|
+
<Col span={12}>
|
|
215
|
+
<Form.Item
|
|
216
|
+
name="unit"
|
|
217
|
+
label="商品单位"
|
|
218
|
+
>
|
|
219
|
+
<Select placeholder="请选择商品单位" disabled={isViewMode}>
|
|
220
|
+
<Select.Option value="件">件</Select.Option>
|
|
221
|
+
<Select.Option value="台">台</Select.Option>
|
|
222
|
+
<Select.Option value="部">部</Select.Option>
|
|
223
|
+
<Select.Option value="块">块</Select.Option>
|
|
224
|
+
<Select.Option value="副">副</Select.Option>
|
|
225
|
+
</Select>
|
|
226
|
+
</Form.Item>
|
|
227
|
+
</Col>
|
|
228
|
+
</Row>,
|
|
229
|
+
]
|
|
230
|
+
|
|
231
|
+
const stockInfoItems = [
|
|
232
|
+
<Row gutter={16} key="stock-row-1">
|
|
233
|
+
<Col span={12}>
|
|
234
|
+
<Form.Item
|
|
235
|
+
name="stock"
|
|
236
|
+
label="商品库存"
|
|
237
|
+
rules={[{ required: true, message: '请输入商品库存' }]}
|
|
238
|
+
>
|
|
239
|
+
<InputNumber
|
|
240
|
+
placeholder="请输入商品库存"
|
|
241
|
+
style={{ width: '100%' }}
|
|
242
|
+
min={0}
|
|
243
|
+
disabled={isViewMode}
|
|
244
|
+
/>
|
|
245
|
+
</Form.Item>
|
|
246
|
+
</Col>
|
|
247
|
+
<Col span={12}>
|
|
248
|
+
<Form.Item
|
|
249
|
+
name="lowStock"
|
|
250
|
+
label="库存预警值"
|
|
251
|
+
>
|
|
252
|
+
<InputNumber
|
|
253
|
+
placeholder="请输入库存预警值"
|
|
254
|
+
style={{ width: '100%' }}
|
|
255
|
+
min={0}
|
|
256
|
+
disabled={isViewMode}
|
|
257
|
+
/>
|
|
258
|
+
</Form.Item>
|
|
259
|
+
</Col>
|
|
260
|
+
</Row>,
|
|
261
|
+
|
|
262
|
+
<Row gutter={16} key="stock-row-2">
|
|
263
|
+
<Col span={12}>
|
|
264
|
+
<Form.Item
|
|
265
|
+
name="weight"
|
|
266
|
+
label="商品重量(kg)"
|
|
267
|
+
>
|
|
268
|
+
<InputNumber
|
|
269
|
+
placeholder="请输入商品重量"
|
|
270
|
+
style={{ width: '100%' }}
|
|
271
|
+
min={0}
|
|
272
|
+
precision={2}
|
|
273
|
+
disabled={isViewMode}
|
|
274
|
+
/>
|
|
275
|
+
</Form.Item>
|
|
276
|
+
</Col>
|
|
277
|
+
<Col span={12}>
|
|
278
|
+
<Form.Item
|
|
279
|
+
name="sort"
|
|
280
|
+
label="排序"
|
|
281
|
+
>
|
|
282
|
+
<InputNumber
|
|
283
|
+
placeholder="请输入排序"
|
|
284
|
+
style={{ width: '100%' }}
|
|
285
|
+
min={0}
|
|
286
|
+
disabled={isViewMode}
|
|
287
|
+
/>
|
|
288
|
+
</Form.Item>
|
|
289
|
+
</Col>
|
|
290
|
+
</Row>,
|
|
291
|
+
]
|
|
292
|
+
|
|
293
|
+
const statusInfoItems = [
|
|
294
|
+
<Row gutter={16} key="status-row-1">
|
|
295
|
+
<Col span={8}>
|
|
296
|
+
<Form.Item
|
|
297
|
+
name="publishStatus"
|
|
298
|
+
label="上架状态"
|
|
299
|
+
valuePropName="checked"
|
|
300
|
+
getValueFromEvent={(checked: boolean) => checked ? 1 : 0}
|
|
301
|
+
getValueProps={(value: number) => ({ checked: value === 1 })}
|
|
302
|
+
>
|
|
303
|
+
<Switch checkedChildren="上架" unCheckedChildren="下架" disabled={isViewMode} />
|
|
304
|
+
</Form.Item>
|
|
305
|
+
</Col>
|
|
306
|
+
<Col span={8}>
|
|
307
|
+
<Form.Item
|
|
308
|
+
name="newStatus"
|
|
309
|
+
label="新品状态"
|
|
310
|
+
valuePropName="checked"
|
|
311
|
+
getValueFromEvent={(checked: boolean) => checked ? 1 : 0}
|
|
312
|
+
getValueProps={(value: number) => ({ checked: value === 1 })}
|
|
313
|
+
>
|
|
314
|
+
<Switch checkedChildren="是" unCheckedChildren="否" disabled={isViewMode} />
|
|
315
|
+
</Form.Item>
|
|
316
|
+
</Col>
|
|
317
|
+
<Col span={8}>
|
|
318
|
+
<Form.Item
|
|
319
|
+
name="recommandStatus"
|
|
320
|
+
label="推荐状态"
|
|
321
|
+
valuePropName="checked"
|
|
322
|
+
getValueFromEvent={(checked: boolean) => checked ? 1 : 0}
|
|
323
|
+
getValueProps={(value: number) => ({ checked: value === 1 })}
|
|
324
|
+
>
|
|
325
|
+
<Switch checkedChildren="是" unCheckedChildren="否" disabled={isViewMode} />
|
|
326
|
+
</Form.Item>
|
|
327
|
+
</Col>
|
|
328
|
+
</Row>,
|
|
329
|
+
|
|
330
|
+
<Row gutter={16} key="status-row-2">
|
|
331
|
+
<Col span={12}>
|
|
332
|
+
<Form.Item
|
|
333
|
+
name="verifyStatus"
|
|
334
|
+
label="审核状态"
|
|
335
|
+
valuePropName="checked"
|
|
336
|
+
getValueFromEvent={(checked: boolean) => checked ? 1 : 0}
|
|
337
|
+
getValueProps={(value: number) => ({ checked: value === 1 })}
|
|
338
|
+
>
|
|
339
|
+
<Switch checkedChildren="已审核" unCheckedChildren="未审核" disabled={isViewMode} />
|
|
340
|
+
</Form.Item>
|
|
341
|
+
</Col>
|
|
342
|
+
<Col span={12}>
|
|
343
|
+
<Form.Item
|
|
344
|
+
name="deleteStatus"
|
|
345
|
+
label="删除状态"
|
|
346
|
+
valuePropName="checked"
|
|
347
|
+
getValueFromEvent={(checked: boolean) => checked ? 1 : 0}
|
|
348
|
+
getValueProps={(value: number) => ({ checked: value === 1 })}
|
|
349
|
+
>
|
|
350
|
+
<Switch checkedChildren="已删除" unCheckedChildren="正常" disabled={isViewMode} />
|
|
351
|
+
</Form.Item>
|
|
352
|
+
</Col>
|
|
353
|
+
</Row>,
|
|
354
|
+
]
|
|
355
|
+
|
|
356
|
+
const descriptionItems = [
|
|
357
|
+
<Form.Item
|
|
358
|
+
key="description"
|
|
359
|
+
name="description"
|
|
360
|
+
label="商品描述"
|
|
361
|
+
>
|
|
362
|
+
<Input.TextArea rows={4} placeholder="请输入商品描述" disabled={isViewMode} />
|
|
363
|
+
</Form.Item>,
|
|
364
|
+
|
|
365
|
+
<Form.Item
|
|
366
|
+
key="note"
|
|
367
|
+
name="note"
|
|
368
|
+
label="备注"
|
|
369
|
+
>
|
|
370
|
+
<Input.TextArea rows={2} placeholder="请输入备注" disabled={isViewMode} />
|
|
371
|
+
</Form.Item>,
|
|
372
|
+
]
|
|
373
|
+
|
|
374
|
+
const tabItems = [
|
|
375
|
+
{
|
|
376
|
+
key: 'basic',
|
|
377
|
+
label: '基本信息',
|
|
378
|
+
children: showBasicInfo ? basicInfoItems : null,
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
key: 'price',
|
|
382
|
+
label: '价格信息',
|
|
383
|
+
children: showPriceInfo ? priceInfoItems : null,
|
|
384
|
+
},
|
|
385
|
+
{
|
|
386
|
+
key: 'stock',
|
|
387
|
+
label: '库存信息',
|
|
388
|
+
children: showStockInfo ? stockInfoItems : null,
|
|
389
|
+
},
|
|
390
|
+
{
|
|
391
|
+
key: 'status',
|
|
392
|
+
label: '状态信息',
|
|
393
|
+
children: showStatusInfo ? statusInfoItems : null,
|
|
394
|
+
},
|
|
395
|
+
{
|
|
396
|
+
key: 'description',
|
|
397
|
+
label: '描述信息',
|
|
398
|
+
children: showDescription ? descriptionItems : null,
|
|
399
|
+
},
|
|
400
|
+
]
|
|
401
|
+
|
|
402
|
+
return (
|
|
403
|
+
<div className={`mall-product-form ${className || ''}`} style={style}>
|
|
404
|
+
<Card>
|
|
405
|
+
<Form
|
|
406
|
+
form={form}
|
|
407
|
+
layout="vertical"
|
|
408
|
+
initialValues={getParsedInitialValues()}
|
|
409
|
+
disabled={isViewMode}
|
|
410
|
+
>
|
|
411
|
+
<Tabs
|
|
412
|
+
activeKey={activeTab}
|
|
413
|
+
onChange={setActiveTab}
|
|
414
|
+
items={tabItems}
|
|
415
|
+
/>
|
|
416
|
+
|
|
417
|
+
<Divider />
|
|
418
|
+
|
|
419
|
+
<Form.Item>
|
|
420
|
+
<Space>
|
|
421
|
+
{!isViewMode && (
|
|
422
|
+
<>
|
|
423
|
+
<Button type="primary" onClick={handleSubmit}>
|
|
424
|
+
{mode === 'create' ? '创建' : '保存'}
|
|
425
|
+
</Button>
|
|
426
|
+
<Button onClick={handleReset}>
|
|
427
|
+
重置
|
|
428
|
+
</Button>
|
|
429
|
+
</>
|
|
430
|
+
)}
|
|
431
|
+
<Button onClick={handleCancel}>
|
|
432
|
+
{isViewMode ? '关闭' : '取消'}
|
|
433
|
+
</Button>
|
|
434
|
+
</Space>
|
|
435
|
+
</Form.Item>
|
|
436
|
+
</Form>
|
|
437
|
+
</Card>
|
|
438
|
+
</div>
|
|
439
|
+
)
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
export default ProductForm
|