|
@@ -1,15 +1,16 @@
|
1
|
|
-import { Input, Card, InputNumber, Button, message } from "antd"
|
2
|
|
-import { useEffect, useState } from 'react'
|
3
|
|
-import { Form } from "antd";
|
|
1
|
+import { Input, Card, InputNumber, Button, message } from 'antd';
|
|
2
|
+import { useEffect, useState } from 'react';
|
|
3
|
+import { Form } from 'antd';
|
4
|
4
|
import { history } from 'umi';
|
5
|
|
-import ProCard from '@ant-design/pro-card'
|
|
5
|
+import ProCard from '@ant-design/pro-card';
|
|
6
|
+import { getSetting, updateSetting } from '@/services/setting';
|
|
7
|
+import SettingRow from '@/components/SettingRow';
|
6
|
8
|
|
7
|
|
-
|
8
|
|
-const FormItem = Form.Item
|
|
9
|
+const FormItem = Form.Item;
|
9
|
10
|
export default (props) => {
|
10
|
|
-
|
11
|
|
- const [form] = Form.useForm()
|
12
|
|
- const [loading, setLoading] = useState(false)
|
|
11
|
+ const [form] = Form.useForm();
|
|
12
|
+ const [loading, setLoading] = useState(false);
|
|
13
|
+ const [data, setData] = useState([]);
|
13
|
14
|
|
14
|
15
|
const formItemLayout = {
|
15
|
16
|
//布局
|
|
@@ -17,25 +18,58 @@ export default (props) => {
|
17
|
18
|
wrapperCol: { span: 14 },
|
18
|
19
|
};
|
19
|
20
|
|
20
|
|
- const Submit = values => {
|
21
|
|
- console.log("🚀 ~ file: index.jsx ~ line 21 ~ values", values)
|
|
21
|
+ const Submit = (values) => {
|
|
22
|
+ console.log('🚀 ~ file: index.jsx ~ line 21 ~ values', values);
|
22
|
23
|
};
|
23
|
|
-
|
|
24
|
+ const handleChange = (item, val) => {
|
|
25
|
+ updateSetting(item.settingId, { ...item, settingValue: val })
|
|
26
|
+ .then(() => {
|
|
27
|
+ message.success('修改' + item.settingDesc + '成功');
|
|
28
|
+ })
|
|
29
|
+ .catch((err) => {
|
|
30
|
+ setLoading(false);
|
|
31
|
+ message.error(err.message || err);
|
|
32
|
+ });
|
|
33
|
+ };
|
|
34
|
+ useEffect(() => {
|
|
35
|
+ getSetting().then((res) => {
|
|
36
|
+ setData(res.records);
|
|
37
|
+ });
|
|
38
|
+ }, []);
|
24
|
39
|
return (
|
25
|
|
- <Card >
|
|
40
|
+ <Card>
|
26
|
41
|
<ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}>
|
27
|
42
|
<ProCard.TabPane key={1} tab="基本参数">
|
28
|
|
- <Form {...formItemLayout} onFinish={Submit} form={form} >
|
29
|
|
- <FormItem label="平台联系电话" name="shopName" rules={[{ required: true, message: '请输入' }]}>
|
30
|
|
- <Input placeholder="请输入" type={"number"} maxLength={11} style={{ width: '350px' }} />
|
|
43
|
+ {data.map((item) => {
|
|
44
|
+ return <SettingRow key={item.settingId} value={item} onChange={handleChange} />;
|
|
45
|
+ })}
|
|
46
|
+ {/* <Form {...formItemLayout} onFinish={Submit} form={form}>
|
|
47
|
+ <FormItem
|
|
48
|
+ label="平台联系电话"
|
|
49
|
+ name="shopName"
|
|
50
|
+ rules={[{ required: true, message: '请输入' }]}
|
|
51
|
+ >
|
|
52
|
+ <Input
|
|
53
|
+ placeholder="请输入"
|
|
54
|
+ type={'number'}
|
|
55
|
+ maxLength={11}
|
|
56
|
+ style={{ width: '350px' }}
|
|
57
|
+ />
|
31
|
58
|
</FormItem>
|
32
|
59
|
|
33
|
|
- <FormItem label=" " colon={false} >
|
34
|
|
- <Button type='primary' loading={loading} htmlType="Submit" style={{ marginLeft: '4em' }}>保存</Button>
|
|
60
|
+ <FormItem label=" " colon={false}>
|
|
61
|
+ <Button
|
|
62
|
+ type="primary"
|
|
63
|
+ loading={loading}
|
|
64
|
+ htmlType="Submit"
|
|
65
|
+ style={{ marginLeft: '4em' }}
|
|
66
|
+ >
|
|
67
|
+ 保存
|
|
68
|
+ </Button>
|
35
|
69
|
</FormItem>
|
36
|
|
- </Form>
|
|
70
|
+ </Form> */}
|
37
|
71
|
</ProCard.TabPane>
|
38
|
72
|
</ProCard>
|
39
|
73
|
</Card>
|
40
|
|
- )
|
41
|
|
-}
|
|
74
|
+ );
|
|
75
|
+};
|