From 460b5e97e60a5c917a98ef831f4f4805ed8b0216 Mon Sep 17 00:00:00 2001
From: zhangwencui <1064582902@qq.com>
Date: 星期六, 07 十一月 2026 19:23:28 +0800
Subject: [PATCH] 考勤异常申请功能
---
src/pages/hrm/attendance-exception/index.vue | 45 ++++++++++++++++++++++++---------------------
1 files changed, 24 insertions(+), 21 deletions(-)
diff --git a/src/pages/hrm/attendance-exception/index.vue b/src/pages/hrm/attendance-exception/index.vue
index f1cfe13..cfe11fb 100644
--- a/src/pages/hrm/attendance-exception/index.vue
+++ b/src/pages/hrm/attendance-exception/index.vue
@@ -1,39 +1,42 @@
<script setup lang="ts">
-import { computed, ref } from "vue";
+import { ref } from "vue";
import { onPullDownRefresh, onReachBottom, onShow } from "@dcloudio/uni-app";
-import { getAttendanceExceptionPage, submitAttendanceException, getAttendanceExceptionProcesses, type AttendanceException, type ApproveProcess } from "../../../api/hrm";
+import { getAttendanceExceptionPage, getAttendanceMyStatus, submitAttendanceException, type AttendanceException } from "../../../api/hrm";
import { useAuth } from "../../../stores/auth";
-import PickerSheet from "../../mes/process-design/components/PickerSheet.vue";
import { confirm, toast } from "../shared";
const { hasPermission, state } = useAuth();
-const rows = ref<AttendanceException[]>([]), processes = ref<ApproveProcess[]>([]), processVisible = ref(false), active = ref<AttendanceException>(), loading = ref(false), pageNo = ref(1), total = ref(0);
+const rows = ref<AttendanceException[]>([]), loading = ref(false), pageNo = ref(1), myEmployeeId = ref<number>(), hasMore = ref(true);
const pageSize = 15;
-const canQuery = computed(() => hasPermission("hrm:attendance-exception:query"));
-const hasMore = computed(() => rows.value.length < total.value);
+const typeText = (type?: number) => ({ 1: "婕忔墦鍗�", 2: "杩熷埌", 3: "鏃╅��", 4: "鍏朵粬" } as Record<number, string>)[Number(type)] || "--";
async function load(reset = true) {
- if (!state.accessToken || !canQuery.value || loading.value) return;
- if (reset) { pageNo.value = 1; total.value = 0; }
+ if (!state.accessToken || loading.value) return;
+ if (reset) { pageNo.value = 1; rows.value = []; hasMore.value = true; }
loading.value = true;
try {
- const data = await getAttendanceExceptionPage(state.accessToken, { pageNo: pageNo.value, pageSize });
- rows.value = reset ? (data.list || []) : [...rows.value, ...(data.list || [])];
- total.value = Number(data.total || 0);
- if (rows.value.length < total.value) pageNo.value += 1;
- if (reset) processes.value = await getAttendanceExceptionProcesses(state.accessToken);
+ if (!myEmployeeId.value) {
+ const status = await getAttendanceMyStatus(state.accessToken);
+ myEmployeeId.value = status.employeeId;
+ }
+ if (!myEmployeeId.value) throw new Error("褰撳墠璐﹀彿鏈叧鑱斿憳宸ユ。妗�");
+ const data = await getAttendanceExceptionPage(state.accessToken, { pageNo: pageNo.value, pageSize, userId: myEmployeeId.value });
+ // 鍗充娇鍚庣鏌ヨ绛栫暐璋冩暣锛孉pp 涔熷彧淇濈暀褰撳墠鍛樺伐鏈汉鐨勭敵璇枫��
+ const pageRows = data.list || [];
+ const ownRows = pageRows.filter(row => Number(row.userId) === Number(myEmployeeId.value));
+ rows.value = reset ? ownRows : [...rows.value, ...ownRows];
+ hasMore.value = pageRows.length === pageSize && pageNo.value * pageSize < Number(data.total || 0);
+ if (hasMore.value) pageNo.value += 1;
} catch (error) { toast(error instanceof Error ? error.message : "鍔犺浇澶辫触"); }
finally { loading.value = false; uni.stopPullDownRefresh(); }
}
-function submit(row: AttendanceException) {
- active.value = row;
- if (processes.value.length === 1) doSubmit(processes.value[0].key);
- else processVisible.value = true;
+function go(id?: number) {
+ uni.navigateTo({ url: `/pages/hrm/attendance-exception/form${id ? `?id=${id}&detail=1` : ""}` });
}
-async function doSubmit(key: string | number) {
- if (!state.accessToken || !active.value?.id || !await confirm("纭鎻愪氦鑰冨嫟寮傚父瀹℃壒锛�")) return;
- try { await submitAttendanceException(state.accessToken, active.value.id, String(key)); toast("鎻愪氦鎴愬姛"); processVisible.value = false; await load(true); }
+async function submit(row: AttendanceException) {
+ if (!state.accessToken || !row.id || Number(row.userId) !== Number(myEmployeeId.value) || !await confirm("纭鎻愪氦鑰冨嫟寮傚父瀹℃壒锛�")) return;
+ try { await submitAttendanceException(state.accessToken, row.id); toast("鎻愪氦鎴愬姛"); await load(true); }
catch (error) { toast(error instanceof Error ? error.message : "鎻愪氦澶辫触"); }
}
onShow(() => load(true));
onPullDownRefresh(() => load(true));
onReachBottom(() => { if (hasMore.value) load(false); });
-</script><template><view class="page"><template v-if="canQuery"><view v-for="row in rows" :key="row.id" class="card" @click="uni.navigateTo({url:`/pages/hrm/attendance-exception/form?id=${row.id}&detail=1`})"><view class="head"><view class="head-main"><text class="name">{{row.userName||'--'}}</text><text class="sub">{{row.deptName||'--'}} 路 {{row.date||'--'}}</text></view><text :class="['tag',row.status===20?'tag-green':row.status===10?'tag-blue':'tag-gray']">{{row.status===0?'鑽夌':row.status===10?'瀹℃壒涓�':row.status===20?'宸查�氳繃':'宸茬粨鏉�'}}</text></view><view class="grid"><text>寮傚父绫诲瀷锛歿{row.exceptionTypeName||row.exceptionType||'--'}}</text><text>鍘熷洜锛歿{row.reason||'--'}}</text><text>澶囨敞锛歿{row.remark||'--'}}</text></view><view class="actions" @click.stop><button @click="uni.navigateTo({url:`/pages/hrm/attendance-exception/form?id=${row.id}&detail=1`})">鏌ョ湅</button><button v-if="row.status===0&&hasPermission('hrm:attendance-exception:submit')" @click="submit(row)">鎻愪氦</button></view></view><view v-if="!rows.length" class="state">{{loading?'鍔犺浇涓�...':'鏆傛棤鑰冨嫟寮傚父鐢宠'}}</view><view v-else class="state more">{{loading ? "鍔犺浇涓�..." : hasMore ? "涓婃媺鍔犺浇鏇村" : "娌℃湁鏇村浜�"}}</view><button v-if="hasPermission('hrm:attendance-exception:create')" class="fab" @click="uni.navigateTo({url:'/pages/hrm/attendance-exception/form'})"><view/></button></template><view v-else class="state">鏆傛棤鑰冨嫟寮傚父鏌ョ湅鏉冮檺</view><PickerSheet v-model:show="processVisible" title="閫夋嫨瀹℃壒娴佺▼" :items="processes.map(x=>({key:x.key,label:x.name}))" :selected-keys="[]" @confirm="k=>doSubmit(k[0])"/></view></template><style scoped lang="scss">@import "../list.scss";</style>
+</script><template><view class="page"><view v-for="row in rows" :key="row.id" class="card" @click="go(row.id)"><view class="head"><view class="head-main"><text class="name">{{row.userName||'--'}}</text><text class="sub">{{row.deptName||'--'}} 路 {{row.date||'--'}}</text></view><text :class="['tag',row.status===20?'tag-green':row.status===10?'tag-blue':'tag-gray']">{{row.status===0?'鑽夌':row.status===10?'瀹℃壒涓�':row.status===20?'宸查�氳繃':row.status===30?'鏈�氳繃':'宸插彇娑�'}}</text></view><view class="grid"><text>寮傚父绫诲瀷锛歿{row.exceptionTypeName||typeText(row.exceptionType)}}</text><text>寮傚父鍘熷洜锛歿{row.reason||'--'}}</text><text>澶囨敞锛歿{row.remark||'--'}}</text></view><view class="actions" @click.stop><button @click="go(row.id)">鏌ョ湅</button><button v-if="(row.status===0||row.status===30)&&hasPermission('hrm:attendance-exception:submit')" @click="submit(row)">鎻愪氦</button></view></view><view v-if="!rows.length" class="state">{{loading?'鍔犺浇涓�...':'鏆傛棤鏈汉鎻愪氦鐨勮�冨嫟寮傚父鐢宠'}}</view><view v-else class="state more">{{loading ? "鍔犺浇涓�..." : hasMore ? "涓婃媺鍔犺浇鏇村" : "娌℃湁鏇村浜�"}}</view><button v-if="hasPermission('hrm:attendance-exception:create')" class="fab" @click="go()"><view/></button></view></template><style scoped lang="scss">@import "../list.scss";</style>
--
Gitblit v1.9.3