import ParameterSelect from '@/components/ParameterSelect';
import ResourceSelect, {
  ResourceSelectorType,
  requiredValidator,
} from '@/components/ResourceSelect';
import SubAreaTitle from '@/components/SubAreaTitle';
import { Col, Form, InputNumber, Row, Select } from 'antd';

// 模型
const modelTypeOptions = [
  'TextCNN',
  'TextRNN',
  'FasetText',
  'TextRCNN',
  'TextRNN_Att',
  'DPCNN',
  'Transformer',
].map((name) => ({ label: name, value: name }));

function TextExecuteConfig() {
  return (
    <>
      <SubAreaTitle
        title="执行配置"
        image={require('@/assets/img/model-deployment.png')}
        style={{ marginTop: '20px', marginBottom: '24px' }}
      ></SubAreaTitle>
      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="模型"
            name="model_type"
            rules={[
              {
                required: true,
                message: '请选择模型',
              },
            ]}
          >
            <Select allowClear placeholder="请选择模型" options={modelTypeOptions} showSearch />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="数据集"
            name="dataset"
            rules={[
              {
                validator: requiredValidator,
                message: '请选择数据集',
              },
            ]}
            required
          >
            <ResourceSelect
              type={ResourceSelectorType.Dataset}
              placeholder="请选择数据集"
              canInput={false}
            />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="资源规格"
            name="computing_resource_id"
            rules={[
              {
                required: true,
                message: '请选择资源规格',
              },
            ]}
          >
            <ParameterSelect dataType="resource" placeholder="请选择资源规格" />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="batch_size"
            name="batch_size"
            rules={[
              {
                required: true,
                message: '请输入 batch_size',
              },
            ]}
          >
            <InputNumber placeholder="请输入 batch_size" min={0} precision={0} />
          </Form.Item>
        </Col>
      </Row>
      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="epochs"
            name="epochs"
            rules={[
              {
                required: true,
                message: '请输入epochs',
              },
            ]}
          >
            <InputNumber placeholder="请输入epochs" min={0} precision={0} />
          </Form.Item>
        </Col>
      </Row>

      <Row gutter={8}>
        <Col span={10}>
          <Form.Item
            label="学习率"
            name="lr"
            rules={[
              {
                required: true,
                message: '请输入学习率',
              },
            ]}
          >
            <InputNumber placeholder="请输入学习率" min={0} />
          </Form.Item>
        </Col>
      </Row>
    </>
  );
}

export default TextExecuteConfig;
