import { Form, Input, InputNumber, Row, Col, Select } from "antd";
import {
  CHONGQING_DISTRICTS,
  QUALIFICATION_INDUSTRY_OPTIONS,
} from "~/enumerate/enterpriseOptions";
import { FILING_UNIT_TYPE_OPTIONS } from "~/enumerate/qualFilingOptions";
import AttachmentUpload from "~/components/AttachmentUpload";

export default function BasicInfoStep({ form, disabled, mode }) {
  return (
    <Form form={form} layout="vertical" disabled={disabled}>
      <Row gutter={16}>
        <Col span={24}>
          <Form.Item
            name="businessScope"
            label={mode === 'filed' ? "已有资质备案" : "申请的业务范围"}
            rules={[{ required: !disabled, message: "请选择业务范围" }]}
          >
            <Select
              options={QUALIFICATION_INDUSTRY_OPTIONS}
              mode="multiple"
              placeholder="请选择证照类型"
            />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="filingTerritoryName"
            label="备案属地"
            rules={[{ required: !disabled, message: "请选择备案属地" }]}
          >
            <Select
              options={CHONGQING_DISTRICTS}
              placeholder="请选择"
              showSearch
              optionFilterProp="label"
            />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item name="filingUnitName" label="备案单位" rules={[{ required: !disabled, message: "请输入备案单位" }]}>
            <Input placeholder="备案单位" maxLength={64} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item name="filingUnitTypeName" label="备案单位类型" rules={[{ required: !disabled, message: "请选择备案单位类型" }]}>
            <Select options={FILING_UNIT_TYPE_OPTIONS} placeholder="请选择" />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item name="creditCode" label="统一社会信用代码" rules={[{ required: !disabled, message: "请输入统一社会信用代码" }]}>
            <Input placeholder="统一社会信用代码" maxLength={18} />
          </Form.Item>
        </Col>
        <Col span={24}>
          <Form.Item name="officeAddress" label="办公地址" rules={[{ required: !disabled, message: "请输入办公地址" }]}>
            <Input placeholder="办公地址" maxLength={128} />
          </Form.Item>
        </Col>
        <Col span={24}>
          <Form.Item name="registerAddress" label="注册地址" rules={[{ required: !disabled, message: "请输入注册地址" }]}>
            <Input placeholder="注册地址" maxLength={128} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item name="qualCertNo" label="资质证书编号" rules={[{ required: !disabled, message: "请输入资质证书编号" }]}>
            <Input placeholder="资质证书编号" maxLength={32} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="infoDisclosureUrl"
            label="信息公开网址"
            rules={[
              { required: !disabled, message: "请输入信息公开网址" },
              {
                pattern: /^https?:\/\/[^\s]+$/,
                message: "请输入正确的网址，需以 http:// 或 https:// 开头",
              },
            ]}
          >
            <Input placeholder="信息公开网址" maxLength={128} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="legalPersonPhone"
            label="法人代表电话"
            rules={[
              { required: !disabled, message: "请输入法人代表电话" },
              {
                pattern: /^(1\d{10}|0\d{2,3}-?\d{7,8})$/,
                message: "请输入正确的手机号或座机号",
              },
            ]}
          >
            <Input placeholder="请输入法人代表电话" maxLength={11} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="contactPhone"
            label="联系人电话"
            rules={[
              { required: !disabled, message: "请输入联系人电话" },
              {
                pattern: /^(1\d{10}|0\d{2,3}-?\d{7,8})$/,
                message: "请输入正确的手机号或座机号",
              },
            ]}
          >
            <Input placeholder="请输入联系人电话" maxLength={11} />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="fixedAssetAmount"
            label="固定资产总值(万元)"
            rules={[
              { required: !disabled, message: "请输入固定资产总值" },
            
            ]}
          >
            <InputNumber
              style={{ width: "100%" }}
              min={0}
              max={100000000}
              precision={2}
              placeholder="万元"
            />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="workplaceArea"
            label="工作场所建筑面积(㎡)"
            rules={[
              { required: !disabled, message: "请输入工作场所建筑面积" },
             
            ]}
          >
            <InputNumber
              style={{ width: "100%" }}
              min={0}
              max={100000000}
              precision={2}
              placeholder="㎡"
            />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="archiveRoomArea"
            label="档案室面积(㎡)"
            rules={[{ required: !disabled, message: "请输入档案室面积" }]}
          >
            <InputNumber
              style={{ width: "100%" }}
              min={0}
              max={100000000}
              precision={2}
              placeholder="㎡"
            />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="fulltimeEvaluatorCount"
            label="专职安全评价师数量(人)"
            rules={[{ required: !disabled, message: "请输入专职安全评价师数量" }]}
          >
            <InputNumber style={{ width: "100%" }} min={0} max={100000000} maxLength={9} placeholder="人" />
          </Form.Item>
        </Col>
        <Col span={12}>
          <Form.Item
            name="registeredEngineerCount"
            label="注册安全工程师数量(人)"
            rules={[{ required: !disabled, message: "请输入注册安全工程师数量" }]}
          >
            <InputNumber style={{ width: "100%" }} min={0} max={100000000} maxLength={9} placeholder="人" />
          </Form.Item>
        </Col>
        <Col span={24}>
          <Form.Item name="unitIntro" label="单位基本情况介绍" rules={[{ required: !disabled, message: "请输入单位基本情况介绍" }]}>
            <Input.TextArea rows={3} placeholder="请输入单位基本情况介绍" maxLength={500} showCount />
          </Form.Item>
        </Col>
        <Col span={24}>
          <AttachmentUpload
            name="attachmentUrl"
            rules={[{ required: !disabled, message: "请上传附件" }]}
            label="上传附件"
            disabled={disabled}
            extra={'最多上传12个PDF、DOC、DOCX格式文件'}
            maxCount={12}
            accept=".pdf,.doc,.docx"
          />
        </Col>
      </Row>
    </Form>
  );
}
