import { FC } from "react";
import { Form, Input, InputNumber, Modal, ModalProps } from "antd";
import style from "@/components/AddIndexModal/index.module.scss";

export interface EvaluationModalProps extends Omit<ModalProps, "onOk"> {
  onCancel?: () => void;
  onOk?: (val: any) => void;
}

const { TextArea } = Input;

export const EvaluationModal: FC<EvaluationModalProps> = ({
  open,
  onOk,
  onCancel,
  ...rest
}) => {
  const [form] = Form.useForm<any>();

  const handleCancel = () => {
    form.resetFields();
    onCancel?.();
  };

  const handleConfirm = () => {
    form.submit();
  };

  const handleSubmit = async (values: any) => {
    onOk?.(values);
    handleCancel();
  };

  return (
    <Modal
      className={style.modal}
      title="评定意见"
      okText="提交"
      cancelText="取消"
      open={open}
      width={640}
      okButtonProps={{
        disabled: false,
      }}
      onOk={handleConfirm}
      onCancel={handleCancel}
      {...rest}
    >
      <Form
        labelCol={{ span: 4, offset: 2 }}
        form={form}
        onFinish={handleSubmit}
      >
        <Form.Item name="">
          <TextArea
            rows={6}
            maxLength={2000}
            placeholder="请输入内容，不超过2000字"
          />
        </Form.Item>
      </Form>
    </Modal>
  );
};
