|
@@ -1,5 +1,5 @@
|
1
|
|
-import React, { useRef } from 'react'
|
2
|
|
-import { Button, Card, Form, Input, Select, Row, Col } from 'antd'
|
|
1
|
+import React, { useRef } from "react";
|
|
2
|
+import { Button, Card, Form, Input, Select, Row, Col } from "antd";
|
3
|
3
|
import {
|
4
|
4
|
ProForm,
|
5
|
5
|
ProFormDateTimeRangePicker,
|
|
@@ -7,56 +7,56 @@ import {
|
7
|
7
|
ProFormSelect,
|
8
|
8
|
ProFormText,
|
9
|
9
|
ProFormRadio,
|
10
|
|
-} from '@ant-design/pro-components'
|
11
|
|
-import useBool from '@/utils/hooks/useBool'
|
12
|
|
-import { useSearchParams, useNavigate } from 'react-router-dom'
|
13
|
|
-import Page from '@/components/Page'
|
14
|
|
-import { formItemLayout, tailFormItemLayout } from '@/utils/form'
|
15
|
|
-import { postTaCustom, putTaCustom, getTaCustomId } from '@/services/taCustom'
|
16
|
|
-const { Option } = Select
|
|
10
|
+} from "@ant-design/pro-components";
|
|
11
|
+import useBool from "@/utils/hooks/useBool";
|
|
12
|
+import { useSearchParams, useNavigate } from "react-router-dom";
|
|
13
|
+import Page from "@/components/Page";
|
|
14
|
+import { formItemLayout, tailFormItemLayout } from "@/utils/form";
|
|
15
|
+import { postTaCustom, putTaCustom, getTaCustomId } from "@/services/taCustom";
|
|
16
|
+const { Option } = Select;
|
17
|
17
|
|
18
|
18
|
export default (props) => {
|
19
|
|
- const formRef = useRef()
|
20
|
|
- const [submiting, startSubmit, cancelSubmit] = useBool()
|
|
19
|
+ const formRef = useRef();
|
|
20
|
+ const [submiting, startSubmit, cancelSubmit] = useBool();
|
21
|
21
|
|
22
|
|
- const [searchParams] = useSearchParams()
|
23
|
|
- const navigate = useNavigate()
|
|
22
|
+ const [searchParams] = useSearchParams();
|
|
23
|
+ const navigate = useNavigate();
|
24
|
24
|
|
25
|
|
- const id = searchParams.get('id')
|
|
25
|
+ const id = searchParams.get("id");
|
26
|
26
|
|
27
|
27
|
React.useEffect(() => {
|
28
|
28
|
if (id) {
|
29
|
29
|
getTaCustomId(id).then((res) => {
|
30
|
|
- formRef.current?.setFieldsValue(res)
|
31
|
|
- })
|
|
30
|
+ formRef.current?.setFieldsValue(res);
|
|
31
|
+ });
|
32
|
32
|
}
|
33
|
|
- })
|
|
33
|
+ });
|
34
|
34
|
|
35
|
35
|
const onFinish = (values) => {
|
36
|
|
- startSubmit()
|
|
36
|
+ startSubmit();
|
37
|
37
|
if (id) {
|
38
|
38
|
//修改
|
39
|
|
- const customId = id
|
|
39
|
+ const customId = id;
|
40
|
40
|
putTaCustom(id, { customId, ...values })
|
41
|
41
|
.then((res) => {
|
42
|
|
- cancelSubmit()
|
43
|
|
- navigate(-1)
|
|
42
|
+ cancelSubmit();
|
|
43
|
+ navigate(-1);
|
44
|
44
|
})
|
45
|
45
|
.catch(() => {
|
46
|
|
- cancelSubmit()
|
47
|
|
- })
|
|
46
|
+ cancelSubmit();
|
|
47
|
+ });
|
48
|
48
|
} else {
|
49
|
49
|
//新增
|
50
|
50
|
postTaCustom(values)
|
51
|
51
|
.then((res) => {
|
52
|
|
- cancelSubmit()
|
53
|
|
- navigate(-1)
|
|
52
|
+ cancelSubmit();
|
|
53
|
+ navigate(-1);
|
54
|
54
|
})
|
55
|
55
|
.catch(() => {
|
56
|
|
- cancelSubmit()
|
57
|
|
- })
|
|
56
|
+ cancelSubmit();
|
|
57
|
+ });
|
58
|
58
|
}
|
59
|
|
- }
|
|
59
|
+ };
|
60
|
60
|
|
61
|
61
|
return (
|
62
|
62
|
<Page>
|
|
@@ -87,18 +87,23 @@ export default (props) => {
|
87
|
87
|
<ProFormText name="account" label="客户账号" />
|
88
|
88
|
<ProFormText name="contactsName" label="联系人姓名" />
|
89
|
89
|
<ProFormText name="contactsTitle" label="联系人头衔" />
|
90
|
|
- <ProFormText name="contactsPhone" label="联系人手机" />
|
|
90
|
+ <ProFormText
|
|
91
|
+ name="contactsPhone"
|
|
92
|
+ label="联系人手机"
|
|
93
|
+ maxlength={11}
|
|
94
|
+ type="number"
|
|
95
|
+ />
|
91
|
96
|
<ProFormText name="contactsEmail" label="联系人邮箱" />
|
92
|
97
|
<ProFormRadio.Group
|
93
|
98
|
name="isOrg"
|
94
|
99
|
label="是否企业"
|
95
|
100
|
options={[
|
96
|
|
- { label: '否', value: 0 },
|
97
|
|
- { label: '是', value: 1 },
|
|
101
|
+ { label: "否", value: 0 },
|
|
102
|
+ { label: "是", value: 1 },
|
98
|
103
|
]}
|
99
|
104
|
/>
|
100
|
105
|
</ProForm>
|
101
|
106
|
</Card>
|
102
|
107
|
</Page>
|
103
|
|
- )
|
104
|
|
-}
|
|
108
|
+ );
|
|
109
|
+};
|