许静 5 yıl önce
ebeveyn
işleme
9e28e72f8d

+ 1
- 1
package.json Dosyayı Görüntüle

@@ -26,7 +26,7 @@
26 26
     "test:component": "umi test ./src/components",
27 27
     "ui": "umi ui"
28 28
   },
29
-  "husky": { "hooks": { "pre-commit": "npm run lint-staged" } },
29
+
30 30
   "lint-staged": {
31 31
     "**/*.less": "stylelint --syntax less",
32 32
     "**/*.{js,jsx,tsx,ts,less,md,json}": ["prettier --write", "git add"],

+ 88
- 42
src/pages/integralMall/GoodsList.jsx Dosyayı Görüntüle

@@ -1,36 +1,82 @@
1 1
 import React from 'react';
2
-import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag } from 'antd';
2
+import { Input, Menu, Dropdown, Button, Icon, 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
+
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
+  }
42
+
43
+  render() {
44
+
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
+    });
67
+
68
+  }
69
+};
21 70
 const dataSource = [
22 71
   {
23 72
     key: '1',
24 73
     img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
25
-    name: '123',
26
-    age: 32,
27
-    address: '西湖区湖底公园1号',
74
+    name: '华为P30 Pro',
28 75
   },
29 76
   {
30 77
     key: '2',
31 78
     img: '',
32
-    age: 42,
33
-    address: '西湖区湖底公园1号',
79
+    name: '大米',
34 80
   },
35 81
 ];
36 82
 
@@ -40,7 +86,6 @@ const columns = [
40 86
     dataIndex: 'img',
41 87
     key: 'img',
42 88
     align: 'center',
43
-
44 89
     render: (text, record) => <img src={record.img} className={styles.touxiang} />,
45 90
   },
46 91
   {
@@ -48,7 +93,7 @@ const columns = [
48 93
     dataIndex: 'name',
49 94
     key: 'name',
50 95
     align: 'center',
51
-    render: text => <a>{text}</a>,
96
+
52 97
   },
53 98
   {
54 99
     title: '所属积分',
@@ -85,36 +130,37 @@ const columns = [
85 130
     dataIndex: 'handle',
86 131
     key: 'handle',
87 132
     align: 'center',
88
-    render: () => <a>Delete</a>,
133
+    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 134
   },
90 135
 ];
136
+function confirm() {
137
+  Modal.confirm({
138
+    title: '确认下架该商品?',
139
+    okText: '确认',
140
+    cancelText: '取消',
141
+    onOk() {
142
+      console.log('OK');
143
+    },
144
+    onCancel() {
145
+      console.log('Cancel');
146
+    },
147
+  });
91 148
 
149
+}
92 150
 export default () => (
93 151
   <>
94 152
     <div className={styles.searchBox}>
95 153
       <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} />
154
+      <StateDropdown />
155
+      <App />
156
+      <Input placeholder="最小积分" className={styles.searchItem} />
157
+      <Input placeholder="最大积分" className={styles.searchItem} />
108 158
       <Button type="primary" size="small">
109 159
         查询
110 160
       </Button>
111 161
     </div>
112 162
     <Button className={styles.addBtn}>新增</Button>
113 163
     <Table dataSource={dataSource} columns={columns} />
164
+
114 165
   </>
115 166
 );
116
-
117
-function handleMenuClick(e) {
118
-  message.info('Click on menu item.');
119
-  console.log('click', e);
120
-}

+ 10
- 0
src/pages/style/GoodsList.less Dosyayı Görüntüle

@@ -29,3 +29,13 @@
29 29
 .ant-table-column-title {
30 30
   font-weight: 600;
31 31
 }
32
+.shoppingCart{
33
+  color: #dcdcdc;
34
+  margin-left: 6px;
35
+  font-size: 16px;
36
+}
37
+.edit{
38
+  color: #dcdcdc;
39
+  margin-left: 6px;
40
+  font-size: 15px;
41
+}