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