import { MyBetaModalFormProps, MyButtons, MyModalFormProps } from '@/common';
import { Apis } from '@/gen/Apis';
import { BetaSchemaForm } from '@ant-design/pro-components';
import { Form, message } from 'antd';

export default function Create(props: MyBetaModalFormProps) {
  const [form] = Form.useForm();
  return (
    <BetaSchemaForm<ApiTypes.Archive.HouseRegisters.Store>
      {...MyModalFormProps.props}
      title={`添加${props.title}`}
      wrapperCol={{ span: 24 }}
      width="500px"
      form={form}
      trigger={
        <MyButtons.Default title={props.title} size="small" type="link" />
      }
      onFinish={async (values) =>
        Apis.Archive.HouseRegisters.Store({
          ...values,
          asset_houses_id: props?.item?.id,
          type: 'MoveOut',
          customer_info: props?.item?.id,
        })
          .then(() => {
            props.reload?.();
            message.success(props.title + '成功');
            return true;
          })
          .catch(() => false)
      }
      columns={[
        {
          title: '搬离日期',
          valueType: 'date',
          dataIndex: '',
          colProps: { span: 24 },
          fieldProps: {
            maxLength: 11,
            style: {
              width: '100%',
            },
          },
        },
      ]}
    />
  );
}
