dingxin 5 vuotta sitten
vanhempi
commit
f4a60dfebc

+ 9
- 4
config/config.js Näytä tiedosto

@@ -246,13 +246,18 @@ export default {
246 246
               component: '../layouts/BlankLayout',
247 247
               routes: [
248 248
                 {
249
-                  path: '/news/NewsType',
249
+                  path: '/news/type/NewsType',
250 250
                   name: '资讯类型',
251 251
                   component: './news/type/NewsType',
252 252
                 },
253 253
                 {
254
-                  path: '/news/NewsList',
255
-                  name: '咨询列表',
254
+                  path: '/news/type/editNews',
255
+                  name: '',
256
+                  component: './news/type/editNews',
257
+                },
258
+                {
259
+                  path: '/news/list/NewsList',
260
+                  name: '资讯列表',
256 261
                   component: './news/list/NewsList',
257 262
                 },
258 263
               ],
@@ -342,7 +347,7 @@ export default {
342 347
 
343 348
   proxy: {
344 349
     '/api/': {
345
-      target: 'http://localhost:8080/',
350
+      target: 'http://192.168.0.84:8080/',
346 351
       changeOrigin: true,
347 352
       // pathRewrite: { '^/server': '' },
348 353
     },

+ 22
- 5
src/components/Wangedit/Wangedit.jsx Näytä tiedosto

@@ -8,7 +8,10 @@ import E from 'wangeditor'
8 8
 class Wangedit extends React.Component {
9 9
   constructor(props, context) {
10 10
     super(props, context);
11
-    this.state = {}
11
+    this.state = {
12
+      html: undefined,
13
+    }
14
+    this.editor = undefined;
12 15
   }
13 16
 
14 17
   render() {
@@ -20,11 +23,25 @@ class Wangedit extends React.Component {
20 23
 
21 24
   componentDidMount() {
22 25
     const elem = this.refs.editorElem
23
-    const editor = new E(elem)
26
+    this.editor = new E(elem)
24 27
     // 使用 onchange 函数监听内容的变化
25
-    editor.customConfig.onchange = this.props.onChange
26
-    editor.create()
27
-    editor.txt.html(this.props.value)
28
+    this.editor.customConfig.onchange = html => {
29
+      this.setState({ html })
30
+
31
+      if (typeof this.props.onChange === 'function') {
32
+        this.props.onChange(html)
33
+      }
34
+    }
35
+    this.editor.create()
36
+    this.editor.txt.html(this.props.value)
37
+  }
38
+
39
+  componentDidUpdate(props, state) {
40
+    if (this.props.value && !state.html) {
41
+      if (this.editor) {
42
+        this.editor.txt.html(this.props.value)
43
+      }
44
+    }
28 45
   }
29 46
 }
30 47
 

+ 1
- 1
src/components/XForm/WrapperItem.jsx Näytä tiedosto

@@ -84,7 +84,7 @@ const WrapperItem = (props) => {
84 84
     return <></>;
85 85
   }
86 86
 
87
-  const SelectOpts = (dict || []).map((item, index) => (<Option value={item.value}>{item.name}</Option>))
87
+  const SelectOpts = (dict || []).map((item, index) => (<Option value={item.value}>{item.label}</Option>))
88 88
 
89 89
   let Field = <></>;
90 90
   if (render) {

+ 1
- 1
src/layouts/BasicLayout.jsx Näytä tiedosto

@@ -100,7 +100,7 @@ const BasicLayout = props => {
100 100
       }}
101 101
       footerRender={footerRender}
102 102
       menuDataRender={menuDataRender}
103
-      formatMessage={formatMessage}
103
+      // formatMessage={formatMessage}
104 104
       rightContentRender={rightProps => <RightContent {...rightProps} />}
105 105
       {...props}
106 106
       {...settings}

+ 1
- 0
src/pages/activity/editActivity.jsx Näytä tiedosto

@@ -155,6 +155,7 @@ const { MonthPicker, RangePicker, WeekPicker } = DatePicker;
155 155
         })
156 156
       }
157 157
     }
158
+    
158 159
     return <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
159 160
   }
