fangmingyue 2 年之前
父節點
當前提交
f3e868d8c3

+ 67
- 0
src/pages/rotationChart/introduction/edit/index.jsx 查看文件

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

+ 90
- 25
src/pages/rotationChart/introduction/index.jsx 查看文件

@@ -1,28 +1,93 @@
1
-import { ProFormTextArea, ProForm } from '@ant-design/pro-components';
2
-import { Col, Row, Space } from 'antd';
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';
3 7
 
4
-export default (props) => {
5
-  console.log('小方', props);
6
-  return (
7
-    <ProForm
8
-      submitter={{
9
-        searchConfig: {
10
-          resetText: '返回',
11
-        },
12
-        onReset: () => navigate(-1),
13
-        render: (props, doms) => {
14
-          return (
15
-            <Row>
16
-              <Col span={8} offset={11}>
17
-                <Space>{doms}</Space>
18
-              </Col>
19
-            </Row>
20
-          );
21
-        },
22
-      }}
23
-    >
24
-      <ProFormTextArea placeholder="请输入..."></ProFormTextArea>
25
-    </ProForm>
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>,
26 52
 
27
-  )
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
+  );
28 91
 }
92
+
93
+export default IntroductionList;

+ 1
- 1
src/pages/stockClassification/list/index.jsx 查看文件

@@ -1,5 +1,5 @@
1 1
 
2
-import { getStoreTypeList,deleteStoreType } from '@/services/stock';
2
+import { getStoreTypeList, deleteStoreType } from '@/services/stock';
3 3
 import { queryTable } from '@/utils/request';
4 4
 import { PageContainer, ProTable } from '@ant-design/pro-components';
5 5
 import { useNavigate } from 'react-router-dom';

+ 8
- 15
src/regulation/edit/index.jsx 查看文件

@@ -1,4 +1,5 @@
1
-import { addRegulation, updataRegulation, getRegulationById } from '@/services/regulation';
1
+import { addRegulation, getRegulationById } from '@/services/regulation';
2
+import { queryDict } from '@/utils/request';
2 3
 import { PageContainer, ProForm, ProFormSelect, ProFormText } from '@ant-design/pro-components';
3 4
 import { Card, Col, message, Row, Space } from 'antd';
4 5
 import { useNavigate, useSearchParams } from 'react-router-dom';
