AreaTable.tsx
2.99 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
77
78
79
80
81
82
83
84
85
86
87
88
89
import {Table} from 'antd';
import React, {useState} from 'react';
import { useStore } from '@/pages/pms/partPlan/AmountPlan';
import {PartVO} from "@/pages/pms/partPlan/MinRatioPlan/api";
import useInitial from "@/hooks/useInitail";
import {getList, ListVO} from "@/pages/pms/partPlan/AmountPlan/api";
import DetailModal from './DetailModal';
const { Column } = Table;
interface Props {
showAnalyse?: boolean
// eslint-disable-next-line react/no-unused-prop-types
type?: number, // 类型1区域库2库房3车系4车型5配件
// eslint-disable-next-line react/no-unused-prop-types
detailType?: number, // 类型1区域库2库房3车系4车型5配件
// eslint-disable-next-line react/no-unused-prop-types
id?: number, // 上一个列表ID
}
export default function Index(props: Props = {}) {
const {showAnalyse=true} = props;
const { dfParams } = useStore();
const { data: parts } = useInitial(getList, [], {...dfParams, ...props});
const [visible, setVisible] = useState(false);
// 类型1区域库2库房3车系4车型5配件
const [detailType, setDetailType] = useState<number>();
const [id, setId] = useState<number>();
return (
<div>
<Table rowKey={(v: PartVO) => `${v.partId}`} scroll={{y: 500, x: 1000}} dataSource={parts || []} pagination={false}>
<Column title="区域库" dataIndex="name" fixed="left" />
<Column title="本次计划金额(元)" dataIndex="thisTimeAmount" />
<Column title="动态库销比" dataIndex="ratio" render={t => (t || 0).toFixed(2)} />
<Column title="库存金额" dataIndex="stockAmount" render={t => (t || 0).toFixed(2)} />
<Column title="滚动90天月均出库金额" dataIndex="outAmount" render={t => (t || 0).toFixed(2)} />
{showAnalyse && (
<>
<Column
title="库房分析"
render={(t, _: ListVO) => (
<a onClick={() => {
setVisible(true);
setId(_.id);
setDetailType(2);
}}
>
查看
</a>
)}
/>
<Column
title="车系分析"
render={(t, _: ListVO) => (
<a onClick={() => {
setVisible(true);
setId(_.id);
setDetailType(3);
}}
>
查看
</a>
)}
/>
<Column
title="配件分析"
render={(t, _: ListVO) => (
<a onClick={() => {
setVisible(true);
setId(_.id);
setDetailType(5);
}}
>
查看
</a>
)}
/>
</>
)}
</Table>
<DetailModal
visible={visible}
onCancel={() => setVisible(false)}
id={id}
detailType={detailType}
type={1}
/>
</div>
);
}