From a385917c1f82edbdf1063ac1505bc9b57c6c1108 Mon Sep 17 00:00:00 2001
From: liu <2021943741@qq.com>
Date: 星期五, 30 十月 2026 21:46:11 +0800
Subject: [PATCH] feat(hrm,bi): 移植长辉电力的考勤请假展示与 BI 大屏

---
 src/api/hrm/attendance/record/index.ts                  |  144 +++++++++++-
 src/views/bi/dashboard/index.vue                        |   56 ++++
 src/views/hrm/attendance/record/data.ts                 |   57 +++++
 src/views/hrm/resignation/data.ts                       |    2 
 src/views/hrm/salary/calculation/data.ts                |    2 
 src/views/hrm/attendance/record/modules/clock-panel.vue |  234 +++++++++++++++++---
 src/views/hrm/attendance/record/index.vue               |   13 +
 src/views/hrm/employee/components/select-dropdown.vue   |  102 +++++++++
 8 files changed, 552 insertions(+), 58 deletions(-)

diff --git a/src/api/hrm/attendance/record/index.ts b/src/api/hrm/attendance/record/index.ts
index 8962dc1..4ba6d04 100644
--- a/src/api/hrm/attendance/record/index.ts
+++ b/src/api/hrm/attendance/record/index.ts
@@ -10,6 +10,7 @@
     userName?: string;
     deptId?: number;
     deptName?: string;
+    phone?: string;
     date?: string;
     clockInTime?: string;
     clockOutTime?: string;
@@ -20,10 +21,87 @@
     workHours?: number;
     overtimeHours?: number;
     location?: string;
+    /** 涓婄彮鎵撳崱缁忓害锛圵GS84锛� */
+    clockInLongitude?: number;
+    /** 涓婄彮鎵撳崱绾害锛圵GS84锛� */
+    clockInLatitude?: number;
+    /** 涓婄彮瀹氫綅绮惧害锛岀背 */
+    clockInAccuracy?: number;
+    /** 涓婄彮璺濇墦鍗″湴鐐硅窛绂伙紝绫� */
+    clockInDistance?: number;
+    /** 涓婄彮鎵撳崱鍦扮偣鍦板潃蹇収 */
+    clockInAddress?: string;
+    /** 涓嬬彮鎵撳崱缁忓害锛圵GS84锛� */
+    clockOutLongitude?: number;
+    /** 涓嬬彮鎵撳崱绾害锛圵GS84锛� */
+    clockOutLatitude?: number;
+    /** 涓嬬彮瀹氫綅绮惧害锛岀背 */
+    clockOutAccuracy?: number;
+    /** 涓嬬彮璺濇墦鍗″湴鐐硅窛绂伙紝绫� */
+    clockOutDistance?: number;
+    /** 涓嬬彮鎵撳崱鍦扮偣鍦板潃蹇収 */
+    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;
+    };
   }
 
   /** 鑰冨嫟缁熻 */
@@ -41,11 +119,40 @@
   }
 }
 
+/** 瀹氫綅鎵撳崱鍧愭爣锛屽悗绔粎鎺ュ彈 WGS84 */
+export interface AttendanceClockLocation {
+  longitude: number;
+  latitude: number;
+  accuracy: number;
+  coordinateSystem: 'WGS84';
+}
+
+/** 瀹氫綅鎵撳崱缁撴灉锛涙湭鍚敤瀹氫綅鑼冨洿鏍¢獙鏃讹紝璺濈涓庡崐寰勪负绌� */
+export interface AttendanceClockResponse {
+  record?: HrmAttendanceRecordApi.AttendanceRecord;
+  locationName?: string;
+  distanceMeters?: number;
+  radiusMeters?: number;
+  withinRange?: boolean;
+}
+
 /** 鏌ヨ鑰冨嫟璁板綍鍒嗛〉鍒楄〃 */
 export function getAttendanceRecordPage(params: PageParam) {
   return requestClient.get<PageResult<HrmAttendanceRecordApi.AttendanceRecord>>(
     '/hrm/attendance/record/page',
     { params },
+  );
+}
+
+/**
+ * 鏌ヨ褰撳墠鐧诲綍浜虹殑鑰冨嫟鐘舵��
+ *
+ * @param date 鑰冨嫟鏃ユ湡锛屾牸寮� yyyy-MM-dd锛屼笉浼犲彇鏈嶅姟鍣ㄥ綋澶�
+ */
+export function getAttendanceMyStatus(date?: string) {
+  return requestClient.get<HrmAttendanceRecordApi.AttendanceMyStatus>(
+    '/hrm/attendance/record/my-status',
+    date ? { params: { date } } : undefined,
   );
 }
 
