From a024b819ddb6999874faa77aacbb26a50b5f8999 Mon Sep 17 00:00:00 2001
From: xiaoyi <908147524@qq.com>
Date: 星期五, 30 十月 2026 16:19:45 +0800
Subject: [PATCH] feat(hrm): 考勤页面展示请假状态,打卡面板提示已请假

---
 src/api/hrm/attendance/record/index.ts                   |   69 +++++++++++++
 src/api/mes/md/item/batchConfig/index.ts                 |    4 
 src/views/hrm/attendance/record/data.ts                  |   57 +++++++++++
 src/views/mes/md/item/modules/item-batch-config-form.vue |    6 
 src/views/hrm/attendance/record/modules/clock-panel.vue  |  109 +++++++++++++++++++++
 src/views/hrm/attendance/record/index.vue                |   13 ++
 6 files changed, 246 insertions(+), 12 deletions(-)

diff --git a/src/api/hrm/attendance/record/index.ts b/src/api/hrm/attendance/record/index.ts
index 4ca4bb5..4ba6d04 100644
--- a/src/api/hrm/attendance/record/index.ts
+++ b/src/api/hrm/attendance/record/index.ts
@@ -43,8 +43,65 @@
     clockOutAddress?: string;
     dataSource?: number;
     dataSourceName?: string;
+    /** 褰撳ぉ鏄惁璇峰亣锛堝瓨鍦ㄥ鎵归�氳繃涓斾笌宸ヤ綔鏃舵閲嶅彔鐨勮鍋囧崟锛� */
+    leaveFlag?: boolean;
+    /** 褰撳ぉ璇峰亣宸ユ椂锛堝皬鏃讹級锛屾湭璇峰亣涓� 0 */
+    leaveHours?: number;
+    /** 褰撳ぉ璇峰亣绫诲瀷锛岄�楀彿鍒嗛殧鐨� HrmLeaveTypeEnum.type锛屽 "1,2" */
+    leaveTypes?: string;
     remark?: string;
     createTime?: string;
+  }
+
+  /** 鎴戠殑鑰冨嫟鐘舵�侊紙/hrm/attendance/record/my-status锛� */
+  export interface AttendanceMyStatus {
+    /** 鍛樺伐濮撳悕 */
+    employeeName?: string;
+    userName?: string;
+    deptName?: string;
+    /** 鑰冨嫟鏃ユ湡 */
+    date?: string;
+    /** 鏈嶅姟鍣ㄦ椂闂� */
+    serverTime?: string;
+    /** 鏄惁宸ヤ綔鏃� */
+    workDay?: boolean;
+    /** 浼戞伅鏃ュ師鍥狅紝濡傦細鍥藉簡鑺傘�佸懆鍏� */
+    restDayReason?: string;
+    /** 鎵撳崱鍦扮偣鍚嶇О */
+    locationName?: string;
+    locationAddress?: string;
+    /** 鏄惁鍚敤瀹氫綅鑼冨洿鏍¢獙 */
+    locationRequired?: boolean;
+    /** 鍏佽鎵撳崱鍗婂緞锛屽崟浣嶇背 */
+    radiusMeters?: number;
+    /** 褰撴棩鑰冨嫟璁板綍锛屾湭鎵撳崱鏃朵负 null */
+    record?: AttendanceRecord;
+    /** 浠婃棩璁板綍ID */
+    recordId?: number;
+    clockInTime?: string;
+    clockOutTime?: string;
+    clockInType?: number;
+    clockOutType?: number;
+    clockInDone?: boolean;
+    clockOutDone?: boolean;
+    workHours?: number;
+    overtimeHours?: number;
+    location?: string;
+    /** 褰撳ぉ鏄惁璇峰亣 */
+    onLeave?: boolean;
+    /** 褰撳ぉ璇峰亣宸ユ椂锛堝皬鏃讹級锛屾湭璇峰亣涓� 0 */
+    leaveHours?: number;
+    /** 褰撳ぉ璇峰亣绫诲瀷鍚嶇О锛屽娈电敤椤垮彿鍒嗛殧锛屽 "浜嬪亣銆佺梾鍋�" */
+    leaveTypeNames?: string;
+    /** 褰撳墠鍙墦鍗$姸鎬� */
+    clockable?: {
+      clockIn?: boolean;
+      clockOut?: boolean;
+      /** 涓嬩竴姝ュ姩浣滐細in-涓婄彮鎵撳崱锛宱ut-涓嬬彮鎵撳崱锛宯one-鏃犻渶鎵撳崱 */
+      nextAction?: 'in' | 'none' | 'out' | string;
+      /** 鎻愮ず鏂囨 */
+      message?: string;
+    };
   }
 
   /** 鑰冨嫟缁熻 */
