// 供应商评价结果得分明细
import React, { useState, useEffect } from 'react';
import { Tabs, Button, Typography, Row, Col } from 'antd';
import { ArrowLeftOutlined } from '@ant-design/icons';
import { history, useLocation } from 'umi';
import GeneralEvaluation from './components/GeneralEvaluation';
import TechnicalEvaluation from './components/TechnicalEvaluation';
import styles from './supplierEvaluateResult.less';

const { Title } = Typography;
const { TabPane } = Tabs;

const SupplierEvaluateResultScoreDetail: React.FC = () => {
  const location = useLocation<{ record: SupplierEvaluate.EvaluateResultDetailRecord }>();
  const [supplierRecord, setSupplierRecord] = useState<SupplierEvaluate.EvaluateResultDetailRecord | null>(null);
  const [activeTab, setActiveTab] = useState<string>('1');

  // 获取上级页面传递的数据
  useEffect(() => {
    if (location.state?.record) {
      setSupplierRecord(location.state.record);
    }
  }, [location]);

  // 处理Tab切换
  const handleTabChange = (key: string) => {
    setActiveTab(key);
  };

  // 返回上一页
  const handleBack = () => {
    history.goBack();
  };

  return (
    <div className="common-container">
      <div className={styles.headerRow}>
        <div className={styles.titleSection}>
          <Title level={4} className={styles.pageTitle}>
            {supplierRecord?.supplierName || '供应商'} - 评价得分明细
          </Title>
        </div>
        <div className={styles.actionSection}>
          <Button type="link" icon={<ArrowLeftOutlined />} onClick={handleBack}>
            返回
          </Button>
        </div>
      </div>

      <div className="content-area">
        <Tabs activeKey={activeTab} onChange={handleTabChange} type="card">
          <TabPane tab="通用评价" key="1">
            <GeneralEvaluation supplierName={supplierRecord?.supplierName} />
          </TabPane>
          <TabPane tab="技术评价" key="2">
            <TechnicalEvaluation supplierName={supplierRecord?.supplierName} />
          </TabPane>
        </Tabs>
      </div>
    </div>
  );
};

export default SupplierEvaluateResultScoreDetail;
