This commit is contained in:
ljx
2025-09-12 22:01:26 +08:00
parent 6bc9ed7054
commit 8316636c68
8 changed files with 426 additions and 381 deletions

View File

@ -5,7 +5,7 @@ import { AxiosPromise } from 'axios';
export const getScreenWeather = (projectId: number | string) => {
return request({
url: '/project/big/screen/weather/' + projectId,
method: 'get',
method: 'get'
});
};
@ -13,7 +13,7 @@ export const getScreenWeather = (projectId: number | string) => {
export const getScreenSafetyDay = (projectId: number | string) => {
return request({
url: '/project/big/screen/safetyDay/' + projectId,
method: 'get',
method: 'get'
});
};
@ -21,7 +21,7 @@ export const getScreenSafetyDay = (projectId: number | string) => {
export const getScreenNews = (projectId: number | string) => {
return request({
url: '/project/big/screen/news/' + projectId,
method: 'get',
method: 'get'
});
};
@ -29,7 +29,7 @@ export const getScreenNews = (projectId: number | string) => {
export const getScreenLand = (projectId: number | string) => {
return request({
url: '/project/big/screen/' + projectId,
method: 'get',
method: 'get'
});
};
@ -37,7 +37,7 @@ export const getScreenLand = (projectId: number | string) => {
export const getScreenImgProcess = (projectId: number | string) => {
return request({
url: '/project/big/screen/imageProgress/' + projectId,
method: 'get',
method: 'get'
});
};
@ -45,15 +45,18 @@ export const getScreenImgProcess = (projectId: number | string) => {
export const getScreenPeople = (projectId: number | string) => {
return request({
url: '/project/big/screen/people/' + projectId,
method: 'get',
method: 'get'
});
};
// 查询项目AI安全巡检
export const getScreenSafetyInspection = (projectId: number | string) => {
return request({
url: '/project/big/screen/safetyInspection/' + projectId,
url: '/project/big/screen/safetyInspection/',
method: 'get',
params: {
projectId
}
});
};
@ -61,7 +64,7 @@ export const getScreenSafetyInspection = (projectId: number | string) => {
export const getScreenGeneralize = (projectId: number | string) => {
return request({
url: '/project/big/screen/generalize/' + projectId,
method: 'get',
method: 'get'
});
};
@ -76,7 +79,7 @@ export const getGps = (projectId) => {
export const getSelectList = (params) => {
return request({
url: '/project/big/screen/getList',
method: 'get',
method: 'get',
params
});
};
@ -93,7 +96,7 @@ export const setSelect = (data) => {
export const getModelList = (params) => {
return request({
url: '/yjearth4.0/api/v1/source/list',
method: 'get',
method: 'get',
params
});
};
};

View File

@ -53,6 +53,8 @@ const router = useRouter();
const getProjectGisData = async () => {
try {
const response = await projectGis();
console.log(response, 111111111111);
if (response.code === 200) {
// 过滤掉没有经纬度的项目
projectData.value = response.data.filter((item: any) => item.lng !== null && item.lat !== null && item.lng !== '' && item.lat !== '');
@ -108,6 +110,7 @@ const initEcharts = () => {
// 从接口数据生成散点数据
const scatterData = projectData.value.map((item) => ({
name: item.projectName,
id: item.id,
value: [parseFloat(item.lng), parseFloat(item.lat)], // 转换为数值类型
shortName: item.shortName,
projectSite: item.projectSite,
@ -200,15 +203,18 @@ const initEcharts = () => {
myChart.setOption(option);
// 添加点击事件监听 - 这是关键修改部分
myChart.on('click', function (params: any) {
console.log(params, 111111);
// 检查点击的是散点图系列
if (params.componentType === 'series' && params.seriesType === 'scatter') {
// 跳转到项目详情页
navigateToProjectDetail();
navigateToProjectDetail(params.data);
}
});
};
const navigateToProjectDetail = () => {
window.open('http://xny.yj-3d.com:7788/ProjectScreen', '_blank');
const navigateToProjectDetail = (data) => {
window.open('http://localhost:7788/ProjectScreen?projectId=' + data.id + '&projectName=' + data.name, '_blank');
//xny.yj-3d.com
};
const risk_level_type1 = ref([]);
const safety_inspection_type1 = ref([]);

View File

@ -5,7 +5,7 @@
</div>
<div class="endPage" :class="{ 'slide-out-down': isHide }">
<Title title="AI安全巡检">
<img src="@/assets/projectLarge/robot.svg" alt="" height="20px" width="20px">
<img src="@/assets/projectLarge/robot.svg" alt="" height="20px" width="20px" />
</Title>
<div class="swiper" v-if="inspectionList.length">
<div class="arrow" :class="{ 'canUse': canLeft }" @click="swiperClick('left')">
@ -15,7 +15,7 @@
</div>
<div class="swiper_content" ref="swiperContent">
<div class="swiper_item" v-for="(item, i) in inspectionList" :key="i">
<img :src="item.picture" alt="安全巡检" class="swiper_img">
<img :src="item.picture" alt="安全巡检" class="swiper_img" />
<div class="swiper_date">{{ item.createTime.slice(5, 16) }}</div>
<div class="swiper_tip">{{ item.label || '未佩戴安全帽' }}</div>
</div>
@ -31,14 +31,15 @@
</template>
<script setup>
import { ref, onMounted, toRefs, getCurrentInstance } from "vue"
import Title from './title.vue'
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue'
import { getScreenSafetyInspection } from '@/api/projectScreen'
import newMap from "./newmap.vue"
import { ref, onMounted, toRefs, getCurrentInstance } from 'vue';
import Title from './title.vue';
import { ArrowLeft, ArrowRight } from '@element-plus/icons-vue';
import { getScreenSafetyInspection } from '@/api/projectScreen';
import newMap from './newmap.vue';
const { proxy } = getCurrentInstance();
const { violation_level_type } = toRefs(proxy?.useDict('violation_level_type'));
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
const props = defineProps({
isHide: {
type: Boolean,
@ -46,88 +47,91 @@ const props = defineProps({
},
projectId: {
type: String,
default: ""
default: ''
}
})
});
const inspectionList = ref([{
id: "",
label: "",
picture: "",
createTime: ""
}])
const swiperContent = ref()
const swiperItemWidth = ref(100)
const canLeft = ref(false)
const canRight = ref(true)
const inspectionList = ref([
{
id: '',
label: '',
picture: '',
createTime: ''
}
]);
const swiperContent = ref();
const swiperItemWidth = ref(100);
const canLeft = ref(false);
const canRight = ref(true);
const swiperClick = (direction) => {
if (!swiperContent.value) return
if (!swiperContent.value) return;
if (direction === 'right') {
if (swiperContent.value.scrollLeft >= swiperContent.value.scrollWidth - swiperContent.value.clientWidth) {
canRight.value = false
canLeft.value = true
return
canRight.value = false;
canLeft.value = true;
return;
}
swiperContent.value.scrollLeft += swiperItemWidth.value
swiperContent.value.scrollLeft += swiperItemWidth.value;
} else {
if (swiperContent.value.scrollLeft <= 0) {
canLeft.value = false
canRight.value = true
return
canLeft.value = false;
canRight.value = true;
return;
}
swiperContent.value.scrollLeft -= swiperItemWidth.value
swiperContent.value.scrollLeft -= swiperItemWidth.value;
}
// 更新箭头状态
canLeft.value = swiperContent.value.scrollLeft > 0
canRight.value = swiperContent.value.scrollLeft < swiperContent.value.scrollWidth - swiperContent.value.clientWidth
}
canLeft.value = swiperContent.value.scrollLeft > 0;
canRight.value = swiperContent.value.scrollLeft < swiperContent.value.scrollWidth - swiperContent.value.clientWidth;
};
const getInspectionList = async () => {
const res = await getScreenSafetyInspection(props.projectId)
const { code, data } = res
if (code === 200) {
console.log(violation_level_type.value)
data.map(item => {
item.label = violation_level_type.value.find((i) => i.value === item.violationType)?.label
})
inspectionList.value = data
}
}
const getInspectionList = () => {
getScreenSafetyInspection(projectIdTwo).then((res) => {
const { code, data } = res;
if (code === 200) {
console.log(violation_level_type.value);
data.map((item) => {
item.label = violation_level_type.value.find((i) => i.value === item.violationType)?.label;
});
inspectionList.value = data;
}
});
};
// 创建地球
const createEarth = () => {
window.YJ.on({
ws: true,
ws: true
// host: getIP(), //资源所在服务器地址
// username: this.loginForm.username, //用户名 可以不登录(不填写用户名),不登录时无法加载服务端的数据
// password: md5pass, //密码 生成方式md5(用户名_密码)
}).then((res) => {
let earth = new YJ.YJEarth("earth");
let earth = new YJ.YJEarth('earth');
window.Earth1 = earth;
YJ.Global.openRightClick(window.Earth1);
YJ.Global.openLeftClick(window.Earth1);
let view = {
"position": {
"lng": 102.03643298211526,
"lat": 34.393586474501,
"alt": 11298179.51993155
'position': {
'lng': 102.03643298211526,
'lat': 34.393586474501,
'alt': 11298179.51993155
},
"orientation": {
"heading": 360,
"pitch": -89.94481747201486,
"roll": 0
'orientation': {
'heading': 360,
'pitch': -89.94481747201486,
'roll': 0
}
}
loadBaseMap(earth.viewer)
};
loadBaseMap(earth.viewer);
YJ.Global.CesiumContainer(window.Earth1, {
compass: false, //罗盘
compass: false //罗盘
});
// YJ.Global.flyTo(earth, view);
// YJ.Global.setDefaultView(earth.viewer, view)
})
}
});
};
// 加载底图
const loadBaseMap = (viewer) => {
// 创建瓦片提供器
@ -146,14 +150,14 @@ const loadBaseMap = (viewer) => {
// 添加图层到视图
const layer = viewer.imageryLayers.addImageryProvider(imageryProvider);
}
};
onMounted(() => {
getInspectionList()
getInspectionList();
if (swiperContent.value && swiperContent.value.children.length > 0) {
swiperItemWidth.value = swiperContent.value.children[0].clientWidth + 20
swiperItemWidth.value = swiperContent.value.children[0].clientWidth + 20;
}
})
});
</script>
<style scoped lang="scss">

View File

@ -11,7 +11,7 @@
</div>
</div>
<div class="title">
<div>{{ currentProjectName }}</div>
<div>{{ projectName ? projectName : currentProjectName }}</div>
<div>施工现场数智化管理</div>
</div>
<div class="header_right">
@ -19,8 +19,12 @@
<!-- 左侧天气图标 + 日期文字 -->
<div class="left-section">
<div class="weather-list" @mouseenter="requestPause" @mouseleave="resumeScroll">
<div v-for="(item, i) in weatherList" :key="i" class="weather-item"
:style="{ transform: `translateY(-${offsetY}px)`, transition: transition }">
<div
v-for="(item, i) in weatherList"
:key="i"
class="weather-item"
:style="{ transform: `translateY(-${offsetY}px)`, transition: transition }"
>
<img :src="`/assets/demo/${item.icon}.png`" alt="" />
<div>{{ item.weather }}{{ item.tempMin }}°/{{ item.tempMax }}°</div>
<div>{{ item.week }}({{ item.date }})</div>
@ -60,7 +64,9 @@
import { ref, onMounted, onUnmounted } from 'vue';
import { getScreenSafetyDay, getScreenWeather } from '@/api/projectScreen';
import { useUserStoreHook } from '@/store/modules/user';
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
const projectName = urlParams.get('projectName');
const userStore = useUserStoreHook();
const currentProjectName = computed(() => userStore.selectedProject?.name);
@ -81,6 +87,10 @@ const props = defineProps({
isFull: {
type: Boolean,
default: false
},
projectName: {
type: String,
default: ''
}
});
@ -230,13 +240,13 @@ onUnmounted(() => {
text-align: center;
}
.title>div:first-child {
.title > div:first-child {
/* 第一个子元素的样式 */
font-size: 38px;
letter-spacing: 0.1em;
}
.title>div:last-child {
.title > div:last-child {
/* 最后一个子元素的样式 */
font-size: 26px;
}
@ -269,7 +279,7 @@ onUnmounted(() => {
display: flex;
align-items: center;
&>div:last-child {
& > div:last-child {
margin-left: 10px;
}

View File

@ -90,7 +90,8 @@ import Title from './title.vue';
import { getScreenNews, getScreenPeople } from '@/api/projectScreen/index';
import { mapOption } from './optionList';
import * as echarts from 'echarts';
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
const props = defineProps({
projectId: {
type: String,
@ -128,7 +129,7 @@ const showNewsDetail = (item: any) => {
* 获取项目人员出勤数据
*/
const getPeopleData = async () => {
const res = await getScreenPeople(props.projectId);
const res = await getScreenPeople(projectIdTwo);
const { data, code } = res;
if (code === 200) {
console.log(data);
@ -143,7 +144,7 @@ const getPeopleData = async () => {
* 获取项目新闻数据
*/
const getNewsData = async () => {
const res = await getScreenNews(props.projectId);
const res = await getScreenNews(projectIdTwo);
const { data, code } = res;
if (code === 200) {
news.value = data;

View File

@ -2,42 +2,46 @@
import { onMounted, ref, onUnmounted, defineProps } from 'vue';
import CesiumImageLabelEntity from '../js/CesiumImageLabelEntity.js';
import CesiumFlyToRoamingController from '../js/CesiumFlyToRoamingController.js';
import { setSelect, getSelectList, getGps, getModelList } from '@/api/projectScreen/index.ts'
import videoDialog from "./video.vue"
import { setSelect, getSelectList, getGps, getModelList } from '@/api/projectScreen/index.ts';
import videoDialog from './video.vue';
import { getToken } from '@/utils/auth';
import axios from 'axios';
import md5 from 'js-md5';
const defaultExpandedKeys = [1, 2, 3] //默认展开第一级节点
const defaultCheckedKeys = ref([]) //默认选中节点
const defaultExpandedKeys = [1, 2, 3]; //默认展开第一级节点
const defaultCheckedKeys = ref([]); //默认选中节点
const data = ref([]);
const deviceId = ref('');
const videoDialogRef = ref(null);
const token = getToken();
let ws = new ReconnectingWebSocket(import.meta.env.VITE_APP_BASE_WS_API + '?Authorization=' + token + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID + '&projectId=' + '1897160897167638529');
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
let ws = new ReconnectingWebSocket(
import.meta.env.VITE_APP_BASE_WS_API + '?Authorization=' + token + '&clientid=' + import.meta.env.VITE_APP_CLIENT_ID + '&projectId=' + projectIdTwo
);
// 连接ws
const connectWs = () => {
ws.onopen = (e) => {
// let message ={
// projectId:'1897160897167638529',
// }
// ws.send(JSON.stringify(message));
ws.onmessage = (e) => {
console.log('ws', e);
};
ws.onopen = (e) => {
// let message ={
// projectId:'1897160897167638529',
// }
// ws.send(JSON.stringify(message));
ws.onmessage = (e) => {
console.log('ws', e);
};
}
};
};
const props = defineProps({
isHide: {
type: Boolean,
default: true,
}
})
isHide: {
type: Boolean,
default: true
}
});
console.log('props', props);
const defaultProps = {
children: 'children',
label: 'label',
}
children: 'children',
label: 'label'
};
let entityManager = null;
window.deviceMap = new Map();
window.ModelList = new Map();
@ -48,299 +52,311 @@ let modelList = ref([]);
let roamingController = null;
// 获取模型列表
async function getModelListData() {
let res = await axios.post(import.meta.env.VITE_APP_BASE_EARTH_API + '/yjearth4.0/api/v1/user/sign-in',
{ "username": "admin", "password": "3598f66fbc93c0d5abd2dabab9de74cc" }
)
console.log('res', res.data);
if (res.data.code == 0) {
let toekn = res.data.data.token;
console.log('toekn', toekn);
let res1 = await axios({
url: import.meta.env.VITE_APP_BASE_EARTH_API + '/yjearth4.0/api/v1/source/list',
method: 'post',
data: {
data: { "page": 1, "page_size": 10 },
},
headers: {
'token': toekn
}
})
if (res1.data.code == 0) {
modelList.value = res1.data.data.list;
}
let res = await axios.post(import.meta.env.VITE_APP_BASE_EARTH_API + '/yjearth4.0/api/v1/user/sign-in', {
'username': 'admin',
'password': '3598f66fbc93c0d5abd2dabab9de74cc'
});
console.log('res', res.data);
if (res.data.code == 0) {
let toekn = res.data.data.token;
console.log('toekn', toekn);
let res1 = await axios({
url: import.meta.env.VITE_APP_BASE_EARTH_API + '/yjearth4.0/api/v1/source/list',
method: 'post',
data: {
data: { 'page': 1, 'page_size': 10 }
},
headers: {
'token': toekn
}
});
if (res1.data.code == 0) {
modelList.value = res1.data.data.list;
}
}
}
// 获取GPS数据
function getGpsData() {
getGps('1897160897167638529').then(res => {
console.log('res', res);
if (res.code === 200) {
data.value = res.data;
if (res.data.length > 0) {
res.data.forEach(element => {
list.value = [...list.value, ...element.children]
});
}
}
})
getGps(projectIdTwo).then((res) => {
console.log('res', res);
if (res.code === 200) {
data.value = res.data;
if (res.data.length > 0) {
res.data.forEach((element) => {
list.value = [...list.value, ...element.children];
});
}
}
});
}
// 设置选中节点
function setCheckedNode(idList) {
let obj = {
projectId: '1897160897167638529',
idList
}
setSelect(obj).then(res => {
console.log('res', res);
})
let obj = {
projectId: projectIdTwo,
idList
};
setSelect(obj).then((res) => {
console.log('res', res);
});
}
// 获取选中节点
function getCheckedNode() {
getSelectList({
projectId: '1897160897167638529'
}).then(res => {
if (res.code == 200) {
defaultCheckedKeys.value = res.data || []
}
})
getSelectList({
projectId: projectIdTwo
}).then((res) => {
if (res.code == 200) {
defaultCheckedKeys.value = res.data || [];
}
});
}
// 渲染无人机、摄像头、定位设备
function renderDevice(item) {
const imageEntity = new CesiumImageLabelEntity(Earth1.viewer, {
id: item.id,
position: {
lng: Number(item.lng),
lat: Number(item.lat),
height: 0
},
imageWidth: 64,
imageHeight: 64,
name: item.label || item.id,
imageUrl: `/image/${item.type}.png`,
onClick: (entity) => {
entityClickHandler(entity, item);
}
});
window.deviceMap.set(item.id, imageEntity);
const imageEntity = new CesiumImageLabelEntity(Earth1.viewer, {
id: item.id,
position: {
lng: Number(item.lng),
lat: Number(item.lat),
height: 0
},
imageWidth: 64,
imageHeight: 64,
name: item.label || item.id,
imageUrl: `/image/${item.type}.png`,
onClick: (entity) => {
entityClickHandler(entity, item);
}
});
window.deviceMap.set(item.id, imageEntity);
}
// 实体的点击事件
function entityClickHandler(entity, item) {
console.log('entity', entity, item);
if (item.type == 'camera') {
deviceId.value = 'AE9470016';
videoDialogRef.value.show();
videoDialogRef.value.videoPlay(deviceId.value);
}
console.log('entity', entity, item);
if (item.type == 'camera') {
deviceId.value = 'AE9470016';
videoDialogRef.value.show();
videoDialogRef.value.videoPlay(deviceId.value);
}
}
// 初始化地球
async function initEarth() {
let earth = new YJ.YJEarth('earth');
let earth = new YJ.YJEarth("earth");
window.Earth1 = earth;
// 加载底图
// earth.viewer.terrainProvider = Cesium.createWorldTerrain();
// Earth1.viewer
addArcgisLayer(Earth1.viewer, 'img_w')
// 添加倾斜数据
// 获取中心点
YJ.Global.CesiumContainer(window.Earth1, {
compass: false,//罗盘
legend: false, //图
});
// 创建实体管理器实例
list.value.forEach(item => {
if (defaultCheckedKeys.value.includes(item.id)) {
console.log("defaultCheckedKeys", item.id);
renderDevice(item)
}
});
roamingController = new CesiumFlyToRoamingController(window.Earth1.viewer, {
duration: 5, // 每个点之间飞行5秒
pitch: -89 // 20度俯角
});
window.roamingController = roamingController;
window.Earth1 = earth;
// 加载底图
// earth.viewer.terrainProvider = Cesium.createWorldTerrain();
// Earth1.viewer
addArcgisLayer(Earth1.viewer, 'img_w');
// 添加倾斜数据
// 获取中心点
YJ.Global.CesiumContainer(window.Earth1, {
compass: false, //罗盘
legend: false //图例
});
// 创建实体管理器实
list.value.forEach((item) => {
if (defaultCheckedKeys.value.includes(item.id)) {
console.log('defaultCheckedKeys', item.id);
renderDevice(item);
}
});
roamingController = new CesiumFlyToRoamingController(window.Earth1.viewer, {
duration: 5, // 每个点之间飞行5秒
pitch: -89 // 20度俯角
});
window.roamingController = roamingController;
}
async function loadTiltData(item) {
let tileset = new YJ.Obj.Tileset(window.Earth1, { id: item.source_id });
ModelList.set(item.source_id, tileset);
await tileset.on();
tileset.flyTo();
let tileset = new YJ.Obj.Tileset(window.Earth1, { id: item.source_id });
ModelList.set(item.source_id, tileset);
await tileset.on();
tileset.flyTo();
}
// 获取ArcGIS服务的URL
function getArcGisUrlByType(type) {
switch (type) {
//影像
case "img_w":
return "https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}";
//电子
case "vec_w":
return "https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer";
//蓝色底图
case "vec_blue":
return "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer";
//灰色底图
case "vec_gray":
return "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer";
//暖色底图
case "vec_warm":
return "http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer";
}
switch (type) {
//影像
case 'img_w':
return 'https://webst01.is.autonavi.com/appmaptile?style=6&x={x}&y={y}&z={z}';
//电子
case 'vec_w':
return 'https://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer';
//蓝色底图
case 'vec_blue':
return 'http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetPurplishBlue/MapServer';
//灰色底图
case 'vec_gray':
return 'http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetGray/MapServer';
//暖色底图
case 'vec_warm':
return 'http://map.geoq.cn/arcgis/rest/services/ChinaOnlineStreetWarm/MapServer';
}
}
// 添加ArcGIS图层
function addArcgisLayer(viewer, type) {
let url = getArcGisUrlByType(type)
const layerProvider = new Cesium.UrlTemplateImageryProvider({
url: url
});
viewer.imageryLayers.addImageryProvider(layerProvider);
let url = getArcGisUrlByType(type);
const layerProvider = new Cesium.UrlTemplateImageryProvider({
url: url
});
viewer.imageryLayers.addImageryProvider(layerProvider);
}
// 节点单击事件
function handleNodeClick(data) {
console.log('data', data);
let entity = window.deviceMap.get(data.id);
if (entity) {
entity.flyTo();
}
console.log('data', data);
let entity = window.deviceMap.get(data.id);
if (entity) {
entity.flyTo();
}
}
// 复选框选中事件
// 复选框选中事件
function handleCheck(checkedNodes, nodes) {
console.log('check', checkedNodes, nodes);
// 处理单个节点的通用函数
const handleNode = (node) => {
if (!window.deviceMap.has(node.id)) {
console.log("defaultCheckedKeys", node.id);
renderDevice(node);
} else {
const device = window.deviceMap.get(node.id);
// 根据当前显示状态切换显示/隐藏
device[device.entity.show ? 'hide' : 'show']();
}
};
// 处理选中的节点(可能是单个节点或包含子节点的集合)
if (checkedNodes?.children?.length) {
console.log('children', checkedNodes.children);
checkedNodes.children.forEach(handleNode);
console.log('check', checkedNodes, nodes);
// 处理单个节点的通用函数
const handleNode = (node) => {
if (!window.deviceMap.has(node.id)) {
console.log('defaultCheckedKeys', node.id);
renderDevice(node);
} else {
handleNode(checkedNodes);
const device = window.deviceMap.get(node.id);
// 根据当前显示状态切换显示/隐藏
device[device.entity.show ? 'hide' : 'show']();
}
};
setCheckedNode(nodes.checkedKeys);
// 处理选中的节点(可能是单个节点或包含子节点的集合)
if (checkedNodes?.children?.length) {
console.log('children', checkedNodes.children);
checkedNodes.children.forEach(handleNode);
} else {
handleNode(checkedNodes);
}
setCheckedNode(nodes.checkedKeys);
}
// 开始漫游
function startRoaming() {
if (roamingController) {
roamingController.startPathRoaming([
Cesium.Cartesian3.fromDegrees(106.49556855602525, 29.534393226355515, 200),
Cesium.Cartesian3.fromDegrees(106.49142431645038, 29.534472802500083, 200),
Cesium.Cartesian3.fromDegrees(106.49142125177437, 29.541881138875755, 200)
], 3, false);
} else {
console.log('请先初始化地球');
}
if (roamingController) {
roamingController.startPathRoaming(
[
Cesium.Cartesian3.fromDegrees(106.49556855602525, 29.534393226355515, 200),
Cesium.Cartesian3.fromDegrees(106.49142431645038, 29.534472802500083, 200),
Cesium.Cartesian3.fromDegrees(106.49142125177437, 29.541881138875755, 200)
],
3,
false
);
} else {
console.log('请先初始化地球');
}
}
// 停止漫游
function stopRoaming() {
if (roamingController) {
roamingController.stopRoaming();
} else {
console.log('请先初始化地球');
}
if (roamingController) {
roamingController.stopRoaming();
} else {
console.log('请先初始化地球');
}
}
onMounted(async () => {
// 连接ws
connectWs();
// 获取选中节点
getCheckedNode();
// 获取GPS数据
getGpsData();
await getModelListData();
await YJ.on({
username: 'admin',
password: md5('admin_admin123'),
host: 'http://192.168.110.2:8895/'
}).then((res) => {
initEarth();
modelList.value.forEach(item => {
loadTiltData(item)
})
// 连接ws
connectWs();
// 获取选中节点
getCheckedNode();
// 获取GPS数据
getGpsData();
await getModelListData();
await YJ.on({
username: 'admin',
password: md5('admin_admin123'),
host: 'http://192.168.110.2:8895/'
}).then((res) => {
initEarth();
modelList.value.forEach((item) => {
loadTiltData(item);
});
});
});
onUnmounted(() => {
window.deviceMap.forEach((item) => {
item.destroy();
})
window.deviceMap.clear();
window.roamingController.destroy();
window.Earth1.destroy();
})
window.deviceMap.forEach((item) => {
item.destroy();
});
window.deviceMap.clear();
window.roamingController.destroy();
window.Earth1.destroy();
});
</script>
<template>
<div class="earth-container-big">
<div class="earth" id="earth"></div>
<!-- <div v-show="isHide" class="left">
<div class="earth-container-big">
<div class="earth" id="earth"></div>
<!-- <div v-show="isHide" class="left">
<div style="width: 100%;height: 100%;">
<el-button type="primary" @click="startRoaming">开始漫游</el-button>
<el-button type="primary" @click="stopRoaming">停止漫游</el-button>
</div>
</div> -->
<div v-show="isHide" class="right">
<el-tree show-checkbox :data="data" :props="defaultProps" node-key="id" :expand-on-click-node="false"
:check-on-click-node="false" :check-on-click-leaf="false" :default-expanded-keys="defaultExpandedKeys"
:default-checked-keys="defaultCheckedKeys" @check="handleCheck" @node-click="handleNodeClick" />
</div>
<videoDialog :data="deviceId" ref="videoDialogRef"></videoDialog>
<div v-show="isHide" class="right">
<el-tree
show-checkbox
:data="data"
:props="defaultProps"
node-key="id"
:expand-on-click-node="false"
:check-on-click-node="false"
:check-on-click-leaf="false"
:default-expanded-keys="defaultExpandedKeys"
:default-checked-keys="defaultCheckedKeys"
@check="handleCheck"
@node-click="handleNodeClick"
/>
</div>
<videoDialog :data="deviceId" ref="videoDialogRef"></videoDialog>
</div>
</template>
<style lang="scss">
.earth-container-big {
position: relative;
position: relative;
width: 100%;
height: 100%;
.earth {
width: 100%;
height: 100%;
}
.earth {
width: 100%;
height: 100%;
}
.right {
top: 50%;
right: 0;
}
.left {
top: 50%;
left: 0;
}
.right,
.left {
position: absolute;
width: 400px;
height: 100%;
transform: translateY(-50%);
background-color: #00000052;
padding: 20px;
box-sizing: border-box;
z-index: 10;
.el-tree {
background-color: transparent;
--el-tree-node-hover-bg-color: transparent;
--el-tree-text-color: #fff;
.el-text {
color: azure;
}
.el-tree-node__content:hover {
background-color: transparent;
}
}
.right {
top: 50%;
right: 0;
}
.left {
top: 50%;
left: 0;
}
.right,
.left {
position: absolute;
width: 400px;
height: 100%;
transform: translateY(-50%);
background-color: #00000052;
padding: 20px;
box-sizing: border-box;
z-index: 10;
.el-tree {
background-color: transparent;
--el-tree-node-hover-bg-color: transparent;
--el-tree-text-color: #fff;
.el-text {
color: azure;
}
.el-tree-node__content:hover {
background-color: transparent;
}
}
}
}
</style>
</style>

View File

@ -16,30 +16,31 @@
</template>
<script setup lang="ts">
import { ref, onMounted, onUnmounted, nextTick } from "vue"
import Title from './title.vue'
import { ref, onMounted, onUnmounted, nextTick } from 'vue';
import Title from './title.vue';
import * as echarts from 'echarts';
import { pieOption, barOption } from './optionList';
import { getScreenLand, getScreenImgProcess, getScreenGeneralize } from '@/api/projectScreen';
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
const props = defineProps({
projectId: {
type: String,
default: 0
}
})
});
const generalize = ref()
const generalize = ref();
// 饼图相关
const pieChartRef = ref<HTMLDivElement | null>(null);
let pieChart: any = null;
const totalPercent = ref(0)
const totalPercent = ref(0);
// 折线图相关
const lineChartRef = ref<HTMLDivElement | null>(null);
let lineChart: any = null;
// 土地数据 折线图
const designAreaData = ref([])
const transferAreaData = ref([])
const designAreaData = ref([]);
const transferAreaData = ref([]);
// 饼图数据
let pieData = [
{ label: 'areaPercentage', name: '场区', value: 0 },
@ -47,8 +48,8 @@ let pieData = [
{ label: 'collectorLinePercentage', name: '集电线路', value: 0 },
{ label: 'exportLinePercentage', name: '送出线路', value: 0 },
{ label: 'substationPercentage', name: '升压站', value: 0 },
{ label: 'boxTransformerPercentage', name: '箱变', value: 0 },
]
{ label: 'boxTransformerPercentage', name: '箱变', value: 0 }
];
// 初始化饼图
const initPieChart = () => {
@ -56,14 +57,14 @@ const initPieChart = () => {
console.error('未找到饼图容器元素');
return;
}
pieOption.series.data = pieData
pieOption.graphic[0].style.text = totalPercent.value + '%'
pieOption.series.data = pieData;
pieOption.graphic[0].style.text = totalPercent.value + '%';
pieChart = echarts.init(pieChartRef.value, null, {
renderer: 'canvas',
useDirtyRect: false
});
pieChart.setOption(pieOption);
}
};
// 初始化折线图
const initLineChart = () => {
@ -71,55 +72,55 @@ const initLineChart = () => {
console.error('未找到折线图容器元素');
return;
}
barOption.series[0].data = designAreaData.value
barOption.series[1].data = transferAreaData.value
barOption.series[0].data = designAreaData.value;
barOption.series[1].data = transferAreaData.value;
lineChart = echarts.init(lineChartRef.value, null, {
renderer: 'canvas',
useDirtyRect: false
});
lineChart.setOption(barOption);
}
};
/**
* 获取项目土地统计数据
*/
const getScreenLandData = async () => {
const res = await getScreenLand(props.projectId);
const { data, code } = res
const res = await getScreenLand(projectIdTwo);
const { data, code } = res;
if (code === 200) {
designAreaData.value = data.map((item: any) => Number(item.designArea))
transferAreaData.value = data.map((item: any) => Number(item.transferArea))
designAreaData.value = data.map((item: any) => Number(item.designArea));
transferAreaData.value = data.map((item: any) => Number(item.transferArea));
initLineChart();
}
}
};
/**
* 获取项目形象进度数据
*/
const getScreenImgProcessData = async () => {
const res = await getScreenImgProcess(props.projectId);
const { data, code } = res
const res = await getScreenImgProcess(projectIdTwo);
const { data, code } = res;
if (code === 200) {
totalPercent.value = data.totalPercentage
totalPercent.value = data.totalPercentage;
pieData.forEach((item: any) => {
item.value = data[item.label]
})
pieData = pieData.filter((item: any) => item.value != '0.0')
console.log(pieData)
initPieChart()
item.value = data[item.label];
});
pieData = pieData.filter((item: any) => item.value != '0.0');
console.log(pieData);
initPieChart();
}
}
};
/**
* 获取项目概况数据
*/
const getScreenGeneralizeData = async () => {
const res = await getScreenGeneralize(props.projectId);
const { data, code, msg } = res
const res = await getScreenGeneralize(projectIdTwo);
const { data, code, msg } = res;
if (code === 200) {
generalize.value = msg
generalize.value = msg;
}
}
};
// 响应窗口大小变化
const handleResize = () => {
@ -129,9 +130,9 @@ const handleResize = () => {
// 组件挂载时初始化图表
onMounted(() => {
getScreenLandData()
getScreenImgProcessData()
getScreenGeneralizeData()
getScreenLandData();
getScreenImgProcessData();
getScreenGeneralizeData();
nextTick(() => {
initPieChart();
window.addEventListener('resize', handleResize);

View File

@ -1,15 +1,15 @@
<template>
<div class="large_screen">
<Header :projectId="projectId" :isFull="isFull" @changePage="handleChangePage" />
<Header :projectId="projectIdTwo ? projectIdTwo : projectId" :isFull="isFull" :projectName="projectName" @changePage="handleChangePage" />
<div class="nav">
<div class="nav_left" :style="{ left: isHideOther ? '-25vw' : '0' }">
<leftPage :projectId="projectId" />
<leftPage :projectId="projectIdTwo ? projectIdTwo : projectId" />
</div>
<div class="nav_center" :style="{ width: isFull ? '100%' : 'calc(50vw - 30px)' }">
<centerPage :projectId="projectId" :isHide="isFull" />
<centerPage :projectId="projectIdTwo ? projectIdTwo : projectId" :isHide="isFull" />
</div>
<div class="nav_right" :style="{ right: isHideOther ? '-25vw' : '0' }">
<rightPage :projectId="projectId" />
<rightPage :projectId="projectIdTwo ? projectIdTwo : projectId" />
</div>
</div>
</div>
@ -26,6 +26,10 @@ const userStore = useUserStoreHook();
const projectId = computed(() => userStore.selectedProject.id);
const isFull = ref(false);
const isHideOther = ref(false);
const urlParams = new URLSearchParams(new URL(window.location.href).search);
const projectIdTwo = urlParams.get('projectId');
const projectName = urlParams.get('projectName');
console.log(projectName);
/**
* 切换中心页面全屏