From 71147a728d5e49e8d55bc162601e5e7c42ebb162 Mon Sep 17 00:00:00 2001 From: Lei OT Date: Tue, 23 Jul 2024 16:14:35 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A7=E5=93=81=E7=AE=A1=E7=90=86:=20?= =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E9=A1=B5=E9=9D=A2:=20=E8=B0=83=E6=95=B4Heade?= =?UTF-8?q?r=E7=BB=84=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/products/Audit.jsx | 133 +------------------------- src/views/products/Detail/Header.jsx | 137 +++++++++++++++++++++++++++ 2 files changed, 140 insertions(+), 130 deletions(-) create mode 100644 src/views/products/Detail/Header.jsx diff --git a/src/views/products/Audit.jsx b/src/views/products/Audit.jsx index f426b6a..8026a9c 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, Navigate, useNavigate } from 'react-router-dom'; -import { App, Empty, Button, Collapse, Table, Space, Divider, Select } from 'antd'; +import { useParams, Link } from 'react-router-dom'; +import { App, Empty, Button, Collapse, Table, Space } from 'antd'; import { useProductsTypes, useProductsAuditStatesMapVal } from '@/hooks/useProductsSets'; import SecondHeaderWrapper from '@/components/SecondHeaderWrapper'; import { useTranslation } from 'react-i18next'; @@ -8,135 +8,8 @@ import useProductsStore, { postProductsQuoteAuditAction, } from '@/stores/Produc import { cloneDeep, 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 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(); - - 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 [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`); - - 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 } })); - }; - - 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(param); - } - } - }) - .catch((ex) => { - notification.error({ - message: 'Notification', - description: ex.message, - placement: 'top', - duration: 4, - }); - }); - }; - return ( -
-
-

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

+
+ {/* */} + {/* */} + + + {t('Edit')} + + + + + + {/* */} + + + + {/* todo: export, 审核完成之后才能导出 */} + + {/* */} +
+ ); +}; +export default Header;