刘妍 2024-09-02 09:20:16 +08:00
commit 80fc630be1
4 changed files with 355 additions and 122 deletions

View File

@ -0,0 +1,223 @@
<template>
<div>
<a-row ::gutter="0">
<a-col :span="5">
<div class="RightBox">
<a-tooltip class="box-item" placement="top">
<template #title>
<span>上一年</span>
</template>
<a-button type="text" @click="handleSubYear">
<Icon icon="bi:chevron-double-left" style="color: #ffffff" :size="30" />
</a-button>
</a-tooltip>
<a-tooltip class="box-item" placement="top">
<template #title>
<span>上一月</span>
</template>
<a-button type="text" style="margin-left: 10px" @click="handleSubMouth">
<Icon icon="bi:chevron-left" style="color: #ffffff" :size="30" />
</a-button>
</a-tooltip>
<a-tooltip class="box-item" placement="top">
<template #title>
<span>播放/暂停</span>
</template>
<a-button type="text" style="margin-left: 10px" @click="handlePlay">
<Icon v-if="!playSwitch" icon="bi:play-circle" style="color: #ffffff" :size="30" />
<Icon v-if="playSwitch" icon="bi:pause-circle" style="color: #ffffff" :size="30" />
</a-button>
</a-tooltip>
<a-tooltip class="box-item" placement="top">
<template #title>
<span>下一月</span>
</template>
<a-button type="text" style="margin-left: 10px" @click="handleAddMouth">
<Icon icon="bi:chevron-right" style="color: #ffffff" :size="30" />
</a-button>
</a-tooltip>
<a-tooltip class="box-item" placement="top">
<template #title>
<span>下一年</span>
</template>
<a-button type="text" style="margin-left: 10px" @click="handleAddYear">
<Icon icon="bi:chevron-double-right" style="color: #ffffff" :size="30" />
</a-button>
</a-tooltip>
</div>
</a-col>
<a-col :span="19">
<div class="timeBox">
<a-slider
v-model:value="value"
:tooltipOpen="true"
:tip-formatter="getValue"
:marks="marks"
:step="1"
:max="maxDays"
:min="1"
@afterChange="sliderChange"
>
<template #mark="{ label, point }">
<template v-if="label.slice(-2) == '01'">
<span :style="{ color: 'white' }">{{ label }}</span>
</template>
<template v-if="label.slice(-4) == '1231'">
<span :style="{ color: 'white' }">{{ label }}</span>
</template>
</template>
</a-slider>
</div>
</a-col>
</a-row>
<!-- </div>
<div class="timeBox">
-->
</div>
</template>
<script lang="ts" setup>
// vue
import { ref, watch, computed, onBeforeMount, onMounted, onBeforeUpdate, onUpdated } from 'vue';
import Icon from '@/components/Icon/Icon.vue';
import dayjs from 'dayjs';
const emit = defineEmits(['handleNowValueChange']);
const value = ref<number>(parseInt(dayjs().dayOfYear()));
const marks = ref<Record<number, any>>();
const maxDays = ref(365);
const calculateDayOfYearAndDates = (time) => {
const startDate = dayjs(time).startOf('year');
const endDate = dayjs(time).endOf('year');
// marks
marks.value = {};
maxDays.value = parseInt(endDate.dayOfYear());
for (
let currentDate = startDate;
currentDate.isBefore(endDate);
currentDate = currentDate.add(1, 'day')
) {
const dayOfYear = parseInt(currentDate.dayOfYear());
const dateString = currentDate.format('YYYYMMDD');
marks.value[dayOfYear] = dateString;
}
};
const getValue = (key: number) => {
if (marks.value) {
return marks.value[key];
} else {
return key;
}
};
//
const sliderChange = (key: number) => {
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
playSwitch.value = false;
};
// /
const playSwitch = ref(false);
const handlePlay = () => {
playSwitch.value = !playSwitch.value;
if (playSwitch.value && value.value < maxDays.value) {
addValue();
}
};
function addValue() {
console.log(playSwitch.value);
if (playSwitch.value) {
setTimeout(() => {
value.value = parseInt(dayjs(getValue(value.value)).add(7, 'day').dayOfYear());
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
addValue();
}, 1000);
}
}
//
const handleSubYear = () => {
if (isLeapYear(dayjs(getValue(value.value)).year()) && value.value > 58) {
value.value -= 1;
}
if (isLeapYear(dayjs(getValue(value.value)).year() - 1) && value.value > 58) {
value.value += 1;
}
calculateDayOfYearAndDates(dayjs(getValue(value.value)).add(-1, 'year'));
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
playSwitch.value = false;
};
//
const handleSubMouth = () => {
if (value.value <= 31) {
calculateDayOfYearAndDates(dayjs(getValue(value.value)).add(-1, 'month'));
value.value = parseInt(dayjs(getValue(value.value)).add(11, 'month').dayOfYear());
} else {
value.value = parseInt(dayjs(getValue(value.value)).add(-1, 'month').dayOfYear());
}
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
playSwitch.value = false;
};
//
const handleAddMouth = () => {
if (value.value >= parseInt(dayjs(dayjs().year() + '-12-01').dayOfYear())) {
calculateDayOfYearAndDates(dayjs(getValue(value.value)).add(1, 'month'));
value.value = parseInt(dayjs(getValue(value.value)).add(-11, 'month').dayOfYear());
} else {
value.value = parseInt(dayjs(getValue(value.value)).add(1, 'month').dayOfYear());
}
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
playSwitch.value = false;
};
//
const handleAddYear = () => {
if (isLeapYear(dayjs(getValue(value.value)).year()) && value.value > 58) {
value.value -= 1;
}
if (isLeapYear(dayjs(getValue(value.value)).year() + 1) && value.value > 58) {
value.value += 1;
}
calculateDayOfYearAndDates(dayjs(getValue(value.value)).add(1, 'year'));
emit('handleNowValueChange', [dayjs(getValue(1)), dayjs(getValue(value.value))]);
playSwitch.value = false;
};
///
function isLeapYear(y: number): boolean {
return (y % 4 === 0 && y % 100 !== 0) || y % 400 === 0;
}
onMounted(() => {
calculateDayOfYearAndDates(dayjs());
});
</script>
<style lang="less" scoped>
.timeBox {
position: relative;
top: 40px;
width: 900px;
}
.RightBox {
position: relative;
top: 40px;
width: 300px;
}
.box-item {
justify-content: center;
width: 25px;
Icon {
display: flex;
}
}
</style>

