许静 5 years ago
parent
commit
64736ff0ef

+ 10
- 17
config/config.js View File

@@ -30,11 +30,11 @@ const plugins = [
30 30
       // },
31 31
       pwa: pwa
32 32
         ? {
33
-            workboxPluginMode: 'InjectManifest',
34
-            workboxOptions: {
35
-              importWorkboxFrom: 'local',
36
-            },
37
-          }
33
+          workboxPluginMode: 'InjectManifest',
34
+          workboxOptions: {
35
+            importWorkboxFrom: 'local',
36
+          },
37
+        }
38 38
         : false, // default close dll, because issue https://github.com/ant-design/ant-design-pro/issues/4665
39 39
       // dll features https://webpack.js.org/plugins/dll-plugin/
40 40
       // dll: {
@@ -124,18 +124,6 @@ export default {
124 124
                 },
125 125
               ],
126 126
             },
127
-            // {
128
-            //   path: '/welcome2',
129
-            //   name: '首页2',
130
-            //   component: '../layouts/BlankLayout',
131
-            //   routes:[
132
-            //     {
133
-            //       path: '/welcome3',
134
-            //       name: '首页3',
135
-            //       component: './Welcome',
136
-            //     },
137
-            //   ]
138
-            // },
139 127
             {
140 128
               path: '/integralMall',
141 129
               name: '积分商城',
@@ -146,6 +134,11 @@ export default {
146 134
                   name: '商品列表',
147 135
                   component: './integralMall/GoodsList',
148 136
                 },
137
+                {
138
+                  path: '/integralMall/editGoods',
139
+                  name: '',
140
+                  component: './integralMall/editGoods',
141
+                },
149 142
               ],
150 143
             },
151 144
             {

+ 98
- 78
src/pages/integralMall/GoodsList.jsx View File

@@ -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

+ 27
- 0
src/pages/integralMall/editGoods.jsx View File

@@ -0,0 +1,27 @@
1
+import React from 'react';
2
+import { Form, Input, Button, Icon, Select } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import styles from '../style/GoodsList.less';
5
+
6
+
7
+
8
+/**
9
+ *
10
+ *
11
+ * @param {*} props
12
+ * @returns
13
+ */
14
+
15
+
16
+function header(props) {
17
+  const { getFieldDecorator } = props.form
18
+  return (
19
+
20
+    <>
21
+     <div>编辑商品</div>
22
+    </>
23
+  )
24
+}
25
+const WrappedHeader = Form.create({ name: 'header' })(header);
26
+
27
+export default WrappedHeader

+ 0
- 17
src/pages/style/GoodsList.less View File

@@ -1,20 +1,3 @@
1
-.searchBox {
2
-  font-size: 30px;
3
-  color: red;
4
-  display: flex;
5
-  display: flex;
6
-  justify-items: center;
7
-  align-items: center;
8
-  justify-content: space-between;
9
-  .searchItem {
10
-    min-width: 200px;
11
-    margin-right: 20px;
12
-    text-align: left;
13
-    .anticon-down {
14
-      float: right !important;
15
-    }
16
-  }
17
-}
18 1
 .addBtn {
19 2
   padding: 0 30px;
20 3
   height: 36px;