|
|
|
@ -1,10 +1,27 @@
|
|
|
|
|
import { useState } from 'react';
|
|
|
|
|
import { useState, useMemo } from 'react';
|
|
|
|
|
import { Button, Table, Popover, Typography } from 'antd';
|
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
|
import { getPPLogAction, getPPRunningAction } from '@/stores/Products/Index';
|
|
|
|
|
import { HT_HOST } from '@/config';
|
|
|
|
|
import { fetchJSON } from '@/utils/request';
|
|
|
|
|
import { formatGroupSize } from '@/hooks/useProductsSets';
|
|
|
|
|
import { isEmpty, isNotEmpty } from '@/utils/commons';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 产品价格日志
|
|
|
|
|
*/
|
|
|
|
|
const getPPLogAction = async (params) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_log`, params)
|
|
|
|
|
return errcode !== 0 ? [] : result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 产品价格: 已发布的
|
|
|
|
|
*/
|
|
|
|
|
const getPPRunningAction = async (params) => {
|
|
|
|
|
const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/agency_product_price_running`, params)
|
|
|
|
|
return errcode !== 0 ? [] : result;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const parseJson = (str) => {
|
|
|
|
|
let result;
|
|
|
|
|
if (str === null || str === undefined || str === '') {
|
|
|
|
@ -139,8 +156,8 @@ const useLogMethod = (method) => {
|
|
|
|
|
'published': {
|
|
|
|
|
title: t('versionPublished'),
|
|
|
|
|
fetchData: async (params) => {
|
|
|
|
|
const { travel_agency_id, product_id, price_id } = params;
|
|
|
|
|
const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id });
|
|
|
|
|
const { travel_agency_id, product_id, price_id, use_year } = params;
|
|
|
|
|
const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id, use_year });
|
|
|
|
|
return data?.[0]?.quotation || [];
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
@ -162,9 +179,11 @@ const useLogMethod = (method) => {
|
|
|
|
|
* @param {number} props.travel_agency_id - ID of the travel agency (used in data fetching)
|
|
|
|
|
* @param {number} props.product_id - ID of the product (used in data fetching)
|
|
|
|
|
* @param {number} props.price_id - ID of the price entry (used in data fetching)
|
|
|
|
|
* @param {number} props.use_year - Year to use for fetching data (used in data fetching)
|
|
|
|
|
* @param {Function} props.onOpenChange - Callback function to be called when the popover opens or closes
|
|
|
|
|
*/
|
|
|
|
|
const ProductQuotationLogPopover = ({ method, triggerProps = {}, ...props }) => {
|
|
|
|
|
const { travel_agency_id, product_id, price_id } = props;
|
|
|
|
|
const ProductQuotationLogPopover = ({ method, triggerProps = {}, onOpenChange, ...props }) => {
|
|
|
|
|
const { travel_agency_id, product_id, price_id, use_year } = props;
|
|
|
|
|
|
|
|
|
|
const { t } = useTranslation('products');
|
|
|
|
|
const [open, setOpen] = useState(false);
|
|
|
|
@ -172,9 +191,17 @@ const ProductQuotationLogPopover = ({ method, triggerProps = {}, ...props }) =>
|
|
|
|
|
|
|
|
|
|
const { title, fetchData } = useLogMethod(method);
|
|
|
|
|
|
|
|
|
|
const tablePagination = useMemo(() => method === 'history' ? { pageSize: 5, position: ['bottomLeft']} : { pageSize: 10, position: ['bottomLeft']}, [method]);
|
|
|
|
|
const getData = async () => {
|
|
|
|
|
const data = await fetchData({ travel_agency_id, product_id, price_id });
|
|
|
|
|
const data = await fetchData({ travel_agency_id, product_id, price_id, use_year });
|
|
|
|
|
setLogData(data);
|
|
|
|
|
invokeOpenChange(true);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const invokeOpenChange = (_open) => {
|
|
|
|
|
if (typeof onOpenChange === 'function') {
|
|
|
|
|
onOpenChange(_open);
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const columns = [...columnsSets(t, false), { title: '时间', dataIndex: 'updatetime', key: 'updatetime' }];
|
|
|
|
@ -185,22 +212,28 @@ const ProductQuotationLogPopover = ({ method, triggerProps = {}, ...props }) =>
|
|
|
|
|
rootClassName='w-5/6'
|
|
|
|
|
{...props}
|
|
|
|
|
title={
|
|
|
|
|
<div className='flex justify-between mt-0 gap-4 items-center'>
|
|
|
|
|
<div className='flex justify-between mt-0 gap-4 items-center '>
|
|
|
|
|
<Typography.Text strong>{title}</Typography.Text>
|
|
|
|
|
<Button size='small' onClick={() => setOpen(false)}>
|
|
|
|
|
<Button
|
|
|
|
|
size='small'
|
|
|
|
|
onClick={() => {
|
|
|
|
|
setOpen(false);
|
|
|
|
|
invokeOpenChange(false);
|
|
|
|
|
}}>
|
|
|
|
|
×
|
|
|
|
|
</Button>
|
|
|
|
|
</div>
|
|
|
|
|
}
|
|
|
|
|
content={
|
|
|
|
|
<>
|
|
|
|
|
<Table columns={columns} dataSource={logData} rowKey={'id'} size='small' />
|
|
|
|
|
<Table columns={columns} dataSource={logData} rowKey={'id'} size='small' pagination={tablePagination} />
|
|
|
|
|
</>
|
|
|
|
|
}
|
|
|
|
|
trigger={['click']}
|
|
|
|
|
open={open}
|
|
|
|
|
onOpenChange={(v) => {
|
|
|
|
|
setOpen(v);
|
|
|
|
|
invokeOpenChange(v);
|
|
|
|
|
}}>
|
|
|
|
|
<Button {...triggerProps} onClick={getData} title={title}>
|
|
|
|
|
{title}
|
|
|
|
|