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/index.vue | 263 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 263 insertions(+), 0 deletions(-)
diff --git a/src/views/hrm/training/index.vue b/src/views/hrm/training/index.vue
new file mode 100644
index 0000000..30d130a
--- /dev/null
+++ b/src/views/hrm/training/index.vue
@@ -0,0 +1,263 @@
+<script lang="ts" setup>
+import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+import type { HrmTrainingApi } from '#/api/hrm/training';
+
+import { ref } from 'vue';
+
+import { Page, useVbenModal } from '@vben/common-ui';
+import { isEmpty } from '@vben/utils';
+
+import { message, Modal, Tag } from 'ant-design-vue';
+
+import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
+import {
+ cancelTraining,
+ completeTraining,
+ deleteTraining,
+ getTrainingPage,
+ startTraining,
+} from '#/api/hrm/training';
+import { $t } from '#/locales';
+
+import { useGridColumns, useGridFormSchema } from './data';
+import Form from './modules/form.vue';
+import Participants from './modules/participants.vue';
+
+/** HRM 鍩硅绠$悊鍒楄〃 */
+defineOptions({ name: 'HrmTraining' });
+
+const [FormModal, formModalApi] = useVbenModal({
+ connectedComponent: Form,
+ destroyOnClose: true,
+});
+const [ParticipantsModal, participantsModalApi] = useVbenModal({
+ connectedComponent: Participants,
+ destroyOnClose: true,
+});
+
+function handleRefresh() {
+ gridApi.query();
+}
+
+function handleCreate() {
+ formModalApi.setData({ formType: 'create' }).open();
+}
+
+function handleEdit(row: HrmTrainingApi.Training) {
+ formModalApi.setData({ formType: 'edit', id: row.id }).open();
+}
+
+function handleDetail(row: HrmTrainingApi.Training) {
+ formModalApi.setData({ formType: 'detail', id: row.id }).open();
+}
+
+function handleParticipants(row: HrmTrainingApi.Training) {
+ participantsModalApi.setData({ trainingId: row.id }).open();
+}
+
+async function handleDelete(ids: number[]) {
+ const hideLoading = message.loading({
+ content: $t('ui.actionMessage.deleting'),
+ duration: 0,
+ });
+ try {
+ await deleteTraining(ids);
+ message.success($t('ui.actionMessage.deleteSuccess'));
+ handleRefresh();
+ } finally {
+ hideLoading();
+ }
+}
+
+/** 寮�濮嬪煿璁細鑽夌 鈫� 寰呭紑灞� */
+function handleStart(row: HrmTrainingApi.Training) {
+ Modal.confirm({
+ title: '寮�濮嬪煿璁�',
+ content: `鏄惁寮�濮嬪煿璁��${row.name}銆嶏紵`,
+ onOk: async () => {
+ await startTraining(row.id!);
+ message.success('寮�濮嬪煿璁垚鍔�');
+ handleRefresh();
+ },
+ });
+}
+
+/** 瀹屾垚鍩硅锛氳崏绋�/寰呭紑灞� 鈫� 宸插畬鎴� */
+function handleComplete(row: HrmTrainingApi.Training) {
+ Modal.confirm({
+ title: '瀹屾垚鍩硅',
+ content: `鏄惁瀹屾垚鍩硅銆�${row.name}銆嶏紵`,
+ onOk: async () => {
+ await completeTraining(row.id!);
+ message.success('瀹屾垚鍩硅鎴愬姛');
+ handleRefresh();
+ },
+ });
+}
+
+/** 鍙栨秷鍩硅锛氳崏绋�/寰呭紑灞� 鈫� 宸插彇娑� */
+function handleCancel(row: HrmTrainingApi.Training) {
+ Modal.confirm({
+ title: '鍙栨秷鍩硅',
+ content: `鏄惁鍙栨秷鍩硅銆�${row.name}銆嶏紵`,
+ onOk: async () => {
+ await cancelTraining(row.id!);
+ message.success('鍙栨秷鍩硅鎴愬姛');
+ handleRefresh();
+ },
+ });
+}
+
+const checkedIds = ref<number[]>([]);
+function handleRowCheckboxChange({
+ records,
+}: {
+ records: HrmTrainingApi.Training[];
+}) {
+ checkedIds.value = records.map((item) => item.id!);
+}
+
+const [Grid, gridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: useGridFormSchema(),
+ },
+ gridOptions: {
+ columns: useGridColumns(),
+ height: 'auto',
+ keepSource: true,
+ proxyConfig: {
+ ajax: {
+ query: async ({ page }, formValues) => {
+ return await getTrainingPage({
+ pageNo: page.currentPage,
+ pageSize: page.pageSize,
+ ...formValues,
+ });
+ },
+ },
+ },
+ rowConfig: {
+ keyField: 'id',
+ isHover: true,
+ },
+ toolbarConfig: {
+ refresh: true,
+ search: true,
+ },
+ } as VxeTableGridOptions<HrmTrainingApi.Training>,
+ gridEvents: {
+ checkboxAll: handleRowCheckboxChange,
+ checkboxChange: handleRowCheckboxChange,
+ },
+});
+</script>
+
+<template>
+ <Page auto-content-height>
+ <FormModal @success="handleRefresh" />
+ <ParticipantsModal @success="handleRefresh" />
+ <Grid table-title="鍩硅绠$悊鍒楄〃">
+ <template #toolbar-tools>
+ <TableAction
+ :actions="[
+ {
+ label: $t('ui.actionTitle.create', ['鍩硅']),
+ type: 'primary',
+ icon: ACTION_ICON.ADD,
+ auth: ['hrm:training:create'],
+ onClick: handleCreate,
+ },
+ {
+ label: '鎵归噺鍒犻櫎',
+ type: 'primary',
+ danger: true,
+ disabled: isEmpty(checkedIds),
+ icon: ACTION_ICON.DELETE,
+ auth: ['hrm:training:delete'],
+ popConfirm: {
+ title: '鏄惁鍒犻櫎鎵�閫変腑鏁版嵁锛�',
+ confirm: handleDelete.bind(null, checkedIds),
+ },
+ },
+ ]"
+ />
+ </template>
+ <template #status="{ row }">
+ <Tag v-if="row.status === 0" color="default">鑽夌</Tag>
+ <Tag v-else-if="row.status === 10" color="processing">寰呭紑灞�</Tag>
+ <Tag v-else-if="row.status === 20" color="success">宸插畬鎴�</Tag>
+ <Tag v-else-if="row.status === 30" color="error">宸插彇娑�</Tag>
+ <Tag v-else color="default">-</Tag>
+ </template>
+ <template #actions="{ row }">
+ <TableAction
+ :actions="[
+ {
+ label: $t('common.detail'),
+ type: 'link',
+ icon: ACTION_ICON.VIEW,
+ auth: ['hrm:training:query'],
+ onClick: handleDetail.bind(null, row),
+ },
+ {
+ label: '缂栬緫',
+ type: 'link',
+ icon: ACTION_ICON.EDIT,
+ auth: ['hrm:training:update'],
+ ifShow: () => row.status === 0,
+ onClick: handleEdit.bind(null, row),
+ },
+ {
+ label: '鍙傝浜哄憳',
+ type: 'link',
+ icon: 'lucide:users',
+ auth: ['hrm:training:update'],
+ ifShow: () => row.status === 0 || row.status === 10 || row.status === 20,
+ onClick: handleParticipants.bind(null, row),
+ },
+ {
+ label: '寮�濮�',
+ type: 'link',
+ icon: 'lucide:play',
+ auth: ['hrm:training:update'],
+ ifShow: () => row.status === 0,
+ onClick: handleStart.bind(null, row),
+ },
+ {
+ label: '瀹屾垚',
+ type: 'link',
+ icon: 'lucide:check',
+ auth: ['hrm:training:update'],
+ ifShow: () => row.status === 0 || row.status === 10,
+ onClick: handleComplete.bind(null, row),
+ },
+ {
+ label: '鍙栨秷',
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.CLOSE,
+ auth: ['hrm:training:update'],
+ ifShow: () => row.status === 0 || row.status === 10,
+ popConfirm: {
+ title: '鏄惁鍙栨秷鍩硅锛�',
+ confirm: handleCancel.bind(null, row),
+ },
+ },
+ {
+ label: $t('common.delete'),
+ type: 'link',
+ danger: true,
+ icon: ACTION_ICON.DELETE,
+ auth: ['hrm:training:delete'],
+ ifShow: () => row.status === 0,
+ popConfirm: {
+ title: $t('ui.actionMessage.deleteConfirm', [row.name]),
+ confirm: handleDelete.bind(null, [row.id!]),
+ },
+ },
+ ]"
+ />
+ </template>
+ </Grid>
+ </Page>
+</template>
\ No newline at end of file
--
Gitblit v1.9.3