@@ -79,25 +186,32 @@
   return requestClient.download('/hrm/attendance/record/export-excel', { params });
 }
 
-export interface AttendanceClockLocation {
-  longitude: number;
-  latitude: number;
-  accuracy: number;
-  coordinateSystem: 'WGS84';
-}
-
-/** 涓婄彮鎵撳崱 */
-export function clockIn(data: AttendanceClockLocation) {
-  return requestClient.post<HrmAttendanceRecordApi.AttendanceRecord>(
+/**
+ * 涓婄彮鎵撳崱
+ *
+ * 鍚屾椂鎻愪氦瀹氫綅锛圝SON body锛変笌鏃х増鍦扮偣鏂囨湰锛坬uery 鍙傛暟锛夛細
+ * - 鏂板悗绔寜瀹氫綅鏍¢獙鎵撳崱鑼冨洿锛屾湭鍚敤瀹氫綅鏃跺拷鐣ュ畾浣嶏紱
+ * - 鏃у悗绔彧璇诲彇 location 鍙傛暟锛屼繚璇佸崌绾у墠鍚庨兘鑳芥甯告墦鍗°��
+ */
+export function clockIn(
+  data?: AttendanceClockLocation | null,
+  location?: string,
+) {
+  return requestClient.post<AttendanceClockResponse>(
     '/hrm/attendance/record/clock-in',
-    data,
+    data ?? null,
+    location ? { params: { location } } : undefined,
   );
 }
 
-/** 涓嬬彮鎵撳崱 */
-export function clockOut(data: AttendanceClockLocation) {
-  return requestClient.post<HrmAttendanceRecordApi.AttendanceRecord>(
+/** 涓嬬彮鎵撳崱锛屽弬鏁拌鏄庡悓 clockIn */
+export function clockOut(
+  data?: AttendanceClockLocation | null,
+  location?: string,
+) {
+  return requestClient.post<AttendanceClockResponse>(
     '/hrm/attendance/record/clock-out',
-    data,
+    data ?? null,
+    location ? { params: { location } } : undefined,
   );
 }
diff --git a/src/views/bi/dashboard/index.vue b/src/views/bi/dashboard/index.vue
index 0685f54..1a5c3e9 100644
--- a/src/views/bi/dashboard/index.vue
+++ b/src/views/bi/dashboard/index.vue
@@ -80,6 +80,31 @@
 const dashboardRef = ref<HTMLElement>();
 let resizeObserver: ResizeObserver | null = null;
 
+/**
+ * 绮剧‘璁$畻鍥捐〃鍖哄彲鐢ㄩ珮搴︼紝鍐欏叆 CSS 鍙橀噺 --fill-h
+ *
+ * 浠呴潬 flex + 1fr 鍦ㄩ儴鍒嗗満鏅笉鐢熸晥锛岃繖閲岀洿鎺ラ噺娴嬪ご閮ㄣ�並PI 琛屻��
+ * 琛ㄦ牸鍗$墖鍗犵敤楂樺害锛屾妸鍓╀綑楂樺害绠楀嚭鏉ョ粰鍥捐〃鍖恒��
+ */
+function layoutFill() {
+  const el = dashboardRef.value;
+  if (!el) return;
+  if (!isFullscreen.value) {
+    el.style.removeProperty('--fill-h');
+    return;
+  }
+  const header = el.querySelector('.dash-header') as HTMLElement | null;
+  const kpi = el.querySelector('.kpi-row') as HTMLElement | null;
+  const tables = el.querySelectorAll<HTMLElement>('.table-card');
+  const cs = getComputedStyle(el);
+  let used = (parseFloat(cs.paddingTop) || 0) + (parseFloat(cs.paddingBottom) || 0);
+  if (header) used += header.offsetHeight + 24;
+  if (kpi) used += kpi.offsetHeight + 16;
+  tables.forEach((t) => { used += t.offsetHeight + 16; });
+  const avail = Math.max(240, window.innerHeight - used);
+  el.style.setProperty('--fill-h', `${avail}px`);
+}
+
 function resizeAllCharts() {
   setTimeout(() => window.dispatchEvent(new Event('resize')), 100);
 }
@@ -100,11 +125,11 @@
     await document.exitFullscreen();
     isFullscreen.value = false;
   }
-  setTimeout(resizeAllCharts, 400);
+  setTimeout(() => { layoutFill(); resizeAllCharts(); }, 400);
 }
 function onFullscreenChange() {
   isFullscreen.value = !!document.fullscreenElement;
-  setTimeout(resizeAllCharts, 300);
+  setTimeout(() => { layoutFill(); resizeAllCharts(); }, 300);
 }
 
 // ======== KPI 鏁板瓧鍔ㄧ敾 ========
@@ -667,7 +692,32 @@
 
 /* ======== 鍏ㄥ睆 ======== */
 .is-fullscreen {
-  max-height: none; min-height: 100vh; padding: 24px 28px; border-radius: 0; overflow-y: auto;
+  height: 100vh;
+  min-height: 100vh;
+  max-height: 100vh;
+  padding: 24px 28px;
+  border-radius: 0;
+  overflow-y: auto;
+}
+
+/* 澶撮儴涓� KPI 琛屼繚鎸佽嚜鐒堕珮搴� */
+.is-fullscreen > .dash-header,
+.is-fullscreen > .kpi-row {
+  flex: 0 0 auto;
+}
+
+/* 鍥捐〃鍖哄悆鎺夊墿浣欓珮搴︼紝琛岄珮鍧囧垎锛岄伩鍏嶅簳閮ㄥぇ鐗囩暀鐧� */
+.is-fullscreen > .chart-row {
+  flex: 0 0 auto;
+  /* 楂樺害鐢� layoutFill() 閲忔祴鍚庡啓鍏ワ紝淇濊瘉姝eソ濉弧瑙嗗彛 */
+  height: var(--fill-h, auto);
+  grid-auto-rows: minmax(200px, 1fr);
+  align-content: stretch;
+}
+
+/* 琛ㄦ牸鍗$墖涓嶆姠楂樺害锛屽唴瀹硅秴鍑烘椂瀹瑰櫒婊氬姩 */
+.is-fullscreen > .table-card {
+  flex: 0 1 auto;
 }
 .is-fullscreen::before,
 .is-fullscreen::after {
diff --git a/src/views/hrm/attendance/record/data.ts b/src/views/hrm/attendance/record/data.ts
index 933798f..ce59bac 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: '璇烽�夋嫨鏄惁璇峰亣',
+      },
+    },
   ];
 }
 
