+

{{ person.sh.mjCode }}
@@ -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;
// id:人员ID 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 =
{node.label} 临时人员;
- }else if(node.level === 4 && isTeamLeader === 0 && type === 0){
+ } else if (node.level === 4 && isTeamLeader === 0 && type === 0) {
icon = '';
span =
{node.label};
}