// 评价结果详情 import React, { useState, useEffect } from 'react'; import { Card, Form, Button, Descriptions, Divider, Row, Col, Tabs, message } from 'antd'; import { ArrowLeftOutlined } from '@ant-design/icons'; import { history, useLocation } from 'umi'; import { EvaluateLevel, EvaluateLevelText } from '@/dicts/supplierTemplateDict'; import GeneralEvaluation from './components/GeneralEvaluation'; import TechnicalEvaluation from './components/TechnicalEvaluation'; import styles from './supplierEvaluateResult.less'; const { TabPane } = Tabs; // 组件使用默认的接口定义 const SupplierEvaluateResultByZb: React.FC = () => { const location = useLocation<{ record: any }>(); const [loading, setLoading] = useState(false); const [scoreRecord, setScoreRecord] = useState(null); const [evaluationData, setEvaluationData] = useState<{ general: any[]; technical: any[]; }>({ general: [], technical: [], }); // 模拟获取评价详情数据 const fetchEvaluationData = (record: any) => { setLoading(true); try { // 模拟API请求 setTimeout(() => { // 模拟通用评价数据 const generalData = [ { id: '1', firstIndex: '质量管理', firstDescription: '供应商质量管理体系评价', secondIndex: '质量管理体系认证', secondDescription: '是否通过ISO9001认证', score: 9, weight: 0.1, weightedScore: 0.9, comment: '已通过ISO9001认证,证书有效', }, { id: '2', firstIndex: '质量管理', firstDescription: '供应商质量管理体系评价', secondIndex: '质量控制流程', secondDescription: '是否建立完善的质量控制流程', score: 8, weight: 0.1, weightedScore: 0.8, comment: '质量控制流程完善,但执行记录不够完整', }, { id: '3', firstIndex: '交付能力', firstDescription: '供应商交付能力评价', secondIndex: '准时交付率', secondDescription: '过去一年准时交付率评价', score: 9.5, weight: 0.15, weightedScore: 1.425, comment: '准时交付率98%,表现优秀', }, ]; // 模拟技术评价数据 const technicalData = [ { id: '1', firstIndex: '技术能力', firstDescription: '供应商技术研发能力评价', secondIndex: '研发投入', secondDescription: '研发投入占营业额比例', score: 8.5, weight: 0.1, weightedScore: 0.85, comment: '研发投入占营业额5%,符合行业平均水平', }, { id: '2', firstIndex: '技术能力', firstDescription: '供应商技术研发能力评价', secondIndex: '专利数量', secondDescription: '拥有专利数量评价', score: 9, weight: 0.05, weightedScore: 0.45, comment: '拥有15项有效专利,其中发明专利5项', }, { id: '3', firstIndex: '设备设施', firstDescription: '供应商设备设施评价', secondIndex: '设备先进性', secondDescription: '生产设备先进程度评价', score: 8, weight: 0.1, weightedScore: 0.8, comment: '主要生产设备较为先进,但部分设备需要更新', }, ]; setEvaluationData({ general: generalData, technical: technicalData, }); setLoading(false); }, 500); } catch (error) { console.error('获取评价详情数据失败:', error); message.error('获取评价详情数据失败'); setLoading(false); } }; // 获取上级页面传递的数据 useEffect(() => { if (location.state?.record) { setScoreRecord(location.state.record); // 模拟获取评价详情数据 fetchEvaluationData(location.state.record); } }, [location]); // 返回上一页 const handleBack = () => { history.goBack(); }; // 计算总得分 const calculateTotalScore = () => { let totalScore = 0; let totalWeight = 0; // 计算通用评价得分 evaluationData.general.forEach((item: any) => { totalScore += item.weightedScore; totalWeight += item.weight; }); // 计算技术评价得分 evaluationData.technical.forEach((item: any) => { totalScore += item.weightedScore; totalWeight += item.weight; }); // 如果权重总和不为0,则计算加权平均分 if (totalWeight > 0) { return (totalScore / totalWeight).toFixed(2); } return '0.00'; }; // 获取评价等级 const getEvaluateLevel = (score: number) => { if (score >= 90) { return EvaluateLevelText[EvaluateLevel.EXCELLENT]; } else if (score >= 80) { return EvaluateLevelText[EvaluateLevel.GOOD]; } else if (score >= 70) { return EvaluateLevelText[EvaluateLevel.AVERAGE]; } else { return EvaluateLevelText[EvaluateLevel.POOR]; } }; if (!scoreRecord) { return
加载中...
; } return (
{scoreRecord.supplierName} {scoreRecord.category} {scoreRecord.evaluateUnit} {scoreRecord.evaluator} {scoreRecord.evaluateTime} {scoreRecord.score} {getEvaluateLevel(scoreRecord.score)}
); }; export default SupplierEvaluateResultByZb;