供应商评价模板管理详情返回报错
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import { history, useIntl } from 'umi';
|
||||
import { useIntl, history, useLocation } from 'umi';
|
||||
import { Button, Card, Descriptions, Divider, Spin, message, Typography, Empty } from 'antd';
|
||||
import { ArrowLeftOutlined } from '@ant-design/icons';
|
||||
import { getTemplateDetail } from '@/servers/api/supplierEvaluate';
|
||||
@ -12,12 +12,11 @@ const { Title } = Typography;
|
||||
const SupplierTemplateManageDetail: React.FC = () => {
|
||||
const intl = useIntl();
|
||||
const [loading, setLoading] = useState<boolean>(false);
|
||||
const [templateDetail, setTemplateDetail] = useState<SupplierTemplateManage.TemplateDetailResponse['data'] | null>(null);
|
||||
const [templateDetail, setTemplateDetail] = useState<
|
||||
SupplierTemplateManage.TemplateDetailResponse['data'] | null
|
||||
>(null);
|
||||
const [templateData, setTemplateData] = useState<SupplierTemplateManage.IndicatorSt[]>([]);
|
||||
|
||||
// 从路由获取ID
|
||||
const { id } = history.location.state as { id: string };
|
||||
|
||||
const location = useLocation<{ id: string }>();
|
||||
// 获取模板详情
|
||||
const fetchTemplateDetail = async (templateId: string) => {
|
||||
try {
|
||||
@ -43,16 +42,13 @@ const SupplierTemplateManageDetail: React.FC = () => {
|
||||
setLoading(false);
|
||||
}
|
||||
};
|
||||
|
||||
// 首次加载获取数据
|
||||
useEffect(() => {
|
||||
if (id) {
|
||||
if (location.state?.id) {
|
||||
const id = location.state.id;
|
||||
fetchTemplateDetail(id);
|
||||
} else {
|
||||
message.error(intl.formatMessage({ id: 'supplierTemplateManage.detail.idNotExist' }));
|
||||
history.goBack();
|
||||
}
|
||||
}, [id]);
|
||||
}, [location]);
|
||||
|
||||
// 返回列表页
|
||||
const handleBack = () => {
|
||||
|
Reference in New Issue
Block a user