魏超 преди 5 години
родител
ревизия
905f175485
променени са 1 файла, в които са добавени 66 реда и са изтрити 46 реда
  1. 66
    46
      src/pages/news/NewTypeList.jsx

+ 66
- 46
src/pages/news/NewTypeList.jsx Целия файл

@@ -1,46 +1,49 @@
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
-import styles from '../style/News.less';
4
+import styles from '../style/GoodsList.less';
5
+import router from 'umi/router';
5 6
 
6
-
7
-class StateDropdown extends React.Component {
8
-    state = {
9
-      goodState: '请选择',
10
-    }
11
-  
12
-    render() {
13
-  
14
-      const menu = (
15
-        <Menu onClick={this.handleMenuClick}>
16
-          <Menu.Item key="1">
17
-            上架
18
-          </Menu.Item>
19
-          <Menu.Item key="2">
20
-            下架
21
-          </Menu.Item>
22
-        </Menu>
23
-      );
24
-      return (
25
-        < Dropdown overlay={menu} className={styles.searchItem} >
26
-          <Button>
27
-            {this.state.goodState} <Icon type="down" />
28
-          </Button>
29
-        </Dropdown>
30
-      )
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)
31 14
     }
32
-    handleMenuClick = e => {
33
-      this.setState({
34
-        goodState: e.item.props.children,
35
-      });
36
-  
37
-    }
38
-  };
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
+ */
39 42
 
40 43
 const dataSource = [
41 44
   {
42 45
     key: '1',
43
-    img: 'https://www.baidu.com/link?url=ukdsmDsrQ_2MkqTJlvDqO_qKzNPrQr2cFPKHF4zGr6bUG4JX6xfVuBLqYzFD6Pl4EIx_-clALifzoU8M2vtGBrsZH5v6g839XSYRr51YxmQ6saKbL2IsuDGlR6AXj_wGlw2MdNSWQUEhWwExhfBADvE78S6xwXa7imN9Pxg9qIwTUIYjefqI8Ngh2t3-_5VQz3sdxUpsA_OvbjUeYBECMWLLSB33z2xqCV_hdD8or0Vnjp4MYV6_wDlbXXEw2fBRT6jMX2MU-JdgeyF6uZEHYhcggH95vgtDXdW1Wg3ymkiiCYrQ8XpntziG5ClIbMXofwSw5XtsCpQTqech0Bjdq4nJZUWE0jYOlBGV6ZyNAw5dPEswruke6Gu-qGDJNxsnvyj1xYMdGC5UM9iKPV8y20Brk7Y7z_eIHQwnOd4Hie0RqJfDxiuQvn8jQonm8qB1t8sJ7Wo9Fh5BPe56KYfwNDiVTPjm7iXLdUtnjJA8UXWtStFfTfw3yRQnQnEbBUHWtaJBcLPdgbxveUHUU4aum_&wd=&eqid=ddc9f9630001ed6a000000045d8047a3',
46
+    img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
44 47
     name: '华为P30 Pro',
45 48
   },
46 49
   {
@@ -65,15 +68,18 @@ const columns = [
65 68
     align: 'center',
66 69
 
67 70
   },
71
+
68 72
   {
69 73
     title: '操作',
70 74
     dataIndex: 'handle',
71 75
     key: 'handle',
72 76
     align: 'center',
73
-    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></>,
77
+    render: () => <>
78
+    <span style={{ color: '#1990FF', marginRight: '20px' }} onClick={confirm}>删除<Icon type="shopping-cart" className={styles.shoppingCart} /></span>
79
+    <span style={{ color: '#FF925C' }}>编辑<Icon type="form" className={styles.edit} /></span></>,
74 80
   },
75 81
 ];
76
-function confirm() {
82
+const confirm = () => {
77 83
   Modal.confirm({
78 84
     title: '确认删除该商品?',
79 85
     okText: '确认',
@@ -87,13 +93,27 @@ function confirm() {
87 93
   });
88 94
 
89 95
 }
90
-export default () => (
91
-  <>
92
-    <div className={styles.searchBox}>
93
-        <StateDropdown />
94
-    </div>  
95
-    <Button type="primary" className={styles.addBtn}>新增</Button>
96
-    <Table dataSource={dataSource} columns={columns} />
97 96
 
98
-  </>
99
-);
97
+const header = (props) => {
98
+  const { getFieldDecorator } = props.form
99
+  return (
100
+
101
+    <>
102
+      <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
103
+        <Form.Item>
104
+          {getFieldDecorator('goodState')(
105
+            <Select style={{ width: '180px' }} placeholder="请选择" onChange={handleSelectChange}>
106
+              <Option value="1">上架</Option>
107
+              <Option value="0">下架</Option>
108
+            </Select>,
109
+          )}
110
+        </Form.Item>
111
+      </Form>
112
+      <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
113
+      <Table dataSource={dataSource} columns={columns} />
114
+    </>
115
+  )
116
+}
117
+const WrappedHeader = Form.create({ name: 'header' })(header);
118
+
119
+export default WrappedHeader