xiaoyi
5 天以前 27c8277d717b34b55f3ea967027b53b067f77df3
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
<script lang="ts" setup>
import type { HrmPerformanceAppraiseApi } from '#/api/hrm/performance-appraise';
 
import { ref } from 'vue';
 
import { useVbenModal } from '@vben/common-ui';
 
import { Modal } from 'ant-design-vue';
 
import { DICT_TYPE } from '@vben/constants';
import { getDictLabel } from '@vben/hooks';
 
import { getAppraiseResultPage } from '#/api/hrm/performance-appraise';
 
const emit = defineEmits(['success']);
 
const appraiseId = ref<number>();
const resultList = ref<HrmPerformanceAppraiseApi.AppraiseResult[]>([]);
const total = ref(0);
const pageNo = ref(1);
const pageSize = ref(10);
const loading = ref(false);
 
const detailOpen = ref(false);
const detailRows = ref<HrmPerformanceAppraiseApi.ResultItem[]>([]);
 
function getGradeLabel(grade?: number): string {
  return grade == null ? '-' : getDictLabel(DICT_TYPE.HRM_PERFORMANCE_GRADE, grade);
}
 
async function loadResults() {
  loading.value = true;
  try {
    const data = await getAppraiseResultPage({
      appraiseId: appraiseId.value!,
      pageNo: pageNo.value,
      pageSize: pageSize.value,
    });
    resultList.value = data.list ?? [];
    total.value = data.total ?? 0;
  } finally {
    loading.value = false;
  }
}
 
function handlePageChange(page: number, size: number) {
  pageNo.value = page;
  pageSize.value = size;
  loadResults();
}
 
function handleDetail(row: HrmPerformanceAppraiseApi.AppraiseResult) {
  detailRows.value = row.items ?? [];
  detailOpen.value = true;
}
 
const [ModalRoot, modalApi] = useVbenModal({
  async onOpenChange(isOpen: boolean) {
    if (!isOpen) {
      appraiseId.value = undefined;
      resultList.value = [];
      total.value = 0;
      pageNo.value = 1;
      return;
    }
    const data = modalApi.getData<{ id: number }>();
    appraiseId.value = data?.id;
    await loadResults();
  },
});
</script>
 
<template>
  <ModalRoot title="考核结果" class="w-3/4">
    <div class="mb-3 text-sm text-gray-500">
      综合得分 = Σ(权重 × 单指标得分) / Σ权重;档级 ≥90 优秀 / ≥80 良好 / ≥60 合格 / &lt;60 待改进
    </div>
    <a-table
      :data-source="resultList"
      :loading="loading"
      :pagination="{
        current: pageNo,
        pageSize,
        total,
        showSizeChanger: true,
        showTotal: (t: number) => `共 ${t} 人`,
      }"
      :scroll="{ y: 380 }"
      bordered
      row-key="id"
      size="small"
      @change="(pag: { current?: number; pageSize?: number }) =>
        handlePageChange(pag.current ?? 1, pag.pageSize ?? 10)"
    >
      <a-table-column title="员工" data-index="employeeName" min-width="120" />
      <a-table-column title="自评总分" data-index="selfScore" width="100" />
      <a-table-column title="上级评总分" data-index="superiorScore" width="110" />
      <a-table-column title="综合得分" data-index="finalScore" width="100">
        <template #default="{ record }">
          <span class="font-medium">{{ record.finalScore ?? '-' }}</span>
        </template>
      </a-table-column>
      <a-table-column title="档级" width="90">
        <template #default="{ record }">
          <a-tag :color="record.grade === 1 ? 'success' : record.grade === 2 ? 'processing' : record.grade === 3 ? 'warning' : 'error'">
            {{ getGradeLabel(record.grade) }}
          </a-tag>
        </template>
      </a-table-column>
      <a-table-column title="评语" data-index="comment" min-width="160" ellipsis />
      <a-table-column title="操作" width="90" align="center">
        <template #default="{ record }">
          <a-button type="link" @click="handleDetail(record)">明细</a-button>
        </template>
      </a-table-column>
    </a-table>
 
    <Modal
      v-model:open="detailOpen"
      title="指标评分明细"
      width="640px"
      :footer="null"
    >
      <a-table
        :data-source="detailRows"
        :pagination="false"
        bordered
        row-key="id"
        size="small"
      >
        <a-table-column title="指标名称" data-index="itemName" min-width="160" />
        <a-table-column title="权重" data-index="weight" width="90" />
        <a-table-column title="自评得分" data-index="selfScore" width="100" />
        <a-table-column title="上级评得分" data-index="superiorScore" width="110" />
      </a-table>
    </Modal>
  </ModalRoot>
</template>