diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index 3d727be..365ea7a 100644 --- a/src/stores/Products/Index.js +++ b/src/stores/Products/Index.js @@ -30,7 +30,7 @@ export const copyAgencyDataAction = async (postbody) => { }; export const getAgencyProductsAction = async (param) => { - const _param = { ...param, use_year: String(param.use_year || '').replace('all', ''), audit_state: (param.audit_state || '').replace('all', '') }; + const _param = { ...param, use_year: String(param.use_year || '').replace('all', ''), audit_state: String(param.audit_state || '').replace('all', '') }; const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, _param); return errcode !== 0 ? { agency: {}, products: [] } : result; }; diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index dc35d85..35fd4e3 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -12,11 +12,13 @@ import RequireAuth from '@/components/RequireAuth'; import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; import dayjs from 'dayjs'; import VendorSelector from '@/components/VendorSelector'; +import AuditStateSelector from '@/components/AuditStateSelector'; const Header = ({ refresh, ...props }) => { const { travel_agency_id, use_year, audit_state } = useParams(); const { t } = useTranslation(); const isPermitted = useAuthStore(state => state.isPermitted); const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]); + const stateMapVal = useProductsAuditStatesMapVal(); const { message, notification } = App.useApp(); const navigate = useNavigate(); @@ -29,6 +31,8 @@ const Header = ({ refresh, ...props }) => { const [param, setParam] = useState({ pick_year: baseYear, pick_agency: travel_agency_id, }); const [pickYear, setPickYear] = useState(baseYear); + const [pickAgency, setPickAgency] = useState({value: activeAgency.travel_agency_id, label: activeAgency.travel_agency_name }); + const [pickAuditState, setPickAuditState] = useState(); useEffect(() => { refresh(param); navigate(`/products/${activeAgency.travel_agency_id}/${pickYear}/${audit_state}/audit`); @@ -36,12 +40,28 @@ const Header = ({ refresh, ...props }) => { return () => {}; }, [param]); + const emptyPickState = { value: '', label: t('products:State') }; + useEffect(() => { + const baseState = audit_state === 'all' ? emptyPickState : stateMapVal[`${audit_state}`]; + if (isEmpty(pickAuditState)) { + setPickAuditState(baseState); + } + return () => {}; + }, [audit_state, stateMapVal]) + + const handleYearChange = (value) => { setPickYear(value); setParam((pre) => ({ ...pre, ...{ pick_year: value } })); }; + const handleAuditStateChange = (labelValue) => { + const { value } = labelValue || emptyPickState; + setPickAuditState(labelValue || emptyPickState); + setParam((pre) => ({ ...pre, ...{ pick_state: value } })); + }; const handleAgencyChange = ({ label, value }) => { + setPickAgency({ label, value }); setActiveAgency({ travel_agency_id: value, travel_agency_name: label }); setParam((pre) => ({ ...pre, ...{ pick_agency: value } })); }; @@ -71,8 +91,9 @@ const Header = ({ refresh, ...props }) => {

{isPermitted(PERM_PRODUCTS_OFFER_AUDIT) ? ( { )}