有效期; 有效的周X; style:

feature/price_manager
Lei OT 1 year ago
parent 697fa00be3
commit b0d4943f09

@ -54,6 +54,24 @@
"lastThreeMonth": "Last Three Month",
"thisYear": "This Year"
},
"weekdays": {
"1": "Monday",
"2": "Tuesday",
"3": "Wednesday",
"4": "Thursday",
"5": "Friday",
"6": "Saturday",
"7": "Sunday"
},
"weekdaysShort": {
"1": "Mon",
"2": "Tue",
"3": "Wed",
"4": "Thu",
"5": "Fri",
"6": "Sat",
"7": "Sun"
},
"menu": {
"Reservation": "Reservation",
"Invoice": "Invoice",

@ -41,7 +41,10 @@
"Unit": "Unit",
"GroupSize": "Group Size",
"UseDates": "Use Dates",
"Weekdays": "Weekdays",
"OnWeekdays": "On Weekdays: ",
"Unlimited": "Unlimited",
"UseYear": "Use Year",

@ -54,6 +54,24 @@
"lastThreeMonth": "前三个月",
"thisYear": "今年"
},
"weekdays": {
"1": "一",
"2": "二",
"3": "三",
"4": "四",
"5": "五",
"6": "六",
"7": "日"
},
"weekdaysShort": {
"1": "一",
"2": "二",
"3": "三",
"4": "四",
"5": "五",
"6": "六",
"7": "日"
},
"menu": {
"Reservation": "团预订",
"Invoice": "账单",

@ -40,7 +40,10 @@
"Unit": "单位",
"GroupSize": "人等",
"UseDates": "使用日期",
"Weekdays": "有效日/周X",
"OnWeekdays": "周: ",
"Unlimited": "不限",
"UseYear": "年份",

@ -1,9 +1,9 @@
import { Outlet, useNavigate } from 'react-router-dom';
import { Layout, Flex, theme } from 'antd';
import { Layout, Flex, theme, Spin } from 'antd';
import BackBtn from './BackBtn';
const { Content, Header } = Layout;
const HeaderWrapper = ({ children, header, ...props }) => {
const HeaderWrapper = ({ children, header, loading, ...props }) => {
const navigate = useNavigate();
const {
token: { colorBgContainer },
@ -11,6 +11,7 @@ const HeaderWrapper = ({ children, header, ...props }) => {
return (
<>
<Layout className=''>
<Spin spinning={loading || false}>
<Header className='header px-6 h-10 ' style={{ background: 'white' }}>
<Flex justify={'space-between'} align={'center'} className='h-full'>
{/* {header} */}
@ -21,6 +22,7 @@ const HeaderWrapper = ({ children, header, ...props }) => {
<Content className='' style={{ backgroundColor: colorBgContainer }}>
{children || <Outlet />}
</Content>
</Spin>
</Layout>
</>
);

@ -49,7 +49,7 @@ export const useProductsTypes = () => {
{ label: t('products:type.Overtravel'), value: 'B', key: 'B' },
{ label: t('products:type.Car'), value: 'J', key: 'J' },
{ label: t('products:type.Guide'), value: 'Q', key: 'Q' },
{ label: t('products:type.Package'), value: 'D', key: 'D' },
{ label: t('products:type.Package'), value: 'D', key: 'D' }, // 包价线路
{ label: t('products:type.Attractions'), value: '7', key: '7' },
{ label: t('products:type.Meals'), value: 'C', key: 'C' },
{ label: t('products:type.Extras'), value: '8', key: '8' },
@ -67,11 +67,11 @@ export const useProductsAuditStates = () => {
useEffect(() => {
const newData = [
{ key: '-1', value: '-1', label: t('products:auditState.New') },
{ key: '0', value: '0', label: t('products:auditState.Pending') },
{ key: '2', value: '2', label: t('products:auditState.Approved') },
{ key: '3', value: '3', label: t('products:auditState.Rejected') },
{ key: '1', value: '1', label: t('products:auditState.Published') },
{ key: '-1', value: '-1', label: t('products:auditState.New'), color: 'gray-500' },
{ key: '0', value: '0', label: t('products:auditState.Pending'), color: '' },
{ key: '2', value: '2', label: t('products:auditState.Approved'), color: 'primary' },
{ key: '3', value: '3', label: t('products:auditState.Rejected'), color: 'red-500' },
{ key: '1', value: '1', label: t('products:auditState.Published'), color: 'primary' },
// ELSE 未知
];
setTypes(newData);

@ -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>
</>

@ -16,7 +16,7 @@ function Index() {
const handleSearchAgency = (formVal = undefined) => {
const { starttime, endtime, ...param } = formVal || formValuesToSub;
const searchParam = objectMapper(param, { agency: 'travel_agency_ids', startdate: 'edit_date1', enddate: 'edit_date2' });
const searchParam = objectMapper(param, { agency: 'travel_agency_ids', startdate: 'edit_date1', enddate: 'edit_date2', year: 'use_year' });
setSearchValues(searchParam);
searchAgency(searchParam);
}
@ -39,8 +39,8 @@ function Index() {
key: 'action',
render: (_, r) => (
<Space size={'large'}>
<Link to={`/products/${r.travel_agency_id}/${searchValues.year || 'all'}/${searchValues.audit_state || 'all'}/edit`}>{t('Edit')}</Link>
<Link to={`/products/${r.travel_agency_id}/${searchValues.year || 'all'}/${searchValues.audit_state || 'all'}/audit`}>{t('Audit')}</Link>
<Link to={`/products/${r.travel_agency_id}/${searchValues.use_year || 'all'}/${searchValues.audit_state || 'all'}/edit`}>{t('Edit')}</Link>
<Link to={`/products/${r.travel_agency_id}/${searchValues.use_year || 'all'}/${searchValues.audit_state || 'all'}/audit`}>{t('Audit')}</Link>
</Space>
),
},

Loading…
Cancel
Save