| | |
| | | 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"> |
| | |
| | | <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> |
| | |
| | | }); |
| | | }; |
| | | |
| | | // 获取当前位置 |
| | | const getCurrentLocation = () => { |
| | | return new Promise((resolve, reject) => { |
| | | if (navigator.geolocation) { |
| | | navigator.geolocation.getCurrentPosition( |
| | | position => { |
| | | const { longitude, latitude } = position.coords; |
| | | resolve({ longitude, latitude }); |
| | | }, |
| | | error => { |
| | | console.log("获取位置失败:", error); |
| | | reject(error); |
| | | } |
| | | ); |
| | | } else { |
| | | reject(new Error("浏览器不支持地理定位")); |
| | | } |
| | | }); |
| | | }; |
| | | |
| | | // 打卡 |
| | | const handleCheckInOut = () => { |
| | | createPersonalAttendanceRecord({}).then(res => { |
| | | fetchData(); |
| | | fetchTodayData(); |
| | | ElMessage.success("打卡成功!"); |
| | | }); |
| | | getCurrentLocation() |
| | | .then(location => { |
| | | createPersonalAttendanceRecord(location).then(res => { |
| | | fetchData(); |
| | | fetchTodayData(); |
| | | ElMessage.success("打卡成功!"); |
| | | }); |
| | | }) |
| | | .catch(error => { |
| | | // 获取位置失败时,仍允许打卡 |
| | | ElMessage.warning("获取位置失败,将使用默认位置打卡"); |
| | | createPersonalAttendanceRecord({}).then(res => { |
| | | fetchData(); |
| | | fetchTodayData(); |
| | | ElMessage.success("打卡成功!"); |
| | | }); |
| | | }); |
| | | }; |
| | | |
| | | onMounted(() => { |