import React from 'react';
import { Card, Table } from 'antd';
import styles from '../../supplierTaskManageDetail.less';

interface WeightInfoProps {
  taskData: SupplierEvaluate.TaskDetailData;
}

const WeightInfo: React.FC<WeightInfoProps> = ({ taskData }) => {
  const columns = [
    {
      title: '序号',
      dataIndex: 'index',
      key: 'index',
      render: (_: any, __: any, index: number) => index + 1,
      width: 80,
    },
    {
      title: '部门名称',
      dataIndex: 'weightDept',
      key: 'weightDept',
    },
    {
      title: '权重值',
      dataIndex: 'weightValue',
      key: 'weightValue',
      render: (value: number) => `${value}%`,
    },
  ];

  if (!taskData || !taskData.taskDeptWeightList || taskData.taskDeptWeightList.length === 0) {
    return <div className={styles.emptyData}>暂无权重设置数据</div>;
  }

  return (
    <Card className={styles.detailCard}>
      <Table
        columns={columns}
        dataSource={taskData.taskDeptWeightList}
        rowKey="id"
        pagination={false}
        className={styles.tableContainer}
      />
    </Card>
  );
};

export default WeightInfo;
