import { ElForm } from "element-plus";
import { ref } from "vue";

export function useAudit(callback: () => void) {
  const formRef = ref<InstanceType<typeof ElForm>>(null);

  function handleAudit() {
    formRef.value.validate(isValid => {
      if (!isValid) callback();
    });
  }

  return {
    formRef,
    handleAudit
  };
}
