StepBnt.tsx
1.39 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
import React from "react";
import { Button } from 'antd';
import { useStore } from '@/pages/pms/partPlan/MinRatioPlan';
import _ from 'lodash';
interface Props {
length: number
}
export default function Index({length}: Props) {
const { bntLoading, getStep2, current, setCurrent, getSummary, submit, summarySupplier, brandId, parts } = useStore();
// const flag = _.flattenDeep(summarySupplier.map(it => it.parts || [])).length == parts.length;
const next = _.throttle(() => {
if (current == 1) {
getStep2();
}
if (current == 2) {
getSummary();
}
}, 1000);
const prev = _.throttle(() => {
setCurrent(current - 1);
}, 1000);
const onSubmit = _.throttle(() => {
submit();
}, 1000);
return (
<div style={{ display: "flex", justifyContent: "center" }}>
{current > 1 && (
<Button style={{ margin: "0 8px" }} onClick={prev} loading={bntLoading} disabled={!brandId}>
上一步
</Button>
)}
{current < length && (
<Button type="primary" onClick={next} loading={bntLoading} disabled={!brandId}>
下一步
</Button>
)}
{current == length && (
<Button
type="primary"
disabled={!brandId || summarySupplier.length == 0 }
loading={bntLoading}
onClick={onSubmit}
>
确认并提交
</Button>
)}
</div>
);
}