<script lang="ts" setup>
|
import type { MesPdDocumentAuditApi } from '#/api/mes/pd/document-audit';
|
|
import { useVbenModal } from '#/packages/effects/common-ui/src';
|
import { DICT_TYPE } from '#/packages/constants/src';
|
import { getDictOptions } from '#/packages/effects/hooks/src';
|
|
import { message } from 'ant-design-vue';
|
|
import { useVbenForm } from '#/adapter/form';
|
import { updatePdDocumentAudit } from '#/api/mes/pd/document-audit';
|
import { $t } from '#/locales';
|
|
const emit = defineEmits(['success']);
|
|
const [Form, formApi] = useVbenForm({
|
commonConfig: { componentProps: { class: 'w-full' }, labelWidth: 100 },
|
layout: 'horizontal',
|
schema: [
|
{ fieldName: 'id', component: 'Input', dependencies: { triggerFields: [''], show: () => false } },
|
{ fieldName: 'auditNo', label: '审核单号', component: 'Input', componentProps: { disabled: true } },
|
{ fieldName: 'documentName', label: '资料名称', component: 'Input', componentProps: { disabled: true } },
|
{ fieldName: 'documentVersion', label: '资料版本', component: 'Input', componentProps: { disabled: true } },
|
{ fieldName: 'reviewerNickname', label: '审核人', component: 'Input', componentProps: { disabled: true } },
|
{
|
fieldName: 'auditStatus',
|
label: '审核结果',
|
component: 'Select',
|
componentProps: { options: getDictOptions(DICT_TYPE.MES_PD_DOCUMENT_AUDIT_STATUS, 'number'), placeholder: '请选择审核结果' },
|
rules: 'selectRequired',
|
},
|
{ fieldName: 'remark', label: '审核意见', component: 'Textarea', componentProps: { placeholder: '请输入审核意见', rows: 3 } },
|
],
|
showDefaultActions: false,
|
});
|
|
const [Modal, modalApi] = useVbenModal({
|
async onConfirm() {
|
const { valid } = await formApi.validate();
|
if (!valid) return;
|
modalApi.lock();
|
try {
|
const raw = await formApi.getValues();
|
await updatePdDocumentAudit({ id: raw.id, auditStatus: raw.auditStatus, remark: raw.remark, auditTime: Date.now() });
|
emit('success');
|
message.success($t('ui.actionMessage.operationSuccess'));
|
await modalApi.close();
|
} finally {
|
modalApi.unlock();
|
}
|
},
|
async onOpenChange(isOpen: boolean) {
|
if (!isOpen) return;
|
const data = modalApi.getData<MesPdDocumentAuditApi.DocumentAudit>();
|
modalApi.setState({ title: '资料审核' });
|
await formApi.setValues(data);
|
},
|
});
|
</script>
|
|
<template>
|
<Modal class="w-[520px]">
|
<Form class="mx-4" />
|
</Modal>
|
</template>
|