liu
2026-09-07 a7dc7b230fcc6abc6ee5a7bfadb90789b03d2ca8
src/views/hrm/leave/modules/form.vue
@@ -4,6 +4,8 @@
import { computed, ref } from 'vue';
import { useUserStore } from '@vben/stores';
import { useVbenModal } from '#/packages/effects/common-ui/src';
import { message } from 'ant-design-vue';
@@ -16,6 +18,8 @@
const emit = defineEmits(['success']);
const formType = ref<FormType>('create');
const userStore = useUserStore();
const isDetail = computed(() => formType.value === 'detail');
const getTitle = computed(() => {
@@ -74,11 +78,23 @@
    formApi.setDisabled(data.formType === 'detail');
    modalApi.setState({ showConfirmButton: data.formType !== 'detail' });
    if (!data?.id) {
      // 新增时默认申请人为当前登录用户,可修改
      await formApi.setFieldValue('userId', userStore.userInfo?.id);
      return;
    }
    modalApi.lock();
    try {
      await formApi.setValues(await getLeave(data.id));
      const detail = await getLeave(data.id);
      await formApi.setValues(detail);
      if (detail.attachmentList?.length) {
        await formApi.setFieldValue('blobIds', detail.attachmentList.map(item => ({
          uid: String(item.id),
          name: item.name || '',
          url: item.url || '',
          status: 'done',
          id: item.id,
        })));
      }
    } finally {
      modalApi.unlock();
    }