Blame view

src/pages/Order/components/HistoryModal.tsx 3.89 KB
zhongnanhuang authored
1
import { postServiceOrderQueryHistoryOrderRecord } from '@/services';
zhongnanhuang authored
2
import { enumValueToLabel, formatDateTime } from '@/utils';
zhongnanhuang authored
3
import { Button, Col, Empty, Flex, Modal, Row, Spin } from 'antd';
zhongnanhuang authored
4
import { useEffect, useState } from 'react';
zhongnanhuang authored
5
6
7
8
9
import {
  FINANCIAL_STATUS_OPTIONS,
  HISTORY_OPT_TYPE,
  ORDER_STATUS_OPTIONS,
} from '../constant';
zhongnanhuang authored
10
11
12
13
14

export default ({ subOrders, onClose }) => {
  let subOrderIds = subOrders?.map((subOrder: any) => {
    return subOrder.id;
  });
zhongnanhuang authored
15
  const [data, setData] = useState([]);
zhongnanhuang authored
16
17
  const [loading, setLoading] = useState(true);
  let i = 0;
zhongnanhuang authored
18
19
20
21
22
23
24
25
26

  const handleOk = () => {
    onClose();
  };

  const getHistory = async () => {
    let res = await postServiceOrderQueryHistoryOrderRecord({
      data: { ids: subOrderIds },
    });
zhongnanhuang authored
27
    setData(res.data);
zhongnanhuang authored
28
    setLoading(false);
zhongnanhuang authored
29
  };
zhongnanhuang authored
30
31
32
33

  useEffect(() => {
    getHistory();
  }, []);
zhongnanhuang authored
34
35
36
37
38
39
40
41
42
43

  const handleCancel = () => {
    onClose();
  };

  return (
    <>
      <Modal
        title="订单历史记录"
        open
zhongnanhuang authored
44
        width={650}
zhongnanhuang authored
45
46
47
48
49
50
51
52
        onOk={handleOk}
        onCancel={handleCancel}
        footer={() => (
          <>
            <Button onClick={handleCancel}>返回</Button>
          </>
        )}
      >
zhongnanhuang authored
53
54
55
56
        <Spin tip="加载中" spinning={loading}>
          <Row className="max-h-[500px] overflow-auto" gutter={[0, 14]}>
            {data.map((item) => {
              return (
zhongnanhuang authored
57
                <Col span={24} key={i}>
zhongnanhuang authored
58
                  <Flex vertical>
zhongnanhuang authored
59
60
61
62
63
64
65
66
67
68
69
70
                    <div>
                      <span className="py-2 text-[#5E5E5E]">
                        {'商品' + ++i}
                      </span>
                      <span className="text-[#8C8C8C]">
                        -【{subOrders[i - 1].productName}】
                      </span>
                    </div>

                    <Flex vertical>
                      {item.historySubOrderRecordDto?.map((history) => {
                        return (
zhongnanhuang authored
71
                          <div className="py-1" key={history.id}>
zhongnanhuang authored
72
73
74
75
76
77
78
79
80
81
82
                            <span className="pr-2 text-[#5E5E5E]">
                              {formatDateTime(history.createTime)}
                            </span>
                            <span className="text-[#3b83e5]">
                              {history.createByName}
                            </span>
                            进行了
                            <span className="text-[#3b83e5]">
                              {HISTORY_OPT_TYPE.get(history.record)}
                            </span>
zhongnanhuang authored
83
84
85
86
                            {enumValueToLabel(
                              history.status,
                              ORDER_STATUS_OPTIONS,
                            ) === undefined
zhongnanhuang authored
87
88
89
90
91
92
93
94
                              ? '子订单开票状态为'
                              : '子订单状态为'}

                            <span className="text-[#3b83e5]">
                              {enumValueToLabel(
                                history.status,
                                ORDER_STATUS_OPTIONS,
                              ) === undefined
zhongnanhuang authored
95
96
97
98
                                ? enumValueToLabel(
                                    history.status,
                                    FINANCIAL_STATUS_OPTIONS,
                                  )
zhongnanhuang authored
99
100
101
102
103
104
105
106
107
                                : enumValueToLabel(
                                    history.status,
                                    ORDER_STATUS_OPTIONS,
                                  )}
                            </span>
                          </div>
                        );
                      })}
                    </Flex>
zhongnanhuang authored
108
                  </Flex>
zhongnanhuang authored
109
110
111
112
113
114
115
116
117
118
                </Col>
              );
            })}
          </Row>
          {data?.length <= 0 ? (
            <Empty image={Empty.PRESENTED_IMAGE_SIMPLE} />
          ) : (
            ''
          )}
        </Spin>
zhongnanhuang authored
119
120
121
122
      </Modal>
    </>
  );
};