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