施工管控添加定时刷新数据

This commit is contained in:
cwchen 2024-09-20 11:20:27 +08:00
parent 4e5127aa75
commit 58db31c668
2 changed files with 99 additions and 31 deletions

View File

@ -205,7 +205,7 @@ export default {
methods: {
startRefresh() {
// 10
this.intervalId = setInterval(this.refreshData, 1000 * 60 * 5);
this.intervalId = setInterval(this.refreshData, 1000 * 60 * 10);
},
stopRefresh() {
if (this.intervalId) {

View File

@ -16,7 +16,7 @@
</div>
<div class="content">
<div id="searchBox" class="layout" v-if="isShowHistoryGj">
<el-button type="primary" plain @click="clsoeHistoryGj" style="margin-right: 10px;">返回</el-button>
<el-button type="primary" plain @click="closeHistoryGj" style="margin-right: 10px;">返回</el-button>
<el-date-picker v-model="chooseDate" @change="loadHistoryGj" :editable="false" :clearable="false" type="date"
format="yyyy-MM-dd" value-format="yyyy-MM-dd" placeholder="选择日期">
</el-date-picker>
@ -88,12 +88,12 @@
<div class="layout info"><img src="../../../../assets/person_img/bloodPressure.png">{{
person.sh.bloodPressure }}</div>
</div>
<div class="layout" v-if="person.hasSafetyHat">
<!-- <div class="layout" v-if="person.hasSafetyHat">
<div class="layout"><img src="../../../../assets/person_img/hat.png">{{ person.hat.name }}
</div>
<div class="layout info2"><img src="../../../../assets/person_img/talk.png" title="对讲"></div>
<div class="layout info2"><img src="../../../../assets/person_img/video.png" title="播放"></div>
</div>
</div> -->
<div class="layout">
<div class="layout"><img src="../../../../assets/person_img/mj.png">{{ person.sh.mjCode }}</div>
</div>
@ -182,6 +182,7 @@ import no_warn2 from "@/assets/svg/no_warn2.svg";
import warn from "@/assets/svg/warn.svg";
import start from "@/assets/person_img/start.png";
import end from "@/assets/person_img/end.png";
import { number } from "echarts";
export default {
name: 'personManage',
/* 人员树前端筛选 */
@ -307,19 +308,75 @@ export default {
//
teamTreeData: [],
//
checkTeamId: null
checkTeamId: null,
//
intervalId: null,
// ID
checkNodeId: null,
//
checkNodeLevel: null,
// ID
checkNodeTowerId: null,
//
checkPersonObj: {}
};
},
created() {
this.getPersonsTree();
},
mounted(){
// alert('');
mounted() {
this.startRefresh();
},
destroyed(){
// alert('');
destroyed() {
this.stopRefresh();
},
methods: {
startRefresh() {
// 10
this.intervalId = setInterval(this.refreshData, 1000 * 60 * 10);
},
stopRefresh() {
if (this.intervalId) {
clearInterval(this.intervalId);
this.intervalId = null;
}
},
async refreshData() {
this.$message('页面刷新了');
//
this.treeData.splice(0);
this.idArr.splice(0);
await this.getPersonsTree();
if (this.filterText) {
this.$refs.tree.filter();
}
if (this.checkNodeId) {
this.$refs.tree.setCurrentKey(this.checkNodeId);
if (this.checkNodeLevel === 4) {
this.idArr.push(this.checkNodeId);
}
if (this.checkNodeLevel === 2) { //
this.$message('刷新杆塔选中的数据');
this.loadWorkInfo();
} else if (this.checkNodeLevel === 3) { //
this.$message('刷新班组选中的数据');
this.removeOverlay();
const obj = {
'id': this.checkNodeTowerId,
'teamId': this.checkTeamId
}
this.loadPersonsInfo(obj, null);
} else if (this.checkNodeLevel === 4) { //
this.$message('刷新班组人员选中的数据');
this.removeOverlay();
const obj = {
'id': this.checkNodeTowerId,
'teamId': this.checkTeamId
}
this.loadPersonsInfo(obj, this.checkPersonObj);
}
}
},
//
getTodayDate() {
const today = new Date();
@ -338,8 +395,8 @@ export default {
}).catch((res) => { })
},
/* 加载人员树 */
getPersonsTree() {
personsTree().then(res => {
async getPersonsTree() {
await personsTree().then(res => {
const treeData = res.data;
if (treeData && treeData.length > 0) {
this.treeData = treeData
@ -358,14 +415,6 @@ export default {
},
/* 人员树过滤 */
filterNode(value, data, node) {
/* if (!value) {
if (node.level == 1 || node.level == 2) {
node.expanded = true
} else {
node.expanded = false
}
return true
} */
//
let val = value.toLowerCase()
return this.chooseNode(val, data, node)
@ -413,7 +462,6 @@ export default {
/* 加载抽检班组人员树 */
getTeamPersonByTower(params) {
teamPersonByTower(params).then(res => {
console.log(res);
const teamTreeData = res.data;
if (teamTreeData && teamTreeData.length > 0) {
this.teamTreeData = teamTreeData
@ -461,7 +509,7 @@ export default {
} else {
this.form.configType = '1';
}
}).catch((res) => {
})
@ -603,7 +651,12 @@ export default {
},
//
handleNodeClick(data, node, item) {
this.checkNodeId = data.id;
this.checkNodeLevel = data.level;
this.towerId = undefined;
this.checkTeamId = null;
this.checkNodeTowerId = null;
this.checkPersonObj = {};
if (node.level === 2) {
this.removeOverlay();
// towerId,
@ -627,6 +680,7 @@ export default {
'teamId': teamId
}
this.checkTeamId = teamId;
this.checkNodeTowerId = towerId;
this.loadPersonsInfo(obj, null);
} else if (node.level === 4) {
this.isTower = false;
@ -641,6 +695,8 @@ export default {
'teamId': teamId
}
this.checkTeamId = teamId;
this.checkNodeTowerId = towerId;
this.checkPersonObj = _.cloneDeep(data);
this.loadPersonsInfo(obj, data);
} else {
//
@ -663,6 +719,13 @@ export default {
},
//
clickMarker(item) {
let userId = null;
if (new RegExp(/^[0-9]*$/).test(item.id)) {
userId = item.id;
this.$refs.tree.setCurrentKey(item.type === 0 ? 'zs-' + item.id : 'ls-' + item.id);
} else {
userId = item.type === 0 ? parseInt(item.id.replace('zs-', '')) : parseInt(item.id.replace('ls-', ''))
}
const allOverlay = this.map.getOverlays();
for (let index = 0; index < allOverlay.length; index++) {
let overlay = allOverlay[index];
@ -679,7 +742,7 @@ export default {
let overlay = allOverlay[index];
//
const flag = this.isOverlayPoint(overlay);
if (flag && ("marker-" + item.type + '-' + item.id === overlay.id)) {
if (flag && ("marker-" + item.type + '-' + userId === overlay.id)) {
if (item.isWarn === 0) {
let myIcon = new BMap.Icon(no_warn2, new BMap.Size(50, 50))
myIcon.setImageSize(new BMap.Size(50, 50));
@ -693,7 +756,7 @@ export default {
this.isPerson = true;
// idID type: 0 1
const obj = {
'id': item.id,
'id': userId,
'type': item.type
}
this.loadPersonDetail(obj);
@ -706,7 +769,6 @@ export default {
},
/* 添加人员定位的覆盖物 */
addPersonMarker(item) {
console.log(item);
let point = new BMap.Point(item.lon, item.lat)
let marker = "", myIcon = "";
if (item.isWarn === 0) {
@ -724,6 +786,8 @@ export default {
marker.isWarn = item.isWarn;
this.map.addOverlay(marker);
//
console.error(item);
marker.addEventListener("click", () => { this.clickMarker(item) });
},
//
@ -733,14 +797,18 @@ export default {
this.isShowHistoryGj = true;
},
//
clsoeHistoryGj() {
closeHistoryGj() {
this.removeOverlay();
this.isShowHistoryGj = false;
const obj = {
'id': this.id,
'teamId': this.teamId
'id': this.checkNodeTowerId,
'teamId': this.checkTeamId
}
if (Object.keys(this.checkPersonObj).length === 0) {
this.loadPersonsInfo(obj, null);
} else {
this.loadPersonsInfo(obj, this.checkPersonObj);
}
this.loadPersonsInfo(obj, null);
},
//
loadGj() {
@ -773,8 +841,8 @@ export default {
},
//icon
renderContent(h, { node, data }) {
let isTeamLeader = data.isTeamLeader, type = data.type,isWarn = data.isWarn,style = '';
if(isWarn === 1){
let isTeamLeader = data.isTeamLeader, type = data.type, isWarn = data.isWarn, style = '';
if (isWarn === 1) {
style = 'warnColor'
}
// 使
@ -791,7 +859,7 @@ export default {
} else if (node.level === 4 && type === 1) {
icon = '';
span = <span class={style}>{node.label} <el-tag size="mini">临时人员</el-tag></span>;
}else if(node.level === 4 && isTeamLeader === 0 && type === 0){
} else if (node.level === 4 && isTeamLeader === 0 && type === 0) {
icon = '';
span = <span class={style}>{node.label}</span>;
}