feat: 产品审核: 查看价格修改记录; 查看已发布的价格

main
Lei OT 2 months ago
parent 9592b4b135
commit 3dc8e6d8e5

@ -161,22 +161,6 @@ export const getPPSnapshotAction = async (params) => {
return errcode !== 0 ? [] : result; return errcode !== 0 ? [] : result;
} }
/**
* 产品价格日志
*/
export const getPPLogAction = async (params) => {
const { errcode, result } = await fetchJSON(`http://127.0.0.1:4523/m1/2602949-1933890-default/agency_product_price_log`, params)
return errcode !== 0 ? [] : result;
};
/**
* 产品价格: 已发布的
*/
export const getPPRunningAction = async (params) => {
const { errcode, result } = await fetchJSON(`http://127.0.0.1:4523/m1/2602949-1933890-default/agency_product_price_running`, params)
return errcode !== 0 ? [] : result;
};
/** /**
* 修改产品的类型 * 修改产品的类型
*/ */

@ -28,6 +28,8 @@ const PriceTable = ({ productType, dataSource, refresh }) => {
// console.log(dataSource); // console.log(dataSource);
const [logOpenPriceRow, setLogOpenPriceRow] = useState(null); // price id
const handleAuditPriceItem = (state, row, rowIndex) => { const handleAuditPriceItem = (state, row, rowIndex) => {
postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id }) postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id })
.then((json) => { .then((json) => {
@ -61,7 +63,8 @@ const PriceTable = ({ productType, dataSource, refresh }) => {
const editedCls = (r.audit_state_id === 0 ) ? '!bg-amber-100' : ''; // , const editedCls = (r.audit_state_id === 0 ) ? '!bg-amber-100' : ''; // ,
const newCls = (r.audit_state_id === -1 ) ? '!bg-sky-100' : ''; // , const newCls = (r.audit_state_id === -1 ) ? '!bg-sky-100' : ''; // ,
const editedCls_ = isNotEmpty(r.lastedit_changed) ? (r.audit_state_id === 0 ? '!bg-red-100' : '!bg-sky-100') : ''; const editedCls_ = isNotEmpty(r.lastedit_changed) ? (r.audit_state_id === 0 ? '!bg-red-100' : '!bg-sky-100') : '';
return [trCls, bigTrCls, newCls, editedCls].join(' '); const lodHighlightCls = (r.id === logOpenPriceRow ) ? '!bg-violet-300 !text-violet-900' : '';
return [trCls, bigTrCls, newCls, editedCls, lodHighlightCls].join(' ');
}; };
const columns = [ const columns = [
@ -88,7 +91,7 @@ const PriceTable = ({ productType, dataSource, refresh }) => {
<Space className='w-full [&>*:last-child]:ms-auto' > <Space className='w-full [&>*:last-child]:ms-auto' >
<Button onClick={() => handleAuditPriceItem('2', r, ri)}></Button> <Button onClick={() => handleAuditPriceItem('2', r, ri)}></Button>
<Button onClick={() => handleAuditPriceItem('3', r, ri)}></Button> <Button onClick={() => handleAuditPriceItem('3', r, ri)}></Button>
<ProductQuotationLogPopover method={'history'} {...{ travel_agency_id, product_id: r.info.id, price_id: r.id }} /> <ProductQuotationLogPopover method={'history'} {...{ travel_agency_id, product_id: r.info.id, price_id: r.id, use_year }} onOpenChange={open => setLogOpenPriceRow(open ? r.id : null)} />
</Space> </Space>
</RequireAuth> </RequireAuth>
) : null, ) : null,
@ -102,7 +105,7 @@ const PriceTable = ({ productType, dataSource, refresh }) => {
const btn2 = r.pendingQuotation ? ( const btn2 = r.pendingQuotation ? (
<ProductQuotationLogPopover <ProductQuotationLogPopover
method={'published'} method={'published'}
{...{ travel_agency_id, product_id: r.info.id, price_id: r.id }} {...{ travel_agency_id, product_id: r.info.id, price_id: r.id, use_year }}
triggerProps={{ type: 'primary', ghost: true, size: 'small' }} triggerProps={{ type: 'primary', ghost: true, size: 'small' }}
placement='bottom' placement='bottom'
className='max-w-[1000px]' className='max-w-[1000px]'

@ -1,10 +1,27 @@
import { useState } from 'react'; import { useState, useMemo } from 'react';
import { Button, Table, Popover, Typography } from 'antd'; import { Button, Table, Popover, Typography } from 'antd';
import { useTranslation } from 'react-i18next'; 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 { formatGroupSize } from '@/hooks/useProductsSets';
import { isEmpty, isNotEmpty } from '@/utils/commons'; 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) => { const parseJson = (str) => {
let result; let result;
if (str === null || str === undefined || str === '') { if (str === null || str === undefined || str === '') {
@ -139,8 +156,8 @@ const useLogMethod = (method) => {
'published': { 'published': {
title: t('versionPublished'), title: t('versionPublished'),
fetchData: async (params) => { fetchData: async (params) => {
const { travel_agency_id, product_id, price_id } = params; const { travel_agency_id, product_id, price_id, use_year } = params;
const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id }); const data = await getPPRunningAction({ travel_agency_id, product_id_list: product_id, use_year });
return data?.[0]?.quotation || []; 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.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.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.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 ProductQuotationLogPopover = ({ method, triggerProps = {}, onOpenChange, ...props }) => {
const { travel_agency_id, product_id, price_id } = props; const { travel_agency_id, product_id, price_id, use_year } = props;
const { t } = useTranslation('products'); const { t } = useTranslation('products');
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@ -172,9 +191,17 @@ const ProductQuotationLogPopover = ({ method, triggerProps = {}, ...props }) =>
const { title, fetchData } = useLogMethod(method); const { title, fetchData } = useLogMethod(method);
const tablePagination = useMemo(() => method === 'history' ? { pageSize: 5, position: ['bottomLeft']} : { pageSize: 10, position: ['bottomLeft']}, [method]);
const getData = async () => { 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); setLogData(data);
invokeOpenChange(true);
};
const invokeOpenChange = (_open) => {
if (typeof onOpenChange === 'function') {
onOpenChange(_open);
}
}; };
const columns = [...columnsSets(t, false), { title: '时间', dataIndex: 'updatetime', key: 'updatetime' }]; const columns = [...columnsSets(t, false), { title: '时间', dataIndex: 'updatetime', key: 'updatetime' }];
@ -185,22 +212,28 @@ const ProductQuotationLogPopover = ({ method, triggerProps = {}, ...props }) =>
rootClassName='w-5/6' rootClassName='w-5/6'
{...props} {...props}
title={ 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> <Typography.Text strong>{title}</Typography.Text>
<Button size='small' onClick={() => setOpen(false)}> <Button
size='small'
onClick={() => {
setOpen(false);
invokeOpenChange(false);
}}>
&times; &times;
</Button> </Button>
</div> </div>
} }
content={ content={
<> <>
<Table columns={columns} dataSource={logData} rowKey={'id'} size='small' /> <Table columns={columns} dataSource={logData} rowKey={'id'} size='small' pagination={tablePagination} />
</> </>
} }
trigger={['click']} trigger={['click']}
open={open} open={open}
onOpenChange={(v) => { onOpenChange={(v) => {
setOpen(v); setOpen(v);
invokeOpenChange(v);
}}> }}>
<Button {...triggerProps} onClick={getData} title={title}> <Button {...triggerProps} onClick={getData} title={title}>
{title} {title}

Loading…
Cancel
Save