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 ApplyClose(
  props: MyBetaModalFormProps & { item: any },
) {
  const [form] = Form.useForm();
  return (
    <BetaSchemaForm<ApiTypes.Emergency.EmergencyEvents.Assign>
      {...MyModalFormProps.props}
      title={`申请关闭`}
      wrapperCol={{ span: 24 }}
      width="600px"
      labelAlign="left"
      trigger={
        <MyButtons.Default
          title="关闭"
          disabled={
            props.item.status !== 'InProgress' &&
            props.item.status !== 'PendingFollowUp'
          }
          type="primary"
        />
      }
      key={new Date().getTime()}
      form={form}
      onFinish={async (values: any) => {
        return Apis.Emergency.EmergencyEvents.ApplyClose({
          ...values,
          id: props.item.id,
        })
          .then(() => {
            props.reload?.();
            message.success('提交成功');
            return true;
          })
          .catch(() => false);
      }}
      columns={[
        {
          title: '处理结果',
          colProps: { span: 24 },
          dataIndex: 'handled_result',
          valueType: 'textarea',
        },
        {
          title: '反思与总结',
          colProps: { span: 24 },
          dataIndex: 'introspection',
          valueType: 'textarea',
        },
      ]}
    />
  );
}
