From a4d0446d7c1c1e56641fd4e887ad4d0ecd0534ca Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期四, 05 三月 2026 17:43:55 +0800
Subject: [PATCH] 排班管理页面完成70%

---
 src/views/personnelManagement/attendanceCheckin/index.vue |  130 ++++++++++++++++++++++++++++++++++++++-----
 1 files changed, 115 insertions(+), 15 deletions(-)

diff --git a/src/views/personnelManagement/attendanceCheckin/index.vue b/src/views/personnelManagement/attendanceCheckin/index.vue
index 6fd1357..9a3acfa 100644
--- a/src/views/personnelManagement/attendanceCheckin/index.vue
+++ b/src/views/personnelManagement/attendanceCheckin/index.vue
@@ -1,11 +1,12 @@
 <template>
   <div class="app-container">
     <!-- 鍛樺伐鎵撳崱鍖� -->
-    <el-card shadow="never"
+    <!-- <el-card shadow="never"
              class="mb16">
       <div class="attendance-header">
         <div>
-          <div class="title">鎵撳崱绛惧埌</div>
+          <div class="title">鎵撳崱绛惧埌
+          </div>
           <div class="sub-title">鏀寔涓�閿墦鍗★紝鑷姩璁板綍涓婁笅鐝椂闂�</div>
         </div>
         <div class="attendance-actions">
@@ -57,8 +58,17 @@
           </el-tag>
         </el-descriptions-item>
       </el-descriptions>
-    </el-card>
+    </el-card> -->
     <div class="attendance-operation">
+      <el-button @click="handleBack"
+                 type="default"
+                 size="small"
+                 style="margin-right: 16px">
+        <el-icon>
+          <ArrowLeft />
+        </el-icon>
+        杩斿洖鎺掔彮绠$悊
+      </el-button>
       <!-- 鏌ヨ鏉′欢锛堢鐞嗗憳鑰冨嫟鏃ユ姤锛� -->
       <el-form :model="searchForm"
                :inline="true"
@@ -149,7 +159,8 @@
             <el-tag v-else
                     type="danger"
                     size="small">
-              {{ scope.row.status === 1 ? '杩熷埌' : scope.row.status === 2 ? '鏃╅��' : '杩熷埌銆佹棭閫�' }}
+              <!-- {{ scope.row.status === 1 ? '杩熷埌' : scope.row.status === 2 ? '鏃╅��' : '杩熷埌銆佹棭閫�' }} -->
+              {{ getStatusText(scope.row.status) }}
             </el-tag>
           </template>
         </el-table-column>
@@ -157,7 +168,7 @@
                          label="澶囨敞"
                          show-overflow-tooltip />
       </el-table>
-      <pagination :total="total"
+      <pagination :total="page.total"
                   layout="total, sizes, prev, pager, next, jumper"
                   :page="page.current"
                   :limit="page.size"
@@ -168,6 +179,7 @@
 
 <script setup>
   import { ref, reactive, computed, onMounted, onBeforeUnmount } from "vue";
+  import { useRouter } from "vue-router";
   import { ElMessage, ElMessageBox } from "element-plus";
   import {
     createPersonalAttendanceRecord,
@@ -176,9 +188,10 @@
   } from "@/api/personnelManagement/personalAttendanceRecords.js";
   import Pagination from "@/components/Pagination/index.vue";
   import { deptTreeSelect } from "@/api/system/user.js";
-  import { Refresh, Search } from "@element-plus/icons-vue";
+  import { Refresh, Search, ArrowLeft } from "@element-plus/icons-vue";
 
   const { proxy } = getCurrentInstance();