160 161
   

+ 141
- 130
src/pages/integralMall/GoodsList.jsx Näytä tiedosto

@@ -1,133 +1,148 @@
1
-import React from 'react';
1
+import React, { useState, useEffect } from 'react';
2 2
 import { Form, Input, Button, Icon, Select, message, Table, Divider, Tag, Pagination, Modal,Breadcrumb } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import styles from '../style/GoodsList.less';
5 5
 import router from 'umi/router';
6
+import BuildSelect from '../../components/SelectButton/BuildSelect'
7
+
8
+import request from '../../utils/request'
6 9
 
7 10
 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
-}
21 11
 
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
-}
35 12
 
36
-/**
37
- *
38
- *
39
- * @param {*} props
40
- * @returns
41
- */
13
+function header(props) {
14
+  // 获取初始化数据
15
+  const [ data, setData ] = useState({})
16
+
17
+  useEffect(() => {
18
+    getList({ pageNum: 1, pageSize: 10 });
19
+  },[])
20
+
21
+  // 查询列表
22
+  const getList = (params) => {
23
+    request({
24
+        url: '/api/admin/taGoods',
25
+        method: 'GET',
26
+        params: { ...params },
27
+    }).then((data) => {
28
+        console.log(data)
29
+        setData(data)
30
+    })
31
+  }
32
+  
33
+  // 提交事件
34
+  const handleSubmit = (e, props) => {
35
+    e.preventDefault();
36
+    props.form.validateFields((err, values) => {
37
+      if (!err) {
38
+        getList({ pageNum: 1, pageSize: 10, ...values })
39
+      }
40
+    });
41
+  }
42
+
43
+  const changePageNum = (pageNumber) => {
44
+    getList({ pageNum: pageNumber, pageSize: 10 })
45
+  }
42 46
 
43
-const dataSource = [
44
-  {
45
-    key: '1',
46
-    img: 'http://img0.imgtn.bdimg.com/it/u=4246326797,2657995307&fm=26&gp=0.jpg',
47
-    name: '华为P30 Pro',
48
-  },
49
-  {
50
-    key: '2',
51
-    img: '',
52
-    name: '大米',
53
-  },
54
-];
55 47
 
56
-const columns = [
57
-  {
58
-    title: '商品图片',
59
-    dataIndex: 'img',
60
-    key: 'img',
61
-    align: 'center',
62
-    render: (text, record) => <img src={record.img} className={styles.touxiang} />,
63
-  },
64
-  {
65
-    title: '商品名称',
66
-    dataIndex: 'name',
67
-    key: 'name',
68
-    align: 'center',
48
+  // 跳转到编辑商品
49
+  const toEditGoods = (goodsId) => () => {
50
+    router.push({
51
+      pathname: '/integralMall/editGoods',
52
+      query: {
53
+        goodsId
54
+      },
55
+    });
56
+  }
69 57
 
70
-  },
71
-  {
72
-    title: '所属积分',
73
-    dataIndex: 'integral',
74
-    key: 'integral',
75
-    align: 'center',
76
-  },
77
-  {
78
-    title: '总数量',
79
-    dataIndex: 'total',
80
-    key: 'total',
81
-    align: 'center',
82
-  },
83
-  {
84
-    title: '已兑换数量',
85
-    dataIndex: 'exchanged',
86
-    key: 'exchanged',
87
-    align: 'center',
88
-  },
89
-  {
90
-    title: '剩余数量',
91
-    dataIndex: 'rest',
92
-    key: 'rest',
93
-    align: 'center',
94
-  },
95
-  {
96
-    title: '状态',
97
-    dataIndex: 'state',
98
-    key: 'state',
99
-    align: 'center',
100
-  },
101
-  {
102
-    title: '操作',
103
-    dataIndex: 'handle',
104
-    key: 'handle',
105
-    align: 'center',
106
-    render: () => <><span style={{ color: '#EF273A', marginRight: '20px' }} onClick={confirm}>下架<Icon type="shopping-cart" className={styles.shoppingCart} /></span><span style={{ color: '#FF925C' }} onClick={toEditGoods}>编辑<Icon type="form" className={styles.edit} /></span></>,
107
-  },
108
-];
109
-function confirm() {
110
-  Modal.confirm({
111
-    title: '确认下架该商品?',
112
-    okText: '确认',
113
-    cancelText: '取消',
114
-    onOk() {
115
-      console.log('OK');
58
+  
59
+  const changeGoodsStatus = (row) => () => {
60
+    Modal.confirm({
61
+      title: '确认下架该商品?',
62
+      okText: '确认',
63
+      cancelText: '取消',
64
+      onOk() {
65
+        request({
66
+          url: '/api/admin/taGoods/change',
67
+          method: 'PUT',
68
+          data: { ...row },
69
+        }).then((data) => {
70
+          message.info('操作成功!')
71
+          getList({ pageNum: 1, pageSize: 10 });
72
+        })
73
+      }
74
+    });
75
+  }
76
+  /**
77
+   *
78
+   *
79
+   * @param {*} props
80
+   * @returns
81
+   */
82
+  const columns = [
83
+    {
84
+      title: '商品图片',
85
+      dataIndex: 'imgUrl',
86
+      key: 'imgUrl',
87
+      align: 'center',
88
+      render: (text, record) => <img src={record.imgUrl} className={styles.touxiang} />,
116 89
     },
117
-    onCancel() {
118
-      console.log('Cancel');
90
+    {
91
+      title: '商品名称',
92
+      dataIndex: 'goodsName',
93
+      key: 'goodsName',
94
+      align: 'center',
95
+
96
+    },
97
+    {
98
+      title: '所属积分',
99
+      dataIndex: 'pointPrice',
100
+      key: 'pointPrice',
101
+      align: 'center',
102
+    },
103
+    {
104
+      title: '总数量',
105
+      dataIndex: 'totalNum',
106
+      key: 'totalNum',
107
+      align: 'center',
108
+    },
109
+    {
110
+      title: '已兑换数量',
111
+      dataIndex: 'exchanged',
112
+      key: 'exchanged',
113
+      align: 'center',
114
+      render: (x,row) => <><span>{row.totalNum - row.inventory}</span></>
115
+    },
116
+    {
117
+      title: '剩余数量',
118
+      dataIndex: 'inventory',
119
+      key: 'inventory',
120
+      align: 'center',
119 121
     },
120
-  });
122
+    {
123
+      title: '状态',
124
+      dataIndex: 'status',
125
+      key: 'status',
126
+      align: 'center',
127
+      render: (status)=> <><span>{status == 1 ? '已上架' : '未上架'}</span></>
128
+    },
129
+    {
130
+      title: '操作',
131
+      dataIndex: 'handle',
132
+      key: 'handle',
133
+      align: 'center',
134
+      render: (x, row) => <><span style={{ color: '#EF273A', marginRight: '20px' }} onClick={changeGoodsStatus(row)}>{row.status == 1 ? '下架' : '上架'}<Icon type="shopping-cart" className={styles.shoppingCart} />
135
+                            </span><span style={{ color: '#FF925C' }} onClick={toEditGoods(row.goodsId)}>编辑<Icon type="form" className={styles.edit} /></span></>,
136
+    },
137
+  ];
121 138
 
122
-}
123
-function header(props) {
124 139
   const { getFieldDecorator } = props.form
125 140
   return (
126 141
 
127 142
     <>
128 143
       <Form layout="inline" onSubmit={e => handleSubmit(e, props)}>
129 144
         <Form.Item>
130
-          {getFieldDecorator('name')(
145
+          {getFieldDecorator('goodsName')(
131 146
             <Input
132 147
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
133 148
               placeholder="商品名称"
@@ -135,49 +150,45 @@ function header(props) {
135 150
           )}
136 151
         </Form.Item>
137 152
         <Form.Item>
138
-          {getFieldDecorator('goodState')(
139
-            <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
140
-              <Option value="1">上架</Option>
141
-              <Option value="0">下架</Option>
153
+          {getFieldDecorator('status')(
154
+            <Select style={{ width: '180px' }} placeholder="状态">
155
+              <Option value="1">上架</Option>
156
+              <Option value="0">下架</Option>
142 157
             </Select>,
143 158
           )}
144 159
         </Form.Item>
145 160
         <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>,
161
+          {getFieldDecorator('buildingId')(
162
+            <BuildSelect />,
151 163
           )}
152 164
         </Form.Item>
153 165
         <Form.Item>
154
-          {getFieldDecorator('min')(
166
+          {getFieldDecorator('priceLesser')(
155 167
             <Input
156 168
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
157
-              placeholder="最小积分"
169
+              placeholder="价格小"
158 170
             />,
159 171
           )}
160 172
         </Form.Item>
161 173
         <Form.Item>
162
-          {getFieldDecorator('max')(
174
+          {getFieldDecorator('priceGreater')(
163 175
             <Input
164 176
               prefix={<Icon type="text" style={{ color: 'rgba(0,0,0,.25)' }} />}
165
-              placeholder="最大积分"
177
+              placeholder="价格大"
166 178
             />,
167 179
           )}
168 180
         </Form.Item>
169 181
         <Form.Item>
170
-          <Button type="primary" htmlType="submit" >
182
+          <Button type="primary" htmlType="submit" className={styles.searchBtn}>
171 183
             搜索
172 184
           </Button>
173 185
         </Form.Item>
174 186
       </Form>
175
-      <Button type="danger" 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> */}
187
+      <Button type="primary" className={styles.addBtn} onClick={toEditGoods()}>新增</Button>
188
+      <Table dataSource={data.records} columns={columns} pagination={false} />
189
+      <div style={{ display: 'flex', justifyContent: 'flex-end', marginTop: '30px' }}>
190
+        <Pagination showQuickJumper defaultCurrent={1} total={data.total} onChange={changePageNum} />
191
+      </div>
181 192
     </>
182 193
   )
183 194
 }

+ 122
- 62
src/pages/integralMall/editGoods.jsx Näytä tiedosto

@@ -2,6 +2,9 @@ import React, { useState, useEffect } from 'react';
2 2
 import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert } from 'antd';
3 3
 import { FormattedMessage } from 'umi-plugin-react/locale';
4 4
 import channels from '../channel/channelList.less';
5
+import BuildSelect from '../../components/SelectButton/BuildSelect'
6
+import XForm, { FieldTypes } from '../../components/XForm';
7
+import Wangedit from '../../components/Wangedit/Wangedit'
5 8
 import router from 'umi/router';
6 9
 import request from '../../utils/request'
7 10
 
@@ -9,78 +12,135 @@ const { TextArea } = Input;
9 12
 const { Option } = Select;
10 13
 
11 14
 const header = props => {
15
+  const goodsId = props.location.query.goodsId
16
+  const [ goodsData, setGoodsData ] = useState({})
17
+  if(goodsId){
18
+    useEffect(() => {
19
+      getGoodsData(goodsId);
20
+    },[])
12 21
 
13
-  const [data, setData] = useState({ channelNmae: [], result: [] })
14
-
15
-  function goBack(){
16
-    router.push({
17
-      pathname: '/integralMall/GoodsList',
18
-    });
19
-  }
20
-
21
-  function addChannel(params) {
22
+  // 查询列表
23
+  const getGoodsData = (goodsId) => {
22 24
     request({
23
-      url: '/api/admin/channel',
24
-      method: 'POST',
25
-      data: { ...params },
26
-      // eslint-disable-next-line no-shadow
27
-    }).then(data => {
28
-      console.log(data)
29
-      setData(data)
30
-      // eslint-disable-next-line no-unused-expressions
31
-      router.go(-1)
25
+        url: '/api/admin/taGoods/' + goodsId,
26
+        method: 'GET',
27
+    }).then((data) => {
28
+        console.log(data)
29
+        setGoodsData(data)
32 30
     })
33 31
   }
32
+  }
34 33
 
35
-  function handleSubmit(e) {
36
-    e.preventDefault();
37
-    props.form.validateFields((err, values) => {
38
-      if (!err) {
39
-        console.log('Received values of form: ', values);
40
-        // eslint-disable-next-line max-len
41
-        addChannel({ channelName: values.channelName, channelContact: values.channelContact, contactTel: values.contactTel })
34
+  const fields = [
35
+    {
36
+      label: '所属项目',
37
+      name: 'buildingId',
38
+      render: <BuildSelect />,
39
+      value: goodsData.buildingId,
40
+      rules: [
41
+        {required: true, message: '请选择所属项目'},
42
+      ]
43
+    },
44
+    {
45
+      label: '商品图片',
46
+      name: 'imgUrl',
47
+      type: FieldTypes.ImageUploader,
48
+      value: goodsData.imgUrl,
49
+    },
50
+    {
51
+      label: '商品名称',
52
+      name: 'goodsName',
53
+      type: FieldTypes.Text,
54
+      value: goodsData.goodsName,
55
+      rules: [
56
+        {required: true, message: '请输入商品名称'},
57
+      ]
58
+    },
59
+    {
60
+      label: '所需积分',
61
+      name: 'pointPrice',
62
+      type: FieldTypes.Text,
63
+      value: goodsData.pointPrice,
64
+      rules: [
65
+        {required: true, message: '请输入所需积分'},
66
+      ]
67
+    },
68
+    {
69
+      label: '商品数量',
70
+      name: 'totalNum',
71
+      type: FieldTypes.Text,
72
+      value: goodsData.totalNum,
73
+      rules: [
74
+        {required: true, message: '请输入商品数量'},
75
+      ]
76
+    },
77
+    {
78
+      label: '剩余数量',
79
+      name: 'inventory',
80
+      type: FieldTypes.Text,
81
+      value: goodsData.inventory,
82
+      rules: [
83
+        {required: true, message: '请输入剩余数量'},
84
+      ]
85
+    },
86
+    {
87
+      label: '商品详情',
88
+      name: 'goodsDescription',
89
+      render: <Wangedit />,
90
+      value: goodsData.goodsDescription,
91
+    },
92
+    {
93
+      label: '状态',
94
+      name: 'status',
95
+      type: FieldTypes.Select,
96
+      dict: [{label:"已上架",value:1},{label:"已下架",value:0}],
97
+      value: goodsData.status != null ? goodsData.status : 1,
98
+    },
99
+    {
100
+      label: '领取地址',
101
+      name: 'address',
102
+      type: FieldTypes.Text,
103
+      value: goodsData.address,
104
+      rules: [
105
+        {required: true, message: '请输入领取地址'},
106
+      ]
107
+    },
108
+  ]
109
+
110
+   
111
+  const handleSubmit = (values) => {
112
+    if(goodsId){
113
+      values.goodsId = goodsId
114
+      request({
115
+        url: '/api/admin/taGoods',
116
+        method: 'PUT',
117
+        data: values,
118
+      }).then((data) => {
119
+        cancelPage()
120
+      }).catch((err) => {
121
+        message.info(err.msg || err.message)
122
+      })
123
+      }else{
124
+      request({
125
+        url: '/api/admin/taGoods/add',
126
+        method: 'POST',
127
+        data: values,
128
+      }).then((data) => {
129
+        cancelPage()
130
+      }).catch((err) => {
131
+        message.info(err.msg || err.message)
132
+      })
42 133
       }
43
-    });
44 134
   }
45 135
 
46
-  const { getFieldDecorator } = props.form;
136
+  const cancelPage = () => {
137
+    router.push({
138
+      pathname: '/integralMall/GoodsList',
139
+    });
140
+  }
47 141
 
48 142
   return (
49
-    <>
50
-      <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
51
-        <Form.Item label="商品名称">
52
-          {getFieldDecorator('channelName', {
53
-            rules: [{ message: '请输入商品名称' }],
54
-          })(<Input className={channels.inpuit} />)}
55
-        </Form.Item>
56
-        <Form.Item label="所需积分">
57
-          {getFieldDecorator('channelContact', {
58
-            rules: [{ message: ' 请输入所需积分' }],
59
-          })(<Input className={channels.inpuit} />)}
60
-        </Form.Item>
61
-        <Form.Item label="商品数量">
62
-          {getFieldDecorator('contactTel', {
63
-            rules: [{ message: '请输入商品数量' }],
64
-          })(<Input className={channels.inpuit} />)}
65
-        </Form.Item>
66
-        <Form.Item label="剩余数量">
67
-          {getFieldDecorator('contactTel', {
68
-            rules: [{ message: '请输入剩余数量' }],
69
-          })(<Input className={channels.inpuit} />)}
70
-        </Form.Item>
71
-        <Form.Item label="商品详情">
72
-          <TextArea className={channels.inpuitTxt} rows={8} />
73
-        </Form.Item>
74
-        <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
75
-          <Button type="primary" htmlType="submit">
76
-            保存
77
-          </Button>
78
-          <Button className={channels.formButton} onClick={goBack} type="primary" htmlType="submit">
79
-            取消
80
-          </Button>
81
-        </Form.Item>
82
-      </Form>
83
-    </>
143
+    <XForm onSubmit={handleSubmit} onCancel={cancelPage} fields={fields}></XForm>
84 144
   )
85 145
 }
86 146
 

+ 3
- 3
src/pages/news/list/NewsList.jsx Näytä tiedosto

@@ -37,7 +37,7 @@ function CartBody(props) {
37 37
             </p>
38 38
             <p className={Styles.cardText}>
39 39
               <span className={Styles.title}>状态</span>
40
-              <span >:{ data.status == '0' ? "已发布" : "未发布" }</span>
40
+              <span >:{ data.status == 0 ? "已发布" : "未发布" }</span>
41 41
             </p>
42 42
             <p className={Styles.cardItem}>
43 43
               <span className={Styles.title}>阅读数量</span>
@@ -173,8 +173,8 @@ function body(props) {
173 173
         <Form.Item>
174 174
           {getFieldDecorator('newsStatus')(
175 175
             <Select style={{ width: '180px' }} placeholder="状态" onChange={handleSelectChange}>
176
-              <Option value="1">已发布</Option>
177
-              <Option value="0">未发布</Option>
176
+              <Option value="0">已发布</Option>
177
+              <Option value="1">未发布</Option>
178 178
             </Select>,
179 179
           )}
180 180
         </Form.Item>

+ 5
- 5
src/pages/news/type/NewsType.jsx Näytä tiedosto

@@ -24,10 +24,10 @@ function onChange(pageNumber) {
24 24
   console.log('Page: ', pageNumber);
25 25
 }
26 26
 
27
-// 跳转到编辑商品
28
-function toEditGoods() {
27
+// 跳转到编辑资讯
28
+function toEditNews() {
29 29
   router.push({
30
-    pathname: '/integralMall/editGoods',
30
+    pathname: '/news/type/editNews',
31 31
     query: {
32 32
       a: 'b',
33 33
     },
@@ -76,7 +76,7 @@ const columns = [
76 76
     align: 'center',
77 77
     render: () => <>
78 78
     <span style={{ color: '#1990FF', marginRight: '20px' }} onClick={confirm}>删除<Icon type="shopping-cart" className={styles.shoppingCart} /></span>
79
-    <span style={{ color: '#FF925C' }} onClick={toEditGoods}>编辑<Icon type="form" className={styles.edit} /></span></>,
79
+    <span style={{ color: '#FF925C' }} onClick={toEditNews}>编辑<Icon type="form" className={styles.edit} /></span></>,
80 80
   },
81 81
 ];
82 82
 function confirm() {
@@ -108,7 +108,7 @@ function header(props) {
108 108
           )}
109 109
         </Form.Item>
110 110
       </Form>
111
-      <Button type="primary" className={styles.addBtn} onClick={toEditGoods}>新增</Button>
111
+      <Button type="primary" className={styles.addBtn} onClick={toEditNews}>新增</Button>
112 112
       <Table dataSource={dataSource} columns={columns} />
113 113
     </>
114 114
   )

+ 75
- 0
src/pages/news/type/editNews.jsx Näytä tiedosto

@@ -0,0 +1,75 @@
1
+import React, { useState, useEffect } from 'react';
2
+import { Input, Menu, Dropdown, Button, Icon, message, Table, Divider, Tag, Select, Form, Alert } from 'antd';
3
+import { FormattedMessage } from 'umi-plugin-react/locale';
4
+import channels from '../../channel/channelList.less';
5
+import router from 'umi/router';
6
+import request from '../../../utils/request'
7
+
8
+const { TextArea } = Input;
9
+const { Option } = Select;
10
+
11
+const header = props => {
12
+
13
+  const [data, setData] = useState({ channelNmae: [], result: [] })
14
+
15
+  function goBack(){
16
+    router.push({
17
+      pathname: '/news/type/NewsType',
18
+    });
19
+  }
20
+
21
+  function addChannel(params) {
22
+    request({
23
+      url: '/api/admin/channel',
24
+      method: 'POST',
25
+      data: { ...params },
26
+      // eslint-disable-next-line no-shadow
27
+    }).then(data => {
28
+      console.log(data)
29
+      setData(data)
30
+      // eslint-disable-next-line no-unused-expressions
31
+      router.go(-1)
32
+    })
33
+  }
34
+
35
+  function handleSubmit(e) {
36
+    e.preventDefault();
37
+    props.form.validateFields((err, values) => {
38
+      if (!err) {
39
+        console.log('Received values of form: ', values);
40
+        // eslint-disable-next-line max-len
41
+        addChannel({ channelName: values.channelName, channelContact: values.channelContact, contactTel: values.contactTel })
42
+      }
43
+    });
44
+  }
45
+
46
+  const { getFieldDecorator } = props.form;
47
+
48
+  return (
49
+    <>
50
+      <Form labelCol={{ span: 7 }} wrapperCol={{ span: 12 }} onSubmit={handleSubmit}>
51
+      <Form.Item label="类型图片">
52
+          {getFieldDecorator('newsName', {
53
+            rules: [{ message: '' }],
54
+          })(<Input className={channels.inpuit} />)}
55
+        </Form.Item>
56
+        <Form.Item label="名称">
57
+          {getFieldDecorator('newsName', {
58
+            rules: [{ message: '请输入资讯名称' }],
59
+          })(<Input className={channels.inpuit} />)}
60
+        </Form.Item>
61
+        <Form.Item wrapperCol={{ span: 15, offset: 7 }}>
62
+          <Button type="primary" htmlType="submit">
63
+            保存
64
+          </Button>
65
+          <Button className={channels.formButton} onClick={goBack} type="primary" htmlType="submit">
66
+            取消
67
+          </Button>
68
+        </Form.Item>
69
+      </Form>
70
+    </>
71
+  )
72
+}
73
+
74
+const WrappedNormalLoginForm = Form.create({ name: 'header' })(header);
75
+export default WrappedNormalLoginForm