diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 8d3fdab..cfbffdd 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -161,22 +161,6 @@ export const getPPSnapshotAction = async (params) => { 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; -}; - /** * 修改产品的类型 */ diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 357ce1b..0aa9f85 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -28,6 +28,8 @@ const PriceTable = ({ productType, dataSource, refresh }) => { // console.log(dataSource); + const [logOpenPriceRow, setLogOpenPriceRow] = useState(null); // price id + const handleAuditPriceItem = (state, row, rowIndex) => { postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id }) .then((json) => { @@ -61,7 +63,8 @@ const PriceTable = ({ productType, dataSource, refresh }) => { const editedCls = (r.audit_state_id === 0 ) ? '!bg-amber-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') : ''; - 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 = [ @@ -88,7 +91,7 @@ const PriceTable = ({ productType, dataSource, refresh }) => { - + setLogOpenPriceRow(open ? r.id : null)} /> ) : null, @@ -102,7 +105,7 @@ const PriceTable = ({ productType, dataSource, refresh }) => { const btn2 = r.pendingQuotation ? ( { + 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={ -
+
{title} -
} content={ <> - +
} trigger={['click']} open={open} onOpenChange={(v) => { setOpen(v); + invokeOpenChange(v); }}>