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/workhour/index.vue | 142 +++++++++++++++++++++++++++++++++++++++++++++++
1 files changed, 142 insertions(+), 0 deletions(-)
diff --git a/src/views/hrm/workhour/index.vue b/src/views/hrm/workhour/index.vue
new file mode 100644
index 0000000..0b5c5b6
--- /dev/null
+++ b/src/views/hrm/workhour/index.vue
@@ -0,0 +1,142 @@
+<script lang="ts" setup>
+ import type { VxeTableGridOptions } from '#/adapter/vxe-table';
+ import type { HrmWorkHourStatisticsApi } from '#/api/hrm/work-hour-statistics';
+
+ import { onBeforeUnmount, onMounted, ref, useTemplateRef } from 'vue';
+
+ import { Page } from '@vben/common-ui';
+ import { useVbenVxeGrid } from '#/adapter/vxe-table';
+
+ import { Tabs } from 'ant-design-vue';
+
+ import {
+ getEmployeeWorkHourSummary,
+ getTeamWorkHourSummary,
+ } from '#/api/hrm/work-hour-statistics';
+
+ /** HRM 宸ユ椂缁熻锛堣�冨嫟鍙e緞 + 鎶ュ伐鍙e緞锛� */
+ defineOptions({ name: 'HrmWorkHourStatistics' });
+
+ const activeTab = ref<'employee' | 'team'>('employee');
+
+ const contentRef = useTemplateRef('contentRef');
+ let resizeObserver: ResizeObserver | undefined;
+
+ /** 璁$畻琛ㄦ牸楂樺害锛氬唴瀹瑰尯鍙敤楂樺害 - Tabs 瀵艰埅绛夊浐瀹氬紑閿�锛岃〃鏍兼拺婊¢〉闈� */
+ function calcTableHeight() {
+ const el = contentRef.value;
+ if (!el) return;
+ const height = Math.max(el.clientHeight - 115, 240);
+ employeeGridApi.setGridOptions({ height });
+ teamGridApi.setGridOptions({ height });
+ }
+
+ onMounted(() => {
+ calcTableHeight();
+ resizeObserver = new ResizeObserver(calcTableHeight);
+ if (contentRef.value) resizeObserver.observe(contentRef.value);
+ });
+
+ onBeforeUnmount(() => {
+ resizeObserver?.disconnect();
+ });
+
+ const [EmployeeGrid, employeeGridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: [
+ {
+ fieldName: 'dateRange',
+ label: '鏃ユ湡鑼冨洿',
+ component: 'RangePicker',
+ componentProps: {
+ class: '!w-full',
+ valueFormat: 'YYYY-MM-DD',
+ placeholder: ['寮�濮嬫棩鏈�', '缁撴潫鏃ユ湡'],
+ },
+ },
+ ],
+ },
+ gridOptions: {
+ columns: [
+ { field: 'userName', title: '鍛樺伐濮撳悕', minWidth: 140 },
+ { field: 'deptName', title: '閮ㄩ棬', minWidth: 140 },
+ { field: 'workDays', title: '鍑哄嫟澶╂暟', width: 110 },
+ { field: 'workHours', title: '姝e父宸ユ椂(浜烘椂)', width: 150 },
+ { field: 'overtimeHours', title: '鍔犵彮宸ユ椂(浜烘椂)', width: 150 },
+ ],
+ height: 400,
+ keepSource: true,
+ // 杩斿洖瑁告暟缁勶紝闇�鍏抽棴鍒嗛〉
+ pagerConfig: { enabled: false },
+ proxyConfig: {
+ ajax: {
+ query: async (_params, formValues) => {
+ const range = formValues?.dateRange ?? [];
+ return await getEmployeeWorkHourSummary({
+ startDate: range?.[0],
+ endDate: range?.[1],
+ });
+ },
+ },
+ },
+ rowConfig: { keyField: 'userId', isHover: true },
+ toolbarConfig: { refresh: true, search: true },
+ } as VxeTableGridOptions<HrmWorkHourStatisticsApi.EmployeeWorkHour>,
+ });
+
+ const [TeamGrid, teamGridApi] = useVbenVxeGrid({
+ formOptions: {
+ schema: [
+ {
+ fieldName: 'timeRange',
+ label: '鏃ユ湡鑼冨洿',
+ component: 'RangePicker',
+ componentProps: {
+ class: '!w-full',
+ valueFormat: 'YYYY-MM-DD HH:mm:ss',
+ placeholder: ['寮�濮嬫椂闂�', '缁撴潫鏃堕棿'],
+ },
+ },
+ ],
+ },
+ gridOptions: {
+ columns: [
+ { field: 'teamName', title: '鐝粍鍚嶇О', minWidth: 160 },
+ { field: 'taskCount', title: '浠诲姟鏁�', width: 100 },
+ { field: 'totalDuration', title: '鎬荤敓浜ф椂闀�(浜烘棩)', width: 160 },
+ { field: 'workHours', title: '鎬诲伐鏃�(浜烘椂)', width: 150 },
+ ],
+ height: 400,
+ keepSource: true,
+ pagerConfig: { enabled: false },
+ proxyConfig: {
+ ajax: {
+ query: async (_params, formValues) => {
+ const range = formValues?.timeRange ?? [];
+ return await getTeamWorkHourSummary({
+ startTime: range?.[0],
+ endTime: range?.[1],
+ });
+ },
+ },
+ },
+ rowConfig: { keyField: 'teamId', isHover: true },
+ toolbarConfig: { refresh: true, search: true },
+ } as VxeTableGridOptions<HrmWorkHourStatisticsApi.TeamWorkHour>,
+ });
+</script>
+
+<template>
+ <Page auto-content-height>
+ <div ref="contentRef" class="flex h-full w-full flex-col">
+ <Tabs v-model:active-key="activeTab" class="min-h-0 flex-1">
+ <Tabs.TabPane key="employee" tab="鍛樺伐宸ユ椂锛堣�冨嫟鍙e緞锛�">
+ <EmployeeGrid table-title="鍛樺伐宸ユ椂缁熻" />
+ </Tabs.TabPane>
+ <Tabs.TabPane key="team" tab="鐝粍宸ユ椂锛堟姤宸ュ彛寰勶級">
+ <TeamGrid table-title="鐝粍宸ユ椂缁熻" />
+ </Tabs.TabPane>
+ </Tabs>
+ </div>
+ </Page>
+</template>
--
Gitblit v1.9.3