|
@@ -1,72 +1,45 @@
|
1
|
1
|
import React from 'react';
|
2
|
|
-import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Pagination, Modal } 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
|
+import router from 'umi/router';
|
5
|
6
|
|
6
|
|
-class StateDropdown extends React.Component {
|
7
|
|
- state = {
|
8
|
|
- goodState: '状态',
|
9
|
|
- }
|
10
|
|
-
|
11
|
|
- render() {
|
12
|
|
-
|
13
|
|
- const menu = (
|
14
|
|
- <Menu onClick={this.handleMenuClick}>
|
15
|
|
- <Menu.Item key="1">
|
16
|
|
- 上架
|
17
|
|
- </Menu.Item>
|
18
|
|
- <Menu.Item key="2">
|
19
|
|
- 下架
|
20
|
|
- </Menu.Item>
|
21
|
|
- </Menu>
|
22
|
|
- );
|
23
|
|
- return (
|
24
|
|
- < Dropdown overlay={menu} className={styles.searchItem} >
|
25
|
|
- <Button>
|
26
|
|
- {this.state.goodState} <Icon type="down" />
|
27
|
|
- </Button>
|
28
|
|
- </Dropdown>
|
29
|
|
- )
|
30
|
|
- }
|
31
|
|
- handleMenuClick = e => {
|
32
|
|
- this.setState({
|
33
|
|
- goodState: e.item.props.children,
|
34
|
|
- });
|
35
|
|
-
|
36
|
|
- }
|
37
|
|
-};
|
38
|
|
-class App extends React.Component {
|
39
|
|
- state = {
|
40
|
|
- good: '请选择',
|
41
|
|
- }
|
|
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
|
+}
|
42
|
21
|
|
43
|
|
- render() {
|
|
22
|
+// 分页
|
|
23
|
+function onChange(pageNumber) {
|
|
24
|
+ console.log('Page: ', pageNumber);
|
|
25
|
+}
|
|
26
|
+// 跳转到编辑商品
|
|
27
|
+function toEditGoods() {
|
|
28
|
+ router.push({
|
|
29
|
+ pathname: '/integralMall/editGoods',
|
|
30
|
+ query: {
|
|
31
|
+ a: 'b',
|
|
32
|
+ },
|
|
33
|
+ });
|
|
34
|
+}
|
44
|
35
|
|
45
|
|
- const menu = (
|
46
|
|
- <Menu onClick={this.handleMenuClick}>
|
47
|
|
- <Menu.Item key="1">
|
48
|
|
- 上架2
|
49
|
|
- </Menu.Item>
|
50
|
|
- <Menu.Item key="2">
|
51
|
|
- 下架2
|
52
|
|
- </Menu.Item>
|
53
|
|
- </Menu>
|
54
|
|
- );
|
55
|
|
- return (
|
56
|
|
- < Dropdown overlay={menu} className={styles.searchItem} >
|
57
|
|
- <Button>
|
58
|
|
- {this.state.good} <Icon type="down" />
|
59
|
|
- </Button>
|
60
|
|
- </Dropdown>
|
61
|
|
- )
|
62
|
|
- }
|
63
|
|
- handleMenuClick = e => {
|
64
|
|
- this.setState({
|
65
|
|
- good: e.item.props.children,
|
66
|
|
- });
|
|
36
|
+/**
|
|
37
|
+ *
|
|
38
|
+ *
|
|
39
|
+ * @param {*} props
|
|
40
|
+ * @returns
|
|
41
|
+ */
|
67
|
42
|
|
68
|
|
- }
|
69
|
|
-};
|
70
|
43
|
const dataSource = [
|
71
|
44
|
{
|
72
|
45
|
key: '1',
|
|
@@ -147,20 +120,67 @@ function confirm() {
|
147
|
120
|
});
|
148
|
121
|
|
149
|
122
|
}
|
150
|
|
-export default () => (
|
151
|
|
- <>
|
152
|
|
- <div className={styles.searchBox}>
|
153
|
|
- <Input placeholder="商品名称" className={styles.searchItem} />
|
154
|
|
- <StateDropdown />
|
155
|
|
- <App />
|
156
|
|
- <Input placeholder="最小积分" className={styles.searchItem} />
|
157
|
|
- <Input placeholder="最大积分" className={styles.searchItem} />
|
158
|
|
- <Button type="primary" className={styles.searchBtn}>
|
159
|
|
- 查询
|
160
|
|
- </Button>
|
161
|
|
- </div>
|
162
|
|
- <Button type="primary" className={styles.addBtn}>新增</Button>
|
163
|
|
- <Table dataSource={dataSource} columns={columns} />
|
|
123
|
+function header(props) {
|
|
124
|
+ const { getFieldDecorator } = props.form
|
|
125
|
+ return (
|
|
126
|
+
|
|
127
|
+ <>
|
|
128
|
+ <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
|
|
129
|
+ <Form.Item>
|
|
130
|
+ {getFieldDecorator('name')(
|
|
131
|
+ <Input
|
|
132
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
133
|
+ placeholder="商品名称"
|
|
134
|
+ />,
|
|
135
|
+ )}
|
|
136
|
+ </Form.Item>
|
|
137
|
+ <Form.Item>
|
|
138
|
+ {getFieldDecorator('goodState')(
|
|
139
|
+ <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
|
|
140
|
+ <Option value="1">上架</Option>
|
|
141
|
+ <Option value="0">下架</Option>
|
|
142
|
+ </Select>,
|
|
143
|
+ )}
|
|
144
|
+ </Form.Item>
|
|
145
|
+ <Form.Item>
|
|
146
|
+ {getFieldDecorator('isMain')(
|
|
147
|
+ <Select style={{ width: '180px' }} placeholder="所属项目" onChange={handleSelectChange}>
|
|
148
|
+ <Option value="1">首页推荐</Option>
|
|
149
|
+ <Option value="0">首页未推荐</Option>
|
|
150
|
+ </Select>,
|
|
151
|
+ )}
|
|
152
|
+ </Form.Item>
|
|
153
|
+ <Form.Item>
|
|
154
|
+ {getFieldDecorator('min')(
|
|
155
|
+ <Input
|
|
156
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
157
|
+ placeholder="最小积分"
|
|
158
|
+ />,
|
|
159
|
+ )}
|
|
160
|
+ </Form.Item>
|
|
161
|
+ <Form.Item>
|
|
162
|
+ {getFieldDecorator('max')(
|
|
163
|
+ <Input
|
|
164
|
+ prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
|
|
165
|
+ placeholder="最大积分"
|
|
166
|
+ />,
|
|
167
|
+ )}
|
|
168
|
+ </Form.Item>
|
|
169
|
+ <Form.Item>
|
|
170
|
+ <Button type="primary" htmlType="submit" className={styles.searchBtn}>
|
|
171
|
+ 搜索
|
|
172
|
+ </Button>
|
|
173
|
+ </Form.Item>
|
|
174
|
+ </Form>
|
|
175
|
+ <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
|
|
176
|
+ <Table dataSource={dataSource} columns={columns} />
|
|
177
|
+ {/* 分页 */
|
|
178
|
+ /* <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
|
|
179
|
+ <Pagination showQuickJumper defaultCurrent={1} total={500} onChange={onChange} />
|
|
180
|
+ </div> */}
|
|
181
|
+ </>
|
|
182
|
+ )
|
|
183
|
+}
|
|
184
|
+const WrappedHeader = Form.create({ name: 'header' })(header);
|
164
|
185
|
|
165
|
|
- </>
|
166
|
|
-);
|
|
186
|
+export default WrappedHeader
|