Yansen преди 5 години
родител
ревизия
4561e4fb27
променени са 2 файла, в които са добавени 19 реда и са изтрити 22 реда
  1. 7
    8
      src/components/ActionList/index.jsx
  2. 12
    14
      src/pages/integralMall/GoodsList.jsx

+ 7
- 8
src/components/ActionList/index.jsx Целия файл

@@ -3,7 +3,6 @@ import { Menu, Dropdown, Icon } from 'antd';
3 3
 
4 4
 import styles from './style.less';
5 5
 
6
-// HOC
7 6
 export default function withActions(actionsRender) {
8 7
   return function ActionList(text, record) {
9 8
     const actions = actionsRender(text, record);
@@ -11,23 +10,23 @@ export default function withActions(actionsRender) {
11 10
 
12 11
     const menus = (
13 12
       <Menu>
14
-        {(leftActs || []).map((Act, index) => (<Menu.Item key={`dm-${index}`}><Act /></Menu.Item>))}
13
+        {(leftActs || []).map((Act, index) => (<Menu.Item key={`dm-${index}`}>{Act}</Menu.Item>))}
15 14
       </Menu>
16 15
     );
17 16
 
18 17
     return (
19
-      <div className={styles.action_list}>
18
+      <div className={styles['action-list']}>
20 19
         {
21
-          Act1 && <span><Act1 /></span>
20
+          Act1 && <span>{Act1}</span>
22 21
         }
23 22
         {
24
-          Act2 && <span><Act2 /></span>
23
+          Act2 && <span>{Act2}</span>
25 24
         }
26 25
         {
27
-          Act3 && <span><Act3 /></span>
26
+          Act3 && <span>{Act3}</span>
28 27
         }
29 28
         {
30
-          leftActs && leftActs.length &&
29
+          leftActs && leftActs.length ?
31 30
           (
32 31
             <span>
33 32
               <Dropdown overlay={menus} trigger={['click']}>
@@ -36,7 +35,7 @@ export default function withActions(actionsRender) {
36 35
                 </a>
37 36
               </Dropdown>
38 37
             </span>
39
-          )
38
+          ) : null
40 39
         }
41 40
       </div>
42 41
     );

+ 12
- 14
src/pages/integralMall/GoodsList.jsx Целия файл

@@ -1,12 +1,12 @@
1 1
 import React, { useState, useEffect } from 'react';
2
-import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal,Breadcrumb } from 'antd';
3
-import { FormattedMessage } from 'umi-plugin-react/locale';
4
-import styles from '../style/GoodsList.less';
2
+import { Form, Input, Button, Icon, Select, message, Table, Pagination, Modal } from 'antd';
5 3
 import router from 'umi/router';
4
+import AuthButton from '@/components/AuthButton';
5
+import withActions from '@/components/ActionList';
6 6
 import BuildSelect from '../../components/SelectButton/BuildSelect'
7 7
 import apis from '../../services/apis';
8 8
 import request from '../../utils/request'
9
-import AuthButton from '@/components/AuthButton';
9
+import styles from '../style/GoodsList.less';
10 10
 
11 11
 const { Option } = Select;
12 12
 
@@ -134,21 +134,19 @@ function header(props) {
134 134
       dataIndex: 'handle',
135 135
       key: 'handle',
136 136
       align: 'center',
137
-      render: (x, row) => (
138
-        <>
137
+      render: withActions((x, row) => [
139 138
           <AuthButton name="admin.taGoods.change.put" noRight={null}>
140
-            <span style={{ color: '#EF273A', marginRight: '20px',cursor: 'pointer' }} onClick={changeGoodsStatus(row)}>
141
-              {row.status == 1 ? '下架' : '上架'}
142
-              {<Icon type="shopping-cart" className={styles.shoppingCart} />}
139
+            <span style={{ color: '#EF273A', marginRight: '20px', cursor: 'pointer' }} onClick={changeGoodsStatus(row)}>
140
+              {row.status === 1 ? '下架' : '上架'}
141
+              <Icon type="shopping-cart" className={styles.shoppingCart} />
143 142
             </span>
144
-          </AuthButton>
143
+          </AuthButton>,
145 144
           <AuthButton name="admin.taGoods.put" noRight={null}>
146
-            <span style={{ color: '#FF925C',cursor: 'pointer' }} onClick={toEditGoods(row.goodsId)}>
145
+            <span style={{ color: '#FF925C', cursor: 'pointer' }} onClick={toEditGoods(row.goodsId)}>
147 146
               编辑<Icon type="form" className={styles.edit} />
148 147
             </span>
149
-          </AuthButton>
150
-        </>
151
-      ),
148
+          </AuthButton>,
149
+        ]),
152 150
     },
153 151
   ];
154 152