更新密码找回uniapp

This commit is contained in:
hero920103 committed 2026-11-16 17:22:50 +08:00
1 parent 7f9a66da0f
commit 3fdda89833
1304 files changed
+3503 -26132

No files matched your search

+397 -14
View File
@@ -1,7 +1,6 @@
<template>
<view class="page">
<view class="body">
<!-- ==================== 今日打卡 ==================== -->
<view class="punch-card">
<view class="punch-head">
<view class="head-left">
@@ -25,7 +24,6 @@
</text>
</view>
<!-- 未匹配排班等提醒:只提示,不阻断打卡 -->
<view v-if="warning" class="warn-bar">
<FaIcon name="triangle-exclamation" color="#b45309" :size="14" />
<text class="warn-text">{{ warning }}</text>
@@ -49,6 +47,17 @@
</view>
</view>
<view v-if="record.id && (record.fix_status_text || canFix(record))" class="punch-fix">
<text
v-if="record.fix_status_text"
class="fix-chip"
:class="fixChipClass(record)"
@tap="openFixApproval(record)"
>{{ record.fix_status_text }} · 查看审批 ›</text>
<text v-else class="punch-fix-tip">打卡异常?可申请补卡</text>
<text v-if="canFix(record)" class="fix-link" @tap="openFixSheet(record)">补卡</text>
</view>
<view class="punch-actions">
<view class="punch-btn is-in" :class="{ 'is-disabled': !canClockIn, 'is-busy': punching }" @tap="punch('in')">
<text class="btn-title">{{ record.clock_in_hm ? '已签到' : '签到' }}</text>
@@ -61,7 +70,6 @@
</view>
</view>
<!-- ==================== 近 7 天 ==================== -->
<view v-if="recentDays.length" class="week-card">
<view class="block-head">
<text class="block-title">近 7 天</text>
@@ -82,7 +90,6 @@
</view>
</view>
<!-- ==================== 考勤卡(本月 / 本季 / 本年) ==================== -->
<view class="stat-card">
<view class="block-head">
<text class="block-title">考勤卡</text>
@@ -107,7 +114,6 @@
</view>
</view>
<!-- ==================== 考勤记录 ==================== -->
<view class="list-card">
<view class="block-head">
<text class="block-title">考勤记录</text>
@@ -139,6 +145,15 @@
<text class="rm-punch">签退 {{ item.clock_out_hm || '--:--' }}</text>
</view>
<text v-if="recordNote(item)" class="rm-note">{{ recordNote(item) }}</text>
<view v-if="item.fix_status_text || canFix(item)" class="rm-foot">
<text
v-if="item.fix_status_text"
class="fix-chip"
:class="fixChipClass(item)"
@tap="openFixApproval(item)"
>{{ item.fix_status_text }} · 查看审批 ›</text>
<text v-if="canFix(item)" class="fix-link" @tap="openFixSheet(item)">补卡</text>
</view>
</view>
<text class="record-status" :class="dayClass(item.day_status)">{{ item.day_status_text }}</text>
</view>
@@ -151,18 +166,70 @@
<view class="bottom-space" />
</view>
<view v-if="fixVisible" class="fix-mask" @tap="closeFixSheet">
<view class="fix-sheet" @tap.stop>
<view class="fix-head">
<text class="fix-cancel" @tap="closeFixSheet">取消</text>
<text class="fix-title">补卡申请</text>
<text class="fix-submit" :class="{ disabled: fixSubmitting }" @tap="submitFix">
{{ fixSubmitting ? '提交中…' : '提交' }}
</text>
</view>
<view class="fix-body">
<view class="fix-info">
<text class="fix-info-date">{{ fixForm.date }}</text>
<text class="fix-info-shift">{{ fixForm.shift }}</text>
</view>
<text class="fix-desc">迟到、早退、缺卡可申请补卡。提交后进入审批,通过后当天打卡恢复正常;审批单与审批意见仍可在审批中心查看。</text>
<text class="fix-label">补卡类型</text>
<view class="fix-types">
<view
v-for="opt in fixTypeOptions"
:key="opt.value"
class="fix-type"
:class="{ on: fixForm.fixType === opt.value }"
@tap="chooseFixType(opt)"
>
<text class="fix-type-text">{{ opt.label }}</text>
<text class="fix-type-sub">{{ opt.sub }}</text>
</view>
</view>
<template v-if="fixForm.needTime">
<text class="fix-label">实际打卡时间</text>
<picker mode="time" :value="fixForm.fixTime" @change="onFixTimeChange">
<view class="fix-input" :class="{ placeholder: !fixForm.fixTime }">
{{ fixForm.fixTime || '请选择时间' }}
</view>
</picker>
</template>
<text class="fix-label">补卡原因</text>
<textarea
v-model="fixForm.reason"
class="fix-textarea"
placeholder="请说明迟到 / 早退 / 缺卡原因"
:maxlength="200"
/>
</view>
</view>
</view>
</view>
</template>
<script setup>
import { computed, ref } from 'vue'
import { computed, reactive, ref } from 'vue'
import { onHide, onReachBottom, onShow, onUnload } from '@dcloudio/uni-app'
import { isLoggedIn } from '@/utils/auth.js'
import {
clockAttendance,
fetchAttendanceStats,
fetchAttendanceToday,
fetchMyAttendanceRecords
fetchMyAttendanceRecords,
submitAttendanceFix
} from '@/api/oaAttendance.js'
const WEEKDAY_LABELS = ['', '周一', '周二', '周三', '周四', '周五', '周六', '周日']
@@ -245,7 +312,6 @@ const statItems = computed(() => {
]
})
// 近 7 天:后端按「最近在前」返回,这里翻成从左到右的时间轴
const recentDays = computed(() => {
const list = Array.isArray(today.value.recent) ? today.value.recent : []
return list.slice().reverse()
@@ -316,6 +382,130 @@ function recordNote(item) {
return item.clock_out_note || item.clock_in_note || ''
}
const FIX_RUNNING = 1
const fixVisible = ref(false)
const fixSubmitting = ref(false)
const fixTypeOptions = ref([])
const fixForm = reactive({
recordId: 0,
date: '',
shift: '',
fixType: 1,
needTime: false,
fixTime: '',
reason: ''
})
function abnormalSides(item) {
const bad = (status) => [2, 3, 4].includes(Number(status))
const sides = []
if (!item.clock_in_hm || bad(item.clock_in_status)) {
sides.push({
value: 1,
label: '签到补卡',
sub: item.clock_in_hm ? `当前 ${item.clock_in_hm} ${item.clock_in_text || '异常'}` : '未签到(缺卡)',
needTime: !item.clock_in_hm
})
}
if (!item.clock_out_hm || bad(item.clock_out_status)) {
sides.push({
value: 2,
label: '签退补卡',
sub: item.clock_out_hm ? `当前 ${item.clock_out_hm} ${item.clock_out_text || '异常'}` : '未签退(缺卡)',
needTime: !item.clock_out_hm
})
}
return sides
}
function canFix(item) {
if (!item || !item.id) return false
return Number(item.day_status) !== 8 && abnormalSides(item).length > 0 && Number(item.fix_status) !== FIX_RUNNING
}
function fixChipClass(item) {
switch (Number(item.fix_status)) {
case 1:
return 'is-running'
case 2:
return 'is-done'
case 3:
return 'is-reject'
default:
return 'is-muted'
}
}
function openFixApproval(item) {
const id = Number(item.fix_instance_id || 0)
if (!id) {
uni.showToast({ title: '暂无审批单,请稍后重试', icon: 'none' })
return
}
uni.navigateTo({ url: `/pages/approval/detail?id=${id}` })
}
function openFixSheet(item) {
const sides = abnormalSides(item)
if (!sides.length) {
uni.showToast({ title: '当前记录无需补卡', icon: 'none' })
return
}
fixTypeOptions.value = sides
const first = sides[0]
fixForm.recordId = item.id
fixForm.date = item.attend_date
fixForm.shift = item.shift_name || '未匹配排班'
fixForm.fixType = first.value
fixForm.needTime = first.needTime
fixForm.fixTime = ''
fixForm.reason = ''
fixVisible.value = true
}
function closeFixSheet() {
if (!fixSubmitting.value) fixVisible.value = false
}
function chooseFixType(opt) {
fixForm.fixType = opt.value
fixForm.needTime = opt.needTime
if (!opt.needTime) fixForm.fixTime = ''
}
function onFixTimeChange(e) {
fixForm.fixTime = (e && e.detail && e.detail.value) || ''
}
async function submitFix() {
if (fixSubmitting.value) return
const reason = String(fixForm.reason || '').trim()
if (!reason) {
uni.showToast({ title: '请填写补卡原因', icon: 'none' })
return
}
if (fixForm.needTime && !fixForm.fixTime) {
uni.showToast({ title: '请选择实际打卡时间', icon: 'none' })
return
}
fixSubmitting.value = true
try {
const data = await submitAttendanceFix({
recordId: fixForm.recordId,
fixType: fixForm.fixType,
fixTime: fixForm.needTime ? fixForm.fixTime : '',
reason
})
fixVisible.value = false
uni.showToast({ title: (data && data.message) || '补卡申请已提交', icon: 'success' })
await Promise.all([loadToday(), loadRecords(true)])
} catch (error) {
uni.showToast({ title: (error && error.message) || '补卡申请提交失败', icon: 'none' })
} finally {
fixSubmitting.value = false
}
}
function confirmDialog(title, content) {
return new Promise((resolve) => {
uni.showModal({
@@ -343,13 +533,11 @@ async function loadToday() {
}
}
/** 月度卡标题(today 接口只返回区间数字,标题在前端拼) */
function monthLabel() {
const now = new Date()
return `${now.getFullYear()} 年 ${now.getMonth() + 1} 月`
}
/** 切换考勤卡维度:本月 / 本季 / 本年(后端返回统一口径的统计) */
async function loadStats(period) {
if (statsLoading.value || (statsPeriod.value === period && statsLabel.value)) {
return
@@ -407,7 +595,6 @@ async function punch(type) {
return
}
// 排班匹配不上:先提醒,确认后仍可打卡
if (warning.value) {
const ok = await confirmDialog('排班提醒', `${warning.value}\n\n是否继续${type === 'in' ? '签到' : '签退'}?`)
if (!ok) return
@@ -471,7 +658,6 @@ onReachBottom(() => {
padding: 28rpx $page-padding-x 0;
}
/* ==================== 今日打卡 ==================== */
.punch-card {
@include card;
padding: 28rpx 24rpx 24rpx;
@@ -688,7 +874,6 @@ onReachBottom(() => {
opacity: 0.9;
}
/* ==================== 近 7 天 ==================== */
.week-card,
.stat-card,
.list-card {
@@ -844,7 +1029,6 @@ onReachBottom(() => {
color: $color-text-muted;
}
/* ==================== 考勤记录 ==================== */
.state-box {
padding: 60rpx 0;
display: flex;
@@ -966,4 +1150,203 @@ onReachBottom(() => {
.bottom-space {
height: 40rpx;
}
.punch-fix {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
margin-top: 20rpx;
}
.punch-fix-tip {
flex: 1;
min-width: 0;
font-size: 22rpx;
color: $color-text-muted;
}
.rm-foot {
display: flex;
align-items: center;
flex-wrap: wrap;
gap: 12rpx;
margin-top: 8rpx;
}
.fix-chip {
font-size: 22rpx;
padding: 6rpx 14rpx;
border-radius: $radius-full;
background: #f1f5f9;
&.is-running { color: $color-primary; background: #e8f1ff; }
&.is-done { color: $color-success; background: #e7f8ee; }
&.is-reject { color: $color-danger; background: #fef2f2; }
&.is-muted { color: $color-text-muted; }
}
.fix-link {
font-size: 24rpx;
color: $color-primary;
padding: 6rpx 14rpx;
border: 1rpx solid $color-primary;
border-radius: $radius-full;
&:active { opacity: 0.6; }
}
.fix-mask {
position: fixed;
left: 0;
top: 0;
right: 0;
bottom: 0;
z-index: 1000;
display: flex;
align-items: flex-end;
background: rgba(15, 23, 42, 0.48);
@include mask-responsive;
}
.fix-sheet {
width: 100%;
box-sizing: border-box;
padding: 28rpx $page-padding-x 40rpx;
padding-bottom: calc(40rpx + env(safe-area-inset-bottom));
border-radius: 32rpx 32rpx 0 0;
background: #ffffff;
@include sheet-responsive;
}
.fix-head {
display: flex;
align-items: center;
justify-content: space-between;
margin-bottom: 24rpx;
}
.fix-cancel {
font-size: 26rpx;
color: $color-text-muted;
}
.fix-title {
font-size: 32rpx;
font-weight: 700;
color: $color-text;
}
.fix-submit {
font-size: 28rpx;
font-weight: 600;
color: $color-primary;
&.disabled { opacity: 0.55; }
}
.fix-body {
max-height: 65vh;
overflow-y: auto;
}
.fix-info {
display: flex;
align-items: center;
gap: 16rpx;
padding: 20rpx;
border-radius: $radius-md;
background: #f8fafc;
}
.fix-info-date {
font-size: 28rpx;
font-weight: 600;
color: $color-text;
}
.fix-info-shift {
font-size: 24rpx;
color: $color-text-secondary;
}
.fix-desc {
display: block;
margin: 20rpx 0 8rpx;
font-size: 22rpx;
line-height: 1.6;
color: $color-text-muted;
}
.fix-label {
display: block;
margin: 22rpx 0 12rpx;
font-size: 25rpx;
font-weight: 600;
color: #334155;
}
.fix-types {
display: flex;
gap: 16rpx;
}
.fix-type {
flex: 1;
min-width: 0;
padding: 18rpx 20rpx;
box-sizing: border-box;
border: 2rpx solid #e2e8f0;
border-radius: $radius-md;
background: #ffffff;
&.on {
border-color: $color-primary;
background: #f2f7ff;
}
}
.fix-type-text {
display: block;
font-size: 27rpx;
font-weight: 600;
color: $color-text;
}
.fix-type-sub {
display: block;
margin-top: 6rpx;
font-size: 21rpx;
color: $color-text-muted;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.fix-input {
height: 88rpx;
line-height: 88rpx;
padding: 0 22rpx;
box-sizing: border-box;
border: 1rpx solid #dce7f7;
border-radius: $radius-md;
background: #fbfdff;
font-size: 28rpx;
color: $color-text;
&.placeholder { color: #adb6c9; font-size: 26rpx; }
}
.fix-textarea {
width: 100%;
min-height: 160rpx;
box-sizing: border-box;
padding: 18rpx 22rpx;
border: 1rpx solid #dce7f7;
border-radius: $radius-md;
background: #fbfdff;
font-size: 27rpx;
line-height: 1.6;
color: $color-text;
}
</style>