import React from 'react';
import { Modal, Form, Row, Col, InputNumber } from 'antd';
import type { DeptWeightItem } from '@/servers/types/supplierEvaluateTask';

interface WeightSettingModalProps {
  visible: boolean;
  onCancel: () => void;
  onOk: () => void;
  taskDeptWeightList: DeptWeightItem[];
  form: any;
}

const WeightSettingModal: React.FC<WeightSettingModalProps> = ({
  visible,
  onCancel,
  onOk,
  taskDeptWeightList,
  form,
}) => {
  return (
    <Modal
      title="设置评分单位权重"
      visible={visible}
      onOk={onOk}
      onCancel={onCancel}
    >
      <Form form={form} layout="horizontal">
        <Row gutter={16}>
          {taskDeptWeightList.map((item) => (
            <Col span={12} key={item.weightDept}>
              <Form.Item
                key={item.weightDept}
                label={item.weightDeptName}
                name={['taskDeptWeightList', item.weightDept]}
                rules={[
                  { required: true, message: '请输入权重值' },
                  { type: 'number', min: 0, message: '请输入大于等于0的数值' },
                ]}
              >
                <InputNumber min={0} max={100} style={{ width: '100%' }} />
              </Form.Item>
            </Col>
          ))}
        </Row>
      </Form>
    </Modal>
  );
};

export default WeightSettingModal;
