fangmingyue 2 vuotta sitten
vanhempi
commit
50a09927a3

+ 9
- 12
src/pages/rotationChart/introduction/edit/index.jsx Näytä tiedosto

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

+ 0
- 2
src/regulation/edit/index.jsx Näytä tiedosto

@@ -10,7 +10,6 @@ export default (props) => {
10 10
   const id = searchParams.get('id');
11 11
   const formRef = useRef();
12 12
   const navigate = useNavigate();
13
-
14 13
   useEffect(() => {
15 14
     if (id) {
16 15
       getRegulationById(id).then((res) => {
@@ -24,7 +23,6 @@ export default (props) => {
24 23
 
25 24
     //添加,修改
26 25
     addRegulation({ ...values, id }).then((res) => {
27
-      // message.success('成功');
28 26
       navigate(-1);
29 27
     });
30 28
     return false;

+ 1
- 4
src/regulation/index.jsx Näytä tiedosto

@@ -8,10 +8,7 @@ import { Button, message, Popconfirm } from 'antd';
8 8
 const RegulationList = (props) => {
9 9
   const actionRef = useRef();
10 10
   const navigate = useNavigate();
11
-
12
-  useEffect(() => {
13
-    actionRef.current.reload();
14
-  });
11
+  // const turn = replace(/<[^]+>/g, '');
15 12
 
16 13
   const handleDelete = (id) => {
17 14
     if (id) {