增加Header,把提交审核按钮和增加产品按钮移到Header
parent
af71ebf18e
commit
01e4dbbf4f
@ -0,0 +1,81 @@
|
||||
import { useEffect, useState } from 'react';
|
||||
import { useParams, Link, useNavigate } from 'react-router-dom';
|
||||
import { App, Button, Divider, Select } from 'antd';
|
||||
import { useProductsAuditStatesMapVal } from '@/hooks/useProductsSets';
|
||||
import { useTranslation } from 'react-i18next';
|
||||
import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Products/Index';
|
||||
import { isEmpty } from '@/utils/commons';
|
||||
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';
|
||||
import dayjs from 'dayjs';
|
||||
import AuditStateSelector from '@/components/AuditStateSelector';
|
||||
const YearSelector = ({ refresh,onStateChange }) => {
|
||||
const { travel_agency_id, use_year, audit_state } = useParams();
|
||||
const { t } = useTranslation();
|
||||
const stateMapVal = useProductsAuditStatesMapVal();
|
||||
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);
|
||||
const [pickAuditState, setPickAuditState] = useState();
|
||||
useEffect(() => {
|
||||
refresh(param);
|
||||
|
||||
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 addproducts = () => {
|
||||
onStateChange('addProducts');
|
||||
};
|
||||
const submitreview = () => {
|
||||
onStateChange('submitReview');
|
||||
}
|
||||
return (
|
||||
<div className='flex justify-end items-center gap-4 h-full'>
|
||||
<div className='grow'>
|
||||
<h2 className='m-0 leading-tight'>
|
||||
<Divider type={'vertical'} />
|
||||
<Select options={yearOptions} variant={'borderless'} className='w-24' size='large' value={pickYear} onChange={handleYearChange} />
|
||||
<Divider type={'vertical'} />
|
||||
<AuditStateSelector variant={'borderless'} className='w-32' size='large' value={pickAuditState} onChange={handleAuditStateChange} />
|
||||
</h2>
|
||||
</div>
|
||||
|
||||
<Button size='small' type={'primary'} onClick={addproducts}>
|
||||
增加产品
|
||||
</Button>
|
||||
<Button size='small' type={'primary'} onClick={submitreview}>
|
||||
提交审核
|
||||
</Button>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
export default YearSelector;
|
Loading…
Reference in New Issue