diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 9a7333a..2228b64 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -5,7 +5,7 @@ import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProdu import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Products/Index'; -import { isEmpty } from '@/utils/commons'; +import { cloneDeep, isEmpty } from '@/utils/commons'; import useAuthStore from '@/stores/Auth'; import RequireAuth from '@/components/RequireAuth'; // import PrintContractPDF from './PrintContractPDF'; @@ -80,15 +80,22 @@ const PriceTable = ({ productType, dataSource, refresh }) => { const { message, notification } = App.useApp(); const stateMapVal = useProductsAuditStatesMapVal(); + const [renderData, setRenderData] = useState(dataSource); + // console.log(dataSource); - const handleAuditPriceItem = (state, row) => { + const handleAuditPriceItem = (state, row, rowIndex) => { postProductsQuoteAuditAction(state, { id: row.id, travel_agency_id: activeAgency.travel_agency_id }) .then((json) => { if (json.errcode === 0) { message.success(json.errmsg); + if (typeof refresh === 'function') { - refresh(); + // refresh(); // debug: 不要刷新, 等太久 + // const newData = structuredClone(renderData); + const newData = cloneDeep(renderData); + newData.splice(rowIndex, 1, {...row, audit_state_id: state, }); + setRenderData(newData); } } }) @@ -142,18 +149,18 @@ const PriceTable = ({ productType, dataSource, refresh }) => { { title: '', key: 'action', - render: (_, r) => - r.audit_state_id <= 0 ? ( + render: (_, r, ri) => + (Number(r.audit_state_id)) === 0 ? ( - - + + ) : null, }, ]; - return r.id} />; + return
r.id} />; }; /**