KPI 设置: 计算累计

feature/person-num
Lei OT 2 years ago
parent 3e3e7f1485
commit f3b6b1ed5a

@ -36,7 +36,7 @@ export default observer((props) => {
const PercentInput = useMemo( const PercentInput = useMemo(
() => () =>
// eslint-disable-next-line react/display-name // eslint-disable-next-line react/display-name
({ value, onChange, record, ...extProps }) => { ({ value, onChange, record, month, ...extProps }) => {
// // eslint-disable-next-line react-hooks/rules-of-hooks // // eslint-disable-next-line react-hooks/rules-of-hooks
const [inputValue, setInputValue] = useState(value); const [inputValue, setInputValue] = useState(value);
const handleInputChange = (e) => { const handleInputChange = (e) => {
@ -44,10 +44,11 @@ export default observer((props) => {
onChange?.(e.target.value); onChange?.(e.target.value);
}; };
const calcV = inputValue ? numberConvert10K(fixToInt((Number(record?.yearValue) * inputValue) / 100)) : 0; const calcV = inputValue ? numberConvert10K(fixToInt((Number(record?.yearValue) * inputValue) / 100)) : 0;
const sumUtil = new Array(month).fill(1).reduce((r, v, i) => r + fixToInt((Number(record?.yearValue || 0) * record[`M${i + 1}Percent`]) / 100), 0); //
return ( return (
<Space direction={'vertical'}> <Space direction={'vertical'}>
<Input key={'input'} suffix="%" type={'number'} value={inputValue} onChange={handleInputChange} step={0.1} /> <Input key={'input'} suffix="%" type={'number'} value={inputValue} onChange={handleInputChange} step={0.1} />
<Text type={'secondary'}>{calcV}</Text> <Text type={'secondary'}>{calcV}<Text italic type={'secondary'}>, {numberConvert10K(sumUtil)}</Text> </Text>
</Space> </Space>
); );
}, },

Loading…
Cancel
Save