ソースを参照

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

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

17
   const navigate = useNavigate();
17
   const navigate = useNavigate();
18
 
18
 
19
   const formRef = useRef();
19
   const formRef = useRef();
20
-
21
   useEffect(() => {
20
   useEffect(() => {
22
     if (id) {
21
     if (id) {
23
       getPostsDetail(id).then((res) => {
22
       getPostsDetail(id).then((res) => {
24
         formRef.current.setFieldsValue({
23
         formRef.current.setFieldsValue({
25
           ...res,
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
   }, [id]);
29
   }, [id]);
31
 
30
 
32
   const onFinish = async (values) => {
31
   const onFinish = async (values) => {
32
+    console.log(values);
33
+
34
+    //添加,修改
35
+    // addRegulation({ ...values, id }).then((res) => {
33
     savePosts({
36
     savePosts({
34
       ...values,
37
       ...values,
35
       type: 'regulation',
38
       type: 'regulation',
36
       filesList: values.filesList
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
         : null,
48
         : null,
46
       status: Number(values.status),
49
       status: Number(values.status),
47
-      ...(id?{id}:{}),
50
+      ...(id ? { id } : {}),
48
     }).then((res) => {
51
     }).then((res) => {
49
       navigate(-1);
52
       navigate(-1);
50
     });
53
     });