@@ -87,6 +144,18 @@
   );
 }
 
+/**
+ * 鏌ヨ褰撳墠鐧诲綍浜虹殑鑰冨嫟鐘舵��
+ *
+ * @param date 鑰冨嫟鏃ユ湡锛屾牸寮� yyyy-MM-dd锛屼笉浼犲彇鏈嶅姟鍣ㄥ綋澶�
+ */
+export function getAttendanceMyStatus(date?: string) {
+  return requestClient.get<HrmAttendanceRecordApi.AttendanceMyStatus>(
+    '/hrm/attendance/record/my-status',
+    date ? { params: { date } } : undefined,
+  );
+}
+
 /** 鏌ヨ鑰冨嫟缁熻锛堟寜鏈堬級 */
 export function getAttendanceStatistics(params: {
   userId?: number;
diff --git a/src/api/mes/md/item/batchConfig/index.ts b/src/api/mes/md/item/batchConfig/index.ts
index ac97d8d..e602b5a 100644
--- a/src/api/mes/md/item/batchConfig/index.ts
+++ b/src/api/mes/md/item/batchConfig/index.ts
@@ -1,4 +1,4 @@
-锘縤mport { requestClient } from '#/api/request';
+import { requestClient } from '#/api/request';
 
 export namespace MesMdItemBatchConfigApi {
   /** MES 鐗╂枡鎵规灞炴�ч厤缃� */
@@ -12,7 +12,7 @@
     clientFlag?: boolean; // 鎵规灞炴��-瀹㈡埛
     salesOrderCodeFlag?: boolean; // 鎵规灞炴��-閿�鍞鍗曠紪鍙�
     purchaseOrderCodeFlag?: boolean; // 鎵规灞炴��-閲囪喘璁㈠崟缂栧彿
-    workorderFlag?: boolean; // 鎵规灞炴��-鐢熶骇璁㈠崟
+    workOrderFlag?: boolean; // 鎵规灞炴��-鐢熶骇宸ュ崟
     taskFlag?: boolean; // 鎵规灞炴��-鐢熶骇浠诲姟
     workstationFlag?: boolean; // 鎵规灞炴��-宸ヤ綔绔�
     toolFlag?: boolean; // 鎵规灞炴��-宸ュ叿
diff --git a/src/views/hrm/attendance/record/data.ts b/src/views/hrm/attendance/record/data.ts
index 98581f2..5ba317f 100644
--- a/src/views/hrm/attendance/record/data.ts
+++ b/src/views/hrm/attendance/record/data.ts
@@ -3,10 +3,44 @@
 import type { HrmAttendanceRecordApi } from '#/api/hrm/attendance/record';
 
 import { DICT_TYPE } from '#/packages/constants/src';
-import { getDictOptions } from '#/packages/effects/hooks/src';
+import { getDictLabel, getDictOptions } from '#/packages/effects/hooks/src';
 
 import { getDeptList } from '#/api/system/dept';
 import { handleTree } from '#/packages/utils/src';
+
+/** 璇峰亣绫诲瀷鐨勫厹搴曞悕绉帮紝涓庡悗绔� HrmLeaveTypeEnum 淇濇寔涓�鑷� */
+const LEAVE_TYPE_FALLBACK_LABELS: Record<number, string> = {
+  1: '浜嬪亣',
+  2: '鐥呭亣',
+  3: '骞村亣',
+  4: '濠氬亣',
+  5: '浜у亣',
+  6: '涓у亣',
+};
+
+/**
+ * 璇峰亣绫诲瀷鐨勫瓧鍏告爣绛�
+ *
+ * 瀛楀吀 hrm_leave_type 鏈悓姝ユ椂杩斿洖绌轰覆锛岀敱璋冪敤鏂瑰喅瀹氬厹搴曪紝
+ * 閬垮厤杩欑被鐜鎶婅鍋囩被鍨嬫樉绀烘垚 "-" 鑰岃浜鸿浠ヤ负娌℃湁璇峰亣銆�
+ */
+export function getLeaveTypeLabel(type: number | string) {
+  const label = getDictLabel(DICT_TYPE.HRM_LEAVE_TYPE, String(type));
+  return label || LEAVE_TYPE_FALLBACK_LABELS[Number(type)] || '';
+}
+
+/** 鎶� leaveTypes锛堝 "1,2"锛夌炕璇戞垚璇峰亣绫诲瀷鍚嶇О锛屽娈电敤椤垮彿鍒嗛殧 */
+export function formatLeaveTypeNames(leaveTypes?: string) {
+  if (!leaveTypes) {
+    return '';
+  }
+  return leaveTypes
+    .split(',')
+    .map((type) => type.trim())
+    .filter(Boolean)
+    .map((type) => getLeaveTypeLabel(type) || type)
+    .join('銆�');
+}
 
 /** 鍒楄〃鐨勬悳绱㈣〃鍗� */
 export function useGridFormSchema(): VbenFormSchema[] {
@@ -67,6 +101,19 @@
         placeholder: '璇烽�夋嫨涓嬬彮鎵撳崱绫诲瀷',
       },
     },
+    {
+      fieldName: 'leaveFlag',
+      label: '鏄惁璇峰亣',
+      component: 'Select',
+      componentProps: {
+        allowClear: true,
+        options: [
+          { label: '宸茶鍋�', value: true },
+          { label: '鏈鍋�', value: false },
+        ],
+        placeholder: '璇烽�夋嫨鏄惁璇峰亣',
+      },
+    },
   ];
 }
 
