|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import { useState, useEffect } from "react";
|
|
|
|
|
import { Grid, Divider, Layout, Spin, Input, Col, Row, Space, Checkbox, Table, Button } from "antd";
|
|
|
|
|
import { PhoneOutlined, CustomerServiceOutlined, AudioOutlined, AuditOutlined } from "@ant-design/icons";
|
|
|
|
|
import { Grid, Divider, Layout, Spin, Input, Col, Row, Space, Checkbox, Table, Button, App } from "antd";
|
|
|
|
|
import { PhoneOutlined, CustomerServiceOutlined, FrownTwoTone, LikeTwoTone } from "@ant-design/icons";
|
|
|
|
|
import { useParams, useHref, useNavigate, NavLink } from "react-router-dom";
|
|
|
|
|
import { isEmpty, formatColonTime } from "@/utils/commons";
|
|
|
|
|
import dayjs from "dayjs";
|
|
|
|
@ -12,12 +12,14 @@ import { usingStorage } from "@/hooks/usingStorage";
|
|
|
|
|
|
|
|
|
|
const Invoice = props => {
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
const { notification } = App.useApp();
|
|
|
|
|
const { travelAgencyId } = usingStorage();
|
|
|
|
|
const [getVEIFlightBill, vEIFlightBill, loading] = airTicketStore(state => [state.getVEIFlightBill, state.vEIFlightBill, state.loading]);
|
|
|
|
|
const [getVEIFlightBill, vEIFlightBill, loading, postVEIFlightBillSubmit] = airTicketStore(state => [state.getVEIFlightBill, state.vEIFlightBill, state.loading, state.postVEIFlightBillSubmit]);
|
|
|
|
|
const showTotal = total => `合计 ${total} `;
|
|
|
|
|
const [selectedValues, setSelectedValues] = useState([]);
|
|
|
|
|
|
|
|
|
|
//统计总的费用
|
|
|
|
|
const totalFee = vEIFlightBill.reduce((acc, curr) => acc + curr.ServiceFee, 0);
|
|
|
|
|
const totalFee = vEIFlightBill && vEIFlightBill.reduce((acc, curr) => acc + curr.ServiceFee, 0);
|
|
|
|
|
const vEIFlightBillColumns = [
|
|
|
|
|
{
|
|
|
|
|
title: "团名",
|
|
|
|
@ -61,7 +63,6 @@ const Invoice = props => {
|
|
|
|
|
dataIndex: "FlightNo",
|
|
|
|
|
render: (text, record) => (record.CostType == "出票" ? text : "-"),
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
|
title: "PNR",
|
|
|
|
|
key: "PNR",
|
|
|
|
@ -101,9 +102,20 @@ const Invoice = props => {
|
|
|
|
|
title: "审核状态",
|
|
|
|
|
children: [
|
|
|
|
|
{
|
|
|
|
|
title: <Button type="link">全选</Button>,
|
|
|
|
|
title: (
|
|
|
|
|
<Button type="link" onClick={() => checkALL()}>
|
|
|
|
|
全选
|
|
|
|
|
</Button>
|
|
|
|
|
),
|
|
|
|
|
dataIndex: "CheckStatus", //状态小于2,表示还未提交审核
|
|
|
|
|
render: (text, record) => (record.CheckStatus < 2 ? <Checkbox>待提交</Checkbox> : record.CheckStatusName),
|
|
|
|
|
render: (text, record) =>
|
|
|
|
|
record.CheckStatus < 2 ? (
|
|
|
|
|
<Checkbox onChange={event => handleCheckboxChange(event, record.CLC_SN, record.OPI_SN)} checked={checkboxStates(record.CLC_SN)}>
|
|
|
|
|
待提交
|
|
|
|
|
</Checkbox>
|
|
|
|
|
) : (
|
|
|
|
|
record.CheckStatusName
|
|
|
|
|
),
|
|
|
|
|
},
|
|
|
|
|
],
|
|
|
|
|
sorter: (a, b) => {
|
|
|
|
@ -111,6 +123,48 @@ const Invoice = props => {
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
//获取当前状态
|
|
|
|
|
const checkboxStates = CLC_SN => {
|
|
|
|
|
return selectedValues.some(v => v.CLC_SN === CLC_SN);
|
|
|
|
|
};
|
|
|
|
|
// 处理checkbox改变事件
|
|
|
|
|
const handleCheckboxChange = (event, CLC_SN, OPI_SN) => {
|
|
|
|
|
const value = { CLC_SN: CLC_SN, OPI_SN: OPI_SN };
|
|
|
|
|
if (event.target.checked) {
|
|
|
|
|
setSelectedValues([...selectedValues, value]); // 如果被选中,则添加到数组
|
|
|
|
|
} else {
|
|
|
|
|
setSelectedValues(selectedValues.filter(v => v.CLC_SN !== value.CLC_SN)); // 如果取消选中,则从数组中移除
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
//提交账单
|
|
|
|
|
const postInvoice = () => {
|
|
|
|
|
postVEIFlightBillSubmit(selectedValues)
|
|
|
|
|
.then(() => {
|
|
|
|
|
notification.success({
|
|
|
|
|
message: `成功`,
|
|
|
|
|
description: "保存成功!",
|
|
|
|
|
placement: "top",
|
|
|
|
|
duration: 4,
|
|
|
|
|
icon: <LikeTwoTone />,
|
|
|
|
|
});
|
|
|
|
|
setSelectedValues([]); //清空选中的项目
|
|
|
|
|
})
|
|
|
|
|
.catch(() => {
|
|
|
|
|
notification.error({
|
|
|
|
|
message: `错误`,
|
|
|
|
|
description: "保存失败",
|
|
|
|
|
placement: "top",
|
|
|
|
|
duration: 4,
|
|
|
|
|
icon: <FrownTwoTone />,
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
//全选或不全选
|
|
|
|
|
const checkALL = () => {
|
|
|
|
|
if (isEmpty(vEIFlightBill)) return;
|
|
|
|
|
const allChecked = selectedValues.length === vEIFlightBill.filter(item => item.CheckStatus < 2).length;
|
|
|
|
|
setSelectedValues(allChecked ? [] : vEIFlightBill.filter(item => item.CheckStatus < 2).map(item => ({ CLC_SN: item.CLC_SN, OPI_SN: item.OPI_SN }))); // 如果全选,则清空数组,否则添加所有项
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {}, []);
|
|
|
|
|
|
|
|
|
@ -141,10 +195,19 @@ const Invoice = props => {
|
|
|
|
|
|
|
|
|
|
<Row>
|
|
|
|
|
<Col md={24} lg={24} xxl={24}>
|
|
|
|
|
<Table bordered={true} rowKey="id" columns={vEIFlightBillColumns} dataSource={vEIFlightBill} loading={loading} pagination={{ defaultPageSize: 100, showTotal: showTotal }} />
|
|
|
|
|
<Table bordered={true} rowKey="CLC_SN" columns={vEIFlightBillColumns} dataSource={vEIFlightBill} loading={loading} pagination={{ defaultPageSize: 100, showTotal: showTotal }} />
|
|
|
|
|
</Col>
|
|
|
|
|
<Col md={24} lg={24} xxl={24}></Col>
|
|
|
|
|
</Row>
|
|
|
|
|
<Row>
|
|
|
|
|
<Col md={24} lg={22} xxl={22}></Col>
|
|
|
|
|
|
|
|
|
|
<Col md={24} lg={2} xxl={2}>
|
|
|
|
|
<Button type="primary" size="large" onClick={postInvoice} disabled={selectedValues.length == 0}>
|
|
|
|
|
提交账单
|
|
|
|
|
</Button>
|
|
|
|
|
</Col>
|
|
|
|
|
</Row>
|
|
|
|
|
</Space>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|