云查询主题结果弹窗

dianlixunjian
滕嵩 2024-09-09 17:33:50 +08:00
parent 0fc79b9538
commit ec9686791c
3 changed files with 331 additions and 244 deletions

View File

@ -2,7 +2,9 @@
<div class="show-map-div">
<div class="select-menu">
<div class="add-on-map" v-if="selectType !== 2">
<a-checkbox v-model:checked="addOnMap" @change="(e) => addOnMapChange(e.target.checked)">叠加到地图</a-checkbox>
<a-checkbox v-model:checked="addOnMap" @change="(e) => addOnMapChange(e.target.checked)">
叠加到地图
</a-checkbox>
</div>
<a-radio-group v-model:value="selectType" button-style="solid" size="small">
<a-radio-button :value="0">专题图</a-radio-button>
@ -11,210 +13,282 @@
</a-radio-group>
</div>
<template v-if="selectType === 0 && !addOnMap">
<a-image
:width="470"
:height="470"
:src="showData?.url"
/>
<a-image :width="470" :height="470" :src="showData?.url" />
</template>
<template v-if="selectType === 1 && !addOnMap">
<a-image
:width="470"
:height="470"
:src="showData.screenshotImage"
/>
<a-image :width="470" :height="470" :src="showData?.url" />
</template>
<template v-if="selectType === 2 || addOnMap">
<ModalMap :width="'470px'" :height="'470px'" @getMap="getMap"/>
<ModalMap :width="'470px'" :height="'470px'" @getMap="getMap" />
</template>
</div>
<a-tabs v-model:activeKey="type">
<a-tabs v-model:activeKey="activeKey">
<a-tab-pane key="1" tab="土地分类">
<ShowTableList
:columns="landClassificationColumns"
<ShowTableList
:columns="landClassificationColumns"
:data="landClassifyTable"
:title="'土地利用现状查询结果'"/>
:title="'土地利用现状查询结果'"
/>
</a-tab-pane>
<a-tab-pane key="2" tab="耕地占用">
<ShowTableList
:columns="landPlanningColumns"
<ShowTableList
:columns="landPlanningColumns"
:data="plowLandOccupyTable"
:title="'土地规划查询结果'"/>
:title="'土地规划查询结果'"
/>
</a-tab-pane>
</a-tabs>
</template>
<script setup lang="ts">
import { ref, defineProps, computed, watch, onMounted } from "vue"
import ShowTableList from '@/views/dashboard/test/components/ShowTableList/index.vue'
import ModalMap from './ModalMap/index.vue'
import { ref, defineProps, computed, watch, onMounted } from 'vue';
import ShowTableList from '@/views/dashboard/test/components/ShowTableList/index.vue';
import ModalMap from './ModalMap/index.vue';
import mapboxgl from 'mapbox-gl';
//
import { getAppEnvConfig } from '@/utils/env';
const { VITE_GLOB_API_URL } = getAppEnvConfig();
const VITE_GLOB_API_URL_VAR = ref<String>(VITE_GLOB_API_URL + '/');
const props = defineProps(['data'])
let map
onMounted(() => {
if(props.data){
type.value = props.data[0].name
const props = defineProps(['data']);
let map;
onMounted(() => {
if (props.data) {
activeKey.value = '1';
props.data.forEach((d) => {
d.url = isValidUrl(d.url) ? d.url : VITE_GLOB_API_URL_VAR.value + d.url;
});
}
});
// URL
function isValidUrl(url: string): boolean {
const regex =
/^(?:http|ftp)s?:\/\/(?:(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+(?:[A-Z]{2,6}\.?|[A-Z0-9-]{2,}\.?)|localhost|\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}|\[?[A-F0-9]*:[A-F0-9:]+\]?)(?::\d+)?(?:\/?|[\/?]\S+)$/i;
return regex.test(url);
}
})
const type = ref('1')
const landClassifyTable = computed(() => {
let data
props.data?.forEach(item => {
if(item.name == '土地分类'){
data = {...item}
const activeKey = ref('1');
watch(
() => activeKey.value,
() => {
selectType.value = 2;
addOnMap.value = false;
},
);
const landClassifyTable = computed(() => {
let data;
props.data?.forEach((item) => {
console.log(props.data);
if (item.name == '土地分类') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
return data && data.list;
});
const plowLandOccupyTable = computed(() => {
let data;
props.data?.forEach((item) => {
if (item.name == '耕地占用') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
return data && data.list;
});
const showData = computed(() => {
let data;
switch (activeKey.value) {
case '1':
props.data?.forEach((item) => {
if (item.name == '土地分类') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
return data;
case '2':
props.data?.forEach((item) => {
if (item.name == '耕地占用') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
return data;
}
})
return data && data.list
})
const plowLandOccupyTable = computed(() => {
let data
props.data?.forEach(item => {
if(item.name == '耕地分类'){
data = {...item}
}
})
return data && data.list
})
const showData = computed(() => {
let data
switch(type.value){
case '1':
props.data?.forEach(item => {
if(item.name == '土地分类'){
data = {...item}
});
const addOnMap = ref(false);
const selectType = ref(2);
const landClassificationColumns = [
{
title: '地类名称',
dataIndex: 'type',
key: 'type',
sorter: (a, b) => a.landName - b.landName,
sortDirections: ['descend', 'ascend'],
},
{
title: '联合属性',
dataIndex: 'stats',
key: 'stats',
sorter: (a, b) => a.stats.length - b.stats.length,
sortDirections: ['descend', 'ascend'],
},
{
title: '面积(亩)',
dataIndex: 'area',
key: 'area',
sorter: (a, b) => a.area - b.area,
sortDirections: ['descend', 'ascend'],
},
];
const landPlanningColumns = [
{
title: '类型',
dataIndex: 'type',
key: 'type',
sorter: (a, b) => a.type.length - b.type.length,
sortDirections: ['descend', 'ascend'],
},
{
title: '面积(亩)',
dataIndex: 'area',
key: 'area',
sorter: (a, b) => a.area - b.area,
sortDirections: ['descend', 'ascend'],
},
];
const getMap = (value) => {
map = value;
};
//
const preloadImage = (url: string): Promise<string> => {
return new Promise((resolve, reject) => {
const img = new Image();
img.onload = () => {
resolve(url);
};
img.onerror = (error) => {
reject(error);
};
img.src = url;
});
};
const addOnMapChange = (value) => {
setTimeout(async () => {
let url = '';
let fourpoint = '';
if (value) {
let data = {};
if (activeKey.value == '1') {
props.data.forEach((item) => {
if (item.name == '土地分类') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
} else if (activeKey.value == '2') {
props.data.forEach((item) => {
if (item.name == '耕地占用') {
data = { ...item };
data.url = isValidUrl(data.url) ? data.url : VITE_GLOB_API_URL_VAR.value + data.url;
}
});
}
})
return data
case '2':
props.data?.forEach(item => {
if(item.name == '耕地分类'){
data = {...item}
if (selectType.value == 0 || selectType.value == 1) {
url = data.url;
fourpoint = JSON.parse(`[${data.fourpoint}]`);
}
let image = new Image();
image.crossOrigin = 'anonymous';
image.src = url;
image.onload = () => {
console.log(205, image);
// Canvas
const canvas = document.createElement('canvas');
canvas.width = image.width;
canvas.height = image.height;
// Canvas
const ctx = canvas.getContext('2d');
// Canvas
ctx.drawImage(image, 0, 0, image.width, image.height);
// CanvasURL
const dataURL = canvas.toDataURL('image/jpeg');
console.log(216, dataURL);
//
if (map.getSource('radar')) {
map.removeSource('radar');
map.removeLayer('radar-layer');
}
})
return data
}
})
const addOnMap = ref(false)
const selectType = ref(0)
const landClassificationColumns = [
{
title: '地类名称',
dataIndex: 'type',
key: 'type',
sorter:(a,b) => a.landName - b.landName,
sortDirections: ['descend', 'ascend'],
},
{
title: '联合属性',
dataIndex: 'stats',
key: 'stats',
sorter:(a,b) => a.stats.length - b.stats.length,
sortDirections: ['descend', 'ascend'],
},
{
title: '面积(亩)',
dataIndex: 'area',
key: 'area',
sorter:(a,b) => a.area - b.area,
sortDirections: ['descend', 'ascend'],
},
]
const landPlanningColumns = [
{
title: '类型',
dataIndex: 'type',
key: 'type',
sorter:(a,b) => a.type.length - b.type.length,
sortDirections: ['descend', 'ascend'],
},
{
title: '面积(亩)',
dataIndex: 'area',
key: 'area',
sorter:(a,b) => a.area - b.area,
sortDirections: ['descend', 'ascend'],
},
]
const getMap = (value) => {
map = value
}
const addOnMapChange = (value) => {
setTimeout(() => {
let url= ''
let fourpoint = ''
if(value){
let data = {}
if(type.value == '1'){
props.data.forEach(item => {
if(item.name == '土地分类'){
data = {...item}
//
map.addSource('radar', {
type: 'image',
url: dataURL,
coordinates: fourpoint,
// coordinates: [
// [118.79657110932101, 35.1014168593995],
// [118.79971349626699, 35.1014168593995],
// [118.79971349626699, 35.0976945740112],
// [118.79371349626699, 35.0976945740112],
// ],
});
map.addLayer({
id: 'radar-layer',
type: 'raster',
source: 'radar',
paint: {
'raster-fade-duration': 0,
},
});
let x = 0;
let y = 0;
let length = fourpoint.length;
for (let i = 0; i < fourpoint.length; i++) {
x = x + fourpoint[i][0];
y = y + fourpoint[i][1];
}
})
}else if(type.value == '2'){
props.data.forEach(item => {
if(item.name == '耕地分类'){
data = {...item}
}
})
x = x / length;
y = y / length;
map.flyTo({
center: [fourpoint[0][0], fourpoint[0][1]],
zoom: 14,
});
};
}
if(selectType.value == 0){
url = data.url
fourpoint = JSON.parse(`[${data.fourpoint}]`)
}
}
map.addSource('radar', {
type: 'image',
url:url,
coordinates: fourpoint
});
map.addLayer({
id: 'radar-layer',
type: 'raster',
source: 'radar',
paint: {
'raster-fade-duration': 0
}
});
let x = 0
let y = 0
let length = fourpoint.length
for(let i = 0; i < fourpoint.length; i++){
x = x + fourpoint[i][0]
y = y + fourpoint[i][1]
}
x = x / length
y = y / length
map.flyTo({
center: [x,y],
zoom: 14,
});
},500)
}
}, 1000);
};
</script>
<style lang="scss" scoped>
.select-menu{
display: flex;
position: absolute;
top: 10px;
right: 10px;
z-index: 100;
.add-on-map{
width: 110px;
background: rgba(0, 0, 0, 0.2);
.select-menu {
display: flex;
align-items: center;
justify-content: center;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
position: absolute;
top: 10px;
right: 10px;
z-index: 100;
.add-on-map {
width: 110px;
background: rgba(0, 0, 0, 0.2);
display: flex;
align-items: center;
justify-content: center;
border-top-left-radius: 5px;
border-bottom-left-radius: 5px;
}
}
.show-map-div {
width: 470px;
height: 470px;
position: relative;
}
}
.show-map-div{
width: 470px;
height: 470px;
position: relative;
}
</style>

View File

@ -11,61 +11,65 @@
</div>
<div style="display: flex; width: 100%">
<div :style="`display: block; width: ${compare ? '50%' : '100%'};`">
<CloudQueryModal :info="info"/>
<CloudQueryModal :info="info" />
</div>
<div style="display: block; width: 50%; margin-left: 20px" v-if="compare">
<CloudQueryModal :info="info"/>
<CloudQueryModal :info="info" />
</div>
</div>
</div>
</template>
<script setup lang="ts">
import { ref, onMounted, defineEmits } from "vue"
import Icon from '@/components/Icon/Icon.vue';
import CloudQueryModal from './CloudQueryModal/index.vue';
import { useCloudQueryStore } from '@/store/modules/cloudquery';
import { LoadCloudQueryById } from '@/api/demo/cloudQuery'
import { ref, onMounted, defineEmits } from 'vue';
import Icon from '@/components/Icon/Icon.vue';
import CloudQueryModal from './CloudQueryModal/index.vue';
import { useCloudQueryStore } from '@/store/modules/cloudquery';
import { LoadCloudQueryById } from '@/api/demo/cloudQuery';
const useCloudQuery = useCloudQueryStore();
const emits = defineEmits(['changeCompare'])
const compare = ref(false);
const info = ref()
const changeCompare = () => {
compare.value = !compare.value;
console.log('compare.value', compare.value);
emits('changeCompare', compare.value)
};
onMounted(() => {
let id = useCloudQuery.getCloudQueryInfo.id
LoadCloudQueryById({id}).then(res => {
let data = JSON.parse(res.receiveContent)
info.value = data
})
})
const useCloudQuery = useCloudQueryStore();
const emits = defineEmits(['changeCompare']);
const compare = ref(false);
const info = ref();
const changeCompare = () => {
compare.value = !compare.value;
console.log('compare.value', compare.value);
emits('changeCompare', compare.value);
};
onMounted(() => {
let id = useCloudQuery.getCloudQueryInfo.id;
// console.log(41, useCloudQuery.getCloudQueryInfo);
LoadCloudQueryById({ id }).then((res) => {
let data = JSON.parse(res.receiveContent);
if (typeof data == 'string') {
data = JSON.parse(data);
}
info.value = data;
});
});
</script>
<style lang="scss" scoped>
.modal-content-div {
padding: 53px 20px 10px 20px;
width: 100%;
.title-text {
display: flex;
justify-content: center;
font-size: 18px;
color: #2f83d9;
text-decoration: underline;
font-weight: 600;
position: relative;
.modal-content-div {
padding: 53px 20px 10px 20px;
width: 100%;
.title-text {
display: flex;
justify-content: center;
font-size: 18px;
color: #2f83d9;
text-decoration: underline;
font-weight: 600;
position: relative;
}
.split-button {
font-size: 20px;
display: inline-flex;
position: absolute;
right: 8px;
top: 2px;
color: #000000a3;
cursor: pointer;
}
}
.split-button {
font-size: 20px;
display: inline-flex;
position: absolute;
right: 8px;
top: 2px;
color: #000000a3;
cursor: pointer;
}
}
</style>

View File

@ -1,43 +1,52 @@
<template>
<div class="title">{{ title }}</div>
<a-table :columns="columns" :data-source="props.data" :pagination="false" size="small" :scroll="{y: 100}">
<a-table
:columns="columns"
:data-source="props.data"
:pagination="false"
size="small"
:scroll="{ y: 100 }"
>
<template #summary>
<a-table-summary fixed>
<a-table-summary-row>
<a-table-summary-cell>合计</a-table-summary-cell>
<a-table-summary-cell v-for="col in columns.length-2">
<a-table-summary-cell v-for="col in columns.length - 2">
<a-typography-text></a-typography-text>
</a-table-summary-cell>
<a-table-summary-cell>
<a-typography-text>{{ result }}</a-typography-text>
</a-table-summary-cell>
</a-table-summary-row>
</a-table-summary>
</a-table-summary>
</template>
</a-table>
</template>
<script setup lang="ts">
import { defineProps, computed } from "vue"
const props = defineProps(["columns", "data", "title"])
const { columns=[], title="" } = props
const result = computed(() => {
let sum = 0
props.data?.forEach(item => {
sum += item.area
})
return sum
})
import { defineProps, computed } from 'vue';
const props = defineProps(['columns', 'data', 'title']);
const { columns = [], title = '' } = props;
const result = computed(() => {
let sum = 0;
if (props.data) {
props.data?.forEach((item) => {
// item.area = item.area.toFixed(16);
sum += item.area;
});
return sum;
}
});
</script>
<style lang="scss" scoped>
.title {
display: flex;
justify-content: center;
font-size: 16px;
font-weight: 600;
}
:deep(.ant-table-summary){
background: #fafafa;
}
.title {
display: flex;
justify-content: center;
font-size: 16px;
font-weight: 600;
}
:deep(.ant-table-summary) {
background: #fafafa;
}
</style>