perf: 产品管理: catch

perf/export-docx
Lei OT 11 months ago
parent 605eae0db5
commit f308b994e3

@ -28,6 +28,7 @@
"sureCancel": "Are you sure to cancel?",
"sureDelete":"Are you sure to delete?",
"sureSubmit":"Are you sure to submit?",
"Yes": "Yes",
"No": "No",

@ -28,6 +28,7 @@
"sureCancel": "确定取消?",
"sureDelete":"确定删除?",
"sureSubmit":"确定提交?",
"Yes": "是",
"No": "否",

@ -164,16 +164,26 @@ const TypesPanels = (props) => {
};
const Audit = ({ ...props }) => {
const { notification, modal } = App.useApp()
const isPermitted = useAuthStore(state => state.isPermitted);
const { travel_agency_id, use_year, audit_state } = useParams();
const [loading, activeAgency, getAgencyProducts] = useProductsStore((state) => [state.loading, state.activeAgency, state.getAgencyProducts]);
const [activeAgency, getAgencyProducts] = useProductsStore((state) => [state.activeAgency, state.getAgencyProducts]);
const [loading, setLoading] = useProductsStore(state => [state.loading, state.setLoading]);
const { travelAgencyId } = usingStorage();
const handleGetAgencyProducts = ({pick_year, pick_agency, pick_state}={}) => {
const year = pick_year || use_year || dayjs().year();
const agency = pick_agency || travel_agency_id || travelAgencyId;
const state = pick_state ?? audit_state;
getAgencyProducts({ travel_agency_id: agency, use_year: year, audit_state: state });
getAgencyProducts({ travel_agency_id: agency, use_year: year, audit_state: state }).catch(ex => {
setLoading(false);
notification.error({
message: 'Notification',
description: ex.message,
placement: 'top',
duration: 4,
})
});
};
return (

@ -1,5 +1,5 @@
import { useState } from 'react';
import { Divider, Empty, Flex } from 'antd';
import { App, Divider, Empty, Flex } from 'antd';
import { isEmpty } from '@/utils/commons';
import SecondHeaderWrapper from '@/components/SecondHeaderWrapper';
import Header from './Detail/Header';
@ -12,10 +12,12 @@ import ProductInfo from './Detail/ProductInfo';
import NewProductModal from './Detail/NewProductModal';
function Detail() {
const { notification, modal } = App.useApp()
const { travel_agency_id, audit_state, use_year } = useParams();
const [addProductVisible, setAddProductVisible] = useState(false);
const [agencyProducts, loading, switchParams] = useProductsStore((state) => [state.agencyProducts, state.loading, state.switchParams]);
const [agencyProducts, switchParams] = useProductsStore((state) => [state.agencyProducts, state.switchParams]);
const [getAgencyProducts, activeAgency] = useProductsStore((state) => [state.getAgencyProducts, state.activeAgency]);
const [loading, setLoading] = useProductsStore(state => [state.loading, state.setLoading]);
const { travelAgencyId } = usingStorage();
const handleGetAgencyProducts = ({ pick_year, pick_agency, pick_state } = {}) => {
@ -24,7 +26,15 @@ function Detail() {
const state = pick_state ?? audit_state;
const param = { travel_agency_id: agency, use_year: year, audit_state: state };
// setEditingProduct({});
getAgencyProducts(param);
getAgencyProducts(param).catch(ex => {
setLoading(false);
notification.error({
message: 'Notification',
description: ex.message,
placement: 'top',
duration: 4,
})
});
};
return (

@ -101,13 +101,20 @@ export const CopyProductsFormModal = ({ source, action = '#' | 'o', open, onSubm
const handleCopyAgency = async (param) => {
param.target_agency = isEmpty(param.target_agency) ? source.sourceAgency.travel_agency_id : param.target_agency;
setCopyLoading(true);
console.log(param);
const toID = param.target_agency;
const success = await copyAgencyDataAction({...param, source_agency: source.sourceAgency.travel_agency_id});
// console.log(param);
// const toID = param.target_agency;
const success = await copyAgencyDataAction({...param, source_agency: source.sourceAgency.travel_agency_id}).catch(ex => {
notification.error({
message: 'Notification',
description: ex.message,
placement: 'top',
duration: 4,
})
});
setCopyLoading(false);
success ? message.success(t('Success')) : message.error(t('Failed'));
if (typeof onSubmit === 'function') {
if (success && typeof onSubmit === 'function') {
onSubmit(param);
}
// setCopyModalVisible(false);

@ -1,6 +1,6 @@
import { useEffect, useState } from 'react';
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 { useTranslation } from 'react-i18next';
import useProductsStore, { postProductsQuoteAuditAction, postAgencyAuditAction } from '@/stores/Products/Index';
@ -184,10 +184,12 @@ const Header = ({ refresh, newActionable, ...props }) => {
{activeAgencyState === 0 && (
<>
<RequireAuth subject={PERM_PRODUCTS_OFFER_PUT}>
<Button size='small' type={'primary'} onClick={handleSubmitForAudit}>
{t('Submit')}
{t('Audit')}
</Button>
<Popconfirm title={t('sureSubmit')} onConfirm={handleSubmitForAudit} okText={t('Yes')} placement={'bottom'}>
<Button size='small' type={'primary'} >
{t('Submit')}
{t('Audit')}
</Button>
</Popconfirm>
</RequireAuth>
</>
)}

@ -68,6 +68,14 @@ const ProductInfo = ({ ...props }) => {
info: readyToSubInfo,
lgc_details: Object.values(mergedLgc),
quotation: Object.values(mergedQ),
}).catch(ex => {
setLoading(false);
notification.error({
message: 'Notification',
description: ex.message,
placement: 'top',
duration: 4,
})
});
setLoading(false);
success ? message.success(t('Success')) : message.error(t('Failed'));

@ -18,7 +18,7 @@ const ProductInfoLgc = ({ editable, formInstance, ...props }) => {
useEffect(() => {
const existsLgc = (editingProduct?.lgc_details || []).map((ele, li) => ({
...ele,
label: HTLanguageSetsMapVal[ele.lgc].label,
label: HTLanguageSetsMapVal[ele.lgc]?.label || ele.lgc,
// key: `${editingProduct.info.id}-${ele.id}`,
key: ele.lgc,
closable: false, // isPermitted(PERM_PRODUCTS_MANAGEMENT) ? true : false,

Loading…
Cancel
Save