Blame view

src/pages/pms/partPlan/PlanPool/components/AreaTable.tsx 3.66 KB
f33cc9f7   by1642146903   计划池
1
2
3
4
5
6
  import {Table} from 'antd';
  import React, {useEffect, useState} from 'react';
  import useInitial from "@/hooks/useInitail";
  import {getList, ListVO} from "@/pages/pms/partPlan/PlanPool/api";
  import DetailModal from './DetailModal';
  import {useStore} from "@/pages/pms/partPlan/PlanPool";
da356727   jiangwei   配件计划调整
7
  import _ from 'lodash';
f33cc9f7   by1642146903   计划池
8
9
10
11
  
  const { Column } = Table;
  interface Props {
    showAnalyse?: boolean
f33cc9f7   by1642146903   计划池
12
13
14
    type?: number, // 类型1区域库2库房3车系4车型5配件
    // eslint-disable-next-line react/no-unused-prop-types
    detailType?: number, // 类型1区域库2库房3车系4车型5配件
f33cc9f7   by1642146903   计划池
15
16
17
    id?: number, // 上一个列表ID
  }
  export default function Index(props: Props = {}) {
57b51c35   jiangwei   配件计划池增加查看90天出库详情和...
18
    const { dfParams, key, setItem, setOutVisible, setCustVisible } = useStore();
f33cc9f7   by1642146903   计划池
19
    const {showAnalyse=true} = props;
48df7798   jiangwei   计划池展示信息优化
20
    const { data: parts, setParams, loading } = useInitial(getList, [], {...dfParams, ...props});
f33cc9f7   by1642146903   计划池
21
22
23
24
25
26
    const [visible, setVisible] = useState(false);
    // 类型1区域库2库房3车系4车型5配件
    const [detailType, setDetailType] = useState<number>();
    const [id, setId] = useState<number>();
  
    useEffect(() => {
f33cc9f7   by1642146903   计划池
27
28
29
30
31
32
33
      if (key == props.type) {
        setParams(dfParams, true);
      }
    }, [dfParams, key]);
  
    return (
      <div>
48df7798   jiangwei   计划池展示信息优化
34
        <Table rowKey={(v: ListVO) => `${v.id}`} scroll={{y: 500, x: 2500}} dataSource={parts || []} pagination={false} loading={loading}>
f33cc9f7   by1642146903   计划池
35
          <Column title="区域库" dataIndex="name" fixed="left" />
5f69c1aa   jiangwei   样式交互优化
36
          <Column title="本次计划数量(个)" dataIndex="cnt" fixed="left" />
da356727   jiangwei   配件计划调整
37
          <Column title="计划前库销比" dataIndex="ratio" render={t => (t ? t.toFixed(2) : "--")} />
26e33634   jiangwei   库销比展示
38
          <Column title="计划后库销比" dataIndex="planRatio" render={t => (t ? t.toFixed(2) : "--")} />
f33cc9f7   by1642146903   计划池
39
          <Column title="本次计划金额(元)" dataIndex="thisTimeAmount" />
bef418e5   jiangwei   优化
40
          <Column title="客户订件数量(个)" render={r => (r.buyCnt ? <a onClick={() => { setCustVisible(true); setItem(r); }}>{r.buyCnt}</a> : r.buyCnt)} />
48df7798   jiangwei   计划池展示信息优化
41
          <Column title="客户订件金额(元)" dataIndex="buyAmount" />
48df7798   jiangwei   计划池展示信息优化
42
          <Column title="在途未锁(个)" dataIndex="onTheWayUnlockCnt" />
b63dc2a7   jiangwei   fix
43
          
48df7798   jiangwei   计划池展示信息优化
44
          <Column title="在库未锁(个)" dataIndex="storageUnlockCnt" />
b63dc2a7   jiangwei   fix
45
          <Column title="在库已锁(个)" dataIndex="storageLockedCnt" />
da356727   jiangwei   配件计划调整
46
          <Column title="近90天月均出库(个)" render={r => (r.outStockCnt ? <a onClick={() => { setOutVisible(true); setItem(r); }}>{_.floor(r.outStockCnt/3)}</a> : r.outStockCnt)} />
f33cc9f7   by1642146903   计划池
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
90
91
92
93
94
95
96
97
98
99
100
          {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>
    );
  }