魏超 преди 5 години
родител
ревизия
b1d2417fc2
променени са 4 файла, в които са добавени 92 реда и са изтрити 12 реда
  1. 9
    4
      config/config.js
  2. 3
    3
      src/pages/news/list/NewsList.jsx
  3. 5
    5
      src/pages/news/type/NewsType.jsx
  4. 75
    0
      src/pages/news/type/editNews.jsx

+ 9
- 4
config/config.js Целия файл

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

+ 3
- 3
src/pages/news/list/NewsList.jsx Целия файл

@@ -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 Целия файл

@@ -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 Целия файл

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