+  const router = useRouter();
   const tableLoading = ref(false);
   // 鍒嗛〉鍙傛暟
   const page = reactive({
@@ -300,7 +313,7 @@
     findPersonalAttendanceRecords({ ...page, ...searchForm })
       .then(res => {
         tableData.value = res.data.records;
-        page.value.total = res.data.total;
+        page.total = res.data.total;
       })
       .finally(() => {
         tableLoading.value = false;
@@ -309,9 +322,9 @@
 
   // 鏌ヨ浠婃棩鎵撳崱淇℃伅
   const fetchTodayData = () => {
-    findTodayPersonalAttendanceRecord({}).then(res => {
-      todayRecord.value = res.data;
-    });
+    // findTodayPersonalAttendanceRecord({}).then(res => {
+    //   todayRecord.value = res.data;
+    // });
   };
 
   const paginationChange = pagination => {
@@ -340,13 +353,93 @@
       });
   };
 
+  // 鑾峰彇褰撳墠浣嶇疆
+  const getCurrentLocation = () => {
+    return new Promise((resolve, reject) => {
+      if (!navigator.geolocation) {
+        reject(new Error("娴忚鍣ㄤ笉鏀寔鍦扮悊瀹氫綅"));
+        return;
+      }
+
+      // 妫�鏌ユ槸鍚︿娇鐢℉TTPS
+      const isSecureContext =
+        window.isSecureContext || window.location.protocol === "https:";
+      console.log(
+        "褰撳墠鍗忚:",
+        window.location.protocol,
+        "鏄惁瀹夊叏涓婁笅鏂�:",
+        isSecureContext
+      );
+
+      if (!isSecureContext) {
+        console.warn("褰撳墠涓嶆槸HTTPS鍗忚锛屽湴鐞嗕綅缃瓵PI鍙兘鍙楅檺");
+      }
+
+      navigator.geolocation.getCurrentPosition(
+        position => {
+          const { longitude, latitude } = position.coords;
+          console.log("鑾峰彇浣嶇疆鎴愬姛:", longitude, latitude);
+          resolve({ longitude, latitude });
+        },
+        error => {
+          console.log("鑾峰彇浣嶇疆澶辫触:", error);
+          let errorMessage = "鑾峰彇浣嶇疆澶辫触";
+
+          // 鏍规嵁閿欒绫诲瀷鎻愪緵鏇村叿浣撶殑鎻愮ず
+          switch (error.code) {
+            case error.PERMISSION_DENIED:
+              errorMessage =
+                "鐢ㄦ埛鎷掔粷浜嗕綅缃潈闄愯姹傦紝璇峰湪娴忚鍣ㄨ缃腑鍏佽浣嶇疆璁块棶";
+              break;
+            case error.POSITION_UNAVAILABLE:
+              errorMessage = "浣嶇疆淇℃伅涓嶅彲鐢紝璇锋鏌ヨ澶囧畾浣嶅姛鑳�";
+              break;
+            case error.TIMEOUT:
+              errorMessage = "鑾峰彇浣嶇疆瓒呮椂锛岃閲嶈瘯";
+              break;
+            case error.UNKNOWN_ERROR:
+              errorMessage = "鑾峰彇浣嶇疆鏃跺彂鐢熸湭鐭ラ敊璇�";
+              break;
+            default:
+              errorMessage = `鑾峰彇浣嶇疆澶辫触: ${error.message}`;
+          }
+
+          // 妫�鏌ユ槸鍚︽槸HTTPS闂
+          if (error.code === error.PERMISSION_DENIED && !isSecureContext) {
+            errorMessage += "锛堟敞鎰忥細鐢熶骇鐜闇�瑕佷娇鐢℉TTPS鍗忚鎵嶈兘鑾峰彇浣嶇疆锛�";
+          }
+
+          reject(new Error(errorMessage));
+        },
+        {
+          enableHighAccuracy: true,
+          timeout: 10000,
+          maximumAge: 0,
+        }
+      );
+    });
+  };
+
   // 鎵撳崱
   const handleCheckInOut = () => {
-    createPersonalAttendanceRecord({}).then(res => {
-      fetchData();
-      fetchTodayData();
-      ElMessage.success("鎵撳崱鎴愬姛锛�");
-    });
+    getCurrentLocation()
+      .then(location => {
+        console.log("浣嶇疆鎴愬姛");
+        createPersonalAttendanceRecord(location).then(res => {
+          fetchData();
+          fetchTodayData();
+          ElMessage.success("鎵撳崱鎴愬姛锛�");
+        });
+      })
+      .catch(error => {
+        // 鑾峰彇浣嶇疆澶辫触鏃讹紝浠嶅厑璁告墦鍗�
+        ElMessage.warning("鑾峰彇浣嶇疆澶辫触锛屽皢浣跨敤榛樿浣嶇疆鎵撳崱");
+        createPersonalAttendanceRecord({}).then(res => {
+          fetchData();
+          fetchTodayData();
+          ElMessage.success("鎵撳崱鎴愬姛锛�");
+        });
+      });
   };
 
   onMounted(() => {
@@ -363,6 +456,13 @@
     fetchDeptOptions();
   });
 
+  // 杩斿洖鎺掔彮绠$悊椤甸潰
+  const handleBack = () => {
+    router.push({
+      path: "/personnelManagement/classsSheduling/index",
+    });
+  };
+
   onBeforeUnmount(() => {
     if (timer) {
       clearInterval(timer);

--
Gitblit v1.9.3