flx:修改

This commit is contained in:
Rain_ 2025-08-22 15:27:37 +08:00
parent 029d0f969d
commit 3aa2ec1aa7
7 changed files with 802 additions and 240 deletions

View File

@ -296,6 +296,27 @@ Vue.use(vuescroll, {
}, },
}, },
}) })
const scrollDirective = {
bind(el, binding) {
const handler = binding.value;
const scrollHandler = (event) => {
handler(event);
};
// 存储滚动处理函数,方便后续解绑
el._scrollHandler = scrollHandler;
window.addEventListener('scroll', scrollHandler);
},
unbind(el) {
if (el._scrollHandler) {
window.removeEventListener('scroll', el._scrollHandler);
delete el._scrollHandler;
}
},
}
// 按钮权限控制指令
Vue.directive('scroll', scrollDirective);
// 按钮权限控制指令 // 按钮权限控制指令
Vue.directive('permission', { Vue.directive('permission', {

View File

@ -1,6 +1,6 @@
<template> <template>
<div class="attendanceManage fullHeight whiteBlock" ref="attendanceManage"> <div class="attendanceManage fullHeight whiteBlock" ref="attendanceManage">
<vue-scroll style="width: 100%; height: 100%"> <vue-scroll style="width: 100%; height: 100%" ref="scrollDiv">
<el-form <el-form
:inline="true" :inline="true"
:model="formInline" :model="formInline"
@ -15,6 +15,7 @@
</el-form-item> </el-form-item>
<el-form-item v-if="formInline.type == 1"> <el-form-item v-if="formInline.type == 1">
<el-date-picker <el-date-picker
ref="monthPicker"
value-format="yyyy-MM" value-format="yyyy-MM"
v-model="formInline.monthTime" v-model="formInline.monthTime"
type="monthrange" type="monthrange"
@ -28,6 +29,7 @@
</el-form-item> </el-form-item>
<el-form-item v-else-if="formInline.type == 2"> <el-form-item v-else-if="formInline.type == 2">
<el-date-picker <el-date-picker
ref="monthPicker"
value-format="yyyy-MM-dd" value-format="yyyy-MM-dd"
v-model="formInline.dayTime" v-model="formInline.dayTime"
type="daterange" type="daterange"
@ -41,6 +43,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select <el-select
ref="enterpriseTypeSelectRef"
filterable filterable
:clearable="true" :clearable="true"
v-model="formInline.enterpriseTypeId" v-model="formInline.enterpriseTypeId"
@ -56,6 +59,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select <el-select
ref="enterpriseSelectRef"
filterable filterable
:clearable="true" :clearable="true"
v-model="formInline.enterpriseId" v-model="formInline.enterpriseId"
@ -73,6 +77,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select <el-select
ref="teamSelectRef"
filterable filterable
:clearable="true" :clearable="true"
v-model="formInline.teamId" v-model="formInline.teamId"
@ -89,6 +94,7 @@
</el-form-item> </el-form-item>
<el-form-item> <el-form-item>
<el-select <el-select
ref="departmentSelectRef"
filterable filterable
:clearable="true" :clearable="true"
v-model="formInline.departmentId" v-model="formInline.departmentId"
@ -280,7 +286,31 @@ export default {
deep: true, deep: true,
}, },
}, },
mounted() {
this.$nextTick(() => {
this.$refs.scrollDiv.$el.children[0].addEventListener(
"scroll",
this.handleScroll,
true
);
});
},
methods: { methods: {
handleScroll(e) {
console.log("滚动了", this.$refs.enterpriseTypeSelectRef);
//
if (this.$refs.monthPicker && this.$refs.monthPicker.pickerVisible) {
this.$refs.monthPicker.handleClose();
}
//
const objRefList = ["enterpriseTypeSelectRef", "enterpriseSelectRef", "teamSelectRef", "departmentSelectRef"];
objRefList.forEach((item) => {
if (this.$refs[item] && this.$refs[item].visible) {
this.$refs[item].blur();
}
})
},
initDate() { initDate() {
this.getCountWorkerDailyAttendanceStatisticsV2(); this.getCountWorkerDailyAttendanceStatisticsV2();
this.getListData(); this.getListData();

View File

@ -420,6 +420,7 @@
<el-button <el-button
icon="el-icon-circle-check" icon="el-icon-circle-check"
type="primary" type="primary"
:loading="exportLoading"
@click="onSumbit" @click="onSumbit"
>确定</el-button >确定</el-button
> >
@ -543,6 +544,7 @@ export default {
title: "进出场打卡", title: "进出场打卡",
}, },
], ],
exportLoading: false,
videoTypeList: [], videoTypeList: [],
}; };
}, },
@ -554,6 +556,7 @@ export default {
onSumbit() { onSumbit() {
this.$refs.exportSettingInfo.validate((valid) => { this.$refs.exportSettingInfo.validate((valid) => {
if (valid) { if (valid) {
this.exportLoading = true;
const requestData = { const requestData = {
...this.exportSettingInfo, ...this.exportSettingInfo,
startDate: this.exportSettingInfo.startDate[0], startDate: this.exportSettingInfo.startDate[0],
@ -600,12 +603,25 @@ export default {
.catch((error) => { .catch((error) => {
// //
console.error(error); console.error(error);
})
.finally(() => {
this.exportLoading = false;
}); });
} }
}); });
}, },
initExportSetting() {
this.exportSettingInfo = {
startDate: [],
downloadType: "",
};
},
// //
handleExportSetting() { handleExportSetting() {
this.initExportSetting(); //
this.$nextTick(() => {
this.$refs.exportSettingInfo.clearValidate(); //
});
this.exportSettingDialog = true; this.exportSettingDialog = true;
}, },
handleSelectionChange(row) { handleSelectionChange(row) {
@ -659,27 +675,27 @@ export default {
this.countWorkerDailyInfo = [ this.countWorkerDailyInfo = [
{ {
title: "当日进场", title: "当日进场",
countNum: res.inServiceCount, countNum: res.result.inServiceCount,
content: "当日在职人数之和", content: "当日在职人数之和",
}, },
{ {
title: "当日出勤", title: "当日出勤",
countNum: res.attendanceCount, countNum: res.result.attendanceCount,
content: "累加当日的总出勤人数之和", content: "累加当日的总出勤人数之和",
}, },
{ {
title: "当日缺勤", title: "当日缺勤",
countNum: res.absentCount, countNum: res.result.absentCount,
content: "累加当日的未出勤人数之和", content: "累加当日的未出勤人数之和",
}, },
{ {
title: "出勤率", title: "出勤率",
countNum: res.attendanceRate, countNum: res.result.attendanceRate,
content: "当日出勤人数*1.0/当日在职人数", content: "当日出勤人数*1.0/当日在职人数",
}, },
{ {
title: "当日退场", title: "当日退场",
countNum: res.leftCount, countNum: res.result.leftCount,
content: "当日退场人数之和", content: "当日退场人数之和",
}, },
]; ];

View File

@ -326,7 +326,7 @@ export default {
}, },
]), ]),
}, },
data: result.map((item) => item.absence), data: result.map((item) => item.attendance),
}, },
{ {
name: "累计缺勤", name: "累计缺勤",
@ -343,7 +343,7 @@ export default {
}, },
]), ]),
}, },
data: result.map((item) => item.attendance), data: result.map((item) => item.absence),
}, },
], ],
dataZoom: [ dataZoom: [
@ -423,17 +423,17 @@ export default {
this.countWorkerDailyInfo = [ this.countWorkerDailyInfo = [
{ {
title: "在职", title: "在职",
countNum: res.inServe, countNum: res.result.inServe,
content: "在职天数", content: "在职天数",
}, },
{ {
title: "出勤", title: "出勤",
countNum: res.attendance, countNum: res.result.attendance,
content: "出勤天数", content: "出勤天数",
}, },
{ {
title: "缺勤", title: "缺勤",
countNum: res.absence, countNum: res.result.absence,
content: "缺勤天数", content: "缺勤天数",
}, },
]; ];

View File

@ -143,7 +143,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span <span
style="cursor: pointer;color: #5181F6;" style="cursor: pointer; color: #5181f6"
@click="handleSelectionChange(scope.row)" @click="handleSelectionChange(scope.row)"
>{{ scope.row.workerName }}</span >{{ scope.row.workerName }}</span
> >
@ -324,6 +324,7 @@
<el-button <el-button
icon="el-icon-circle-check" icon="el-icon-circle-check"
type="primary" type="primary"
:loading="isLoading"
@click="onSumbit" @click="onSumbit"
>确定</el-button >确定</el-button
> >
@ -477,6 +478,7 @@ export default {
title: "每日明细", title: "每日明细",
}, },
], ],
isLoading: false,
enterpriseListData: [], enterpriseListData: [],
showTime: [], showTime: [],
itemKey: "", itemKey: "",
@ -676,20 +678,25 @@ export default {
onSumbit() { onSumbit() {
this.$refs.exportSettingInfo.validate((valid) => { this.$refs.exportSettingInfo.validate((valid) => {
if (valid) { if (valid) {
this.isLoading = true;
const requestData = { const requestData = {
...this.exportSettingInfo, ...this.exportSettingInfo,
startDate: this.exportSettingInfo.startDate[0], startDate: this.exportSettingInfo.startDate[0],
endDate: this.exportSettingInfo.startDate[1], endDate: this.exportSettingInfo.startDate[1],
projectSn: this.projectSn, projectSn: this.projectSn,
} };
fetch(this.$http.defaults.baseURL + 'xmgl/workerDailyAttendanceStatisticsV2/exportWorkerDailyAttendancesStaticsByMonthXls', { fetch(
this.$http.defaults.baseURL +
"xmgl/workerDailyAttendanceStatisticsV2/exportWorkerDailyAttendancesStaticsByMonthXls",
{
method: "post", method: "post",
headers: { headers: {
Authorization: this.$store.state.userInfo.token, Authorization: this.$store.state.userInfo.token,
"Content-Type": "application/json", // JSON "Content-Type": "application/json", // JSON
}, },
body: JSON.stringify(requestData), body: JSON.stringify(requestData),
}) }
)
.then((response) => { .then((response) => {
// //
if (!response.ok) { if (!response.ok) {
@ -699,12 +706,26 @@ export default {
}) })
.then((blob) => { .then((blob) => {
console.log("导出成功"); console.log("导出成功");
const groupByTypeName = {
1: "按项目",
2: "按参建单位",
3: "按班组/部门",
4: "按人员",
}
let objName = "";
if(this.exportSettingInfo.groupByType == 1 || this.exportSettingInfo.groupByType == 3) {
const find = this.downloadTypeList.find(item => item.id == this.exportSettingInfo.downloadType)
objName = find ? `-${find.title}` : ``;
} else if(this.exportSettingInfo.groupByType == 2) {
const find = this.enterpriseListData.find(item => item.id == this.exportSettingInfo.enterpriseId)
objName = find ? `-${find.enterpriseName}` : "";
}
// //
const url = window.URL.createObjectURL(blob); const url = window.URL.createObjectURL(blob);
// <a> // <a>
const link = document.createElement("a"); const link = document.createElement("a");
link.href = url; link.href = url;
link.download = '考勤月报.xlsx'; // link.download = `考勤月报-${groupByTypeName[this.exportSettingInfo.groupByType]}${objName}.xlsx`; //
// //
document.body.appendChild(link); document.body.appendChild(link);
link.click(); link.click();
@ -718,12 +739,27 @@ export default {
.catch((error) => { .catch((error) => {
// //
console.error(error); console.error(error);
}).finally(() => {
this.isLoading = false;
}); });
} }
}); });
}, },
initExportSetting() {
this.exportSettingInfo = {
groupByType: 1,
startDate: [],
downloadType: "",
enterpriseId: "",
hourValBegin: "",
};
},
// //
handleExportSetting() { handleExportSetting() {
this.initExportSetting(); //
this.$nextTick(() => {
this.$refs.exportSettingInfo.clearValidate(); //
});
this.exportSettingDialog = true; this.exportSettingDialog = true;
}, },
handleSelectionChange(row) { handleSelectionChange(row) {

View File

@ -129,7 +129,7 @@
> >
<template slot-scope="scope"> <template slot-scope="scope">
<span <span
style="cursor: pointer;color: #5181F6;" style="cursor: pointer; color: #5181f6"
@click="handleSelectionChange(scope.row)" @click="handleSelectionChange(scope.row)"
>{{ scope.row.workerName }}</span >{{ scope.row.workerName }}</span
> >
@ -574,7 +574,54 @@ export default {
onSumbit() {}, onSumbit() {},
// //
handleExportSetting() { handleExportSetting() {
this.exportSettingDialog = true; // this.exportSettingDialog = true;
const requestData = {
// ...this.exportSettingInfo,
// startDate: this.exportSettingInfo.startDate[0],
// endDate: this.exportSettingInfo.startDate[1],
projectSn: this.projectSn,
idList: this.$refs.multipleTable.selection.map((item) => item.id),
};
fetch(
this.$http.defaults.baseURL + "xmgl/workerAttendance/exportXls",
{
method: "post",
headers: {
Authorization: this.$store.state.userInfo.token,
"Content-Type": "application/json", // JSON
},
body: JSON.stringify(requestData),
}
)
.then((response) => {
//
if (!response.ok) {
throw new Error("导出失败");
}
return response.blob();
})
.then((blob) => {
console.log("导出成功");
//
const url = window.URL.createObjectURL(blob);
// <a>
const link = document.createElement("a");
link.href = url;
link.download = "人员考勤.xlsx"; //
//
document.body.appendChild(link);
link.click();
document.body.removeChild(link);
// URL
window.URL.revokeObjectURL(url);
//
// 使blob
this.exportSettingDialog = false; //
})
.catch((error) => {
//
console.error(error);
});
}, },
handleSelectionChange(row) { handleSelectionChange(row) {
this.multipleSelection = row; this.multipleSelection = row;