ソースを参照

Merge branch 'dev' of http://git.ycjcjy.com/jgz/admin into dev

Yansen 2 年 前
コミット
73736a7fc3
共有2 個のファイルを変更した22 個の追加22 個の削除を含む
  1. 9
    12
      src/pages/rotationChart/introduction/edit/index.jsx
  2. 13
    10
      src/regulation/edit/index.jsx

+ 9
- 12
src/pages/rotationChart/introduction/edit/index.jsx ファイルの表示

@@ -1,4 +1,4 @@
1
-import { addRegulation, getRegulationList } from '@/services/regulation';
1
+import { addRegulation, getRegulationList, getRegulationById } 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';
@@ -6,27 +6,25 @@ import { useEffect, useRef, useState } from 'react';
6 6
 import { queryTable } from '@/utils/request';
7 7
 
8 8
 export default (props) => {
9
-
10
-  const [searchParams, setSearchParams] = useSearchParams();
11
-  const id = searchParams.get('id');
12
-  const [data, setData] = useState({});
13 9
   const formRef = useRef();
10
+  const idRef = useRef();
14 11
   const navigate = useNavigate();
15 12
 
16 13
   useEffect(() => {
17 14
     getRegulationList({ type: `station` }).then((res) => {
18 15
       formRef.current.setFieldsValue(res.records[0]);
19
-      console.log('tt', res)
16
+      idRef.current = res.records[0].id;
20 17
     });
21 18
   }, []);
22 19
 
23 20
   const onFinish = async (values) => {
24
-    //添加,修改
21
+    //修改
22
+    const id = idRef.current;
23
+    console.log('id', id)
25 24
     addRegulation({ ...values, id }).then((res) => {
26
-      // message.success('成功');
27 25
       navigate(-1);
28
-    });
29
-    return false;
26
+      return false;
27
+    })
30 28
   };
31 29
 
32 30
   return (
@@ -42,7 +40,7 @@ export default (props) => {
42 40
             searchConfig: {
43 41
               resetText: '返回',
44 42
             },
45
-            // onReset: () => navigate(-1),
43
+            onReset: () => navigate(-1),
46 44
             render: (props, doms) => {
47 45
               return (
48 46
                 <Row>
@@ -61,7 +59,6 @@ export default (props) => {
61 59
             allowClear={false}
62 60
             width={750}
63 61
             name="detail"
64
-            onFinish={onFinish}
65 62
             request={queryTable(getRegulationList)}
66 63
           />
67 64
         </ProForm>

+ 13
- 10
src/regulation/edit/index.jsx ファイルの表示

@@ -17,34 +17,37 @@ export default (props) => {
17 17
   const navigate = useNavigate();
18 18
 
19 19
   const formRef = useRef();
20
-
21 20
   useEffect(() => {
22 21
     if (id) {
23 22
       getPostsDetail(id).then((res) => {
24 23
         formRef.current.setFieldsValue({
25 24
           ...res,
26
-          filesList: res.filesList?.map((x) => x.fileAddr)[0]||null,
25
+          filesList: res.filesList?.map((x) => x.fileAddr)[0] || null,
27 26
         });
28 27
       });
29 28
     }
30 29
   }, [id]);
31 30
 
32 31
   const onFinish = async (values) => {
32
+    console.log(values);
33
+
34
+    //添加,修改
35
+    // addRegulation({ ...values, id }).then((res) => {
33 36
     savePosts({
34 37
       ...values,
35 38
       type: 'regulation',
36 39
       filesList: values.filesList
37 40
         ? [
38
-            {
39
-              fileAddr: values.filesList,
40
-              fileName: values.filesList?.substring(
41
-                values.filesList?.lastIndexOf("/") + 1
42
-              ),
43
-            },
44
-          ]
41
+          {
42
+            fileAddr: values.filesList,
43
+            fileName: values.filesList?.substring(
44
+              values.filesList?.lastIndexOf("/") + 1
45
+            ),
46
+          },
47
+        ]
45 48
         : null,
46 49
       status: Number(values.status),
47
-      ...(id?{id}:{}),
50
+      ...(id ? { id } : {}),
48 51
     }).then((res) => {
49 52
       navigate(-1);
50 53
     });