@@ -96,6 +143,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 80c504d..d456f1f 100644
--- a/src/views/hrm/attendance/record/modules/clock-panel.vue
+++ b/src/views/hrm/attendance/record/modules/clock-panel.vue
@@ -1,79 +1,235 @@
 <script lang="ts" setup>
-import { ref } from 'vue';
+import type { AttendanceClockLocation, AttendanceClockResponse, HrmAttendanceRecordApi } from '#/api/hrm/attendance/record';
+
+import { computed, ref } from 'vue';
 
 import { useVbenModal } from '#/packages/effects/common-ui/src';
 
 import { message } from 'ant-design-vue';
 
-import type { AttendanceClockLocation } from '#/api/hrm/attendance/record';
-import { clockIn, clockOut } from '#/api/hrm/attendance/record';
+import { clockIn, clockOut, getAttendanceMyStatus } from '#/api/hrm/attendance/record';
 
 const emit = defineEmits(['success']);
 
-const loading = ref(false);
+const DEFAULT_LOCATION = '鍏徃鍓嶅彴';
 
-function getCurrentLocation(): Promise<AttendanceClockLocation> {
-  if (!navigator.geolocation) {
-    return Promise.reject(new Error('褰撳墠娴忚鍣ㄤ笉鏀寔瀹氫綅锛岃浣跨敤鏀寔 GPS 鐨勬祻瑙堝櫒'));
+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 new Promise((resolve, reject) => {
+  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 浜ょ粰鍚庣鏍¢獙銆�
+ * 瀹氫綅涓嶅彲鐢紙涓嶆敮鎸併�佹嫆缁濇巿鏉冦�侀潪 HTTPS锛夋椂杩斿洖 null锛�
+ * 鐢卞悗绔寜鑰冨嫟瑙勫垯鍐冲畾鏄惁鍏佽鏃犲畾浣嶆墦鍗°��
+ */
+function getCurrentLocation(): Promise<AttendanceClockLocation | null> {
+  if (!navigator.geolocation) {
+    return Promise.resolve(null);
+  }
+  return new Promise((resolve) => {
     navigator.geolocation.getCurrentPosition(
-      (position) => resolve({
-        longitude: position.coords.longitude,
-        latitude: position.coords.latitude,
-        accuracy: position.coords.accuracy,
-        coordinateSystem: 'WGS84',
-      }),
-      () => reject(new Error('瀹氫綅澶辫触锛岃寮�鍚畾浣嶆潈闄愬悗閲嶈瘯锛堥潪 localhost 闇�浣跨敤 HTTPS锛�')),
+      (position) =>
+        resolve({
+          longitude: Number(position.coords.longitude.toFixed(7)),
+          latitude: Number(position.coords.latitude.toFixed(7)),
+          accuracy: Number(position.coords.accuracy.toFixed(2)),
+          coordinateSystem: 'WGS84',
+        }),
+      () => resolve(null),
       { enableHighAccuracy: true, maximumAge: 0, timeout: 15_000 },
     );
   });
 }
 
-/** 涓婄彮鎵撳崱 */
-async function handleClockIn() {
+/** 鏈惎鐢ㄥ畾浣嶈寖鍥存牎楠屾椂鍚庣涓嶈繑鍥炶窛绂伙紝鐩存帴鎻愮ず鎴愬姛 */
+function buildSuccessMessage(
+  action: string,
+  result?: AttendanceClockResponse,
+) {
+  if (result?.distanceMeters === null || result?.distanceMeters === undefined) {
+    return `${action}鎴愬姛`;
+  }
+  const place = result.locationName ? `璺�${result.locationName}` : '璺濇墦鍗″湴鐐�';
+  return `${action}鎴愬姛锛�${place} ${Number(result.distanceMeters).toFixed(1)} 绫砢;
+}
+
+async function submitClock(action: 'in' | 'out') {
+  if (loading.value) {
+    return;
+  }
   loading.value = true;
   try {
-    await clockIn(await getCurrentLocation());
-    message.success('涓婄彮鎵撳崱鎴愬姛');
+    locating.value = true;
+    const position = await getCurrentLocation();
+    locating.value = false;
+    if (!position) {
+      message.warning(
+        '鏈幏鍙栧埌瀹氫綅锛屽皢鎸夋墦鍗″湴鐐规枃鏈彁浜わ紱鑻ヨ�冨嫟瑙勫垯瑕佹眰瀹氫綅锛岃寮�鍚畾浣嶆潈闄愬悗閲嶈瘯锛堥潪 HTTPS 鐜娴忚鍣ㄤ細绂佺敤瀹氫綅锛�',
+      );
+    }
+    const locationText = location.value.trim() || undefined;
+    const result =
+      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 (e: any) {
-    message.error(e.message || '鎵撳崱澶辫触');
+  } catch (error: any) {
+    // 鎺ュ彛閿欒宸茬敱璇锋眰鎷︽埅鍣ㄧ粺涓�鎻愮ず锛岃繖閲屽彧鍏滃簳鏈湴寮傚父锛岄伩鍏嶉噸澶嶅脊鍑�
+    const handledByInterceptor = Boolean(
+      error?.response || error?.data || error?.isAxiosError || error?.code,
+    );
+    if (!handledByInterceptor) {
+      message.error(error?.message || '鎵撳崱澶辫触');
+    }
   } finally {
+    locating.value = false;
     loading.value = false;
   }
+}
+
+/** 涓婄彮鎵撳崱 */
+function handleClockIn() {
+  return submitClock('in');
 }
 
 /** 涓嬬彮鎵撳崱 */
-async function handleClockOut() {
-  loading.value = true;
-  try {
-    await clockOut(await getCurrentLocation());
-    message.success('涓嬬彮鎵撳崱鎴愬姛');
-    emit('success');
-  } catch (e: any) {
-    message.error(e.message || '鎵撳崱澶辫触');
-  } finally {
-    loading.value = false;
-  }
+function handleClockOut() {
+  return submitClock('out');
 }
 
-const [Modal, modalApi] = useVbenModal({
-  onOpenChange() {},
+const [Modal] = useVbenModal({
+  onOpenChange(isOpen: boolean) {
+    if (isOpen) {
+      // 姣忔鎵撳紑閮芥媺涓�娆′粖鏃ョ姸鎬侊紝閬垮厤灞曠ず杩囨湡鐨勮鍋囦俊鎭�
+      myStatus.value = undefined;
+      lastClockRecord.value = undefined;
+      void loadMyStatus();
+    } else {
+      location.value = DEFAULT_LOCATION;
+    }
+  },
 });
 </script>
 
 <template>
-  <Modal title="鎵撳崱" class="w-[400px]">
+  <Modal title="鎵撳崱" class="w-[420px]">
     <div class="p-4">
-      <div class="mb-4 text-sm text-gray-500">
-        鐐瑰嚮鎵撳崱鍚庡皢鑾峰彇褰撳墠 GPS 浣嶇疆锛屽苟鎸夎�冨嫟瑙勫垯涓殑缁忕含搴﹀拰鎵撳崱鍗婂緞鏍¢獙銆�
+      <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
+          v-model:value="location"
+          placeholder="璇疯緭鍏ユ墦鍗″湴鐐�"
+          style="width: 220px"
+        />
+      </div>
+      <div class="mb-4 text-xs text-gray-500">
+        鐐瑰嚮鎵撳崱鍚庝細鑷姩鑾峰彇褰撳墠 GPS 浣嶇疆锛屽苟鎸夎�冨嫟瑙勫垯涓殑鍦扮偣涓庡厑璁稿崐寰勬牎楠岋紱娴忚鍣ㄥ畾浣嶄笉鍙敤鏃讹紝灏嗘寜涓婃柟鍦扮偣鏂囨湰鎻愪氦銆�
       </div>
       <div class="flex gap-4">
         <a-button
           type="primary"
           size="large"
           :loading="loading"
+          :disabled="loading"
           @click="handleClockIn"
         >
           涓婄彮鎵撳崱
@@ -81,11 +237,15 @@
         <a-button
           size="large"
           :loading="loading"
+          :disabled="loading"
           @click="handleClockOut"
         >
           涓嬬彮鎵撳崱
         </a-button>
       </div>
+      <div v-if="locating" class="mt-2 text-xs text-gray-400">
+        姝e湪鑾峰彇瀹氫綅鈥�
+      </div>
     </div>
   </Modal>
 </template>
diff --git a/src/views/hrm/employee/components/select-dropdown.vue b/src/views/hrm/employee/components/select-dropdown.vue
new file mode 100644
index 0000000..663245b
--- /dev/null
+++ b/src/views/hrm/employee/components/select-dropdown.vue
@@ -0,0 +1,102 @@
+<script lang="ts" setup>
+import type { HrmEmployeeApi } from '#/api/hrm/employee';
+
+import { computed, onMounted, ref, watch } from 'vue';
+
+import { Select } from 'ant-design-vue';
+
+import { getEmployeeSimpleList } from '#/api/hrm/employee';
+
+defineOptions({ name: 'EmployeeSelect', inheritAttrs: false });
+
+const props = withDefaults(
+  defineProps<{
+    allowClear?: boolean;
+    disabled?: boolean;
+    /** 閮ㄩ棬 ID锛屼紶鍏ュ垯鍙樉绀鸿閮ㄩ棬鐨勫憳宸� */
+    deptId?: number;
+    /** 鍗犱綅鏂囨 */
+    placeholder?: string;
+    modelValue?: number;
+  }>(),
+  {
+    allowClear: true,
+    disabled: false,
+    deptId: undefined,
+    placeholder: '杈撳叆濮撳悕鎴栧伐鍙锋悳绱�',
+    modelValue: undefined,
+  },
+);
+
+const emit = defineEmits<{
+  change: [item: HrmEmployeeApi.EmployeeSimple | undefined];
+  'update:modelValue': [value: number | undefined];
+}>();
+
+const loading = ref(false);
+const allOptions = ref<HrmEmployeeApi.EmployeeSimple[]>([]);
+
+/** 涓嬫媺閫夐」锛氬鍚嶏紙閮ㄩ棬锛� */
+const options = computed(() =>
+  allOptions.value
+    .filter((e) => !props.deptId || (e as any).deptId === props.deptId)
+    .map((e) => ({
+      label: e.deptName ? `${e.name}锛�${e.deptName}锛塦 : e.name,
+      value: e.id,
+      raw: e,
+    })),
+);
+
+onMounted(async () => {
+  loading.value = true;
+  try {
+    allOptions.value = (await getEmployeeSimpleList()) || [];
+  } finally {
+    loading.value = false;
+  }
+});
+
+/** 妯$硦鍖归厤锛氬鍚� / 宸ュ彿 / 閮ㄩ棬 */
+function filterOption(input: string, option: any) {
+  const kw = String(input ?? '').toLowerCase().trim();
+  if (!kw) {
+    return true;
+  }
+  const raw = option?.raw || {};
+  const hay = [raw.name, raw.employeeNo, raw.deptName, option?.label]
+    .filter(Boolean)
+    .join(' ')
+    .toLowerCase();
+  return hay.includes(kw);
+}
+
+function handleChange(val: any) {
+  const id = typeof val === 'number' ? val : undefined;
+  emit('update:modelValue', id);
+  emit('change', allOptions.value.find((e) => e.id === id));
+}
+
+watch(
+  () => props.modelValue,
+  () => {
+    // 浠呯敤浜庤Е鍙戣鍥炬洿鏂�
+  },
+);
+</script>
+
+<template>
+  <Select
+    v-bind="$attrs"
+    :allow-clear="allowClear"
+    :disabled="disabled"
+    :filter-option="filterOption"
+    :loading="loading"
+    :options="options"
+    :placeholder="placeholder"
+    :value="modelValue"
+    class="w-full"
+    option-filter-prop="label"
+    show-search
+    @change="handleChange"
+  />
+</template>
diff --git a/src/views/hrm/resignation/data.ts b/src/views/hrm/resignation/data.ts
index 3131c33..ba9d10e 100644
--- a/src/views/hrm/resignation/data.ts
+++ b/src/views/hrm/resignation/data.ts
@@ -48,6 +48,8 @@
       label: '浜ゆ帴浜�',
       component: 'ApiSelect',
       componentProps: {
+        showSearch: true,
+        optionFilterProp: 'label',
         api: getEmployeeSimpleList,
         labelField: 'name',
         valueField: 'id',
diff --git a/src/views/hrm/salary/calculation/data.ts b/src/views/hrm/salary/calculation/data.ts
index 17860e1..c0207a4 100644
--- a/src/views/hrm/salary/calculation/data.ts
+++ b/src/views/hrm/salary/calculation/data.ts
@@ -30,6 +30,8 @@
       label: '鍛樺伐',
       component: 'ApiSelect',
       componentProps: {
+        showSearch: true,
+        optionFilterProp: 'label',
         api: getEmployeeSimpleList,
         labelField: 'name',
         valueField: 'id',

--
Gitblit v1.9.3