|
|
|
@ -1,18 +1,20 @@
|
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
|
import { useParams, } from 'react-router-dom';
|
|
|
|
|
import { App, Button, Collapse, Table, Space, } from 'antd';
|
|
|
|
|
import { useParams } from 'react-router-dom';
|
|
|
|
|
import { App, Button, Collapse, Table, Space, Divider } from 'antd';
|
|
|
|
|
import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
|
|
|
|
|
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index';
|
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
|
// import PrintContractPDF from './PrintContractPDF';
|
|
|
|
|
|
|
|
|
|
const Header = ({ title, agency, refresh, ...props}) => {
|
|
|
|
|
const Header = ({ title, agency, refresh, ...props }) => {
|
|
|
|
|
const { use_year, } = useParams();
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [activeAgency, ] = useProductsStore((state) => [state.activeAgency, ]);
|
|
|
|
|
const [activeAgency] = useProductsStore((state) => [state.activeAgency]);
|
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
|
const handleAuditItem = (state, row) => {
|
|
|
|
|
postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id})
|
|
|
|
|
postProductsQuoteAudit(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id })
|
|
|
|
|
.then((json) => {
|
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
|
message.success(json.errmsg);
|
|
|
|
@ -33,7 +35,7 @@ const Header = ({ title, agency, refresh, ...props}) => {
|
|
|
|
|
return (
|
|
|
|
|
<div className='flex justify-end items-center gap-4 h-full'>
|
|
|
|
|
<div className='grow'>
|
|
|
|
|
<h2 className='m-0 leading-tight'>{title}</h2>
|
|
|
|
|
<h2 className='m-0 leading-tight'>{title} {use_year}</h2>
|
|
|
|
|
</div>
|
|
|
|
|
{/* <Button size='small'>{t('Copy')}</Button> */}
|
|
|
|
|
{/* <Button size='small'>{t('Import')}</Button> */}
|
|
|
|
@ -46,20 +48,21 @@ const Header = ({ title, agency, refresh, ...props}) => {
|
|
|
|
|
<Button size='small' type={'primary'} danger ghost onClick={() => handleAuditItem('3', agency)}>
|
|
|
|
|
{t('products:auditStateAction.Rejected')}
|
|
|
|
|
</Button>
|
|
|
|
|
{/* todo: export */}
|
|
|
|
|
<Button size='small'>{t('Export')} PDF</Button>
|
|
|
|
|
{/* todo: export, 审核完成之后才能导出 */}
|
|
|
|
|
<Button size='small'>{t('Print')} PDF</Button>
|
|
|
|
|
{/* <PrintContractPDF /> */}
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const PriceTable = ({dataSource,refresh}) => {
|
|
|
|
|
const PriceTable = ({ dataSource, refresh }) => {
|
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
|
const [loading, activeAgency, ] = useProductsStore((state) => [state.loading, state.activeAgency, ]);
|
|
|
|
|
const [loading, activeAgency] = useProductsStore((state) => [state.loading, state.activeAgency]);
|
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
|
|
|
|
|
|
const handleAuditPriceItem = (state, row) => {
|
|
|
|
|
postProductsQuoteAudit(state, {id: row.id, travel_agency_id: activeAgency.travel_agency_id})
|
|
|
|
|
postProductsQuoteAudit(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id })
|
|
|
|
|
.then((json) => {
|
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
|
message.success(json.errmsg);
|
|
|
|
@ -79,7 +82,7 @@ const PriceTable = ({dataSource,refresh}) => {
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) },
|
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], width: '16rem', title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) },
|
|
|
|
|
{ key: 'adult', title: t('AgeType.Adult'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` },
|
|
|
|
|
{ key: 'child', title: t('AgeType.Child'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` },
|
|
|
|
|
// {key: 'price', title: t('Currency'), },
|
|
|
|
@ -95,35 +98,37 @@ const PriceTable = ({dataSource,refresh}) => {
|
|
|
|
|
key: 'useDates',
|
|
|
|
|
dataIndex: ['use_dates_start'],
|
|
|
|
|
title: t('UseDates'),
|
|
|
|
|
render: (_, { use_dates_start, use_dates_end }) => `${use_dates_start} ~ ${use_dates_end}`,
|
|
|
|
|
render: (_, { use_dates_start, use_dates_end, weekdays }) => `${use_dates_start} ~ ${use_dates_end}`, // + (weekdays ? `, ${t('OnWeekdays')}${weekdays}` : ''),
|
|
|
|
|
},
|
|
|
|
|
{ key: 'weekdays', dataIndex: ['weekdays'], title: t('Weekdays') },
|
|
|
|
|
{ key: 'weekdays', dataIndex: ['weekdays'], title: t('Weekdays'), render: (text, r) => text || t('Unlimited') },
|
|
|
|
|
{
|
|
|
|
|
key: 'state',
|
|
|
|
|
title: t('State'),
|
|
|
|
|
render: (_, r) => {
|
|
|
|
|
return stateMapVal[`${r.audit_state_id}`]?.label;
|
|
|
|
|
return <span className={`text-${stateMapVal[`${r.audit_state_id}`]?.color}`}>{stateMapVal[`${r.audit_state_id}`]?.label}</span>;
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
title: '价格审核',
|
|
|
|
|
key: 'action',
|
|
|
|
|
render: (_, r) => r.audit_state_id <= 0 ?(
|
|
|
|
|
<Space>
|
|
|
|
|
<Button onClick={() => handleAuditPriceItem('2', r)}>✔</Button>
|
|
|
|
|
<Button onClick={() => handleAuditPriceItem('3', r)}>✖</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
) : null,
|
|
|
|
|
render: (_, r) =>
|
|
|
|
|
r.audit_state_id <= 0 ? (
|
|
|
|
|
<Space>
|
|
|
|
|
<Button onClick={() => handleAuditPriceItem('2', r)}>✔</Button>
|
|
|
|
|
<Button onClick={() => handleAuditPriceItem('3', r)}>✖</Button>
|
|
|
|
|
</Space>
|
|
|
|
|
) : null,
|
|
|
|
|
},
|
|
|
|
|
];
|
|
|
|
|
return <Table pagination={false} {...{ loading, columns, dataSource }} rowKey={(r) => r.id} />;
|
|
|
|
|
}
|
|
|
|
|
return <Table size={'small'} pagination={false} {...{ columns, dataSource }} rowKey={(r) => r.id} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
*
|
|
|
|
|
*/
|
|
|
|
|
const TypesPanels = (props) => {
|
|
|
|
|
const [loading, agencyProducts, ] = useProductsStore((state) => [state.loading, state.agencyProducts]);
|
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]);
|
|
|
|
|
// console.log(agencyProducts);
|
|
|
|
|
const productsTypes = useProductsTypes();
|
|
|
|
|
const [activeKey, setActiveKey] = useState([]);
|
|
|
|
@ -138,7 +143,7 @@ const TypesPanels = (props) => {
|
|
|
|
|
children: (
|
|
|
|
|
<PriceTable
|
|
|
|
|
// loading={loading}
|
|
|
|
|
dataSource={agencyProducts[ele.value].reduce((r, c) => r.concat(c.quotation.map((q, i) => ({ ...q, info: c.info, rowSpan: i === 0 ? c.quotation.length : 0 }))), [])}
|
|
|
|
|
dataSource={agencyProducts[ele.value].reduce((r, c) => r.concat(c.quotation.map((q, i) => ({ ...q, weekdays: q.weekdays.split(',').filter(Boolean).map(w => t(`weekdaysShort.${w}`)).join(', '), info: c.info, rowSpan: i === 0 ? c.quotation.length : 0 }))), [])}
|
|
|
|
|
refresh={props.refresh}
|
|
|
|
|
/>
|
|
|
|
|
),
|
|
|
|
@ -151,31 +156,33 @@ const TypesPanels = (props) => {
|
|
|
|
|
}, [productsTypes, agencyProducts]);
|
|
|
|
|
|
|
|
|
|
const onCollapseChange = (_activeKey) => {
|
|
|
|
|
setActiveKey(_activeKey)
|
|
|
|
|
}
|
|
|
|
|
return (
|
|
|
|
|
<Collapse items={showTypes} activeKey={activeKey} onChange={onCollapseChange} />
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
setActiveKey(_activeKey);
|
|
|
|
|
};
|
|
|
|
|
return <Collapse items={showTypes} activeKey={activeKey} onChange={onCollapseChange} />;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const Audit = ({ ...props }) => {
|
|
|
|
|
const { travel_agency_id, use_year, audit_state } = useParams();
|
|
|
|
|
const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]);
|
|
|
|
|
const [loading, activeAgency, getAgencyProducts] = useProductsStore((state) => [state.loading, state.activeAgency, state.getAgencyProducts]);
|
|
|
|
|
|
|
|
|
|
const handleGetAgencyProducts = () => {
|
|
|
|
|
getAgencyProducts({ travel_agency_id, use_year, audit_state });
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
handleGetAgencyProducts();
|
|
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
|
}, [travel_agency_id])
|
|
|
|
|
}, [travel_agency_id]);
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
<SecondHeaderWrapper header={<Header title={activeAgency.travel_agency_name} agency={activeAgency} refresh={handleGetAgencyProducts} />}>
|
|
|
|
|
<SecondHeaderWrapper header={<Header title={activeAgency.travel_agency_name} agency={activeAgency} refresh={handleGetAgencyProducts} />} loading={loading} >
|
|
|
|
|
<hr />
|
|
|
|
|
{/* <Divider /> */}
|
|
|
|
|
{/* debug: 0 */}
|
|
|
|
|
{/* <PrintContractPDF /> */}
|
|
|
|
|
|
|
|
|
|
<TypesPanels refresh={handleGetAgencyProducts} />
|
|
|
|
|
</SecondHeaderWrapper>
|
|
|
|
|
</>
|
|
|
|
|