gaoluyang
2 天以前 b64a0deae5b5d33f9e20671a68936b27f0b9b00b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
<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>