|
|
@ -7,15 +7,18 @@ import { useTranslation } from 'react-i18next';
|
|
|
|
import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index';
|
|
|
|
import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
const Header = ({ title, agency, ...props}) => {
|
|
|
|
const Header = ({ title, agency, refresh, ...props}) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]);
|
|
|
|
const [activeAgency, ] = useProductsStore((state) => [state.activeAgency, ]);
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const handleAuditItem = (state, row) => {
|
|
|
|
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) => {
|
|
|
|
.then((json) => {
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
message.success('✔');
|
|
|
|
message.success(json.errmsg);
|
|
|
|
|
|
|
|
if (typeof refresh === 'function') {
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((ex) => {
|
|
|
|
.catch((ex) => {
|
|
|
@ -34,8 +37,14 @@ const Header = ({ title, agency, ...props}) => {
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{/* <Button size='small'>{t('Copy')}</Button> */}
|
|
|
|
{/* <Button size='small'>{t('Copy')}</Button> */}
|
|
|
|
{/* <Button size='small'>{t('Import')}</Button> */}
|
|
|
|
{/* <Button size='small'>{t('Import')}</Button> */}
|
|
|
|
<Button size='small' type={'primary'} ghost onClick={() => handleAuditItem('2', agency)}>
|
|
|
|
<Button size='small' type={'primary'} onClick={() => handleAuditItem('2', agency)}>
|
|
|
|
|
|
|
|
{t('products:auditStateAction.Published')}
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
{/* <Button size='small' type={'primary'} ghost onClick={() => handleAuditItem('2', agency)}>
|
|
|
|
{t('products:auditStateAction.Approved')}
|
|
|
|
{t('products:auditStateAction.Approved')}
|
|
|
|
|
|
|
|
</Button> */}
|
|
|
|
|
|
|
|
<Button size='small' type={'primary'} danger ghost onClick={() => handleAuditItem('3', agency)}>
|
|
|
|
|
|
|
|
{t('products:auditStateAction.Rejected')}
|
|
|
|
</Button>
|
|
|
|
</Button>
|
|
|
|
{/* todo: export */}
|
|
|
|
{/* todo: export */}
|
|
|
|
<Button size='small'>{t('Export')} PDF</Button>
|
|
|
|
<Button size='small'>{t('Export')} PDF</Button>
|
|
|
@ -43,9 +52,9 @@ const Header = ({ title, agency, ...props}) => {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const PriceTable = ({dataSource, loading}) => {
|
|
|
|
const PriceTable = ({dataSource,refresh}) => {
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
const [activeAgency, ] = useProductsStore((state) => [state.activeAgency]);
|
|
|
|
const [loading, activeAgency, ] = useProductsStore((state) => [state.loading, state.activeAgency, ]);
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
|
|
|
|
|
|
|
@ -53,7 +62,10 @@ const PriceTable = ({dataSource, loading}) => {
|
|
|
|
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) => {
|
|
|
|
.then((json) => {
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
message.success('✔');
|
|
|
|
message.success(json.errmsg);
|
|
|
|
|
|
|
|
if (typeof refresh === 'function') {
|
|
|
|
|
|
|
|
refresh();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
})
|
|
|
|
.catch((ex) => {
|
|
|
|
.catch((ex) => {
|
|
|
@ -68,11 +80,11 @@ const PriceTable = ({dataSource, loading}) => {
|
|
|
|
|
|
|
|
|
|
|
|
const columns = [
|
|
|
|
const columns = [
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) },
|
|
|
|
{ key: 'title', dataIndex: ['info', 'title'], title: t('Title'), onCell: (r, index) => ({ rowSpan: r.rowSpan }) },
|
|
|
|
{ key: 'value', title: t('Quotation'), render: (_, { value, currency, unit_name }) => `${value} ${currency} / ${unit_name}` },
|
|
|
|
{ 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'), },
|
|
|
|
// {key: 'price', title: t('Currency'), },
|
|
|
|
// {key: 'currency', title: t('Currency'), },
|
|
|
|
// {key: 'currency', title: t('Currency'), },
|
|
|
|
// {key: 'unit', title: t('Unit'), },
|
|
|
|
// {key: 'unit', title: t('Unit'), },
|
|
|
|
{ key: 'ageType', dataIndex: ['age_type'], title: t('AgeType.Type') },
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
key: 'groupSize',
|
|
|
|
key: 'groupSize',
|
|
|
|
dataIndex: ['group_size_min'],
|
|
|
|
dataIndex: ['group_size_min'],
|
|
|
@ -94,24 +106,24 @@ const PriceTable = ({dataSource, loading}) => {
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
{
|
|
|
|
title: '',
|
|
|
|
title: '价格审核',
|
|
|
|
key: 'action',
|
|
|
|
key: 'action',
|
|
|
|
render: (_, r) => r.audit_state_id <= 0 ?(
|
|
|
|
render: (_, r) => r.audit_state_id <= 0 ?(
|
|
|
|
<Space>
|
|
|
|
<Space>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('2', r)}>✔</Button>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('2', r)}>✔</Button>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('0', r)}>✖</Button>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('3', r)}>✖</Button>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
) : null,
|
|
|
|
) : null,
|
|
|
|
},
|
|
|
|
},
|
|
|
|
];
|
|
|
|
];
|
|
|
|
return <Table pagination={false} columns={columns} dataSource={dataSource} rowKey={(r) => r.id} />;
|
|
|
|
return <Table pagination={false} {...{ loading, columns, dataSource }} rowKey={(r) => r.id} />;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
const TypesPanels = () => {
|
|
|
|
const TypesPanels = (props) => {
|
|
|
|
const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]);
|
|
|
|
const [loading, agencyProducts, ] = useProductsStore((state) => [state.loading, state.agencyProducts]);
|
|
|
|
// console.log(agencyProducts);
|
|
|
|
// console.log(agencyProducts);
|
|
|
|
const productsTypes = useProductsTypes();
|
|
|
|
const productsTypes = useProductsTypes();
|
|
|
|
const [activeKey, setActiveKey] = useState([]);
|
|
|
|
const [activeKey, setActiveKey] = useState([]);
|
|
|
@ -125,8 +137,9 @@ const TypesPanels = () => {
|
|
|
|
...ele,
|
|
|
|
...ele,
|
|
|
|
children: (
|
|
|
|
children: (
|
|
|
|
<PriceTable
|
|
|
|
<PriceTable
|
|
|
|
loading={loading}
|
|
|
|
// 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, info: c.info, rowSpan: i === 0 ? c.quotation.length : 0 }))), [])}
|
|
|
|
|
|
|
|
refresh={props.refresh}
|
|
|
|
/>
|
|
|
|
/>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
}));
|
|
|
|
}));
|
|
|
@ -146,11 +159,11 @@ const TypesPanels = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const Audit = ({ ...props }) => {
|
|
|
|
const Audit = ({ ...props }) => {
|
|
|
|
const { travel_agency_id } = useParams();
|
|
|
|
const { travel_agency_id, use_year, audit_state } = useParams();
|
|
|
|
const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]);
|
|
|
|
const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]);
|
|
|
|
|
|
|
|
|
|
|
|
const handleGetAgencyProducts = () => {
|
|
|
|
const handleGetAgencyProducts = () => {
|
|
|
|
getAgencyProducts({ travel_agency_id });
|
|
|
|
getAgencyProducts({ travel_agency_id, use_year, audit_state });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
@ -161,9 +174,9 @@ const Audit = ({ ...props }) => {
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<SecondHeaderWrapper header={<Header title={activeAgency.travel_agency_name} agency={activeAgency} />}>
|
|
|
|
<SecondHeaderWrapper header={<Header title={activeAgency.travel_agency_name} agency={activeAgency} refresh={handleGetAgencyProducts} />}>
|
|
|
|
<hr />
|
|
|
|
<hr />
|
|
|
|
<TypesPanels />
|
|
|
|
<TypesPanels refresh={handleGetAgencyProducts} />
|
|
|
|
</SecondHeaderWrapper>
|
|
|
|
</SecondHeaderWrapper>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|