|
@@ -1,36 +1,55 @@
|
1
|
1
|
import React from 'react';
|
2
|
|
-import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag } from 'antd';
|
|
2
|
+import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal } from 'antd';
|
3
|
3
|
import { FormattedMessage } from 'umi-plugin-react/locale';
|
4
|
4
|
import styles from '../style/GoodsList.less';
|
5
|
|
-const menu = (
|
6
|
|
- <Menu onClick={handleMenuClick}>
|
7
|
|
- <Menu.Item key="1">
|
8
|
|
- <Icon type="user" />
|
9
|
|
- 1st menu item
|
10
|
|
- </Menu.Item>
|
11
|
|
- <Menu.Item key="2">
|
12
|
|
- <Icon type="user" />
|
13
|
|
- 2nd menu item
|
14
|
|
- </Menu.Item>
|
15
|
|
- <Menu.Item key="3">
|
16
|
|
- <Icon type="user" />
|
17
|
|
- 3rd item
|
18
|
|
- </Menu.Item>
|
19
|
|
- </Menu>
|
20
|
|
-);
|
|
5
|
+import router from 'umi/router';
|
|
6
|
+
|
|
7
|
+const { Option } = Select;
|
|
8
|
+// 提交事件
|
|
9
|
+function handleSubmit(e, props) {
|
|
10
|
+ e.preventDefault();
|
|
11
|
+ props.form.validateFields((err, values) => {
|
|
12
|
+ if (!err) {
|
|
13
|
+ console.log('提交数据: ', values)
|
|
14
|
+ }
|
|
15
|
+ });
|
|
16
|
+}
|
|
17
|
+// Change 事件
|
|
18
|
+function handleSelectChange(props) {
|
|
19
|
+ console.log(props)
|
|
20
|
+}
|
|
21
|
+
|
|
22
|
+// 分页
|
|
23
|
+function onChange(pageNumber) {
|
|
24
|
+ console.log('Page: ', pageNumber);
|
|
25
|
+}
|
|
26
|
+// 跳转到编辑商品
|
|
27
|
+function toEditGoods() {
|
|
28
|
+ router.push({
|
|
29
|
+ pathname: '/activity/editActivity',
|
|
30
|
+ query: {
|
|
31
|
+ a: 'b',
|
|
32
|
+ },
|
|
33
|
+ });
|
|
34
|
+}
|
|
35
|
+
|
|
36
|
+/**
|
|
37
|
+ *
|
|
38
|
+ *
|
|
39
|
+ * @param {*} props
|
|
40
|
+ * @returns
|
|
41
|
+ */
|
|
42
|
+
|
21
|
43
|
const dataSource = [
|
22
|
44
|
{
|
23
|
45
|
key: '1',
|
24
|
46
|
img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
|
25
|
|
- name: '123',
|
26
|
|
- age: 32,
|
27
|
|
- address: '西湖区湖底公园1号',
|
|
47
|
+ name: '华为P30 Pro',
|
28
|
48
|
},
|
29
|
49
|
{
|
30
|
50
|
key: '2',
|
31
|
51
|
img: '',
|
32
|
|
- age: 42,
|
33
|
|
- address: '西湖区湖底公园1号',
|
|
52
|
+ name: '大米',
|
34
|
53
|
},
|
35
|
54
|
];
|
36
|
55
|
|
|
@@ -40,7 +59,6 @@ const columns = [
|
40
|
59
|
dataIndex: 'img',
|
41
|
60
|
key: 'img',
|
42
|
61
|
align: 'center',
|
43
|
|
-
|
44
|
62
|
render: (text, record) => <img src={record.img} className={styles.touxiang} />,
|
45
|
63
|
},
|
46
|
64
|
{
|
|
@@ -48,7 +66,7 @@ const columns = [
|
48
|
66
|
dataIndex: 'name',
|
49
|
67
|
key: 'name',
|
50
|
68
|
align: 'center',
|
51
|
|
- render: text => <a>{text}</a>,
|
|
69
|
+
|
52
|
70
|
},
|
53
|
71
|
{
|
54
|
72
|
title: '所属积分',
|
|
@@ -85,36 +103,85 @@ const columns = [
|
85
|
103
|
dataIndex: 'handle',
|
86
|
104
|
key: 'handle',
|
87
|
105
|
align: 'center',
|
88
|
|
- render: () => <a>Delete</a>,
|
|
106
|
+ render: () => <><span style={{ color: '#1990FF', marginRight: '20px' }} onClick={confirm}>下架<Icon type="shopping-cart" className={styles.shoppingCart} /></span><span style={{ color: '#FF925C' }}>编辑<Icon type="form" className={styles.edit} /></span></>,
|
89
|
107
|
},
|
90
|
108
|
];
|
|
109
|
+const confirm = () => {
|
|
110
|
+ Modal.confirm({
|
|
111
|
+ title: '确认下架该商品?',
|
|
112
|
+ okText: '确认',
|
|
113
|
+ cancelText: '取消',
|
|
114
|
+ onOk() {
|
|
115
|
+ console.log('OK');
|
|
116
|
+ },
|
|
117
|
+ onCancel() {
|
|
118
|
+ console.log('Cancel');
|
|
119
|
+ },
|
|
120
|
+ });
|
91
|
121
|
|
92
|
|
-export default () => (
|
93
|
|
- <>
|
94
|
|
- <div className={styles.searchBox}>
|
95
|
|
- <Input placeholder="商品名称" className={styles.searchItem} />
|
96
|
|
- <Dropdown overlay={menu} className={styles.searchItem}>
|
97
|
|
- <Button>
|
98
|
|
- Button <Icon type="down" />
|
99
|
|
- </Button>
|
100
|
|
- </Dropdown>
|
101
|
|
- <Dropdown overlay={menu} className={styles.searchItem}>
|
102
|
|
- <Button>
|
103
|
|
- Button <Icon type="down" />
|
104
|
|
- </Button>
|
105
|
|
- </Dropdown>
|
106
|
|
- <Input placeholder="商品名称" className={styles.searchItem} />
|
107
|
|
- <Input placeholder="商品名称" className={styles.searchItem} />
|
108
|
|
- <Button type="primary" size="small">
|
109
|
|
- 查询
|
110
|
|
- </Button>
|
111
|
|
- </div>
|
112
|
|
- <Button className={styles.addBtn}>新增</Button>
|
113
|
|
- <Table dataSource={dataSource} columns={columns} />
|
114
|
|
- </>
|
115
|
|
-);
|
|
122
|
+}
|
|
123
|
+
|
|
124
|
+const header = (props) => {
|
|
125
|
+ const { getFieldDecorator } = props.form
|
|
126
|
+ return (
|
116
|
127
|
|
117
|
|
-function handleMenuClick(e) {
|
118
|
|
- message.info('Click on menu item.');
|
119
|
|
- console.log('click', e);
|
|
128
|
+ <>
|
|
129
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
130
|
+ <Form.Item>
|
|
131
|
+ {getFieldDecorator('name')(
|
|
132
|
+ <Input
|
|
133
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
134
|
+ placeholder="商品名称"
|
|
135
|
+ />,
|
|
136
|
+ )}
|
|
137
|
+ </Form.Item>
|
|
138
|
+ <Form.Item>
|
|
139
|
+ {getFieldDecorator('goodState')(
|
|
140
|
+ <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
|
|
141
|
+ <Option value="1">上架</Option>
|
|
142
|
+ <Option value="0">下架</Option>
|
|
143
|
+ </Select>,
|
|
144
|
+ )}
|
|
145
|
+ </Form.Item>
|
|
146
|
+ <Form.Item>
|
|
147
|
+ {getFieldDecorator('isMain')(
|
|
148
|
+ <Select style={{ width: '180px' }} placeholder="所属项目" onChange={handleSelectChange}>
|
|
149
|
+ <Option value="1">首页推荐</Option>
|
|
150
|
+ <Option value="0">首页未推荐</Option>
|
|
151
|
+ </Select>,
|
|
152
|
+ )}
|
|
153
|
+ </Form.Item>
|
|
154
|
+ <Form.Item>
|
|
155
|
+ {getFieldDecorator('min')(
|
|
156
|
+ <Input
|
|
157
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
158
|
+ placeholder="最小积分"
|
|
159
|
+ />,
|
|
160
|
+ )}
|
|
161
|
+ </Form.Item>
|
|
162
|
+ <Form.Item>
|
|
163
|
+ {getFieldDecorator('max')(
|
|
164
|
+ <Input
|
|
165
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
166
|
+ placeholder="最大积分"
|
|
167
|
+ />,
|
|
168
|
+ )}
|
|
169
|
+ </Form.Item>
|
|
170
|
+ <Form.Item>
|
|
171
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
172
|
+ 搜索
|
|
173
|
+ </Button>
|
|
174
|
+ </Form.Item>
|
|
175
|
+ </Form>
|
|
176
|
+ <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
|
|
177
|
+ <Table dataSource={dataSource} columns={columns} />
|
|
178
|
+ {/* 分页 */
|
|
179
|
+ /* <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
180
|
+ <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
|
|
181
|
+ </div> */}
|
|
182
|
+ </>
|
|
183
|
+ )
|
120
|
184
|
}
|
|
185
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
|
186
|
+
|
|
187
|
+export default WrappedHeader
|