@@ -21,20 +22,12 @@ export default (props) => {
21 22
   const onFinish = async (values) => {
22 23
     console.log(values);
23 24
 
24
-    if (id) {
25
-      //修改
26
-      updataRegulation({ ...values }, id).then((res) => {
27
-        message.success('修改成功');
28
-        navigate(-1);
29
-      });
30
-
31
-    } else {
32
-      //添加
33
-      addRegulation({ ...values }).then((res) => {
34
-        message.success('添加成功');
35
-        navigate(-1);
36
-      });
37
-    }
25
+    // if (id) {
26
+    //添加,修改
27
+    addRegulation({ ...values, id }).then((res) => {
28
+      message.success('成功');
29
+      navigate(-1);
30
+    });
38 31
     return false;
39 32
   };
40 33
 

+ 11
- 12
src/regulation/index.jsx 查看文件

@@ -1,6 +1,6 @@
1
-import { getRegulationList, updataRegulation, deleteRegulation } from '@/services/regulation';
1
+import { getRegulationList, deleteRegulation } from '@/services/regulation';
2 2
 import { PageContainer, ProTable } from '@ant-design/pro-components';
3
-import { useRef, useState } from 'react';
3
+import { useRef, useState, useEffect } from 'react';
4 4
 import { useNavigate } from 'react-router-dom';
5 5
 import { queryTable } from '@/utils/request';
6 6
 import { Button, message, Popconfirm } from 'antd';
@@ -9,15 +9,9 @@ const RegulationList = (props) => {
9 9
   const actionRef = useRef();
10 10
   const navigate = useNavigate();
11 11
 
12
-  // const updata = (row) => {
13
-  //   if (row.id) {
14
-  //     // 修改
15
-  //     updataRegulation(row.id, { ...values }).then((res) => {
16
-  //       message.success('修改成功');
17
-  //       navigate(-1);
18
-  //     });
19
-  //   }
20
-  // };
12
+  useEffect(() => {
13
+    actionRef.current.reload();
14
+  });
21 15
 
22 16
   const handleDelete = (id) => {
23 17
     if (id) {
@@ -33,28 +27,33 @@ const RegulationList = (props) => {
33 27
       title: 'id',
34 28
       dataIndex: 'id',
35 29
       width: 200,
30
+      search: false,
36 31
     },
37 32
     {
38 33
       title: '标题',
39 34
       dataIndex: 'title',
40 35
       width: 200,
36
+      search: true,
41 37
     },
42 38
 
43 39
     {
44 40
       title: '内容',
45 41
       dataIndex: 'detail',
46 42
       width: 200,
43
+      search: false,
47 44
     },
48 45
 
49 46
     {
50 47
       title: '发布人',
51 48
       dataIndex: 'create_person',
52 49
       width: 200,
50
+      search: false,
53 51
     },
54 52
     {
55 53
       title: '发布时间',
56 54
       dataIndex: 'create_date',
57 55
       width: 200,
56
+      search: false,
58 57
     },
59 58
     {
60 59
       title: '操作',
@@ -92,7 +91,7 @@ const RegulationList = (props) => {
92 91
   return (
93 92
     <PageContainer>
94 93
       <ProTable
95
-        search={false}
94
+        search={true}
96 95
         actionRef={actionRef}
97 96
         rowKey="id"
98 97
         toolBarRender={() => [

+ 9
- 0
src/routes/routes.jsx 查看文件

@@ -30,6 +30,7 @@ import StockClassificationEdit from '@/pages/stockClassification/edit';
30 30
 import RotationChartList from '@/pages/rotationChart/list';
31 31
 import RotationChartEdit from '@/pages/rotationChart/edit';
32 32
 import RotationChartIntroduction from '@/pages/rotationChart/introduction';
33
+import RotationChartIntroductionEdit from '@/pages/rotationChart/introduction/edit';
33 34
 import Roles from '@/pages/roles/index';
34 35
 import RegulationList from '@/regulation';
35 36
 import RegulationEdit from '@/regulation/edit';
@@ -208,6 +209,14 @@ export const authRoutes = [
208 209
           title: "本站信息简介",
209 210
         },
210 211
       },
212
+      {
213
+        path: "rotationChart/introduction/edit",
214
+        element: <RotationChartIntroductionEdit />,
215
+        meta: {
216
+          hideInMenu: true,
217
+          title: "本站信息简介维护",
218
+        },
219
+      },
211 220
       {
212 221
         path: 'regulation',
213 222
         element: <RegulationList />,

+ 14
- 12
src/services/regulation.js 查看文件

@@ -1,4 +1,4 @@
1
-import request from '@/utils/request';
1
+import request, { restful } from '@/utils/request';
2 2
 
3 3
 /**
4 4
  * 查询列表
@@ -8,18 +8,12 @@ import request from '@/utils/request';
8 8
 export const getRegulationList = (params) => request('/posts', { params });
9 9
 
10 10
 /**
11
-* 新增
12
-* @param {*} data
11
+* 新增,更新
12
+*  @param {*} data
13
+ *@param {*} id
13 14
 * @returns
14 15
 */
15
-export const addRegulation = (data) => request('/posts', { method: 'post', data });
16
-
17
-/**
18
- * 更新
19
- * @param {*} data
20
- * @returns
21
- */
22
-export const updataRegulation = (data, id) => request(`/posts/${id}`, { method: 'get', data });
16
+export const addRegulation = (data) => request(`/posts`, { method: 'post', data });
23 17
 
24 18
 /**
25 19
 * 详情
@@ -33,4 +27,12 @@ export const getRegulationById = (id) => request(`/posts/${id}`);
33 27
  * @param {*} id
34 28
  * @returns
35 29
  */
36
-export const deleteRegulation = (id) => request(`/posts/${id}`, { method: 'delete' });
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 });

+ 1
- 1
vite.config.js 查看文件

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