View File

@ -4,12 +4,18 @@
<div class="title"> 图层列表 </div> <div class="title"> 图层列表 </div>
<div class="case-tree"> <div class="case-tree">
<a-directory-tree <a-directory-tree
v-model:expandedKeys="expandedKeys"
v-model:selectedKeys="selectedKeys" v-model:selectedKeys="selectedKeys"
v-model:checkedKeys="checkedKeys"
multiple
:tree-data="treeData" :tree-data="treeData"
@select="onSelect" @select="onSelect"
/> />
</div> </div>
</div> </div>
<div class="timeLineBox">
<TimeLine @handleNowValueChange="handleNowValueChange" />
</div>
<div> <div>
<MapComponent <MapComponent
ref="mapboxComponentRef" ref="mapboxComponentRef"
@ -37,26 +43,17 @@
import type { TreeProps } from 'ant-design-vue'; import type { TreeProps } from 'ant-design-vue';
// vben // vben
import { useMessage } from '@/hooks/web/useMessage'; import { useMessage } from '@/hooks/web/useMessage';
//
import MapComponent from '@/views/demo/system/geoservermanagement/clound/mapComponent.vue'; import MapComponent from '@/views/demo/system/geoservermanagement/clound/mapComponent.vue';
import TimeLine from './TimeLine.vue';
import { import {
AchievementManageAddImageexif,
AchievementManageIntactById,
AchievementManageAddTask,
AchievementManageListTask, AchievementManageListTask,
AchievementManageListDroneShpImageexif, AchievementManageListDroneShpImageexif,
GeoTiffManagerUpdateGeoTiff,
GeoTiffManagerLoadPage, GeoTiffManagerLoadPage,
GeoTiffManagerGet,
getGeomData, getGeomData,
getStatisticalList,
ShpGeoLayerAdd,
ShpGeoLayerLoadPage, ShpGeoLayerLoadPage,
ShpGeoLayerGet,
ShpGeoLayerUpdateLayer,
ShpGeoLayerDelete,
ShpGeoLayerParseShpInfo,
} from '@/api/demo/system'; } from '@/api/demo/system';
import { prepareTreeData, prepareTreeData2, prepareTreeData3 } from './util'; import { prepareTreeData } from './util';
import dayjs from 'dayjs'; import dayjs from 'dayjs';
// //
import { getAppEnvConfig } from '@/utils/env'; import { getAppEnvConfig } from '@/utils/env';
@ -66,12 +63,18 @@
const { createMessage } = useMessage(); const { createMessage } = useMessage();
const selectedKeys = ref<string[]>([]); const selectedKeys = ref<string[]>([]);
const expandedKeys = ref<string[]>(['1', '2', '3']);
const checkedKeys = ref<string[]>([]);
const treeData: any = ref(prepareTreeData); const treeData: any = ref(prepareTreeData);
let tableData1: any = []; let tableData1: any = [];
let tableData2: any = []; let tableData2: any = [];
let tableData3: any = []; let tableData3: any = [];
let tableData3_id_list: any = [];
let tableData3_tupian: any = []; let tableData3_tupian: any = [];
let startTime = dayjs().startOf('year').format('YYYY-MM-DD HH:mm:ss');
let endTime = dayjs().endOf('day').format('YYYY-MM-DD HH:mm:ss');
// //
function fetch() { function fetch() {
// //
@ -108,6 +111,9 @@
pageSize: 100, pageSize: 100,
}).then((res) => { }).then((res) => {
tableData3 = res.items; tableData3 = res.items;
res.items.forEach((item) => {
tableData3_id_list.push(item.id);
});
tableData3_tupian = []; tableData3_tupian = [];
treeData.value[2].children = []; treeData.value[2].children = [];
res.items.forEach((item1) => { res.items.forEach((item1) => {
@ -162,88 +168,81 @@
// ref // ref
const mapboxComponentRef = ref(); const mapboxComponentRef = ref();
let selectedKeys_now: any;
let info_now: any;
// //
const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => { const onSelect: TreeProps['onSelect'] = (selectedKeys, info) => {
console.log(177, selectedKeys, info); // console.log(177, selectedKeys, info);
if (!['1', '2', '3'].includes(selectedKeys[selectedKeys.length - 1])) { selectedKeys_now = selectedKeys;
// - info_now = info;
if (info?.node?.parent?.key == '1') { let filter_hangfei = [];
tableData1.forEach((data) => { selectedKeys.forEach((selectedKey) => {
if (selectedKeys[0] == data.id) { if (!['1', '2', '3'].includes(selectedKey)) {
// // // -
// getGeomData({ dataTable: data.dataTable }).then((res) => { if (info?.node?.parent?.key == '1') {
// if (res == undefined) { let tabledata = getDataByTypeAndTime(1);
// createMessage.error(''); tabledata.forEach((data) => {
// } else { if (selectedKey == data.id) {
// let st: any = res.slice(6, -1); mapboxComponentRef.value.GeoserverManagementRaster(
// st = st.split(' '); data,
mapboxComponentRef.value.GeoserverManagementRaster( [118.30207505530701, 35.30123435040745],
data, 7.848587811931849,
[118.30207505530701, 35.30123435040745], );
7.848587811931849, }
); });
// } }
// }); // -
} else if (info?.node?.parent?.key == '2') {
}); let tabledata = getDataByTypeAndTime(2);
} tabledata.forEach((data) => {
// - if (selectedKey == data.id) {
else if (info?.node?.parent?.key == '2') { mapboxComponentRef.value.GeoTiffManagerRaster(
tableData2.forEach((data) => { data,
if (selectedKeys[0] == data.id) { [118.30207505530701, 35.30123435040745],
// let bbox = getBboxFromUrl(data.accessUrl); 7.848587811931849,
// let lngLat = getCenterPoint(bbox); );
mapboxComponentRef.value.GeoTiffManagerRaster( }
data, });
[118.30207505530701, 35.30123435040745], }
7.848587811931849, // -
); else if (tableData3_id_list.includes(selectedKey)) {
} tableData3.forEach((data) => {
}); if (selectedKey == data.id) {
} if (data.imageCount > 0) {
// - tableData3_tupian.forEach((tupian) => {
else if (info?.node?.parent?.key == '3') { if (tupian.taskId == data.id) {
// console.log('3', selectedKeys, info); if (
tableData3.forEach((data) => { dayjs(startTime).isBefore(data.uploadTime) &&
if (selectedKeys[0] == data.id) { dayjs(endTime).isAfter(data.uploadTime)
AchievementManageListDroneShpImageexif({ ) {
pageIndex: 1, filter_hangfei.push(tupian);
pageSize: data.imageCount, }
}).then((res) => { }
if (res.items.length > 0) { });
handlerUpdateTaskLayerData(res.items);
} else { } else {
createMessage.info('当前选中的任务并无航飞图片'); createMessage.info('当前选中的任务并无航飞图片');
} }
}); }
} });
}); }
} // -
// - else {
else { let filter = tableData3_tupian.filter((item) => item.id == selectedKey);
let filter = tableData3_tupian.filter((item) => item.id == selectedKeys); filter?.forEach((f) => {
handlerUpdateTaskLayerData(filter); filter_hangfei.push(f);
});
}
} }
});
console.log(236, filter_hangfei);
// -
if (filter_hangfei.length > 0) {
handlerUpdateTaskLayerData(filter_hangfei);
} else {
mapboxComponentRef.value.clearTaskLayer('AchievementManageRaster');
} }
}; };
// - bbox
function getBboxFromUrl(url) {
const urlObj = new URL(url);
const params = new URLSearchParams(urlObj.search);
const bbox = params.get('bbox');
return bbox;
}
// -
function getCenterPoint(bbox) {
const coords = bbox.split(',').map((coord) => parseFloat(coord));
const [minLon, minLat, maxLon, maxLat] = coords;
const centerLon = (minLon + maxLon) / 2;
const centerLat = (minLat + maxLat) / 2;
return [centerLon, centerLat];
}
// - // -
function handlerUpdateTaskLayerData(tasklist) { function handlerUpdateTaskLayerData(tasklist) {
let taskLayerGeoJson = { let taskLayerGeoJson = {
@ -272,8 +271,6 @@
taskLayerGeoJson.features.push(feature); taskLayerGeoJson.features.push(feature);
}); });
// zoom
// let result = calculateCenterAndZoom(lngList, latList);
// - // -
mapboxComponentRef.value.AchievementManageRaster( mapboxComponentRef.value.AchievementManageRaster(
taskLayerGeoJson, taskLayerGeoJson,
@ -297,30 +294,41 @@
} }
} }
// -zoom //
function calculateCenterAndZoom(lngList, latList) { function getDataByTypeAndTime(type): any {
// let result: any = [];
if (!lngList || !latList || lngList.length !== latList.length) { switch (type) {
throw new Error(''); case 1:
tableData1.forEach((data) => {
if (
dayjs(startTime).isBefore(data.createTime) &&
dayjs(endTime).isAfter(data.createTime)
) {
result.push(data);
}
});
break;
case 2:
tableData2.forEach((data) => {
if (
dayjs(startTime).isBefore(data.createTime) &&
dayjs(endTime).isAfter(data.createTime)
) {
result.push(data);
}
});
break;
} }
// return result;
const centerLng = lngList.reduce((acc, lng) => acc + lng, 0) / lngList.length;
const centerLat = latList.reduce((acc, lat) => acc + lat, 0) / latList.length;
//
const minLng = Math.min(...lngList);
const maxLng = Math.max(...lngList);
const minLat = Math.min(...latList);
const maxLat = Math.max(...latList);
const deltaLng = maxLng - minLng;
const deltaLat = maxLat - minLat;
//
let zoom = 14 - Math.log2(Math.max(deltaLng, deltaLat)); // 使
zoom = Math.max(8, Math.min(15, zoom)); //
return {
center: [centerLng, centerLat],
zoomLevel: zoom,
};
} }
//
function handleNowValueChange(value) {
startTime = dayjs(value[0]).startOf('year').format('YYYY-MM-DD HH:mm:ss');
endTime = dayjs(value[1]).format('YYYY-MM-DD HH:mm:ss');
onSelect(selectedKeys_now, info_now);
}
onMounted(() => { onMounted(() => {
fetch(); fetch();
}); });
@ -356,13 +364,13 @@
</script> </script>
<style type="less" scoped> <style type="less" scoped>
.case-tree-container { .case-tree-container {
width: 300px; width: 320px;
height: 720px; height: 720px;
background: #041b36; background: #041b36;
position: absolute; position: absolute;
z-index: 1; z-index: 1;
top: 100px; bottom: 20px;
margin-bottom: 20px; left: 20px;
} }
.title { .title {
@ -384,6 +392,15 @@
overflow: auto; overflow: auto;
} }
::v-deep .case-tree { .timeLineBox {
position: absolute;
z-index: 1;
left: 420px;
bottom: 20px;
width: 1200px;
height: 120px;
border: 2px #155dd8;
background-color: rgba(0, 0, 0, 0.5);
border-radius: 60px / 60px;
} }
</style> </style>

