From 27c8277d717b34b55f3ea967027b53b067f77df3 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期四, 20 八月 2026 16:58:49 +0800
Subject: [PATCH] feat 功能变更
---
src/views/hrm/performance-appraise/modules/score.vue | 180 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 180 insertions(+), 0 deletions(-)
diff --git a/src/views/hrm/performance-appraise/modules/score.vue b/src/views/hrm/performance-appraise/modules/score.vue
new file mode 100644
index 0000000..1a2a2c7
--- /dev/null
+++ b/src/views/hrm/performance-appraise/modules/score.vue
@@ -0,0 +1,180 @@
+<script lang="ts" setup>
+import type { HrmPerformanceAppraiseApi } from '#/api/hrm/performance-appraise';
+
+import { markRaw, ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+
+import { message } from 'ant-design-vue';
+
+import {
+ getAppraiseItemList,
+ getAppraiseResult,
+ saveAppraiseResult,
+} from '#/api/hrm/performance-appraise';
+import { HrmEmployeeSelect } from '#/views/hrm/employee/components';
+
+const emit = defineEmits(['success']);
+
+const appraiseId = ref<number>();
+const employeeId = ref<number>();
+const items = ref<HrmPerformanceAppraiseApi.AppraiseItem[]>([]);
+const comment = ref<string>('');
+
+const SCORER_TYPE_OPTIONS = [
+ { label: '鑷瘎', value: 1 },
+ { label: '涓婄骇璇�', value: 2 },
+];
+
+/** 鍔犺浇鎸囨爣鍒楄〃锛堜粎鍦ㄩ娆℃墦寮�鏃讹級 */
+async function loadItems() {
+ items.value = await getAppraiseItemList(appraiseId.value!);
+}
+
+/** 鍒囨崲鍛樺伐鏃跺洖濉凡鏈夎瘎鍒� */
+async function handleEmployeeChange(item: { id?: number } | undefined) {
+ employeeId.value = item?.id;
+ comment.value = '';
+ if (!item?.id) {
+ items.value.forEach((it) => {
+ it.selfScore = undefined;
+ it.superiorScore = undefined;
+ });
+ return;
+ }
+ const result = await getAppraiseResult(appraiseId.value!, item.id);
+ if (result?.items) {
+ items.value.forEach((it) => {
+ const detail = result.items!.find((ri) => ri.itemId === it.id);
+ it.selfScore = detail?.selfScore;
+ it.superiorScore = detail?.superiorScore;
+ });
+ comment.value = result.comment ?? '';
+ } else {
+ items.value.forEach((it) => {
+ it.selfScore = undefined;
+ it.superiorScore = undefined;
+ });
+ }
+}
+
+const [Modal, modalApi] = useVbenModal({
+ async onConfirm() {
+ if (!employeeId.value) {
+ message.warning('璇烽�夋嫨鍛樺伐');
+ return;
+ }
+ modalApi.lock();
+ try {
+ await saveAppraiseResult({
+ appraiseId: appraiseId.value!,
+ employeeId: employeeId.value!,
+ comment: comment.value,
+ items: items.value.map((item) => ({
+ itemId: item.id!,
+ selfScore: item.selfScore,
+ superiorScore: item.superiorScore,
+ })),
+ });
+ await modalApi.close();
+ emit('success');
+ message.success('璇勫垎淇濆瓨鎴愬姛锛屽凡鑷姩璁$畻缁煎悎寰楀垎');
+ } finally {
+ modalApi.unlock();
+ }
+ },
+ async onOpenChange(isOpen: boolean) {
+ if (!isOpen) {
+ appraiseId.value = undefined;
+ employeeId.value = undefined;
+ items.value = [];
+ comment.value = '';
+ return;
+ }
+ const data = modalApi.getData<{ id: number }>();
+ appraiseId.value = data?.id;
+ modalApi.lock();
+ try {
+ await loadItems();
+ } finally {
+ modalApi.unlock();
+ }
+ },
+});
+</script>
+
+<template>
+ <Modal title="鍛樺伐鑰冩牳璇勫垎" class="w-3/4">
+ <div class="mb-4 flex items-center gap-4">
+ <span class="shrink-0">鑰冩牳鍛樺伐锛�</span>
+ <HrmEmployeeSelect
+ :model-value="employeeId"
+ class="!w-72"
+ @change="handleEmployeeChange"
+ @update:model-value="(value: number | undefined) => (employeeId = value)"
+ />
+ </div>
+ <a-table
+ :data-source="items"
+ :pagination="false"
+ :scroll="{ y: 300 }"
+ bordered
+ row-key="id"
+ size="small"
+ >
+ <a-table-column title="鎸囨爣鍚嶇О" min-width="180">
+ <template #default="{ record }">
+ <span>{{ record.itemName }}</span>
+ </template>
+ </a-table-column>
+ <a-table-column title="鏉冮噸" width="90">
+ <template #default="{ record }">
+ <span>{{ record.weight }}</span>
+ </template>
+ </a-table-column>
+ <a-table-column title="璇勫垎浜�" width="90">
+ <template #default="{ record }">
+ <span>{{ record.scorerType === 1 ? '鑷瘎' : '涓婄骇璇�' }}</span>
+ </template>
+ </a-table-column>
+ <a-table-column title="鑷瘎寰楀垎" width="130">
+ <template #default="{ record }">
+ <a-input-number
+ v-model:value="record.selfScore"
+ :min="0"
+ :max="100"
+ :precision="1"
+ class="!w-full"
+ placeholder="鑷瘎寰楀垎"
+ />
+ </template>
+ </a-table-column>
+ <a-table-column title="涓婄骇璇勫緱鍒�" width="130">
+ <template #default="{ record }">
+ <a-input-number
+ v-model:value="record.superiorScore"
+ :min="0"
+ :max="100"
+ :precision="1"
+ class="!w-full"
+ placeholder="涓婄骇璇勫緱鍒�"
+ />
+ </template>
+ </a-table-column>
+ <a-table-column title="璇勫垎鏍囧噯" min-width="180">
+ <template #default="{ record }">
+ <span class="text-xs text-gray-400">{{ record.scoringStandard || '-' }}</span>
+ </template>
+ </a-table-column>
+ </a-table>
+ <div class="mt-3">
+ <span class="mr-2">璇勮锛�</span>
+ <a-textarea
+ v-model:value="comment"
+ :rows="2"
+ placeholder="璇疯緭鍏ヨ瘎璇�"
+ class="!w-full"
+ />
+ </div>
+ </Modal>
+</template>
--
Gitblit v1.9.3