<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 合格 / <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>
|