|
|
@ -1,14 +1,31 @@
|
|
|
|
import { createContext, useContext, useEffect, useState } from 'react';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { Link, useLocation, } from 'react-router-dom';
|
|
|
|
import { useParams, } from 'react-router-dom';
|
|
|
|
import { Button, Collapse, Table, Tabs, Typography, Space, } from 'antd';
|
|
|
|
import { App, Button, Collapse, Table, Space, } from 'antd';
|
|
|
|
import { useProductsTypes, useProductsAuditStatesMapVal, useProductsAuditStates } from '@/hooks/useProductsSets';
|
|
|
|
import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
|
|
|
|
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
|
|
|
|
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import useProductsStore from '@/stores/Products/Index';
|
|
|
|
import useProductsStore, { postProductsQuoteAudit } from '@/stores/Products/Index';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
|
|
const Header = ({title, ...props}) => {
|
|
|
|
const Header = ({ title, agency, ...props}) => {
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
|
|
|
|
const handleAuditItem = (state, row) => {
|
|
|
|
|
|
|
|
postProductsQuoteAudit(state, row)
|
|
|
|
|
|
|
|
.then((json) => {
|
|
|
|
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
|
|
|
|
message.success('✔');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((ex) => {
|
|
|
|
|
|
|
|
notification.error({
|
|
|
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
|
|
|
description: ex.message,
|
|
|
|
|
|
|
|
placement: 'top',
|
|
|
|
|
|
|
|
duration: 4,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<div className='flex justify-end items-center gap-4 h-full'>
|
|
|
|
<div className='flex justify-end items-center gap-4 h-full'>
|
|
|
|
<div className='grow'>
|
|
|
|
<div className='grow'>
|
|
|
@ -16,15 +33,37 @@ const Header = ({title, ...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>{t('Export')} PDF</Button>
|
|
|
|
<Button size='small' type={'primary'} ghost onClick={() => handleAuditItem('2', agency)}>
|
|
|
|
|
|
|
|
{t('products:auditStateAction.Approved')}
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
{/* todo: export */}
|
|
|
|
|
|
|
|
<Button size='small'>{t('Export')} PDF</Button>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
const PriceTable = ({dataSource, loading}) => {
|
|
|
|
const PriceTable = ({dataSource, loading}) => {
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleAuditPriceItem = (state, row) => {
|
|
|
|
|
|
|
|
postProductsQuoteAudit(state, row)
|
|
|
|
|
|
|
|
.then((json) => {
|
|
|
|
|
|
|
|
if (json.errcode === 0) {
|
|
|
|
|
|
|
|
message.success('✔');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
})
|
|
|
|
|
|
|
|
.catch((ex) => {
|
|
|
|
|
|
|
|
notification.error({
|
|
|
|
|
|
|
|
message: 'Notification',
|
|
|
|
|
|
|
|
description: ex.message,
|
|
|
|
|
|
|
|
placement: 'top',
|
|
|
|
|
|
|
|
duration: 4,
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
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 }) => `${value} ${currency} / ${unit}` },
|
|
|
|
{ key: 'value', title: t('Quotation'), render: (_, { value, currency, unit }) => `${value} ${currency} / ${unit}` },
|
|
|
@ -55,10 +94,10 @@ const PriceTable = ({dataSource, loading}) => {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
title: '',
|
|
|
|
title: '',
|
|
|
|
key: 'action',
|
|
|
|
key: 'action',
|
|
|
|
render: () => (
|
|
|
|
render: (_, r) => (
|
|
|
|
<Space>
|
|
|
|
<Space>
|
|
|
|
<Button>✔</Button>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('2', r)}>✔</Button>
|
|
|
|
<Button>✖</Button>
|
|
|
|
<Button onClick={() => handleAuditPriceItem('0', r)}>✖</Button>
|
|
|
|
</Space>
|
|
|
|
</Space>
|
|
|
|
),
|
|
|
|
),
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -76,11 +115,19 @@ const TypesPanels = () => {
|
|
|
|
const [activeKey, setActiveKey] = useState([]);
|
|
|
|
const [activeKey, setActiveKey] = useState([]);
|
|
|
|
const [showTypes, setShowTypes] = useState([]);
|
|
|
|
const [showTypes, setShowTypes] = useState([]);
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
// 只显示有产品的类型
|
|
|
|
// 只显示有产品的类型; 展开产品的价格表, 合并名称列
|
|
|
|
const hasDataTypes = Object.keys(agencyProducts);
|
|
|
|
const hasDataTypes = Object.keys(agencyProducts);
|
|
|
|
const _show = productsTypes
|
|
|
|
const _show = productsTypes
|
|
|
|
.filter((kk) => hasDataTypes.includes(kk.value))
|
|
|
|
.filter((kk) => hasDataTypes.includes(kk.value))
|
|
|
|
.map((ele) => ({ ...ele, 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 }))), [])} /> }));
|
|
|
|
.map((ele) => ({
|
|
|
|
|
|
|
|
...ele,
|
|
|
|
|
|
|
|
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 }))), [])}
|
|
|
|
|
|
|
|
/>
|
|
|
|
|
|
|
|
),
|
|
|
|
|
|
|
|
}));
|
|
|
|
setShowTypes(_show);
|
|
|
|
setShowTypes(_show);
|
|
|
|
|
|
|
|
|
|
|
|
setActiveKey(isEmpty(_show) ? [] : [_show[0].key]);
|
|
|
|
setActiveKey(isEmpty(_show) ? [] : [_show[0].key]);
|
|
|
@ -97,14 +144,24 @@ const TypesPanels = () => {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const Audit = ({ ...props }) => {
|
|
|
|
const Audit = ({ ...props }) => {
|
|
|
|
// const [loading, agencyProducts] = useProductsStore((state) => [state.loading, state.agencyProducts]);
|
|
|
|
const { agencyId: travel_agency_id } = useParams();
|
|
|
|
|
|
|
|
const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const handleGetAgencyProducts = () => {
|
|
|
|
|
|
|
|
getAgencyProducts({ travel_agency_id });
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
handleGetAgencyProducts();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
|
|
|
|
}, [travel_agency_id])
|
|
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<SecondHeaderWrapper header={<Header title={'{供应商名字}'} />}>
|
|
|
|
<SecondHeaderWrapper header={<Header title={activeAgency.travel_agency_name} agency={activeAgency} />}>
|
|
|
|
<hr />
|
|
|
|
<hr />
|
|
|
|
<TypesPanels />
|
|
|
|
<TypesPanels />
|
|
|
|
{/* <PriceTable dataSource={agencyProductsList} /> */}
|
|
|
|
|
|
|
|
</SecondHeaderWrapper>
|
|
|
|
</SecondHeaderWrapper>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
);
|
|
|
|