View File

@ -9,9 +9,6 @@
<a-tab-pane key="3" tab="航飞图片"> <a-tab-pane key="3" tab="航飞图片">
<AchievementManage ref="AchievementManageRef" /> <AchievementManage ref="AchievementManageRef" />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="4" tab="成果展示">
<Display ref="DisplayRef" />
</a-tab-pane>
</a-tabs> </a-tabs>
</template> </template>
<script setup lang="ts"> <script setup lang="ts">
@ -20,17 +17,14 @@
import GeoserverManagement from '@/views/demo/system/geoservermanagement/index.vue'; import GeoserverManagement from '@/views/demo/system/geoservermanagement/index.vue';
import GeoTiffManager from './GeoTiffManager/index.vue'; import GeoTiffManager from './GeoTiffManager/index.vue';
import AchievementManage from './AchievementManage/index.vue'; import AchievementManage from './AchievementManage/index.vue';
import Display from './Display/index.vue';
const activeKey = ref('4'); const activeKey = ref('1');
// //
const GeoserverManagementRef = ref(); const GeoserverManagementRef = ref();
// //
const GeoTiffManagerRef = ref(); const GeoTiffManagerRef = ref();
// //
const AchievementManageRef = ref(); const AchievementManageRef = ref();
//
const DisplayRef = ref();
function changeTabs(activeKey) { function changeTabs(activeKey) {
console.log(activeKey); console.log(activeKey);
@ -40,8 +34,6 @@
// //
} else if (activeKey == 3) { } else if (activeKey == 3) {
// //
} else if (activeKey == 4) {
//
} }
} }
</script> </script>

View File

@ -331,6 +331,7 @@
GeoTiffManagerRaster, GeoTiffManagerRaster,
AchievementManageRaster, AchievementManageRaster,
resize, resize,
clearTaskLayer,
}); });
</script> </script>
<style type="less" scoped> <style type="less" scoped>