2026-08-10 f9e6eb6fc2c2e0c2a2b17238b817fcbfcb6bab56
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
<script lang="ts" setup>
import type { HrmEmployeeContractApi } from '#/api/hrm/employee/contract';
 
import { ref, watch } from 'vue';
 
import { Table, Tag } from 'ant-design-vue';
 
import { getEmployeeContractPage } from '#/api/hrm/employee/contract';
import { DICT_TYPE } from '#/packages/constants/src';
import { getDictLabel } from '#/packages/effects/hooks/src';
 
const props = defineProps<{
  employeeId?: number;
}>();
 
const list = ref<HrmEmployeeContractApi.EmployeeContract[]>([]);
const loading = ref(false);
 
/** 合同状态颜色:1-待生效 2-生效中 3-即将到期 4-已到期 5-已解除 6-已终止 */
const statusColorMap: Record<number, string> = {
  1: 'processing',
  2: 'success',
  3: 'warning',
  4: 'default',
  5: 'error',
  6: 'error',
};
 
/** 刷新列表 */
async function handleRefresh() {
  if (!props.employeeId) return;
  loading.value = true;
  try {
    const res = await getEmployeeContractPage({
      pageNo: 1,
      pageSize: 100,
      employeeId: props.employeeId,
    });
    list.value = res.list;
  } finally {
    loading.value = false;
  }
}
 
/** 监听 employeeId 变化 */
watch(
  () => props.employeeId,
  (val) => {
    if (val) {
      handleRefresh();
    }
  },
  { immediate: true },
);
 
const columns = [
  { title: '合同编号', dataIndex: 'contractNo', width: 150 },
  { title: '续签自', dataIndex: 'parentNo', width: 130, key: 'parentNo' },
  { title: '合同类型', dataIndex: 'contractType', width: 100, key: 'contractType' },
  { title: '期限类型', dataIndex: 'contractTermType', width: 110, key: 'contractTermType' },
  { title: '签订日期', dataIndex: 'signDate', width: 110 },
  { title: '开始日期', dataIndex: 'startDate', width: 110 },
  { title: '结束日期', dataIndex: 'endDate', width: 110 },
  { title: '合同状态', dataIndex: 'status', width: 100, key: 'status' },
  { title: '当前合同', dataIndex: 'isCurrent', width: 90, key: 'isCurrent' },
];
</script>
 
<template>
  <div class="contract-list">
    <Table
      :columns="columns"
      :data-source="list"
      :loading="loading"
      :pagination="false"
      size="small"
      row-key="id"
    >
      <template #bodyCell="{ column, record }">
        <template v-if="column.key === 'parentNo'">
          {{ record.parentNo || '-' }}
        </template>
        <template v-else-if="column.key === 'contractType'">
          {{ getDictLabel(DICT_TYPE.HRM_CONTRACT_TYPE, record.contractType) }}
        </template>
        <template v-else-if="column.key === 'contractTermType'">
          {{ getDictLabel(DICT_TYPE.HRM_CONTRACT_TERM_TYPE, record.contractTermType) }}
        </template>
        <template v-else-if="column.key === 'status'">
          <Tag :color="statusColorMap[record.status!] || 'default'">
            {{ getDictLabel(DICT_TYPE.HRM_CONTRACT_STATUS, record.status) }}
          </Tag>
        </template>
        <template v-else-if="column.key === 'isCurrent'">
          <Tag v-if="record.isCurrent" color="processing">当前</Tag>
          <span v-else>-</span>
        </template>
      </template>
    </Table>
  </div>
</template>
 
<style scoped>
.contract-list {
  padding: 0;
}
</style>