后台首页数据定时刷新

dev_xd
lj7788@126.com 2025-07-10 16:50:49 +08:00
parent db1048aa1f
commit b668ef41c6
11 changed files with 103 additions and 108 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="app-container home"> <div class="app-container home" :key="mainKey">
<el-card class="nav-top"> <el-card class="nav-top">
<nav-top-unit /> <nav-top-unit />
<nav-top-att-worker-count :attInfo="attInfo" :key="elKey" /> <nav-top-att-worker-count :attInfo="attInfo" :key="elKey" />
@ -72,6 +72,7 @@ export default {
vendorsCode: "", vendorsCode: "",
attInfo: null, attInfo: null,
elKey: 0, elKey: 0,
mainKey: 0,
}; };
}, },
mounted() { mounted() {
@ -91,17 +92,21 @@ export default {
} else { } else {
this.loadUniAttendanceData(); this.loadUniAttendanceData();
} }
setTimeout(() => {
this.loadAttInfo();
this.mainKey++;
}, 1000 * 60 * 5);
}, },
loadUniAttendanceData() { loadUniAttendanceData() {
let data = { let data = {
comId: this.currentComId, comId: this.currentComId,
projectId:this.currentPrjId projectId: this.currentPrjId,
}; };
let ajax = []; let ajax = [];
ajax.push(groupByCraftTypeByAttendance({...data,createTime:this.$dt(new Date()).format("YYYY-MM-DD")})) ajax.push(groupByCraftTypeByAttendance({ ...data, createTime: this.$dt(new Date()).format("YYYY-MM-DD") }));
ajax.push(groupByCraftType(data)); ajax.push(groupByCraftType(data));
ajax.push(getEduCompletedCount(this.vendorsCode,this.currentPrjId)) ajax.push(getEduCompletedCount(this.vendorsCode, this.currentPrjId));
Promise.all(ajax).then(res=>{ Promise.all(ajax).then((res) => {
let tmps = res[0].data || []; let tmps = res[0].data || [];
let obj = { let obj = {
job: { job: {
@ -116,27 +121,27 @@ export default {
mgr: 0, mgr: 0,
worker: 0, worker: 0,
}, },
edu:0 edu: 0,
}; };
tmps.forEach(d=>{ tmps.forEach((d) => {
let cnt=(d.id||0)*1 let cnt = (d.id || 0) * 1;
obj.att.total+=cnt obj.att.total += cnt;
if (d.createBy == "管理人员") { if (d.createBy == "管理人员") {
obj.att.mgr+=cnt obj.att.mgr += cnt;
} else { } else {
obj.att.worker+=cnt obj.att.worker += cnt;
} }
}); });
tmps = res[1].data || []; tmps = res[1].data || [];
tmps.forEach(d=>{ tmps.forEach((d) => {
let cnt=(d.id||0)*1 let cnt = (d.id || 0) * 1;
obj.job.total+=cnt obj.job.total += cnt;
if (d.createBy == "管理人员") { if (d.createBy == "管理人员") {
obj.job.mgr+=cnt obj.job.mgr += cnt;
} else { } else {
obj.job.worker+=cnt obj.job.worker += cnt;
} }
}) });
obj.edu = res[2].data || 0; obj.edu = res[2].data || 0;
this.attInfo = obj; this.attInfo = obj;
this.elKey++; this.elKey++;

View File

@ -28,7 +28,7 @@ export default {
data() { data() {
return { return {
chartData: [], chartData: [],
sum:0 sum: 0,
}; };
}, },
mounted() { mounted() {

View File

@ -34,7 +34,7 @@ export default {
this.currentComId = this.userStore.currentComId; this.currentComId = this.userStore.currentComId;
this.vendorsCode = this.userStore.vendorsCode; this.vendorsCode = this.userStore.vendorsCode;
if (this.vendorsCode == "jgw") { if (this.vendorsCode == "jgw") {
this.vendorsCode="uni" this.vendorsCode = "uni";
} }
this.init(); this.init();
}, },

View File

@ -91,7 +91,7 @@ export default {
setTimeout(() => { setTimeout(() => {
let total = this.attInfo ? this.attInfo.job.total : 0; let total = this.attInfo ? this.attInfo.job.total : 0;
let totalAtt = this.attInfo ? this.attInfo.att.total : 0; let totalAtt = this.attInfo ? this.attInfo.att.total : 0;
this.sum=total+totalAtt this.sum = total + totalAtt;
this.chartData = [ this.chartData = [
{ {
name: "出勤人数", name: "出勤人数",

View File

@ -17,13 +17,9 @@ export default {
attInfo: { attInfo: {
type: Object, type: Object,
default: () => { default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>
<style>
</style>

View File

@ -17,13 +17,9 @@ export default {
attInfo: { attInfo: {
type: Object, type: Object,
default: () => { default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>
<style>
</style>

View File

@ -17,9 +17,9 @@ export default {
attInfo: { attInfo: {
type: Object, type: Object,
default: () => { default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>

View File

@ -17,9 +17,9 @@ export default {
attInfo: { attInfo: {
type: Object, type: Object,
default: () => { default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>

View File

@ -42,5 +42,3 @@ export default {
}, },
}; };
</script> </script>
<style></style>