提交: 大屏 项目列表查询 接口更改,地图选择项目 是选中项目标记点 居中 15级缩放 弹窗信息展示。

This commit is contained in:
23688nl 2022-09-07 11:52:35 +08:00
parent fe0bb897ab
commit 2fd3a71175
3 changed files with 120 additions and 94 deletions

View File

@ -70,3 +70,13 @@ export function appDeviceStatistics(query) {
params: query params: query
}) })
} }
// 监控大屏 项目列表
export function bigScreenProjectList(query) {
return request({
url: '/sys/device/projecList',
method: 'get',
params: query
})
}

View File

@ -7,6 +7,7 @@
import AMap from "AMap"; import AMap from "AMap";
import markerIcon from "@/assets/images/big/marker_noalarm.png"; import markerIcon from "@/assets/images/big/marker_noalarm.png";
import markerAlarmIcon from "@/assets/images/big/marker_alarm.png"; import markerAlarmIcon from "@/assets/images/big/marker_alarm.png";
import markerSelect from "@/assets/images/big/marker_select.png";
import infoTopIcon from "@/assets/images/big/map_top.png"; import infoTopIcon from "@/assets/images/big/map_top.png";
import infoBotIcon from "@/assets/images/big/map_bottom.png"; import infoBotIcon from "@/assets/images/big/map_bottom.png";
import infoAlarmIcon from "@/assets/images/big/map_alarm.png"; import infoAlarmIcon from "@/assets/images/big/map_alarm.png";
@ -37,8 +38,8 @@ export default {
}, },
selectProjectId: { selectProjectId: {
type: [String, Number], type: [String, Number],
default: null default: null,
} },
}, },
data() { data() {
return { return {
@ -50,6 +51,7 @@ export default {
}, },
theme: "", theme: "",
infoWindow: null, infoWindow: null,
markerList: [],
}; };
}, },
mounted() { mounted() {
@ -63,13 +65,113 @@ export default {
this.aMap.clearMap(); this.aMap.clearMap();
} }
this.createMarker(); this.createMarker();
// console.log("map_projectList: ", list); },
// this.textFu(); deep: true,
},
selectProjectId: {
handler: function (val, oldVal) {
if (this.projectList && this.projectList.length > 0) {
this.projectList.forEach((pro, idx) => {
if (pro && pro.projectId === this.selectProjectId) {
this.handlerSetMarker(pro, idx, markerSelect, true);
}
if (oldVal !== null && oldVal !== undefined) {
if (pro && pro.projectId === oldVal) {
this.handlerSetMarker( pro, idx, pro.tenantIndexVo["unProcessed"] > 0
? markerAlarmIcon
: markerIcon
);
}
}
});
}
if (val === '' || val === null) {
this.closeInfoWindow()
this.overview()
}
}, },
deep: true, deep: true,
}, },
}, },
methods: { methods: {
// handlerMarkerInfoWindow
handlerMarkerInfoWindow(project, url) {
return `<div class="info-block">
<span class="info-title">报警提醒</span>
<img name="closeImg" class="info-close" onclick="window['amapObj'].clearInfoWindow()" src="${infoCloseIcon}"/>
<img class="info-top" src="${infoTopIcon}" />
<div class="info-wrap">
<div class="info-item"><span class="info-lable">项目</span>
<span class="info-value info-a"
onclick="window['_this'].$router.push({ path:'${url}', query: { 'projectId': '${
project.projectId
}', 'tempType': 'details' } })"
>${project.projectName}</span></div>
<div class="info-item"><span class="info-lable">地址</span>
<marquee style="margin: 0; width:calc(100% - 80px);" behavior="alternate" scrollamount="1" width="calc(100% - 40px)">
<span class="info-value">${project.projectAddress}</span>
</marquee>
</div>
<div class="info-item"><span class="info-lable">报警总数</span>
<span class="info-value" style="color: #ff3739;font-size: 24px;font-weight: 500;">${
project.tenantIndexVo?.unProcessed
}</span></div>
<div class="alarm-icon-block">
<img class="alarm-icon" src="${infoAlarmIcon}"/>
</div>
<div class="list-device">
${this.resultDeviceListStr(
project.deviceAlarmSimpleVoList || []
)}
</div>
</div>
<img class="info-bottom" src="${infoBotIcon}">
</div>`
},
/**
* 单个 marker 设置更替样式
* @param {*} project 对象
* @param {*} idx 点坐标
* @param {*} icon 更新点图标
* @param {*} isSelect 是否选中
*/
handlerSetMarker(project, idx, icon, isSelect) {
if (this.markerList && this.markerList.length > idx) {
//
var newMarker = null;
var projectUrl =
this.$store.getters.tenantId === 0
? "/project/project"
: "/project_tenant/project_tenant";
if (project.projectLat && project.projectLng) {
newMarker = new AMap.Marker({
position: [project.projectLng, project.projectLat],
icon: icon,
offset: new AMap.Pixel(-13, -30),
});
var content = [];
window["amapObj"] = this.aMap;
window["_this"] = this;
content.push(this.handlerMarkerInfoWindow(project, projectUrl));
newMarker.content = _this.createInfoWindow(content.join("<br/>"));
newMarker.on("click", _this.markerClick);
}
//
this.aMap.remove(this.markerList[idx]);
this.markerList[idx] = newMarker;
this.aMap.add(newMarker);
if(isSelect) {
let position = new AMap.LngLat(project.projectLng, project.projectLat);
this.aMap.setZoom(15);
this.aMap.setCenter(position);
if (!this.infoWindow) {
this.createInfoWindowO();
}
this.infoWindow.setContent(newMarker.content);
this.infoWindow.open(this.aMap, position);
}
}
},
overview() { overview() {
if (this.aMap) { if (this.aMap) {
this.aMap.setFitView(); this.aMap.setFitView();
@ -106,47 +208,6 @@ export default {
this.infoWindow.setContent(e.target.content); this.infoWindow.setContent(e.target.content);
this.infoWindow.open(this.aMap, e.target.getPosition()); this.infoWindow.open(this.aMap, e.target.getPosition());
}, },
//
textFu() {
let marker = new AMap.Marker({
position: [116.4224009776628, 39.93482727239599],
icon: markerIcon,
offset: new AMap.Pixel(-13, -30),
});
var content = [];
content.push(
`<div class="info-block">
<span class="info-title">报警提醒</span>
<img class="info-close" src="${infoCloseIcon}"/>
<img class="info-top" src="${infoTopIcon}" />
<div class="info-wrap">
<div class="info-item"><span class="info-lable">项目</span><span class="info-value">智慧园区项目</span></div>
<div class="info-item"><span class="info-lable">地址</span><span class="info-value">智慧园区项目</span></div>
<div class="info-item"><span class="info-lable">报警总数</span><span class="info-value">智慧园区项目</span></div>
<div class="alarm-icon-block">
<img class="alarm-icon" src="${infoAlarmIcon}"/>
</div>
<div class="list-device">
<div class="item-device"><img class="d-img" src="${infoDeviceIcon}" /> <span class="device-info">设备名称设备名称设备名称设备名</span> </div>
<div class="item-device"><img class="d-img" src="${infoDeviceIcon}" /> <span class="device-info">设备名称设备名称设备名称设备名</span></div>
<div class="item-device"><img class="d-img" src="${infoDeviceIcon}" /> <span class="device-info">设备名称设备名称设备名称设备名</span></div>
<div class="item-device"><img class="d-img" src="${infoDeviceIcon}" /> <span class="device-info">设备名称设备名称设备名称设备名</span></div>
</div>
</div>
<img class="info-bottom" src="${infoBotIcon}">
</div>`
);
const contentStr = this.createInfoWindow(content.join("<br/>"));
if (!this.infoWindow) {
this.createInfoWindowO();
}
this.infoWindow.setContent(contentStr);
this.infoWindow.open(this.aMap, [116.4224009776628, 39.93482727239599]);
this.aMap.add(marker);
this.aMap.setFitView();
},
// //
createMarker() { createMarker() {
var markerList = []; var markerList = [];
@ -162,70 +223,26 @@ export default {
this.projectList[i].projectLng, this.projectList[i].projectLng,
this.projectList[i].projectLat, this.projectList[i].projectLat,
], ],
// map: this.aMap,
icon: icon:
this.projectList[i].tenantIndexVo["unProcessed"] > 0 this.projectList[i].tenantIndexVo["unProcessed"] > 0
? markerAlarmIcon ? markerAlarmIcon
: markerIcon, : markerIcon,
// icon:
// new AMap.Icon({
// image: this.projectList[i].tenantIndexVo["unProcessed"] > 0
// ? markerAlarmIcon
// : markerIcon,
// size: new AMap.Size(80, 80),
// imageSize: new AMap.Size(52, 52),
// }),
offset: new AMap.Pixel(-13, -30), offset: new AMap.Pixel(-13, -30),
}); });
var content = []; var content = [];
window["amapObj"] = this.aMap; window["amapObj"] = this.aMap;
window["_this"] = this; window["_this"] = this;
content.push( content.push(this.handlerMarkerInfoWindow(this.projectList[i], projectUrl));
`<div class="info-block">
<span class="info-title">报警提醒</span>
<img name="closeImg" class="info-close" onclick="window['amapObj'].clearInfoWindow()" src="${infoCloseIcon}"/>
<img class="info-top" src="${infoTopIcon}" />
<div class="info-wrap">
<div class="info-item"><span class="info-lable">项目</span>
<span class="info-value info-a"
onclick="window['_this'].$router.push({ path:'${projectUrl}', query: { 'projectId': '${
this.projectList[i].projectId
}', 'tempType': 'details' } })"
>${this.projectList[i].projectName}</span></div>
<div class="info-item"><span class="info-lable">地址</span>
<marquee style="margin: 0; width:calc(100% - 80px);" behavior="alternate" scrollamount="1" width="calc(100% - 40px)">
<span class="info-value">${
this.projectList[i].projectAddress
}</span>
</marquee>
</div>
<div class="info-item"><span class="info-lable">报警总数</span>
<span class="info-value" style="color: #ff3739;font-size: 24px;font-weight: 500;">${
this.projectList[i].tenantIndexVo?.unProcessed
}</span></div>
<div class="alarm-icon-block">
<img class="alarm-icon" src="${infoAlarmIcon}"/>
</div>
<div class="list-device">
${this.resultDeviceListStr(
this.projectList[i].deviceAlarmSimpleVoList || []
)}
</div>
</div>
<img class="info-bottom" src="${infoBotIcon}">
</div>`
);
marker.content = _this.createInfoWindow(content.join("<br/>")); marker.content = _this.createInfoWindow(content.join("<br/>"));
marker.on("click", _this.markerClick); marker.on("click", _this.markerClick);
markerList.push(marker); markerList.push(marker);
} }
} }
this.markerList = [...markerList];
this.aMap.add(markerList); this.aMap.add(markerList);
this.aMap.setFitView(); this.aMap.setFitView();
}, },
handlerMapDevice(e) { handlerMapDevice(e) {
console.log("handler-map-device-click", e);
this.$router.push({ this.$router.push({
name: "Device", name: "Device",
params: { deviceId: e.deviceId, tempType: "details" }, params: { deviceId: e.deviceId, tempType: "details" },
@ -478,5 +495,4 @@ export default {
background-color: #00f7f800; background-color: #00f7f800;
} }
} }
</style> </style>

View File

@ -141,7 +141,7 @@ import Cookies from "js-cookie";
import EProjectCensusTemp from "./profile/EProjectCensusTemp"; import EProjectCensusTemp from "./profile/EProjectCensusTemp";
import NotificationAlarm from './profile/NotificationAlarm'; import NotificationAlarm from './profile/NotificationAlarm';
import { getWarningAnalysis, homeCount, appProjectList } from "@/api/app"; import { getWarningAnalysis, homeCount, bigScreenProjectList } from "@/api/app";
import { import {
getEnergySpaceCensusList, getEnergySpaceCensusList,
getEnergyCensusList, getEnergyCensusList,
@ -337,7 +337,7 @@ export default {
// //
getProjectList() { getProjectList() {
if (this.$store.getters.userType !== "PERSONAL") { if (this.$store.getters.userType !== "PERSONAL") {
appProjectList({ bigScreenProjectList({
regionalismId: this.regionalismId, regionalismId: this.regionalismId,
}).then((response) => { }).then((response) => {
this.projectList = response.data; this.projectList = response.data;