fangmingyue 2 years ago
parent
commit
7ac2843b05

+ 13
- 10
src/pages/rotationChart/introduction/edit/index.jsx View File

@@ -1,28 +1,29 @@
1
-import { addRegulation, getRegulationById } from '@/services/regulation';
1
+import { addRegulation, getRegulationList } from '@/services/regulation';
2 2
 import { PageContainer, ProForm, ProFormTextArea } from '@ant-design/pro-components';
3 3
 import { Card, Col, message, Row, Space } from 'antd';
4 4
 import { useNavigate, useSearchParams } from 'react-router-dom';
5 5
 import { useEffect, useRef, useState } from 'react';
6
+import { queryTable } from '@/utils/request';
6 7
 
7 8
 export default (props) => {
9
+
8 10
   const [searchParams, setSearchParams] = useSearchParams();
9 11
   const id = searchParams.get('id');
12
+  const [data, setData] = useState({});
10 13
   const formRef = useRef();
11 14
   const navigate = useNavigate();
12 15
 
13 16
   useEffect(() => {
14
-    if (id) {
15
-      getRegulationById(id).then((res) => {
16
-        formRef.current.setFieldsValue(res);
17
-      });
18
-    }
19
-  }, [id]);
17
+    getRegulationList({ type: `station` }).then((res) => {
18
+      formRef.current.setFieldsValue(res.records[0]);
19
+      console.log('tt', res)
20
+    });
21
+  }, []);
20 22
 
21 23
   const onFinish = async (values) => {
22 24
     //添加,修改
23 25
     addRegulation({ ...values, id }).then((res) => {
24 26
       message.success('成功');
25
-      navigate(-1);
26 27
     });
27 28
     return false;
28 29
   };
