From dc1d067c566bbde1c7170186960a8bd27f210a47 Mon Sep 17 00:00:00 2001
From: 云 <2163098428@qq.com>
Date: 星期三, 09 九月 2026 13:45:58 +0800
Subject: [PATCH] feat(bi): 新增决策总览仪表盘并优化预测分析功能
---
src/views/hrm/training/modules/participants.vue | 278 +++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 278 insertions(+), 0 deletions(-)
diff --git a/src/views/hrm/training/modules/participants.vue b/src/views/hrm/training/modules/participants.vue
new file mode 100644
index 0000000..2a996e8
--- /dev/null
+++ b/src/views/hrm/training/modules/participants.vue
@@ -0,0 +1,278 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { HrmEmployeeApi } from '#/api/hrm/employee';
+import type { HrmTrainingApi } from '#/api/hrm/training';
+
+import { ref } from 'vue';
+
+import { useVbenModal } from '@vben/common-ui';
+
+import { message, Modal as AntModal, Tag } from 'ant-design-vue';
+
+import { useVbenForm } from '#/adapter/form';
+import { useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+ addTrainingParticipants,
+ deleteTrainingParticipants,
+ getTrainingParticipants,
+ updateTrainingParticipant,
+} from '#/api/hrm/training';
+import { $t } from '#/locales';
+
+import { HrmEmployeeSelectDialog } from '#/views/hrm/employee/components';
+
+defineOptions({ name: 'HrmTrainingParticipants' });
+
+const emit = defineEmits(['success']);
+
+const trainingId = ref<number>();
+
+/** 鍙傝浜哄憳缂栬緫琛ㄥ崟 */
+const participantFormData = ref<HrmTrainingApi.Participant>();
+const editVisible = ref(false);
+const editSaving = ref(false);
+const [EditForm, editFormApi] = useVbenForm({
+ commonConfig: {
+ componentProps: {
+ class: 'w-full',
+ },
+ labelWidth: 120,
+ },
+ wrapperClass: 'grid-cols-2',
+ layout: 'vertical',
+ schema: [
+ {
+ fieldName: 'id',
+ component: 'Input',
+ dependencies: {
+ triggerFields: [''],
+ show: () => false,
+ },
+ },
+ {
+ fieldName: 'attended',
+ label: '鏄惁鍙傝',
+ component: 'Select',
+ componentProps: {
+ options: [
+ { label: '鏄�', value: 1 },
+ { label: '鍚�', value: 0 },
+ ],
+ placeholder: '鏄惁鍙傝',
+ },
+ },
+ {
+ fieldName: 'score',
+ label: '鎴愮哗',
+ component: 'InputNumber',
+ componentProps: {
+ placeholder: '璇疯緭鍏ユ垚缁�',
+ min: 0,
+ precision: 1,
+ style: { width: '100%' },
+ },
+ },
+ {
+ fieldName: 'isPass',
+ label: '鏄惁鍚堟牸',
+ component: 'Select',
+ componentProps: {
+ options: [
+ { label: '鏄�', value: 1 },
+ { label: '鍚�', value: 0 },
+ ],
+ placeholder: '鏄惁鍚堟牸',
+ },
+ },
+ {
+ fieldName: 'remark',
+ label: '澶囨敞',
+ component: 'Textarea',
+ componentProps: {
+ placeholder: '璇疯緭鍏ュ娉�',
+ autoSize: { minRows: 1, maxRows: 2 },
+ },
+ formItemClass: 'col-span-2',
+ },
+ ],
+ showDefaultActions: false,
+});
+
+/** 鎵撳紑缂栬緫寮圭獥 */
+function openEditForm(row: HrmTrainingApi.Participant) {
+ participantFormData.value = row;
+ editFormApi.setValues({
+ id: row.id,
+ attended: row.attended ? 1 : 0,
+ score: row.score,
+ isPass: row.isPass ? 1 : 0,
+ remark: row.remark,
+ });
+ editVisible.value = true;
+}
+
+/** 淇濆瓨鍙傝璁板綍 */
+async function handleEditSave() {
+ const { valid } = await editFormApi.validate();
+ if (!valid) {
+ return;
+ }
+ editSaving.value = true;
+ const values = await editFormApi.getValues<HrmTrainingApi.Participant>();
+ try {
+ await updateTrainingParticipant({
+ id: values.id,
+ attended: Boolean(values.attended),
+ score: values.score,
+ isPass: Boolean(values.isPass),
+ remark: values.remark,
+ } as HrmTrainingApi.Participant);
+ message.success($t('ui.actionMessage.operationSuccess'));
+ editVisible.value = false;
+ await loadParticipants();
+ } finally {
+ editSaving.value = false;
+ }
+}
+
+/** 鍒犻櫎鍙傝璁板綍 */
+async function handleDelete(row: HrmTrainingApi.Participant) {
+ await deleteTrainingParticipants([row.id!]);
+ message.success($t('ui.actionMessage.deleteSuccess'));
+ await loadParticipants();
+}
+
+/** 鍛樺伐閫夋嫨寮圭獥锛堝閫夛級 */
+const employeeDialogRef = ref<InstanceType<typeof HrmEmployeeSelectDialog>>();
+function openEmployeeSelect() {
+ employeeDialogRef.value?.open([], { multiple: true });
+}
+
+async function handleEmployeesSelected(rows: HrmEmployeeApi.Employee[]) {
+ const employeeIds = rows
+ .map((item) => item.id)
+ .filter((id): id is number => id !== undefined && id !== null);
+ if (employeeIds.length === 0) {
+ return;
+ }
+ try {
+ await addTrainingParticipants(trainingId.value!, employeeIds);
+ message.success('娣诲姞鍙傝浜哄憳鎴愬姛');
+ await loadParticipants();
+ emit('success');
+ } catch (e) {
+ // 鍚庣鍏滃簳鎻愮ず宸插脊鍑�
+ }
+}
+
+async function loadParticipants() {
+ if (!trainingId.value) {
+ return;
+ }
+ const list = await getTrainingParticipants(trainingId.value);
+ gridApi.grid.loadData(list);
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ gridOptions: {
+ columns: [
+ { type: 'seq', title: '搴忓彿', width: 60 },
+ { field: 'employeeNo', title: '鍛樺伐缂栧彿', width: 130 },
+ { field: 'employeeName', title: '鍛樺伐濮撳悕', minWidth: 120 },
+ {
+ field: 'attended',
+ title: '鏄惁鍙傝',
+ width: 100,
+ slots: { default: 'attended' },
+ },
+ {
+ field: 'score',
+ title: '鎴愮哗',
+ width: 90,
+ },
+ {
+ field: 'isPass',
+ title: '鏄惁鍚堟牸',
+ width: 100,
+ slots: { default: 'isPass' },
+ },
+ { field: 'remark', title: '澶囨敞', minWidth: 120 },
+ {
+ field: 'action',
+ title: '鎿嶄綔',
+ width: 140,
+ fixed: 'right',
+ slots: { default: 'actions' },
+ },
+ ],
+ height: 'auto',
+ keepSource: true,
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: false,
+ search: false,
+ },
+ } as VxeTableGridOptions<HrmTrainingApi.Participant>,
+});
+
+const [Modal, modalApi] = useVbenModal({
+ onOpenChange(isOpen) {
+ if (!isOpen) {
+ trainingId.value = undefined;
+ return;
+ }
+ const data = modalApi.getData<{ trainingId?: number }>();
+ trainingId.value = data?.trainingId;
+ if (trainingId.value) {
+ loadParticipants();
+ }
+ },
+});
+</script>
+
+<template>
+ <Modal title="鍙傝浜哄憳绠$悊" class="w-[900px]" :show-confirm-button="false">
+ <HrmEmployeeSelectDialog
+ ref="employeeDialogRef"
+ @selected="handleEmployeesSelected"
+ />
+ <Grid table-title="鍙傝浜哄憳鍒楄〃">
+ <template #toolbar-tools>
+ <a-button type="primary" @click="openEmployeeSelect">
+ <i-ant-design-plus-outlined class="mr-1" />娣诲姞鍙傝浜哄憳
+ </a-button>
+ </template>
+ <template #attended="{ row }">
+ <Tag v-if="row.attended" color="success">鏄�</Tag>
+ <Tag v-else color="default">鍚�</Tag>
+ </template>
+ <template #isPass="{ row }">
+ <Tag v-if="row.isPass" color="success">鍚堟牸</Tag>
+ <Tag v-else-if="row.attended" color="error">涓嶅悎鏍�</Tag>
+ <Tag v-else color="default">-</Tag>
+ </template>
+ <template #actions="{ row }">
+ <a-button type="link" size="small" @click="openEditForm(row)">缂栬緫</a-button>
+ <a-popconfirm
+ :title="$t('ui.actionMessage.deleteConfirm', [row.employeeName ?? row.id])"
+ @confirm="handleDelete(row)"
+ >
+ <a-button type="link" danger size="small">鍒犻櫎</a-button>
+ </a-popconfirm>
+ </template>
+ </Grid>
+
+ <AntModal
+ v-model:open="editVisible"
+ title="缂栬緫鍙傝璁板綍"
+ width="480px"
+ :confirm-loading="editSaving"
+ @ok="handleEditSave"
+ >
+ <EditForm class="pt-4" />
+ </AntModal>
+ </Modal>
+</template>
\ No newline at end of file
--
Gitblit v1.9.3