perf: 地理信息

This commit is contained in:
fit2cloud-chenyw 2023-10-30 21:53:58 +08:00
parent 84eabc60ae
commit 636af91cd1
3 changed files with 161 additions and 19 deletions

2
.gitignore vendored
View File

@ -48,3 +48,5 @@ core/core-frontend/src/assets/fsSvg.html
/sdk/dataease-plugin-filter/ /sdk/dataease-plugin-filter/
/sdk/dataease-plugin-interface/ /sdk/dataease-plugin-interface/
/sdk/dataease-plugin-view/ /sdk/dataease-plugin-view/
/extensions/
.vite/

View File

@ -40,7 +40,7 @@ const handleClick = (tab, event: Event) => {
.sys-setting-p { .sys-setting-p {
width: 100%; width: 100%;
background: var(--ContentBG, #ffffff); background: var(--ContentBG, #ffffff);
height: calc(100% - 95px); height: calc(100vh - 176px);
box-sizing: border-box; box-sizing: border-box;
margin-top: 12px; margin-top: 12px;
} }

View File

@ -10,7 +10,13 @@
</span> </span>
</div> </div>
<div class="geo-search"> <div class="geo-search">
<el-input class="m16 w100" v-model="keyword" clearable :placeholder="t('commons.search')"> <el-input
class="m16 w100"
v-model="keyword"
clearable
:placeholder="t('commons.search')"
@change="filterResource"
>
<template #prefix> <template #prefix>
<el-icon> <el-icon>
<Icon name="icon_search-outline_outlined"></Icon> <Icon name="icon_search-outline_outlined"></Icon>
@ -19,18 +25,63 @@
</el-input> </el-input>
</div> </div>
<div class="map-tree-container"> <div class="map-tree-container">
<!-- <el-scrollbar> --> <el-scrollbar class="menu-tree">
<el-tree :data="treeData" :props="defaultProps" @node-click="handleNodeClick"> <el-tree
<template #default="{ node, data }"> menu
<span class="custom-tree-node"> ref="areaTreeRef"
<span>{{ data.name || node.label }}</span> node-key="id"
</span> :data="treeData"
</template> @node-click="handleNodeClick"
</el-tree> :highlight-current="true"
<!-- </el-scrollbar> --> :expand-on-click-node="false"
:default-expand-all="false"
:filter-node-method="filterResourceNode"
>
<template #default="{ node, data }">
<span class="custom-tree-node" :class="{ 'is-disabled': node.disabled || data.root }">
<span
:title="data.name"
v-html="data.colorName && keyword ? data.colorName : data.name"
/>
</span>
</template>
</el-tree>
</el-scrollbar>
</div> </div>
</el-aside> </el-aside>
<el-main>地理信息内容区域</el-main> <el-main class="geometry-main">
<div class="geo-content-container" v-if="!selectedData">
<EmptyBackground img-type="noneWhite" description="请在左侧选择区域" />
</div>
<div v-else class="geo-content-container">
<div class="geo-content-top">
<span>{{ selectedData.name }}</span>
</div>
<div class="geo-content-middle">
<div class="geo-area">
<div class="area-label"><span>区域代码</span></div>
<div class="area-content">
<span>{{ selectedData.id }}</span>
</div>
</div>
<div class="geo-area">
<div class="area-label"><span>上级区域</span></div>
<div class="area-content">
<span>{{ selectedData.parentName }}</span>
<span v-if="selectedData.pid" class="area-secondary">{{
'(' + selectedData.pid + ')'
}}</span>
</div>
</div>
</div>
<div class="geo-content-bottom">
<div class="area-label"><span>坐标文件</span></div>
<el-scrollbar class="area-content-geo">
<span>{{ selectedData.geoJson }}</span>
</el-scrollbar>
</div>
</div>
</el-main>
</el-container> </el-container>
</template> </template>
@ -38,6 +89,10 @@
import { ref } from 'vue' import { ref } from 'vue'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { getWorldTree } from '@/api/map' import { getWorldTree } from '@/api/map'
import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue'
import { getGeoJsonFile } from '@/views/chart/components/js/util'
import { cloneDeep } from 'lodash-es'
import { setColorName } from '@/utils/utils'
const { t } = useI18n() const { t } = useI18n()
const keyword = ref('') const keyword = ref('')
const treeData = ref([]) const treeData = ref([])
@ -45,9 +100,29 @@ interface Tree {
label: string label: string
children?: Tree[] children?: Tree[]
} }
const areaTreeRef = ref(null)
const handleNodeClick = (data: Tree) => { const selectedData = ref(null)
console.log(data)
const handleNodeClick = async (data: Tree) => {
selectedData.value = data
const geoJson = cloneDeep(await getGeoJsonFile(data['id']))
selectedData.value['geoJson'] = geoJson
const pid = data['pid']
if (pid) {
const parent = areaTreeRef.value.getNode(pid)
if (parent) {
selectedData.value.parentName = parent.data.name
}
}
}
const filterResource = val => {
areaTreeRef.value?.filter(val)
}
const filterResourceNode = (value: string, data) => {
setColorName(data, value)
if (!value) return true
return data.name.toLocaleLowerCase().includes(value.toLocaleLowerCase())
} }
const loadTreeData = () => { const loadTreeData = () => {
@ -61,11 +136,6 @@ const loadTreeData = () => {
}) })
} }
const defaultProps = {
children: 'children',
label: 'name'
}
loadTreeData() loadTreeData()
</script> </script>
@ -88,6 +158,7 @@ loadTreeData()
line-height: 24px; line-height: 24px;
} }
.add-icon-span { .add-icon-span {
display: none;
color: #3370ff; color: #3370ff;
height: 20px; height: 20px;
width: 20px; width: 20px;
@ -110,5 +181,74 @@ loadTreeData()
overflow-y: auto; overflow-y: auto;
} }
} }
.geometry-main {
padding: 16px !important;
}
}
.geo-content-container {
width: 100%;
height: 100%;
.geo-content-top {
height: 24px;
line-height: 24px;
margin-bottom: 16px;
span {
font-weight: 500;
font-size: 16px;
color: #1f2329;
}
}
.geo-content-middle {
display: flex;
.geo-area {
height: 48px;
width: 50%;
}
margin-bottom: 16px;
}
:deep(.area-label) {
height: 22px;
line-height: 22px;
span {
font-size: 14px;
color: #646a73;
font-weight: 400;
}
}
:deep(.area-content) {
line-height: 22px;
height: 22px;
span {
font-size: 14px;
color: #1f2329;
font-weight: 400;
}
.area-secondary {
color: #646a73;
}
}
.geo-content-bottom {
width: 100%;
height: calc(100% - 110px);
.area-content-geo {
line-height: 22px;
overflow-x: hidden;
overflow-y: auto;
height: calc(100% - 30px);
span {
font-size: 14px;
color: #1f2329;
font-weight: 400;
}
}
}
}
.custom-tree-node {
flex: 1;
display: flex;
align-items: center;
box-sizing: content-box;
padding-right: 4px;
overflow: hidden;
} }
</style> </style>