@@ -40,7 +41,7 @@ export default (props) => {
40 41
             searchConfig: {
41 42
               resetText: '返回',
42 43
             },
43
-            onReset: () => navigate(-1),
44
+            // onReset: () => navigate(-1),
44 45
             render: (props, doms) => {
45 46
               return (
46 47
                 <Row>
@@ -53,12 +54,14 @@ export default (props) => {
53 54
           }}
54 55
         >
55 56
           <ProFormTextArea
56
-            name="detail"
57 57
             label="发布内容"
58 58
             placeholder="请输入发布内容"
59 59
             rules={[{ required: true, message: '请输入发布内容' }]}
60 60
             allowClear={false}
61 61
             width={750}
62
+            name="detail"
63
+            onFinish={onFinish}
64
+            request={queryTable(getRegulationList)}
62 65
           />
63 66
         </ProForm>
64 67
       </Card>

+ 0
- 93
src/pages/rotationChart/introduction/index.jsx View File

@@ -1,93 +0,0 @@
1
-import { getRegulationList, deleteRegulation } from '@/services/regulation';
2
-import { ProFormTextArea, ProForm, PageContainer, ProTable } from '@ant-design/pro-components';
3
-import { Button, message, Popconfirm } from 'antd';
4
-import { useNavigate } from 'react-router-dom';
5
-import { queryTable } from '@/utils/request';
6
-import { useRef, useState, useEffect } from 'react';
7
-
8
-const IntroductionList = (props) => {
9
-  const actionRef = useRef();
10
-  const navigate = useNavigate();
11
-
12
-  const handleDelete = (id) => {
13
-    if (id) {
14
-      deleteRegulation(id).then((res) => {
15
-        message.success('删除成功');
16
-        actionRef.current.reload();
17
-      });
18
-    }
19
-  };
20
-
21
-  const columns = [
22
-    {
23
-      title: 'id',
24
-      dataIndex: 'id',
25
-      width: 100,
26
-      search: false,
27
-      hideInTable: true,
28
-    },
29
-
30
-    {
31
-      title: '内容',
32
-      dataIndex: 'detail',
33
-      width: 400,
34
-      search: false,
35
-    },
36
-    {
37
-      title: '操作',
38
-      valueType: 'option',
39
-      width: 100,
40
-      render: (_, record) => [
41
-        <Button
42
-          key={2}
43
-          style={{ padding: 0 }}
44
-          type="link"
45
-          onClick={() => {
46
-            console.log(record, ']]');
47
-            navigate(`/cms/rotationChart/introduction/edit?id=${record.id}`);
48
-          }}
49
-        >
50
-          编辑
51
-        </Button>,
52
-
53
-        <Popconfirm
54
-          key={3}
55
-          title="您是否确认删除 ?"
56
-          onConfirm={() => handleDelete(record.id)}
57
-          okText="确定"
58
-          cancelText="取消"
59
-        >
60
-          {/* manualPush */}
61
-          <Button style={{ padding: 0 }} type="link">
62
-            删除
63
-          </Button>
64
-        </Popconfirm>,
65
-      ],
66
-    },
67
-  ];
68
-
69
-  return (
70
-    <PageContainer>
71
-      <ProTable
72
-        search={false}
73
-        actionRef={actionRef}
74
-        rowKey="id"
75
-        toolBarRender={() => [
76
-          <Button
77
-            key="2"
78
-            type="primary"
79
-            onClick={() => {
80
-              navigate('/cms/rotationChart/introduction/edit');
81
-            }}
82
-          >
83
-            新增
84
-          </Button>,
85
-        ]}
86
-        request={queryTable(getRegulationList)}
87
-        columns={columns}
88
-      />
89
-    </PageContainer>
90
-  );
91
-}
92
-
93
-export default IntroductionList;

+ 0
- 1
src/regulation/edit/index.jsx View File

@@ -22,7 +22,6 @@ export default (props) => {
22 22
   const onFinish = async (values) => {
23 23
     console.log(values);
24 24
 
25
-    // if (id) {
26 25
     //添加,修改
27 26
     addRegulation({ ...values, id }).then((res) => {
28 27
       message.success('成功');

+ 3
- 17
src/routes/routes.jsx View File

@@ -192,8 +192,8 @@ export const authRoutes = [
192 192
         element: <Navigate to="rotationChart/list" replace />,
193 193
       },
194 194
       {
195
-        path: "station",
196
-        element: null,
195
+        path: "rotationChart/introduction",
196
+        element: <RotationChartIntroductionEdit />,
197 197
         meta: {
198 198
           title: "本站信息",
199 199
         },
@@ -212,21 +212,7 @@ export const authRoutes = [
212 212
           title: "公告维护",
213 213
         },
214 214
       },
215
-      {
216
-        path: "rotationChart/introduction",
217
-        element: <RotationChartIntroduction />,
218
-        meta: {
219
-          title: "本站信息简介",
220
-        },
221
-      },
222
-      {
223
-        path: "rotationChart/introduction/edit",
224
-        element: <RotationChartIntroductionEdit />,
225
-        meta: {
226
-          hideInMenu: true,
227
-          title: "本站信息简介维护",
228
-        },
229
-      },
215
+
230 216
       {
231 217
         path: 'regulation',
232 218
         element: <RegulationList />,

+ 2
- 10
src/services/regulation.js View File

@@ -1,4 +1,4 @@
1
-import request, { restful } from '@/utils/request';
1
+import request from '@/utils/request';
2 2
 
3 3
 /**
4 4
  * 查询列表
@@ -27,12 +27,4 @@ export const getRegulationById = (id) => request(`/posts/${id}`);
27 27
  * @param {*} id
28 28
  * @returns
29 29
  */
30
-export const deleteRegulation = (id) => request(`/posts/${id}`, { method: 'delete' });
31
-
32
-//标题
33
-/**
34
- * 查询列表
35
- * @param {*} params
36
- * @returns
37
- */
38
-export const getRegulationTitleList = (params) => request('/posts', { params, successTip: false });
30
+export const deleteRegulation = (id) => request(`/posts/${id}`, { method: 'delete' });

+ 1
- 1
vite.config.js View File

@@ -9,7 +9,7 @@ export default defineConfig({
9 9
     proxy: {
10 10
       '/api/': {
11 11
         // 要代理的地址
12
-        target: 'http://192.168.89.76:8087',
12
+        target: 'http://192.168.89.147:8087',
13 13
         // 配置了这个可以从 http 代理到 https
14 14
         // 依赖 origin 的功能可能需要这个,比如 cookie
15 15
         changeOrigin: true,