tuqin
18 小时以前 2cb77a3487b8c5da6fe02f3c1018dcf70f73d29a
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
<script lang="ts" setup>
import type { HrmEmployeeContractApi } from '#/api/hrm/employee/contract';
 
import { ref } from 'vue';
 
import { useVbenModal } from '#/packages/effects/common-ui/src';
 
import { getEmployeeContract } from '#/api/hrm/employee/contract';
 
const attachments = ref<HrmEmployeeContractApi.AttachmentItem[]>([]);
const loading = ref(false);
 
const [Modal, modalApi] = useVbenModal({
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      return;
    }
    const data = modalApi.getData<{ id?: number }>();
    if (!data?.id) {
      return;
    }
    loading.value = true;
    try {
      const detail = await getEmployeeContract(data.id);
      attachments.value = detail.attachmentList || [];
    } finally {
      loading.value = false;
    }
  },
});
</script>
 
<template>
  <Modal title="合同附件" class="w-[560px]">
    <div v-if="loading" class="py-6 text-center text-gray-400">加载中...</div>
    <div v-else-if="attachments.length === 0" class="py-6 text-center text-gray-400">
      暂无附件(可在「更多 → 修改」里上传,或用「生成合同」生成后自动归档)
    </div>
    <ul v-else class="max-h-[50vh] overflow-auto pl-5">
      <li v-for="f in attachments" :key="f.id" class="mb-2 list-disc">
        <a :href="f.url" target="_blank" rel="noopener" class="text-primary">
          {{ f.name || `附件${f.id}` }}
        </a>
      </li>
    </ul>
  </Modal>
</template>