|
|
@ -1,10 +1,10 @@
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { useEffect, useState } from 'react';
|
|
|
|
import { useParams, Link, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { useParams, Link, useNavigate, useLocation } from 'react-router-dom';
|
|
|
|
import { App, Button, Divider, Select } from 'antd';
|
|
|
|
import { App, Button, Divider, Popconfirm, Select } from 'antd';
|
|
|
|
import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
|
|
|
|
import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import { useTranslation } from 'react-i18next';
|
|
|
|
import useProductsStore, { postProductsQuoteAuditAction, postAgencyAuditAction } from '@/stores/Products/Index';
|
|
|
|
import useProductsStore, { postProductsQuoteAuditAction, postAgencyAuditAction } from '@/stores/Products/Index';
|
|
|
|
import { isEmpty } from '@/utils/commons';
|
|
|
|
import { isEmpty, objectMapper } from '@/utils/commons';
|
|
|
|
import useAuthStore from '@/stores/Auth';
|
|
|
|
import useAuthStore from '@/stores/Auth';
|
|
|
|
import RequireAuth from '@/components/RequireAuth';
|
|
|
|
import RequireAuth from '@/components/RequireAuth';
|
|
|
|
// import PrintContractPDF from './PrintContractPDF';
|
|
|
|
// import PrintContractPDF from './PrintContractPDF';
|
|
|
@ -15,19 +15,21 @@ import AuditStateSelector from '@/components/AuditStateSelector';
|
|
|
|
|
|
|
|
|
|
|
|
const Header = ({ refresh, newActionable, ...props }) => {
|
|
|
|
const Header = ({ refresh, newActionable, ...props }) => {
|
|
|
|
const location = useLocation();
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
const isEditPage = location.pathname.includes('edit');
|
|
|
|
const showEditA = !location.pathname.includes('edit');
|
|
|
|
const showEditA = !location.pathname.includes('edit');
|
|
|
|
const showAuditA = !location.pathname.includes('audit');
|
|
|
|
const showAuditA = !location.pathname.includes('audit');
|
|
|
|
const { travel_agency_id, use_year, audit_state } = useParams();
|
|
|
|
const { travel_agency_id, use_year, audit_state } = useParams();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const { t } = useTranslation();
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const isPermitted = useAuthStore((state) => state.isPermitted);
|
|
|
|
const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]);
|
|
|
|
const [activeAgency, setActiveAgency] = useProductsStore((state) => [state.activeAgency, state.setActiveAgency]);
|
|
|
|
const [switchParams] = useProductsStore((state) => [state.switchParams]);
|
|
|
|
const [switchParams, setSwitchParams] = useProductsStore((state) => [state.switchParams, state.setSwitchParams]);
|
|
|
|
|
|
|
|
const [activeAgencyState] = useProductsStore((state) => [state.activeAgencyState]);
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
const stateMapVal = useProductsAuditStatesMapVal();
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const { message, notification } = App.useApp();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
|
|
|
|
const yearOptions = [];
|
|
|
|
const yearOptions = [];
|
|
|
|
const currentYear = dayjs().year();
|
|
|
|
const currentYear = switchParams.use_year || dayjs().year();
|
|
|
|
const baseYear = use_year ? Number(use_year === 'all' ? currentYear : use_year) : currentYear;
|
|
|
|
const baseYear = use_year ? Number(use_year === 'all' ? currentYear : use_year) : currentYear;
|
|
|
|
for (let i = currentYear - 5; i <= baseYear + 5; i++) {
|
|
|
|
for (let i = currentYear - 5; i <= baseYear + 5; i++) {
|
|
|
|
yearOptions.push({ label: i, value: i });
|
|
|
|
yearOptions.push({ label: i, value: i });
|
|
|
@ -38,6 +40,8 @@ const Header = ({ refresh, newActionable, ...props }) => {
|
|
|
|
const [pickAgency, setPickAgency] = useState({ value: activeAgency.travel_agency_id, label: activeAgency.travel_agency_name });
|
|
|
|
const [pickAgency, setPickAgency] = useState({ value: activeAgency.travel_agency_id, label: activeAgency.travel_agency_name });
|
|
|
|
const [pickAuditState, setPickAuditState] = useState();
|
|
|
|
const [pickAuditState, setPickAuditState] = useState();
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
|
|
|
|
const _param = objectMapper(param, { pick_year: 'use_year', pick_agency: 'travel_agency_id', pick_state: 'audit_state' });
|
|
|
|
|
|
|
|
setSwitchParams({ ..._param });
|
|
|
|
refresh(param);
|
|
|
|
refresh(param);
|
|
|
|
|
|
|
|
|
|
|
|
return () => {};
|
|
|
|
return () => {};
|
|
|
@ -169,19 +173,23 @@ const Header = ({ refresh, newActionable, ...props }) => {
|
|
|
|
</RequireAuth>
|
|
|
|
</RequireAuth>
|
|
|
|
{/* 编辑 */}
|
|
|
|
{/* 编辑 */}
|
|
|
|
<Divider type='vertical' />
|
|
|
|
<Divider type='vertical' />
|
|
|
|
{newActionable && (
|
|
|
|
{isEditPage && (
|
|
|
|
|
|
|
|
<RequireAuth subject={PERM_PRODUCTS_OFFER_PUT}>
|
|
|
|
|
|
|
|
<Button size='small' type={'primary'} onClick={props.handleNewProduct}>
|
|
|
|
|
|
|
|
{t('New')}
|
|
|
|
|
|
|
|
{t('products:#')}
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
</RequireAuth>
|
|
|
|
|
|
|
|
)}
|
|
|
|
|
|
|
|
{activeAgencyState === 0 && (
|
|
|
|
<>
|
|
|
|
<>
|
|
|
|
<RequireAuth subject={PERM_PRODUCTS_OFFER_PUT}>
|
|
|
|
<RequireAuth subject={PERM_PRODUCTS_OFFER_PUT}>
|
|
|
|
<Button size='small' type={'primary'} onClick={props.handleNewProduct}>
|
|
|
|
<Popconfirm title={t('sureSubmit')} onConfirm={handleSubmitForAudit} okText={t('Yes')} placement={'bottom'}>
|
|
|
|
{t('New')}
|
|
|
|
<Button size='small' type={'primary'} >
|
|
|
|
{t('products:#')}
|
|
|
|
{t('Submit')}
|
|
|
|
</Button>
|
|
|
|
{t('Audit')}
|
|
|
|
</RequireAuth>
|
|
|
|
</Button>
|
|
|
|
<RequireAuth subject={PERM_PRODUCTS_OFFER_PUT}>
|
|
|
|
</Popconfirm>
|
|
|
|
<Button size='small' type={'primary'} onClick={handleSubmitForAudit}>
|
|
|
|
|
|
|
|
{t('Submit')}
|
|
|
|
|
|
|
|
{t('Audit')}
|
|
|
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
</RequireAuth>
|
|
|
|
</RequireAuth>
|
|
|
|
</>
|
|
|
|
</>
|
|
|
|
)}
|
|
|
|
)}
|
|
|
|