diff --git a/src/stores/Products/Index.js b/src/stores/Products/Index.js index a06850e..3d727be 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: (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: (param.audit_state || '').replace('all', '') }; const { errcode, result } = await fetchJSON(`${HT_HOST}/Service_BaseInfoWeb/travel_agency_products`, _param); return errcode !== 0 ? { agency: {}, products: [] } : result; }; @@ -39,6 +39,7 @@ export const getAgencyProductsAction = async (param) => { * */ export const addProductExtraAction = async (body) => { + console.log('addProductExtraAction', body); return true; // test: 先不更新到HT const { errcode, result } = await postJSON(`${HT_HOST}/Service_BaseInfoWeb/products_extras_add`, body); return errcode === 0 ? true : false; diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index 2228b64..dc35d85 100644 --- a/src/views/products/Audit.jsx +++ b/src/views/products/Audit.jsx @@ -1,6 +1,6 @@ import { useEffect, useState } from 'react'; -import { useParams, Link } from 'react-router-dom'; -import { App, Button, Collapse, Table, Space, Divider } from 'antd'; +import { useParams, Link, Navigate, useNavigate } from 'react-router-dom'; +import { App, Empty, Button, Collapse, Table, Space, Divider, Select } from 'antd'; import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; @@ -10,19 +10,49 @@ import useAuthStore from '@/stores/Auth'; import RequireAuth from '@/components/RequireAuth'; // import PrintContractPDF from './PrintContractPDF'; import { PERM_PRODUCTS_OFFER_AUDIT, PERM_PRODUCTS_OFFER_PUT } from '@/config'; - -const Header = ({ title, agency, refresh, ...props }) => { +import dayjs from 'dayjs'; +import VendorSelector from '@/components/VendorSelector'; +const Header = ({ refresh, ...props }) => { const { travel_agency_id, use_year, audit_state } = useParams(); const { t } = useTranslation(); - const [activeAgency] = useProductsStore((state) => [state.activeAgency]); + const isPermitted = useAuthStore(state => state.isPermitted); + const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]); const { message, notification } = App.useApp(); + const navigate = useNavigate(); + + const yearOptions = []; + const currentYear = dayjs().year(); + const baseYear = Number(use_year === 'all' ? currentYear : use_year); + for (let i = baseYear - 3; i <= baseYear + 3; i++) { + yearOptions.push({ label: i, value: i, }); + } + + const [param, setParam] = useState({ pick_year: baseYear, pick_agency: travel_agency_id, }); + const [pickYear, setPickYear] = useState(baseYear); + useEffect(() => { + refresh(param); + navigate(`/products/${activeAgency.travel_agency_id}/${pickYear}/${audit_state}/audit`); + + return () => {}; + }, [param]); + + const handleYearChange = (value) => { + setPickYear(value); + setParam((pre) => ({ ...pre, ...{ pick_year: value } })); + }; + + const handleAgencyChange = ({ label, value }) => { + setActiveAgency({ travel_agency_id: value, travel_agency_name: label }); + setParam((pre) => ({ ...pre, ...{ pick_agency: value } })); + }; + const handleAuditItem = (state, row) => { 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(param); } } }) @@ -39,20 +69,33 @@ const Header = ({ title, agency, refresh, ...props }) => {

- {title} + {isPermitted(PERM_PRODUCTS_OFFER_AUDIT) ? ( + + ) : ( + activeAgency.travel_agency_name + )} - {(use_year || '').replace('all', '')} +