index.tsx
2.37 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
import React, { useState } from 'react';
import { Card, InputNumber, message } from 'antd';
import { PageHeaderWrapper } from '@ant-design/pro-layout';
import useInitail from '@/hooks/useInitail';
import ConfirmBnt from '../components/ConfirmBnt';
import { getDetail, saveApi, Item } from '../api';
export default function Index() {
const { data, setData, setLoading, loading } = useInitail<Item, { type: number }>(getDetail, {}, { type: 4 });
const [disable, setDisable] = useState(false);
function handleSave() {
saveApi({ ...data, type: 4 }).then(() => {
message.success("操作成功");
setLoading(true);
setDisable(false);
}).catch((e: any) => {
message.error(e.message);
});
}
function handleCancel() {
setData(data);
setDisable(false);
}
return (
<PageHeaderWrapper title="绩效设置">
<Card loading={loading}>
<div style={{ display: "flex", flexDirection: "column", fontSize: 16, padding: 20, }}>
<span style={{ marginBottom: 20 }}>1、库销比≥
<InputNumber
disabled={!disable}
bordered={disable}
size="small"
controls={false}
style={{width: 60}}
value={data.ratioMorax1}
onChange={(value: any) => setData({ ...data, ratioMorax1: value })}
/>
时每增加
<InputNumber
disabled={!disable}
bordered={disable}
size="small"
controls={false}
style={{ width: 60 }}
value={data.ratioMorax2}
onChange={(value: any) => setData({ ...data, ratioMorax2: value })}
/>
扣
<InputNumber
disabled={!disable}
bordered={disable}
size="small"
controls={false}
style={{ width: 60 }}
value={data.ratioMorax3}
onChange={(value: any) => setData({ ...data, ratioMorax3: value })}
/>
%
</span>
<ConfirmBnt
disable={disable}
onOk={handleSave}
onCancel={handleCancel}
onEdit={() => {
setDisable(true);
setData(data);
}}
/>
</div>
</Card>
</PageHeaderWrapper>
);
}