后台首页数据定时刷新

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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