@@ -97,6 +144,14 @@
         props: { type: DICT_TYPE.HRM_CLOCK_TYPE },
       },
     },
+    {
+      field: 'leaveFlag',
+      title: '璇峰亣',
+      width: 160,
+      slots: {
+        default: 'leave',
+      },
+    },
     { field: 'workHours', title: '宸ヤ綔鏃堕暱(h)', width: 100 },
     { field: 'overtimeHours', title: '鍔犵彮鏃堕暱(h)', width: 100 },
     { field: 'location', title: '鎵撳崱鍦扮偣', minWidth: 150 },
diff --git a/src/views/hrm/attendance/record/index.vue b/src/views/hrm/attendance/record/index.vue
index 6aabd6c..7f19806 100644
--- a/src/views/hrm/attendance/record/index.vue
+++ b/src/views/hrm/attendance/record/index.vue
@@ -5,13 +5,13 @@
 import { Page, useVbenModal } from '#/packages/effects/common-ui/src';
 import { downloadFileFromBlobPart } from '#/packages/utils/src';
 
-import { Button, message } from 'ant-design-vue';
+import { message, Tag } from 'ant-design-vue';
 
 import { ACTION_ICON, TableAction, useVbenVxeGrid } from '#/adapter/vxe-table';
 import { exportAttendanceRecord, getAttendanceRecordPage } from '#/api/hrm/attendance/record';
 import { $t } from '#/locales';
 
-import { useGridColumns, useGridFormSchema } from './data';
+import { formatLeaveTypeNames, useGridColumns, useGridFormSchema } from './data';
 import ClockPanel from './modules/clock-panel.vue';
 import ImportForm from './modules/import-form.vue';
 
@@ -108,6 +108,15 @@
           ]"
         />
       </template>
+      <template #leave="{ row }">
+        <Tag v-if="row.leaveFlag" color="blue">
+          {{ formatLeaveTypeNames(row.leaveTypes) || '璇峰亣' }}
+          <span v-if="Number(row.leaveHours) > 0">
+            {{ Number(row.leaveHours).toFixed(2) }}h
+          </span>
+        </Tag>
+        <span v-else>-</span>
+      </template>
     </Grid>
   </Page>
 </template>
\ No newline at end of file
diff --git a/src/views/hrm/attendance/record/modules/clock-panel.vue b/src/views/hrm/attendance/record/modules/clock-panel.vue
index 2190714..d456f1f 100644
--- a/src/views/hrm/attendance/record/modules/clock-panel.vue
+++ b/src/views/hrm/attendance/record/modules/clock-panel.vue
@@ -1,13 +1,13 @@
 <script lang="ts" setup>
