李志伟 3 年之前
父節點
當前提交
3f34a0d77d

+ 2
- 9
config/routes.js 查看文件

@@ -62,13 +62,6 @@ export default [
62 62
         access: 'cmstype',
63 63
         component: './ContentManagementSystem/InformationClassification',
64 64
       },
65
-      {
66
-        path: '/ContentManagementSystem/InformationClassification/InformationClassificationEdit',
67
-        name: '资讯分类编辑',
68
-        component:
69
-          './ContentManagementSystem/InformationClassification/InformationClassificationEdit',
70
-        hideInMenu: true,
71
-      },
72 65
       {
73 66
         path: '/ContentManagementSystem/InformationList',
74 67
         name: '资讯列表',
@@ -76,9 +69,9 @@ export default [
76 69
         component: './ContentManagementSystem/InformationList',
77 70
       },
78 71
       {
79
-        path: '/ContentManagementSystem/InformationList/InformationListEdit',
72
+        path: '/ContentManagementSystem/InformationList/edit.jsx',
80 73
         name: '资讯列表编辑',
81
-        component: './ContentManagementSystem/InformationList/InformationListEdit',
74
+        component: './ContentManagementSystem/InformationList/edit.jsx',
82 75
         hideInMenu: true,
83 76
       },
84 77
       {

+ 49
- 10
src/pages/ContentManagementSystem/Advertisement/edit.jsx 查看文件

@@ -1,10 +1,11 @@
1
-import { Input, Card, Select, Button, message, Upload, Modal } from 'antd';
1
+import { Input, Card, Select, Button, message, InputNumber, Modal } from 'antd';
2 2
 import { useEffect, useState } from 'react';
3 3
 import { Form } from 'antd';
4 4
 import { history } from 'umi';
5 5
 import ProCard from '@ant-design/pro-card';
6 6
 import { UploadImage } from '@/components/Upload';
7 7
 import ExtendContent from '@/components/ExtendContent';
8
+import { addBanner, updateBanner } from '@/services/ad';
8 9
 
9 10
 const { Option } = Select;
10 11
 const goBack = () => {
@@ -12,6 +13,8 @@ const goBack = () => {
12 13
 };
13 14
 const FormItem = Form.Item;
14 15
 export default (props) => {
16
+  const { data } = props.location;
17
+
15 18
   const [form] = Form.useForm();
16 19
   const [loading, setLoading] = useState(false);
17 20
   const [image, setImage] = useState();
@@ -23,13 +26,40 @@ export default (props) => {
23 26
   };
24 27
 
25 28
   const Submit = (values) => {
26
-    message.success(`成功成功成功`);
29
+    setLoading(true);
30
+    if (data) {
31
+      updateBanner(data.bannerId, values)
32
+        .then(() => {
33
+          setLoading(false);
34
+          message.success('数据更新成功');
35
+          goBack();
36
+        })
37
+        .catch((err) => {
38
+          setLoading(false);
39
+          message.error(err.message || err);
40
+        });
41
+    } else {
42
+      addBanner(values)
43
+        .then((res) => {
44
+          setLoading(false);
45
+          message.success('数据保存成功');
46
+          goBack();
47
+        })
48
+        .catch((err) => {
49
+          setLoading(false);
50
+          message.error(err.message || err);
51
+        });
52
+    }
27 53
   };
28
-
54
+  useEffect(() => {
55
+    if (data) {
56
+      form.setFieldsValue(data);
57
+    }
58
+  }, [data]);
29 59
   return (
30 60
     <Card>
31 61
       <ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}>
32
-        <ProCard.TabPane key={1} tab="资讯管理">
62
+        <ProCard.TabPane key={1} tab="广告位管理">
33 63
           <Form {...formItemLayout} onFinish={Submit} form={form}>
34 64
             <FormItem label="名称" name="title" rules={[{ required: true, message: '请输入' }]}>
35 65
               <Input placeholder="请输入" style={{ width: '350px' }} />
@@ -38,19 +68,28 @@ export default (props) => {
38 68
               <UploadImage value={image} onChange={setImage} />
39 69
             </FormItem>
40 70
             <FormItem label="位置" name="position" rules={[{ required: true, message: '请选择' }]}>
41
-              <Select>
42
-                <Option value="index">首次引导页</Option>
43
-                <Option value="index">app启动页</Option>
44
-                <Option value="banner">banner</Option>
71
+              <Select style={{ width: '350px' }}>
72
+                <Option value="index" key="index">
73
+                  首次引导页
74
+                </Option>
75
+                <Option value="appIndex" key="appIndex">
76
+                  app启动页
77
+                </Option>
78
+                <Option value="banner" key="banner">
79
+                  轮播图
80
+                </Option>
45 81
               </Select>
46 82
             </FormItem>
47
-            <FormItem label="详细信息" colon={false}>
83
+            <FormItem label="排序" name="sortNo" rules={[{ required: true, message: '请输入' }]}>
84
+              <InputNumber min={0} placeholder="请输入排序" style={{ width: '350px' }} />
85
+            </FormItem>
86
+            {/* <FormItem label="详细信息" colon={false}>
48 87
               <ExtendContent
49 88
                 targetType="tourist"
50 89
                 targetId={'66'}
51 90
                 onCancel={() => history.goBack()}
52 91
               />
53
-            </FormItem>
92
+            </FormItem> */}
54 93
             <FormItem label=" " colon={false}>
55 94
               <Button type="default" onClick={() => goBack()}>
56 95
                 返回

+ 62
- 62
src/pages/ContentManagementSystem/Advertisement/index.jsx 查看文件

@@ -1,54 +1,54 @@
1 1
 import { history, Link } from 'umi';
2 2
 import { useRef } from 'react';
3
-import { Button, Modal, message, Popconfirm, Tooltip } from 'antd';
4
-import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
3
+import { Button, Modal, message, Popconfirm } from 'antd';
4
+import { PlusOutlined } from '@ant-design/icons';
5 5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
-import ProTable, { TableDropdown } from '@ant-design/pro-table';
6
+import PageTable from '@/components/PageTable';
7
+import { getBannerList, deleteBanner } from '@/services/ad';
8
+import moment from 'moment';
7 9
 
10
+const formatterTime = (val) => {
11
+  return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
12
+};
8 13
 export default (props) => {
9
-  const dataSource = [
10
-    {
11
-      id: 9,
12
-      key: '1',
13
-      name: '胡彦斌',
14
-      age: 32,
15
-      zz: '西湖区湖底公园1号',
16
-      status: 1,
17
-    },
18
-  ];
19
-
20
-  // 测试内容👆-------------------------
21
-
22 14
   const actionRef = useRef();
23
-  const gotoDetail = (id) => {
24
-    history.push(`Advertisement/edit.jsx`);
15
+  const gotoEdit = (val) => {
16
+    if (val) {
17
+      history.push({ pathname: `Advertisement/edit.jsx`, data: val });
18
+    } else {
19
+      history.push(`Advertisement/edit.jsx`);
20
+    }
25 21
   };
26 22
 
27 23
   const handleDelete = (e) => {
28
-    deleteNote(e.noteId).then((res) => {
24
+    deleteBanner(e).then((res) => {
29 25
       message.success('删除成功');
30 26
       actionRef.current.reload();
31 27
     });
32 28
   };
33
-
34 29
   const handleOK = (record, data) => {
35
-    const titleCourse = record.status
36
-      ? '您确定要禁用该用户吗? 禁用后该用户不能在后台登陆!'
37
-      : '您确定要启用该用户吗? 启用后该用户将允许在后台登陆!';
30
+    const title = record.status
31
+      ? '您确定要将该banner状态变更为未发布吗? 变更后该banner将不在移动端显示'
32
+      : '您确定要将该banner状态变更为发布吗? 发布后该banner可以在移动端显示';
38 33
     Modal.confirm({
39
-      title: titleCourse,
34
+      title: title,
40 35
       okText: '确认',
41 36
       cancelText: '取消',
42 37
       onOk() {
43
-        publishNote(record.noteId, record.status ? 'off' : 'on').then((res) => {
44
-          message.success('操作成功');
45
-          actionRef.current.reload();
46
-        });
38
+        updateNews(record.newsId, { ...record, status: record.status === 1 ? 0 : 1 })
39
+          .then((res) => {
40
+            message.success('操作成功');
41
+            actionRef.current.reload();
42
+          })
43
+          .catch((err) => {
44
+            message.error(err);
45
+          });
47 46
       },
48 47
     });
49 48
   };
49
+
50 50
   const actions = () => [
51
-    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>
51
+    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoEdit()}>
52 52
       新增
53 53
     </Button>,
54 54
   ];
@@ -57,50 +57,46 @@ export default (props) => {
57 57
       title: '名称',
58 58
       key: 'title',
59 59
       dataIndex: 'title',
60
-      search: false,
61 60
     },
62 61
     {
63 62
       title: '图片',
64 63
       key: 'thumb',
65 64
       dataIndex: 'thumb',
66
-      search: false,
67 65
       render: (t) => <img width={110} src={t} alt="" />,
68 66
     },
69 67
     {
70 68
       title: '位置',
71 69
       key: 'position',
72 70
       dataIndex: 'position',
73
-      search: false,
71
+      render: (_, record) => {
72
+        return record.position === 'index'
73
+          ? '首次引导页'
74
+          : record.position === 'appIndex'
75
+          ? 'app启动页'
76
+          : '轮播图';
77
+      },
78
+    },
79
+    {
80
+      title: '排序',
81
+      key: 'sortNo',
82
+      dataIndex: 'sortNo',
83
+    },
84
+    {
85
+      title: '创建时间',
86
+      key: 'createDate',
87
+      dataIndex: 'createDate',
88
+      render: formatterTime,
74 89
     },
75 90
     {
76 91
       title: '状态',
77 92
       dataIndex: 'status',
78
-      // initialValue: 'all',
79 93
       key: 'status',
80
-      valueEnum: {
81
-        0: { text: '已发布', status: 'Success' },
82
-        1: { text: '未发布', status: 'Error' },
94
+      width: 100,
95
+      render: (_, record) => {
96
+        return record.status === 1 ? '发布' : '未发布';
83 97
       },
84 98
     },
85 99
 
86
-    {
87
-      title: (
88
-        <>
89
-          创建时间
90
-          <Tooltip placement="top">
91
-            <QuestionCircleOutlined style={{ marginLeft: 4 }} />
92
-          </Tooltip>
93
-        </>
94
-      ),
95
-      // hideInTable: true,
96
-      search: false,
97
-
98
-      key: 'createdAt',
99
-      dataIndex: 'createdAt',
100
-      valueType: 'date',
101
-      // render: (t) => formatterTime(t),
102
-      sorter: (a, b) => a.createdAt - b.createdAt, //时间排序
103
-    },
104 100
     {
105 101
       title: '操作',
106 102
       valueType: 'option',
@@ -108,17 +104,22 @@ export default (props) => {
108 104
       ellipsis: true,
109 105
       width: 200,
110 106
       render: (_, record) => [
111
-        <Link key={2} to={`Advertisement/edit.jsx`}>
107
+        <Button style={{ padding: 0 }} type="link" key={1} onClick={() => handleOK(record)}>
108
+          {record.status === 0 ? '发布' : '取消发布'}
109
+        </Button>,
110
+        <Button style={{ padding: 0 }} type="link" key={2} onClick={() => gotoEdit(record)}>
112 111
           编辑
113
-        </Link>,
112
+        </Button>,
114 113
         <Popconfirm
115 114
           key={3}
116 115
           title="您是否确认删除 ?"
117
-          onConfirm={() => handleDelete(record)}
116
+          onConfirm={() => handleDelete(record.bannerId)}
118 117
           okText="确定"
119 118
           cancelText="取消"
120 119
         >
121
-          <a href="#">删除</a>
120
+          <Button style={{ padding: 0 }} type="link">
121
+            删除
122
+          </Button>
122 123
         </Popconfirm>,
123 124
       ],
124 125
     },
@@ -126,11 +127,10 @@ export default (props) => {
126 127
 
127 128
   return (
128 129
     <PageHeaderWrapper>
129
-      <ProTable
130
-        dataSource={dataSource}
130
+      <PageTable
131 131
         columns={columns}
132
-        // request={getNoteList} 请求
133
-        // rowKey="noteId"
132
+        request={getBannerList}
133
+        rowKey="bannerId"
134 134
         search={false}
135 135
         options={false}
136 136
         toolBarRender={actions}

+ 0
- 50
src/pages/ContentManagementSystem/InformationClassification/InformationClassificationEdit/index.jsx 查看文件

@@ -1,50 +0,0 @@
1
-import { Input, Card, Select, Button, message } from 'antd';
2
-import { useEffect, useState } from 'react';
3
-import { Form } from 'antd';
4
-import { history } from 'umi';
5
-import ProCard from '@ant-design/pro-card';
6
-
7
-const { Option } = Select;
8
-const goBack = () => {
9
-  history.goBack();
10
-};
11
-const FormItem = Form.Item;
12
-export default (props) => {
13
-  const [form] = Form.useForm();
14
-  const [loading, setLoading] = useState(false);
15
-
16
-  const formItemLayout = {
17
-    //布局
18
-    labelCol: { span: 6 },
19
-    wrapperCol: { span: 14 },
20
-  };
21
-
22
-  const Submit = (values) => {};
23
-
24
-  return (
25
-    <Card>
26
-      <ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}>
27
-        <ProCard.TabPane key={1} tab="资讯管理">
28
-          <Form {...formItemLayout} onFinish={Submit} form={form}>
29
-            <FormItem label="分类名" name="name" rules={[{ required: true, message: '请输入' }]}>
30
-              <Input placeholder="请输入" style={{ width: '350px' }} />
31
-            </FormItem>
32
-            <FormItem label=" " colon={false}>
33
-              <Button type="default" onClick={() => goBack()}>
34
-                返回
35
-              </Button>
36
-              <Button
37
-                type="primary"
38
-                loading={loading}
39
-                htmlType="Submit"
40
-                style={{ marginLeft: '4em' }}
41
-              >
42
-                保存
43
-              </Button>
44
-            </FormItem>
45
-          </Form>
46
-        </ProCard.TabPane>
47
-      </ProCard>
48
-    </Card>
49
-  );
50
-};

+ 0
- 77
src/pages/ContentManagementSystem/InformationList/InformationListEdit/index.jsx 查看文件

@@ -1,77 +0,0 @@
1
-import { Input, Card, Select, Button, Form, message } from 'antd';
2
-import { useEffect, useState } from 'react';
3
-import { history } from 'umi';
4
-import ProCard from '@ant-design/pro-card';
5
-import ExtendContent from '@/components/ExtendContent';
6
-import { UploadImage } from '@/components/Upload';
7
-
8
-const { Option } = Select;
9
-const goBack = () => {
10
-  history.goBack();
11
-};
12
-const FormItem = Form.Item;
13
-export default (props) => {
14
-  const [form] = Form.useForm();
15
-  const [loading, setLoading] = useState(false);
16
-  const [image, setImage] = useState();
17
-
18
-  const formItemLayout = {
19
-    //布局
20
-    labelCol: { span: 6 },
21
-    wrapperCol: { span: 14 },
22
-  };
23
-
24
-  const Submit = (values) => {};
25
-
26
-  return (
27
-    <Card>
28
-      <ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}>
29
-        <ProCard.TabPane key={1} tab="资讯管理">
30
-          <Form {...formItemLayout} onFinish={Submit} form={form}>
31
-            <FormItem label="资讯分类" name="user" rules={[{ required: true, message: '请选择' }]}>
32
-              <Select
33
-                placeholder="请选择"
34
-                // onChange={onGenderChange}
35
-                allowClear
36
-                style={{ width: '350px' }}
37
-              >
38
-                <Option value="nongji">一分类</Option>
39
-                <Option value="nonghu">二分类</Option>
40
-              </Select>
41
-            </FormItem>
42
-            <FormItem
43
-              label="资讯名称"
44
-              name="shopName"
45
-              rules={[{ required: true, message: '请输入' }]}
46
-            >
47
-              <Input placeholder="请输入" style={{ width: '350px' }} />
48
-            </FormItem>
49
-            <FormItem label="资讯封面" name="thumb" rules={[{ required: true, message: '请输入' }]}>
50
-              <UploadImage value={image} onChange={setImage} />
51
-            </FormItem>
52
-            <FormItem label="详细信息" colon={false}>
53
-              <ExtendContent
54
-                targetType="tourist"
55
-                targetId={'66'}
56
-                onCancel={() => history.goBack()}
57
-              />
58
-            </FormItem>
59
-            <FormItem label=" " colon={false}>
60
-              <Button type="default" onClick={() => goBack()}>
61
-                返回
62
-              </Button>
63
-              <Button
64
-                type="primary"
65
-                loading={loading}
66
-                htmlType="Submit"
67
-                style={{ marginLeft: '4em' }}
68
-              >
69
-                保存
70
-              </Button>
71
-            </FormItem>
72
-          </Form>
73
-        </ProCard.TabPane>
74
-      </ProCard>
75
-    </Card>
76
-  );
77
-};

+ 122
- 0
src/pages/ContentManagementSystem/InformationList/edit.jsx 查看文件

@@ -0,0 +1,122 @@
1
+import { Input, Card, Select, Button, Form, InputNumber, message } from 'antd';
2
+import { useEffect, useState } from 'react';
3
+import { history } from 'umi';
4
+import ProCard from '@ant-design/pro-card';
5
+import ExtendContent from '@/components/ExtendContent';
6
+import { UploadImage } from '@/components/Upload';
7
+import { getNewsTypeList } from '@/services/newsType';
8
+import { addNews, updateNews, getNewsDetail } from '@/services/news';
9
+
10
+const { Option } = Select;
11
+const goBack = () => {
12
+  history.goBack();
13
+};
14
+const FormItem = Form.Item;
15
+export default (props) => {
16
+  const { location } = props;
17
+  const { id } = location.query;
18
+  const [form] = Form.useForm();
19
+  const [loading, setLoading] = useState(false);
20
+  const [newsTypeList, setNewsTypeList] = useState([]);
21
+
22
+  const formItemLayout = {
23
+    //布局
24
+    labelCol: { span: 6 },
25
+    wrapperCol: { span: 14 },
26
+  };
27
+
28
+  const Submit = (data) => {
29
+    setLoading(true);
30
+    if (id) {
31
+      updateNews(id, data)
32
+        .then(() => {
33
+          setLoading(false);
34
+          message.success('数据更新成功');
35
+          goBack();
36
+        })
37
+        .catch((err) => {
38
+          setLoading(false);
39
+          message.error(err.message || err);
40
+        });
41
+    } else {
42
+      addNews(data)
43
+        .then((res) => {
44
+          setLoading(false);
45
+          message.success('数据保存成功');
46
+          history.replace(`./edit.jsx?id=${res.newsId}`);
47
+        })
48
+        .catch((err) => {
49
+          setLoading(false);
50
+          message.error(err.message || err);
51
+        });
52
+    }
53
+  };
54
+  useEffect(() => {
55
+    getNewsTypeList().then((res) => {
56
+      setNewsTypeList(res.records);
57
+    });
58
+  }, []);
59
+  useEffect(() => {
60
+    if (id) {
61
+      getNewsDetail(id).then((res) => {
62
+        form.setFieldsValue(res);
63
+      });
64
+    }
65
+  }, [id]);
66
+  return (
67
+    <Card>
68
+      <ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}>
69
+        <ProCard.TabPane key={1} tab="资讯管理">
70
+          <Form {...formItemLayout} onFinish={Submit} form={form}>
71
+            <FormItem label="标题" name="title" rules={[{ required: true, message: '请输入' }]}>
72
+              <Input placeholder="请输入" style={{ width: '350px' }} />
73
+            </FormItem>
74
+            <FormItem
75
+              label="资讯分类"
76
+              name="typeId"
77
+              rules={[{ required: true, message: '请选择' }]}
78
+            >
79
+              <Select placeholder="请选择" allowClear style={{ width: '350px' }}>
80
+                {newsTypeList.map((item) => (
81
+                  <Option value={item.typeId} key={item.typeId}>
82
+                    {item.name}
83
+                  </Option>
84
+                ))}
85
+              </Select>
86
+            </FormItem>
87
+            <FormItem label="封面" name="thumb" rules={[{ required: true, message: '请输入' }]}>
88
+              <UploadImage />
89
+            </FormItem>
90
+            <FormItem label="权重" name="weight" rules={[{ required: true, message: '请输入' }]}>
91
+              <InputNumber min={0} placeholder="请输入权重" style={{ width: '350px' }} />
92
+            </FormItem>
93
+            <FormItem label="状态" name="status" rules={[{ required: true, message: '请选择' }]}>
94
+              <Select placeholder="请选择是否发布" style={{ width: '350px' }}>
95
+                <Option value={1}>发布</Option>
96
+                <Option value={0}>未发布</Option>
97
+              </Select>
98
+            </FormItem>
99
+            {id && (
100
+              <FormItem label="详细信息" colon={false}>
101
+                <ExtendContent targetType="info" targetId={id} onCancel={() => history.goBack()} />
102
+              </FormItem>
103
+            )}
104
+            <FormItem label=" " colon={false}>
105
+              <Button type="default" onClick={() => goBack()}>
106
+                返回
107
+              </Button>
108
+              <Button
109
+                type="primary"
110
+                loading={loading}
111
+                htmlType="Submit"
112
+                style={{ marginLeft: '4em' }}
113
+              >
114
+                保存
115
+              </Button>
116
+            </FormItem>
117
+          </Form>
118
+        </ProCard.TabPane>
119
+      </ProCard>
120
+    </Card>
121
+  );
122
+};

+ 108
- 68
src/pages/ContentManagementSystem/InformationList/index.jsx 查看文件

@@ -1,107 +1,147 @@
1
-import { history, Link } from 'umi';
2
-import { useRef } from 'react';
3
-import { Button, Modal, message, Popconfirm, Tooltip } from 'antd';
4
-import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
1
+import React, { useRef, useEffect, useState } from 'react';
2
+import { history } from 'umi';
3
+import { Button, Popconfirm, message, Select, Modal } from 'antd';
4
+import { PlusOutlined } from '@ant-design/icons';
5 5
 import { PageHeaderWrapper } from '@ant-design/pro-layout';
6
-import ProTable, { TableDropdown } from '@ant-design/pro-table';
6
+import PageTable from '@/components/PageTable';
7
+import moment from 'moment';
8
+import { getNewsList, deleteNews, updateNews } from '@/services/news';
9
+import { getNewsTypeList } from '@/services/newsType';
7 10
 
8
-export default (props) => {
9
-  const dataSource = [
10
-    {
11
-      status: 0,
12
-      key: '1',
13
-      name: '胡彦斌',
14
-      age: 32,
15
-      zz: '西湖区湖底公园1号',
16
-    },
17
-  ];
18
-
19
-  // 测试内容👆-------------------------
11
+const formatterTime = (val) => {
12
+  return val && val !== '-' ? moment(val).format('YYYY-MM-DD') : '-';
13
+};
14
+const { Option } = Select;
20 15
 
16
+export default (props) => {
21 17
   const actionRef = useRef();
22
-  const gotoDetail = (id) => {
23
-    history.push(`InformationList/InformationListEdit`);
24
-  };
18
+  const [newsTypeList, setNewsTypeList] = useState([]);
25 19
 
26
-  const handleDelete = (e) => {
27
-    deleteNote(e.noteId).then((res) => {
20
+  const gotoEdit = (id) => {
21
+    const queryStr = id ? `?id=${id}` : '';
22
+    history.push(`./informationList/edit.jsx${queryStr}`);
23
+  };
24
+  const handleDelete = (id) => {
25
+    deleteNews(id).then(() => {
28 26
       message.success('删除成功');
29 27
       actionRef.current.reload();
30 28
     });
31 29
   };
32
-
30
+  //列表切换资讯状态方法
31
+  const handleOK = (record, data) => {
32
+    const title = record.status
33
+      ? '您确定要将该资讯状态变更为未发布吗? 变更后该资讯将不在移动端显示'
34
+      : '您确定要将该资讯状态变更为发布吗? 发布后该资讯可以在移动端显示';
35
+    Modal.confirm({
36
+      title: title,
37
+      okText: '确认',
38
+      cancelText: '取消',
39
+      onOk() {
40
+        updateNews(record.newsId, { ...record, status: record.status === 1 ? 0 : 1 })
41
+          .then((res) => {
42
+            message.success('操作成功');
43
+            actionRef.current.reload();
44
+          })
45
+          .catch((err) => {
46
+            message.error(err);
47
+          });
48
+      },
49
+    });
50
+  };
51
+  useEffect(() => {
52
+    getNewsTypeList().then((res) => {
53
+      setNewsTypeList(res.records);
54
+    });
55
+  }, []);
33 56
   const actions = () => [
34
-    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>
57
+    <Button key="add" type="primary" icon={<PlusOutlined />} onClick={() => gotoEdit()}>
35 58
       新增
36 59
     </Button>,
37 60
   ];
38
-
39 61
   const columns = [
40 62
     {
41
-      title: '分类名',
42
-      key: 'name',
43
-      dataIndex: 'name',
44
-      search: false,
63
+      title: '标题',
64
+      dataIndex: 'title',
65
+      key: 'title',
66
+    },
67
+    {
68
+      title: '资讯类型',
69
+      dataIndex: 'typeId',
70
+      key: 'typeId',
71
+      renderFormItem: (item, field, form) => {
72
+        return (
73
+          <Select style={{ width: '350px' }}>
74
+            {newsTypeList.map((item) => (
75
+              <Option value={item.typeId} key={item.typeId}>
76
+                {item.name}
77
+              </Option>
78
+            ))}
79
+          </Select>
80
+        );
81
+      },
82
+      hideInTable: true,
45 83
     },
46 84
     {
47
-      title: '资讯标题',
48
-      dataIndex: 'zz',
49
-      key: 'zz',
85
+      title: '资讯分类',
86
+      dataIndex: 'typeName',
87
+      key: 'typeName',
50 88
       search: false,
89
+      width: 240,
51 90
     },
52 91
     {
53 92
       title: '封面',
54
-      key: 'thumb',
55 93
       dataIndex: 'thumb',
94
+      key: 'thumb',
95
+      width: 150,
96
+      render: (t) => <img width={110} src={t} alt="" />,
56 97
       search: false,
57
-      render: (t) => <img src={t} alt="" width={110} />,
58 98
     },
59 99
     {
60
-      title: (
61
-        <>
62
-          创建时间
63
-          <Tooltip placement="top">
64
-            <QuestionCircleOutlined style={{ marginLeft: 4 }} />
65
-          </Tooltip>
66
-        </>
67
-      ),
68
-      // hideInTable: true,
100
+      title: '权重',
101
+      dataIndex: 'weight',
102
+      key: 'weight',
69 103
       search: false,
70
-      key: 'createdAt',
71
-      dataIndex: 'createdAt',
72
-      valueType: 'date',
73
-      // render: (t) => formatterTime(t),
74
-      sorter: (a, b) => a.createdAt - b.createdAt, //时间排序
104
+      width: 100,
75 105
     },
76 106
     {
77
-      title: '状态',
107
+      title: '创建时间',
108
+      dataIndex: 'createDate',
109
+      key: 'createDate',
110
+      render: formatterTime,
111
+      search: false,
112
+      width: 100,
113
+    },
114
+    {
115
+      title: '发布状态',
78 116
       dataIndex: 'status',
79
-      // initialValue: 'all',
80 117
       key: 'status',
81
-      valueEnum: {
82
-        0: { text: '已发布', status: 'Success' },
83
-        1: { text: '未发布', status: 'Error' },
118
+      search: false,
119
+      width: 100,
120
+      render: (_, record) => {
121
+        return record.status === 1 ? '发布' : '未发布';
84 122
       },
85 123
     },
86
-
87 124
     {
88 125
       title: '操作',
89 126
       valueType: 'option',
90
-      key: 'option',
91
-      ellipsis: true,
92
-      width: 200,
127
+      width: 240,
93 128
       render: (_, record) => [
94
-        <Link key={2} to={`InformationList/InformationListEdit`}>
129
+        <Button style={{ padding: 0 }} type="link" key={1} onClick={() => handleOK(record)}>
130
+          {record.status === 0 ? '发布' : '取消发布'}
131
+        </Button>,
132
+        <Button style={{ padding: 0 }} type="link" key={2} onClick={() => gotoEdit(record.newsId)}>
95 133
           编辑
96
-        </Link>,
134
+        </Button>,
97 135
         <Popconfirm
98 136
           key={3}
99 137
           title="您是否确认删除 ?"
100
-          onConfirm={() => handleDelete(record)}
138
+          onConfirm={() => handleDelete(record.newsId)}
101 139
           okText="确定"
102 140
           cancelText="取消"
103 141
         >
104
-          <a href="#">删除</a>
142
+          <Button style={{ padding: 0 }} type="link">
143
+            删除
144
+          </Button>
105 145
         </Popconfirm>,
106 146
       ],
107 147
     },
@@ -109,15 +149,15 @@ export default (props) => {
109 149
 
110 150
   return (
111 151
     <PageHeaderWrapper>
112
-      <ProTable
113
-        dataSource={dataSource}
114
-        columns={columns}
115
-        // request={getNoteList} 请求
116
-        // rowKey="noteId"
117
-        search={false}
118
-        options={false}
152
+      <PageTable
153
+        request={getNewsList}
154
+        // expfunc={exportPersonList}
119 155
         toolBarRender={actions}
120 156
         actionRef={actionRef}
157
+        columns={columns}
158
+        rowKey="newsId"
159
+        options={false}
160
+        scroll={{ x: 1000 }}
121 161
       />
122 162
     </PageHeaderWrapper>
123 163
   );

+ 2
- 2
src/pages/Machinery/GPS/index.jsx 查看文件

@@ -83,7 +83,7 @@ export default (props) => {
83 83
 
84 84
   return (
85 85
     <PageHeaderWrapper>
86
-      <ProTable
86
+      {/* <ProTable
87 87
         dataSource={dataSource}
88 88
         columns={columns}
89 89
         // request={getNoteList} 请求
@@ -91,7 +91,7 @@ export default (props) => {
91 91
         options={false}
92 92
         toolBarRender={actions}
93 93
         actionRef={actionRef}
94
-      />
94
+      /> */}
95 95
     </PageHeaderWrapper>
96 96
   );
97 97
 };

+ 2
- 2
src/pages/Machinery/Machinery/index.jsx 查看文件

@@ -26,8 +26,8 @@ export default (props) => {
26 26
   //列表切换农机状态方法
27 27
   const handleOK = (record, data) => {
28 28
     const title = record.status
29
-      ? '您确定要将该农机状态变更为禁用吗? 禁用后该农机将不在移动端显示'
30
-      : '您确定要将该农机状态变更为启用吗? 启用后该农机可以在移动端显示';
29
+      ? '您确定要将该农机状态变更为取消发布吗? 取消后该农机将不在移动端显示'
30
+      : '您确定要将该农机状态变更为发布吗? 发布后该农机可以在移动端显示';
31 31
     Modal.confirm({
32 32
       title: title,
33 33
       okText: '确认',

+ 2
- 2
src/pages/Machinery/MachineryType/index.jsx 查看文件

@@ -28,8 +28,8 @@ export default (props) => {
28 28
   //列表切换分类状态方法
29 29
   const handleOK = (record, data) => {
30 30
     const title = record.status
31
-      ? '您确定要将该分类状态变更为禁用吗? 禁用后该分类将不能录入农机'
32
-      : '您确定要将该分类状态变更为启用吗? 启用后该分类可以录入农机';
31
+      ? '您确定要将该分类状态变更为取消发布吗? 取消后该分类将不能录入农机'
32
+      : '您确定要将该分类状态变更为发布吗? 发布后该分类可以录入农机';
33 33
     Modal.confirm({
34 34
       title: title,
35 35
       okText: '确认',

+ 2
- 2
src/pages/PlatformMessageManagement/MessageManageList/index.jsx 查看文件

@@ -112,7 +112,7 @@ export default (props) => {
112 112
 
113 113
   return (
114 114
     <PageHeaderWrapper>
115
-      <ProTable
115
+      {/* <ProTable
116 116
         dataSource={dataSource}
117 117
         columns={columns}
118 118
         // request={getList}
@@ -120,7 +120,7 @@ export default (props) => {
120 120
         options={false}
121 121
         toolBarRender={actions}
122 122
         scroll={{ x: 1000 }}
123
-      />
123
+      /> */}
124 124
     </PageHeaderWrapper>
125 125
   );
126 126
 };

+ 29
- 0
src/services/ad.js 查看文件

@@ -0,0 +1,29 @@
1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 保存banner
5
+ * @param {*} data
6
+ * @returns
7
+ */
8
+export const addBanner = (data) => request('/banner', { method: 'post', data });
9
+
10
+/**
11
+ * 修改banner
12
+ * @param {*} data
13
+ * @returns
14
+ */
15
+export const updateBanner = (id, data) => request(`/banner/${id}`, { method: 'put', data });
16
+
17
+/**
18
+ * 查询banner列表
19
+ * @param {*} params
20
+ * @returns
21
+ */
22
+export const getBannerList = (params) => request('/banner', { params });
23
+
24
+/**
25
+ * 删除banner
26
+ * @param {*} data
27
+ * @returns
28
+ */
29
+export const deleteBanner = (id) => request(`/banner/${id}`, { method: 'delete' });

+ 18
- 19
src/services/extendContent.js 查看文件

@@ -1,37 +1,36 @@
1
-import request from '@/utils/request'
1
+import request from '@/utils/request';
2 2
 
3 3
 /**
4 4
  * 保存扩展内容
5
- * @param {*} data 
6
- * @returns 
5
+ * @param {*} data
6
+ * @returns
7 7
  */
8
-export const save = (data) => request('/taExtendContent', { method: 'post', data })
8
+export const save = (data) => request('/extend-content', { method: 'post', data });
9 9
 
10 10
 /**
11 11
  * 修改扩展内容
12
- * @param {*} data 
13
- * @returns 
12
+ * @param {*} data
13
+ * @returns
14 14
  */
15
-export const update = (id, data) => request(`/taExtendContent/${id}`, { method: 'put', data })
15
+export const update = (id, data) => request(`/extend-content/${id}`, { method: 'put', data });
16 16
 
17 17
 /**
18
- * 查询扩展内容列表 
19
- * @param {*} params 
20
- * @returns 
18
+ * 查询扩展内容列表
19
+ * @param {*} params
20
+ * @returns
21 21
  */
22
-export const getList = (params) => request('/taExtendContent', { params })
23
-
22
+export const getList = (params) => request('/extend-content', { params });
24 23
 
25 24
 /**
26 25
  * 删除扩展内容
27
- * @param {*} data 
28
- * @returns 
26
+ * @param {*} data
27
+ * @returns
29 28
  */
30
- export const remove = (id) => request(`/taExtendContent/${id}`, { method: 'delete'})
31
- 
29
+export const remove = (id) => request(`/extend-content/${id}`, { method: 'delete' });
30
+
32 31
 /**
33 32
  * 查询扩展内容详情
34
- * @param {*} params 
35
- * @returns 
33
+ * @param {*} params
34
+ * @returns
36 35
  */
37
-export const getDetail = (id) => request(`/taExtendContent/${id}`)
36
+export const getDetail = (id) => request(`/extend-content/${id}`);

+ 36
- 0
src/services/news.js 查看文件

@@ -0,0 +1,36 @@
1
+import request from '@/utils/request';
2
+
3
+/**
4
+ * 保存资讯
5
+ * @param {*} data
6
+ * @returns
7
+ */
8
+export const addNews = (data) => request('/news', { method: 'post', data });
9
+
10
+/**
11
+ * 修改资讯
12
+ * @param {*} data
13
+ * @returns
14
+ */
15
+export const updateNews = (id, data) => request(`/news/${id}`, { method: 'put', data });
16
+
17
+/**
18
+ * 查询资讯列表
19
+ * @param {*} params
20
+ * @returns
21
+ */
22
+export const getNewsList = (params) => request('/news', { params });
23
+
24
+/**
25
+ * 删除资讯
26
+ * @param {*} data
27
+ * @returns
28
+ */
29
+export const deleteNews = (id) => request(`/news/${id}`, { method: 'delete' });
30
+
31
+/**
32
+ * 查询资讯详情
33
+ * @param {*} params
34
+ * @returns
35
+ */
36
+export const getNewsDetail = (id) => request(`/news/${id}`);