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