后台首页数据定时刷新

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" />
@ -14,16 +14,16 @@
<nav-attendance-rate :attInfo="attInfo" :key="elKey" /> <nav-attendance-rate :attInfo="attInfo" :key="elKey" />
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<nav-att-laborer-rate :attInfo="attInfo" :key="elKey"/> <nav-att-laborer-rate :attInfo="attInfo" :key="elKey" />
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<nav-att-manager-rate :attInfo="attInfo" :key="elKey"/> <nav-att-manager-rate :attInfo="attInfo" :key="elKey" />
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<nav-att-laborer-trend /> <nav-att-laborer-trend />
</el-col> </el-col>
<el-col :span="8" v-if="vendorsCode == 'uni'"> <el-col :span="8" v-if="vendorsCode == 'uni'">
<nav-att-woker-prop :attInfo="attInfo" :key="elKey"/> <nav-att-woker-prop :attInfo="attInfo" :key="elKey" />
</el-col> </el-col>
<el-col :span="8"> <el-col :span="8">
<nav-att-job-type-group /> <nav-att-job-type-group />
@ -49,7 +49,7 @@ import navAttWokerProp from "./indexCompents/navAttWokerProp.vue";
import navAttJobTypeGroup from "./indexCompents/navAttJobTypeGroup.vue"; import navAttJobTypeGroup from "./indexCompents/navAttJobTypeGroup.vue";
import NavTopAttOnlineCount from "./indexCompents/navTopAttOnlineCount.vue"; import NavTopAttOnlineCount from "./indexCompents/navTopAttOnlineCount.vue";
import useUserStore from "@/store/modules/user"; import useUserStore from "@/store/modules/user";
import { groupByComany, groupAllByComany,groupByCraftType,groupByCraftTypeByAttendance ,getEduCompletedCount} from "@/api/manage/labor.js"; import { groupByComany, groupAllByComany, groupByCraftType, groupByCraftTypeByAttendance, getEduCompletedCount } from "@/api/manage/labor.js";
export default { export default {
components: { components: {
navTopAttMgrCount, navTopAttMgrCount,
@ -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,28 +121,28 @@ 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() {
@ -92,7 +92,7 @@ export default {
setTimeout(() => { setTimeout(() => {
let total = this.attInfo ? this.attInfo.job.worker : 0; let total = this.attInfo ? this.attInfo.job.worker : 0;
let totalAtt = this.attInfo ? this.attInfo.att.worker : 0; let totalAtt = this.attInfo ? this.attInfo.att.worker : 0;
this.sum=totalAtt+total; this.sum = totalAtt + total;
this.chartData = [ this.chartData = [
{ {
name: "出勤人数", name: "出勤人数",

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="index-nav-body"> <div class="index-nav-body">
<div class="index-nav-body-title">劳务人员出勤趋势图</div> <div class="index-nav-body-title">劳务人员出勤趋势图</div>
<div class="chart-content" v-if="sum>0"> <div class="chart-content" v-if="sum > 0">
<my-chart ref="chart" id="navAttLaborerTrendChart" width="100%" height="100%" :render="renderChart" /> <my-chart ref="chart" id="navAttLaborerTrendChart" width="100%" height="100%" :render="renderChart" />
</div> </div>
<div class="no-data" v-if="sum==0"> <div class="no-data" v-if="sum == 0">
<svg-icon icon-class="nodata"/> <svg-icon icon-class="nodata" />
<div>暂无数据</div> <div>暂无数据</div>
</div> </div>
</div> </div>
@ -25,7 +25,7 @@ export default {
currentPrjId: null, currentPrjId: null,
currentComId: null, currentComId: null,
vendorsCode: "", vendorsCode: "",
sum:0, sum: 0,
}; };
}, },
mounted() { mounted() {
@ -33,8 +33,8 @@ export default {
this.currentPrjId = this.userStore.currentPrjId; this.currentPrjId = this.userStore.currentPrjId;
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();
}, },
@ -104,9 +104,9 @@ export default {
}, },
init() { init() {
groupAttendanceLastWeek(this.vendorsCode, this.currentPrjId).then((d) => { groupAttendanceLastWeek(this.vendorsCode, this.currentPrjId).then((d) => {
this.sum=0; this.sum = 0;
this.weekData = (d.data || []).map((it) => { this.weekData = (d.data || []).map((it) => {
this.sum+=it.cnt; this.sum += it.cnt;
return { return {
name: it.dt.substring(5).replace("-", "."), name: it.dt.substring(5).replace("-", "."),
value: it.cnt, value: it.cnt,

View File

@ -27,7 +27,7 @@ export default {
data() { data() {
return { return {
chartData: [], chartData: [],
sum:0, sum: 0,
}; };
}, },
mounted() { mounted() {
@ -89,9 +89,9 @@ export default {
}, },
init() { init() {
setTimeout(() => { setTimeout(() => {
let total=this.attInfo?this.attInfo.job.mgr:0; let total = this.attInfo ? this.attInfo.job.mgr : 0;
let totalAtt=this.attInfo?this.attInfo.att.mgr:0; let totalAtt = this.attInfo ? this.attInfo.att.mgr : 0;
this.sum=totalAtt+total; this.sum = totalAtt + total;
this.chartData = [ this.chartData = [
{ {
name: "出勤人数", name: "出勤人数",
@ -99,7 +99,7 @@ export default {
}, },
{ {
name: "未出勤人数", name: "未出勤人数",
value: total-totalAtt, value: total - totalAtt,
}, },
]; ];
if (this.$refs.chart) { if (this.$refs.chart) {

View File

@ -28,7 +28,7 @@ export default {
data() { data() {
return { return {
chartData: [], chartData: [],
sum:0, sum: 0,
}; };
}, },
mounted() { mounted() {
@ -92,7 +92,7 @@ export default {
setTimeout(() => { setTimeout(() => {
let total = this.attInfo ? this.attInfo.job.total : 0; let total = this.attInfo ? this.attInfo.job.total : 0;
let edu = this.attInfo ? this.attInfo.edu : 0; let edu = this.attInfo ? this.attInfo.edu : 0;
this.sum=total+edu; this.sum = total + edu;
this.chartData = [ this.chartData = [
{ {
name: "参与人数", name: "参与人数",

View File

@ -1,7 +1,7 @@
<template> <template>
<div class="index-nav-body"> <div class="index-nav-body">
<div class="index-nav-body-title">今日出勤率</div> <div class="index-nav-body-title">今日出勤率</div>
<div class="chart-content" v-if="sum> 0"> <div class="chart-content" v-if="sum > 0">
<my-chart ref="chart" id="navAttendanceRateChart" width="100%" height="100%" :render="renderChart" /> <my-chart ref="chart" id="navAttendanceRateChart" width="100%" height="100%" :render="renderChart" />
</div> </div>
<div class="no-data" v-if="sum == 0"> <div class="no-data" v-if="sum == 0">
@ -28,7 +28,7 @@ export default {
data() { data() {
return { return {
chartData: [], chartData: [],
sum:0, sum: 0,
}; };
}, },
mounted() { mounted() {
@ -89,9 +89,9 @@ export default {
}, },
init() { init() {
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: "出勤人数",
@ -99,7 +99,7 @@ export default {
}, },
{ {
name: "未出勤人数", name: "未出勤人数",
value: total-totalAtt, value: total - totalAtt,
}, },
]; ];
if (this.$refs.chart) { if (this.$refs.chart) {

View File

@ -5,7 +5,7 @@
</div> </div>
<div class="top-data"> <div class="top-data">
<div class="data-title">在岗管理人员数</div> <div class="data-title">在岗管理人员数</div>
<div class="data-number">{{attInfo?attInfo.job.mgr:0}}</div> <div class="data-number">{{ attInfo ? attInfo.job.mgr : 0 }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -13,17 +13,13 @@
<script> <script>
// //
export default { export default {
props:{ props: {
attInfo:{ attInfo: {
type:Object, type: Object,
default:()=>{ default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>
<style>
</style>

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="index-nav-top"> <div class="index-nav-top">
<div class="top-icon"> <div class="top-icon">
<svg-icon icon-class="onlineworker" /> <svg-icon icon-class="onlineworker" />
</div> </div>
<div class="top-data"> <div class="top-data">
<div class="data-title">在岗工人数</div> <div class="data-title">在岗工人数</div>
<div class="data-number">{{attInfo?attInfo.job.worker:0}}</div> <div class="data-number">{{ attInfo ? attInfo.job.worker : 0 }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -13,17 +13,13 @@
<script> <script>
// //
export default { export default {
props:{ props: {
attInfo:{ attInfo: {
type:Object, type: Object,
default:()=>{ default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>
<style>
</style>

View File

@ -5,7 +5,7 @@
</div> </div>
<div class="top-data"> <div class="top-data">
<div class="data-title">完成三级安全教育人数</div> <div class="data-title">完成三级安全教育人数</div>
<div class="data-number">{{attInfo?attInfo.edu:0}}</div> <div class="data-number">{{ attInfo ? attInfo.edu : 0 }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -13,13 +13,13 @@
<script> <script>
// //
export default { export default {
props:{ props: {
attInfo:{ attInfo: {
type:Object, type: Object,
default:()=>{ default: () => {
return null return null;
} },
} },
} },
} };
</script> </script>

View File

@ -1,11 +1,11 @@
<template> <template>
<div class="index-nav-top"> <div class="index-nav-top">
<div class="top-icon"> <div class="top-icon">
<svg-icon icon-class="group" /> <svg-icon icon-class="group" />
</div> </div>
<div class="top-data"> <div class="top-data">
<div class="data-title">总人数</div> <div class="data-title">总人数</div>
<div class="data-number">{{attInfo?attInfo.job.total:0}}</div> <div class="data-number">{{ attInfo ? attInfo.job.total : 0 }}</div>
</div> </div>
</div> </div>
</template> </template>
@ -13,13 +13,13 @@
<script> <script>
// //
export default { export default {
props:{ props: {
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>