<script lang="ts" setup>
|
import type { ArchiveBorrowApi } from '#/api/archive/borrow';
|
|
import { ref } from 'vue';
|
|
import { useVbenModal } from '@vben/common-ui';
|
|
import { message } from 'ant-design-vue';
|
|
import { useVbenForm } from '#/adapter/form';
|
import { returnBorrow } from '#/api/archive/borrow';
|
|
defineOptions({ name: 'ArchiveBorrowReturnForm' });
|
|
const emit = defineEmits(['success']);
|
|
/** 当前归还的借阅单 */
|
const current = ref<ArchiveBorrowApi.Borrow>();
|
|
const [Form, formApi] = useVbenForm({
|
commonConfig: {
|
componentProps: {
|
class: 'w-full',
|
},
|
},
|
wrapperClass: 'grid-cols-1',
|
layout: 'vertical',
|
schema: [
|
{
|
fieldName: 'returnRemark',
|
label: '归还备注',
|
component: 'Textarea',
|
componentProps: {
|
rows: 3,
|
placeholder: '如归还时档案完好、是否有缺页等',
|
},
|
},
|
],
|
showDefaultActions: false,
|
});
|
|
const [Modal, modalApi] = useVbenModal({
|
async onConfirm() {
|
const values = (await formApi.getValues()) as { returnRemark?: string };
|
modalApi.lock();
|
try {
|
await returnBorrow({
|
id: current.value!.id!,
|
returnRemark: values.returnRemark,
|
});
|
await modalApi.close();
|
emit('success');
|
message.success('归还登记成功');
|
} finally {
|
modalApi.unlock();
|
}
|
},
|
async onOpenChange(isOpen: boolean) {
|
if (!isOpen) {
|
current.value = undefined;
|
return;
|
}
|
current.value = modalApi.getData<ArchiveBorrowApi.Borrow>();
|
await formApi.resetForm();
|
},
|
});
|
</script>
|
|
<template>
|
<Modal title="归还登记" class="w-1/2">
|
<div class="mx-3 mb-3 text-sm text-gray-600">
|
<p>
|
借阅单号:{{ current?.no }} 档案:{{ current?.documentNo }}
|
{{ current?.documentTitle }}
|
</p>
|
<p>
|
借阅人:{{ current?.borrowerName }} 归还期限:{{ current?.returnDeadline }}
|
</p>
|
</div>
|
<Form class="mx-3" />
|
</Modal>
|
</template>
|