-import type { AttendanceClockLocation, AttendanceClockResponse } from '#/api/hrm/attendance/record';
+import type { AttendanceClockLocation, AttendanceClockResponse, HrmAttendanceRecordApi } from '#/api/hrm/attendance/record';
 
-import { ref } from 'vue';
+import { computed, ref } from 'vue';
 
 import { useVbenModal } from '#/packages/effects/common-ui/src';
 
 import { message } from 'ant-design-vue';
 
-import { clockIn, clockOut } from '#/api/hrm/attendance/record';
+import { clockIn, clockOut, getAttendanceMyStatus } from '#/api/hrm/attendance/record';
 
 const emit = defineEmits(['success']);
 
@@ -16,6 +16,77 @@
 const location = ref(DEFAULT_LOCATION);
 const loading = ref(false);
 const locating = ref(false);
+/** 浠婃棩鑰冨嫟鐘舵�侊紙鍚鍋囦俊鎭級锛屽姞杞藉け璐ユ椂涓� undefined */
+const myStatus = ref<HrmAttendanceRecordApi.AttendanceMyStatus>();
+const statusLoading = ref(false);
+/** 褰撳墠鎵撳崱杩斿洖鐨勫綋澶╄褰曪紝鐢ㄤ簬鎵撳崱鍚庡嵆鏃跺埛鏂拌鍋囦俊鎭� */
+const lastClockRecord = ref<HrmAttendanceRecordApi.AttendanceRecord>();
+
+/** 褰撳ぉ鏄惁璇峰亣锛氫紭鍏堢敤 my-status 鐨� onLeave锛屽叾娆$敤褰撳ぉ璁板綍涓婄殑 leaveFlag */
+const onLeave = computed(
+  () =>
+    myStatus.value?.onLeave === true ||
+    myStatus.value?.record?.leaveFlag === true ||
+    lastClockRecord.value?.leaveFlag === true,
+);
+
+/** 璇峰亣绫诲瀷鍚嶇О锛屽 "浜嬪亣銆佺梾鍋�" */
+const leaveTypeNames = computed(
+  () =>
+    myStatus.value?.leaveTypeNames ||
+    formatLeaveTypes(
+      myStatus.value?.record?.leaveTypes ||
+        lastClockRecord.value?.leaveTypes,
+    ),
+);
+
+/** 璇峰亣宸ユ椂锛堝皬鏃讹級 */
+const leaveHours = computed(
+  () =>
+    Number(
+      myStatus.value?.leaveHours ??
+        myStatus.value?.record?.leaveHours ??
+        lastClockRecord.value?.leaveHours ??
+        0,
+    ) || 0,
+);
+
+/** 璇峰亣绫诲瀷鍏滃簳鍚嶇О锛屼笌鍚庣 HrmLeaveTypeEnum 淇濇寔涓�鑷� */
+const LEAVE_TYPE_NAMES: Record<number, string> = {
+  1: '浜嬪亣',
+  2: '鐥呭亣',
+  3: '骞村亣',
+  4: '濠氬亣',
+  5: '浜у亣',
+  6: '涓у亣',
+};
+
+/** 鎶� "1,2" 缈昏瘧鎴� "浜嬪亣銆佺梾鍋�" */
+function formatLeaveTypes(leaveTypes?: string) {
+  if (!leaveTypes) {
+    return '';
+  }
+  return leaveTypes
+    .split(',')
+    .map((type) => type.trim())
+    .filter(Boolean)
+    .map((type) => LEAVE_TYPE_NAMES[Number(type)] ?? '')
+    .filter(Boolean)
+    .join('銆�');
+}
+
+/** 鍔犺浇褰撳墠鐧诲綍浜虹殑鑰冨嫟鐘舵�侊紱澶辫触鏃朵笉闃绘柇鎵撳崱 */
+async function loadMyStatus() {
+  statusLoading.value = true;
+  try {
+    myStatus.value = await getAttendanceMyStatus();
+  } catch {
+    // 鎺ュ彛閿欒宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�鎻愮ず锛岃繖閲岄潤榛橀檷绾э紝涓嶅奖鍝嶆墦鍗′富娴佺▼
+    myStatus.value = undefined;
+  } finally {
+    statusLoading.value = false;
+  }
+}
 
 /**
  * 鑾峰彇娴忚鍣ㄥ畾浣嶅苟缁熶竴涓� WGS84 浜ょ粰鍚庣鏍¢獙銆�
@@ -72,9 +143,12 @@
       action === 'in'
         ? await clockIn(position, locationText)
         : await clockOut(position, locationText);
+    lastClockRecord.value = result?.record;
     message.success(
       buildSuccessMessage(action === 'in' ? '涓婄彮鎵撳崱' : '涓嬬彮鎵撳崱', result),
     );
+    // 鎵撳崱鍚庡埛鏂颁粖鏃ョ姸鎬侊紙鍚鍋囦俊鎭級锛屼繚璇侀潰鏉夸笂鐨勬彁绀轰笌鍚庣涓�鑷�
+    await loadMyStatus();
     emit('success');
   } catch (error: any) {
     // 鎺ュ彛閿欒宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�鎻愮ず锛岃繖閲屽彧鍏滃簳鏈湴寮傚父锛岄伩鍏嶉噸澶嶅脊鍑�
@@ -102,7 +176,12 @@
 
 const [Modal] = useVbenModal({
   onOpenChange(isOpen: boolean) {
-    if (!isOpen) {
+    if (isOpen) {
+      // 姣忔鎵撳紑閮芥媺涓�娆′粖鏃ョ姸鎬侊紝閬垮厤灞曠ず杩囨湡鐨勮鍋囦俊鎭�
+      myStatus.value = undefined;
+      lastClockRecord.value = undefined;
+      void loadMyStatus();
+    } else {
       location.value = DEFAULT_LOCATION;
     }
   },
@@ -112,6 +191,28 @@
 <template>
   <Modal title="鎵撳崱" class="w-[420px]">
     <div class="p-4">
+      <a-alert
+        v-if="onLeave"
+        class="mb-4"
+        type="info"
+        show-icon
+        message="浠婃棩宸茶鍋囷紝濡傞渶涓婄彮鍙甯告墦鍗�"
+      >
+        <template #description>
+          <div class="text-xs">
+            <span v-if="leaveTypeNames">璇峰亣绫诲瀷锛歿{ leaveTypeNames }}</span>
+            <span v-if="leaveHours > 0" class="ml-2">
+              璇峰亣 {{ leaveHours.toFixed(2) }} 灏忔椂
+            </span>
+            <div class="mt-1 text-gray-500">
+              璇峰亣褰撳ぉ鎵撳崱涓嶈杩熷埌/鏃╅��锛屼篃涓嶈缂哄崱銆�
+            </div>
+          </div>
+        </template>
+      </a-alert>
+      <div v-else-if="statusLoading" class="mb-4 text-xs text-gray-400">
+        姝e湪鍔犺浇浠婃棩鑰冨嫟鐘舵�佲��
+      </div>
       <div class="mb-4">
         <label class="mr-2">鎵撳崱鍦扮偣锛�</label>
         <a-input
diff --git a/src/views/mes/md/item/modules/item-batch-config-form.vue b/src/views/mes/md/item/modules/item-batch-config-form.vue
index d12bbbd..47772e2 100644
--- a/src/views/mes/md/item/modules/item-batch-config-form.vue
+++ b/src/views/mes/md/item/modules/item-batch-config-form.vue
@@ -1,4 +1,4 @@
-锘�<script lang="ts" setup>
+<script lang="ts" setup>
 import type { FormType } from '../data';
 
 import type { MesMdItemBatchConfigApi } from '#/api/mes/md/item/batchConfig';
@@ -41,7 +41,7 @@
     clientFlag: false,
     salesOrderCodeFlag: false,
     purchaseOrderCodeFlag: false,
-    workorderFlag: false,
+    workOrderFlag: false,
     taskFlag: false,
     workstationFlag: false,
     toolFlag: false,
@@ -155,7 +155,7 @@
           閿�鍞鍗曠紪鍙�
         </Checkbox>
         <Checkbox
-          v-model:checked="formData.workorderFlag"
+          v-model:checked="formData.workOrderFlag"
           :disabled="isReadOnly"
         >
           鐢熶骇璁㈠崟

--
Gitblit v1.9.3