2025-08-07 14:40:39 +08:00
|
|
|
|
<template>
|
|
|
|
|
|
<div class="app-container">
|
|
|
|
|
|
<el-table v-loading="loading" :data="attendanceSummaryDetailList">
|
2025-08-08 10:25:18 +08:00
|
|
|
|
<el-table-column label="用户" align="center" prop="userId" />
|
2025-08-07 14:40:39 +08:00
|
|
|
|
<el-table-column label="正常出勤小时数" align="center" prop="normalHours" />
|
|
|
|
|
|
<el-table-column label="加班小时数" align="center" prop="overtimeHours" />
|
|
|
|
|
|
<el-table-column label="出差小时数" align="center" prop="travelHours" />
|
|
|
|
|
|
</el-table>
|
|
|
|
|
|
</div>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<script setup name="AttendanceSummaryDetail">
|
2025-08-08 10:25:18 +08:00
|
|
|
|
import { ref, watch } from "vue";
|
2025-08-07 14:40:39 +08:00
|
|
|
|
import { listAttendanceSummaryDetail } from "@/api/oa/attendanceSummaryDetail";
|
|
|
|
|
|
|
|
|
|
|
|
const props = defineProps({
|
|
|
|
|
|
// 考勤汇总ID
|
|
|
|
|
|
summaryId: {
|
|
|
|
|
|
type: String,
|
|
|
|
|
|
required: true
|
|
|
|
|
|
}
|
2025-08-08 10:25:18 +08:00
|
|
|
|
});
|
2025-08-07 14:40:39 +08:00
|
|
|
|
|
2025-08-08 10:25:18 +08:00
|
|
|
|
const loading = ref(false);
|
|
|
|
|
|
const attendanceSummaryDetailList = ref([]); // 使用ref替代computed
|
|
|
|
|
|
|
|
|
|
|
|
// 监听summaryId变化
|
|
|
|
|
|
watch(() => props.summaryId, async (newVal) => {
|
|
|
|
|
|
if (newVal) {
|
|
|
|
|
|
try {
|
|
|
|
|
|
loading.value = true;
|
|
|
|
|
|
// 调用API获取数据
|
|
|
|
|
|
const response = await listAttendanceSummaryDetail({
|
|
|
|
|
|
summaryId: newVal,
|
|
|
|
|
|
pageSize: 9999
|
|
|
|
|
|
});
|
|
|
|
|
|
// 先将数字全部转为整数,再判断如果是0转为空字符串
|
|
|
|
|
|
|
|
|
|
|
|
response.rows.forEach(item => {
|
|
|
|
|
|
const normalHours = parseInt(item.normalHours);
|
|
|
|
|
|
const overtimeHours = parseInt(item.overtimeHours);
|
|
|
|
|
|
const travelHours = parseInt(item.travelHours);
|
|
|
|
|
|
item.normalHours = normalHours === 0 ? '' : normalHours;
|
|
|
|
|
|
item.overtimeHours = overtimeHours === 0 ? '' : overtimeHours;
|
|
|
|
|
|
item.travelHours = travelHours === 0 ? '' : travelHours;
|
|
|
|
|
|
});
|
|
|
|
|
|
attendanceSummaryDetailList.value = response.rows || [];
|
|
|
|
|
|
} catch (error) {
|
|
|
|
|
|
console.error("数据获取失败", error);
|
|
|
|
|
|
attendanceSummaryDetailList.value = [];
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
loading.value = false;
|
|
|
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
|
|
|
attendanceSummaryDetailList.value = [];
|
|
|
|
|
|
}
|
|
|
|
|
|
}, { immediate: true }); // 立即执行一次获取初始数据
|
2025-08-07 14:40:39 +08:00
|
|
|
|
</script>
|