考勤汇总快照
This commit is contained in:
@@ -31,7 +31,7 @@ export function updateAttendanceSummary(data) {
|
||||
return request({
|
||||
url: '/oa/attendanceSummary',
|
||||
method: 'put',
|
||||
data: data
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -42,3 +42,12 @@ export function delAttendanceSummary(summaryId) {
|
||||
method: 'delete'
|
||||
})
|
||||
}
|
||||
|
||||
// 新增汇总
|
||||
export function addWithDetails(data) {
|
||||
return request({
|
||||
url: '/oa/attendanceSummary/addWithDetails',
|
||||
method: 'post',
|
||||
data
|
||||
})
|
||||
}
|
||||
|
||||
@@ -149,12 +149,6 @@
|
||||
</el-date-picker> -->
|
||||
</el-form-item>
|
||||
<el-form-item label="结束时间" prop="endTime">
|
||||
<!-- <el-date-picker clearable
|
||||
v-model="form.endTime"
|
||||
type="datetime"
|
||||
value-format="YYYY-MM-DD HH:mm:ss"
|
||||
placeholder="请选择结束时间">
|
||||
</el-date-picker> -->
|
||||
<el-time-picker
|
||||
v-model="form.endTime"
|
||||
placeholder="请选择结束时间"
|
||||
@@ -213,10 +207,9 @@ const data = reactive({
|
||||
userId: undefined,
|
||||
recordDate: undefined,
|
||||
recordType: props.recordType, // 默认考勤
|
||||
// 当天九点
|
||||
startTime: undefined,
|
||||
endTime: undefined,
|
||||
durationHour: 8, // 默认8小时
|
||||
durationHour: undefined,
|
||||
},
|
||||
rules: {
|
||||
userId: [
|
||||
@@ -266,9 +259,9 @@ function reset() {
|
||||
// 填入格式化的日期 YYYY-MM-DD HH:mm:ss
|
||||
recordDate: proxy.parseTime(new Date(), '{y}-{m}-{d}'),
|
||||
recordType: props.recordType, // 默认考勤
|
||||
startTime: proxy.parseTime(new Date(), '{y}-{m}-{d} 09:00:00'),
|
||||
endTime: proxy.parseTime(new Date(), '{y}-{m}-{d} 18:00:00'),
|
||||
durationHour: 8,
|
||||
startTime: props.recordType === 'attendance' ? '09:00:00' : undefined,
|
||||
endTime: props.recordType === 'attendance' ? '18:00:00' : undefined,
|
||||
durationHour: props.recordType === 'attendance' ? 8 : undefined,
|
||||
status: null,
|
||||
createTime: null,
|
||||
createBy: null,
|
||||
@@ -332,9 +325,10 @@ function submitForm() {
|
||||
buttonLoading.value = true;
|
||||
const payload = {
|
||||
...form.value,
|
||||
startTime: form.value.recordDate.split(' ')[0] + ' ' + form.value.startTime,
|
||||
endTime: form.value.recordDate.split(' ')[0] + ' ' + form.value.endTime,
|
||||
recordDate: form.value.recordDate + ' 00:00:00',
|
||||
startTime: form.value.recordDate + ' ' + form.value.startTime,
|
||||
endTime: form.value.recordDate + ' ' + form.value.endTime
|
||||
|
||||
};
|
||||
if (form.value.recordId != null) {
|
||||
updateAttendanceRecord(payload).then(response => {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<template>
|
||||
<div class="app-container">
|
||||
<el-table v-loading="loading" :data="attendanceSummaryDetailList">
|
||||
<el-table-column label="用户" align="center" prop="nickName" />
|
||||
<el-table-column label="用户" align="center" prop="userId" />
|
||||
<el-table-column label="正常出勤小时数" align="center" prop="normalHours" />
|
||||
<el-table-column label="加班小时数" align="center" prop="overtimeHours" />
|
||||
<el-table-column label="出差小时数" align="center" prop="travelHours" />
|
||||
@@ -10,8 +10,8 @@
|
||||
</template>
|
||||
|
||||
<script setup name="AttendanceSummaryDetail">
|
||||
import { ref, watch } from "vue";
|
||||
import { listAttendanceSummaryDetail } from "@/api/oa/attendanceSummaryDetail";
|
||||
import { computed } from "vue";
|
||||
|
||||
const props = defineProps({
|
||||
// 考勤汇总ID
|
||||
@@ -19,10 +19,40 @@ const props = defineProps({
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
})
|
||||
});
|
||||
|
||||
const loading = ref(false)
|
||||
const attendanceSummaryDetailList = computed(() => {
|
||||
return props.summaryId ? listAttendanceSummaryDetail({summaryId: props.summaryId, pageSize: 9999}) : []
|
||||
})
|
||||
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 }); // 立即执行一次获取初始数据
|
||||
</script>
|
||||
|
||||
@@ -28,14 +28,14 @@
|
||||
<el-table-column type="selection" width="55" align="center" />
|
||||
<el-table-column label="汇总主表ID" align="center" prop="summaryId" v-if="false"/>
|
||||
<el-table-column label="汇总名称" align="center" prop="summaryName" />
|
||||
<el-table-column label="汇总开始日期" align="center" prop="startDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.startDate, '{y}-{m}-{d}') }}</span>
|
||||
<el-table-column label="汇总开始日期" align="center" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ formatDate(row.startDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="汇总结束日期" align="center" prop="endDate" width="180">
|
||||
<template #default="scope">
|
||||
<span>{{ parseTime(scope.row.endDate, '{y}-{m}-{d}') }}</span>
|
||||
<el-table-column label="汇总结束日期" align="center" width="180">
|
||||
<template #default="{ row }">
|
||||
{{ formatDate(row.endDate) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="备注" align="center" prop="remark" />
|
||||
@@ -92,24 +92,44 @@
|
||||
</template>
|
||||
</el-dialog>
|
||||
|
||||
<el-dialog :title="title" v-model="detailOpen" width="500px" append-to-body>
|
||||
<snapshot-detail :summary-id="form.summaryId" />
|
||||
<el-dialog
|
||||
:title="title"
|
||||
v-model="detailOpen"
|
||||
width="500px"
|
||||
append-to-body
|
||||
:close-on-click-modal="false"
|
||||
@closed="handleDetailDialogClosed"
|
||||
>
|
||||
<snapshot-detail v-if="detailOpen && currentSummaryId" :summary-id="currentSummaryId" />
|
||||
</el-dialog>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup name="AttendanceSummary">
|
||||
import { listAttendanceSummary, getAttendanceSummary, delAttendanceSummary, addAttendanceSummary, updateAttendanceSummary } from "@/api/oa/attendanceSummary";
|
||||
import { listAttendanceSummary, getAttendanceSummary, delAttendanceSummary, addWithDetails, updateAttendanceSummary } from "@/api/oa/attendanceSummary";
|
||||
|
||||
import UserSelect from '@/components/UserSelect/index.vue';
|
||||
import { listUser } from "@/api/system/user";
|
||||
import snapshotDetail from "./components/snapshotDetail.vue";
|
||||
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
// 日期格式化方法
|
||||
const formatDate = (date) => {
|
||||
if (!date) return '';
|
||||
return proxy.parseTime(date, '{y}-{m}-{d}');
|
||||
};
|
||||
|
||||
const attendanceSummaryList = ref([]);
|
||||
const userOptions = ref([]); // 用户选项列表
|
||||
const open = ref(false);
|
||||
const detailOpen = ref(false);
|
||||
const currentSummaryId = ref(null);
|
||||
const buttonLoading = ref(false);
|
||||
|
||||
// 处理详情对话框关闭
|
||||
const handleDetailDialogClosed = () => {
|
||||
currentSummaryId.value = null;
|
||||
};
|
||||
const loading = ref(true);
|
||||
const showSearch = ref(true);
|
||||
const ids = ref([]);
|
||||
@@ -173,12 +193,6 @@ function handleQuery() {
|
||||
getList();
|
||||
}
|
||||
|
||||
/** 重置按钮操作 */
|
||||
function resetQuery() {
|
||||
proxy.resetForm("queryRef");
|
||||
handleQuery();
|
||||
}
|
||||
|
||||
// 多选框选中数据
|
||||
function handleSelectionChange(selection) {
|
||||
ids.value = selection.map(item => item.summaryId);
|
||||
@@ -189,10 +203,6 @@ function handleSelectionChange(selection) {
|
||||
/** 新增按钮操作 */
|
||||
function handleAdd() {
|
||||
reset();
|
||||
// 获取用户列表
|
||||
listUser().then(response => {
|
||||
userOptions.value = response.rows;
|
||||
});
|
||||
open.value = true;
|
||||
title.value = "添加考勤汇总";
|
||||
}
|
||||
@@ -211,14 +221,13 @@ function handleUpdate(row) {
|
||||
}
|
||||
|
||||
function handleDetail(row) {
|
||||
loading.value = true;
|
||||
const _summaryId = row.summaryId || ids.value;
|
||||
getAttendanceSummary(_summaryId).then(response => {
|
||||
loading.value = false;
|
||||
form.value = response.data;
|
||||
detailOpen.value = true;
|
||||
title.value = "考勤汇总详情";
|
||||
});
|
||||
if (!row || !row.summaryId) {
|
||||
proxy.$modal.msgError("无效的记录");
|
||||
return;
|
||||
}
|
||||
currentSummaryId.value = row.summaryId;
|
||||
title.value = "考勤汇总详情";
|
||||
detailOpen.value = true;
|
||||
}
|
||||
|
||||
/** 提交按钮 */
|
||||
@@ -235,7 +244,11 @@ function submitForm() {
|
||||
buttonLoading.value = false;
|
||||
});
|
||||
} else {
|
||||
addAttendanceSummary(form.value).then(response => {
|
||||
addWithDetails({
|
||||
...form.value,
|
||||
startDate: form.value.startDate + ' 00:00:00',
|
||||
endDate: form.value.endDate + ' 23:59:59'
|
||||
}).then(response => {
|
||||
proxy.$modal.msgSuccess("新增成功");
|
||||
open.value = false;
|
||||
getList();
|
||||
|
||||
Reference in New Issue
Block a user