Commit 5dc0bc30 authored by 郭铭瑶's avatar 郭铭瑶 🤘

添加撒点 (待政务网环境测试)

parent 6d618b0b
...@@ -2,6 +2,7 @@ import { onUnmounted } from 'vue' ...@@ -2,6 +2,7 @@ import { onUnmounted } from 'vue'
import * as esriloader from 'esri-loader' import * as esriloader from 'esri-loader'
import useJsApi from '@/hooks/useJsApi' import useJsApi from '@/hooks/useJsApi'
import sceneViewPopup from '@/util/sceneViewPopup' import sceneViewPopup from '@/util/sceneViewPopup'
import { transOrgHtml, transMemberHtml, transListHtml } from '@/util/data2html'
export default async function useInitMap(el: HTMLElement, camera: any) { export default async function useInitMap(el: HTMLElement, camera: any) {
const config = { const config = {
...@@ -192,67 +193,75 @@ function addEventListener() { ...@@ -192,67 +193,75 @@ function addEventListener() {
window.sceneView.on('click', function (event) { window.sceneView.on('click', function (event) {
window.sceneView.popup.close() window.sceneView.popup.close()
window.sceneView.hitTest(event).then(async function (response) { window.sceneView.hitTest(event).then(async function (response) {
console.log('~~', response)
if (response.results.length > 0) { if (response.results.length > 0) {
const { layer } = response.results[0].graphic const { layer } = response.results[0].graphic
const layername = response.results[0].graphic.layer.id const layername = response.results[0].graphic.layer.id
const objectId = response.results[0].graphic.attributes.OBJECTID const objectId = response.results[0].graphic.attributes.OBJECTID
console.log(layername)
window.sceneView.whenLayerView(layer).then(function (layerView) { window.sceneView.whenLayerView(layer).then(function (layerView) {
const query = layer.createQuery() const query = layer.createQuery()
query.outFields = ['*'] query.outFields = ['*']
query.objectIds = [objectId] query.objectIds = [objectId]
layerView layerView
.queryFeatures(query) .queryFeatures(query)
.then(function (result) { .then(function ({ features }) {
if (result.features.length > 0) { if (!features || features.length === 0) return
let html = '' let html = ''
let title = '' const title = ''
const data = features[0]?.attributes // TODO 判断依据取值?
if (data?.['活动名称']) {
} else if (data?.['姓名']) {
html = transMemberHtml(data)
} else if (data?.['党组织名称']) {
html = transOrgHtml(data)
} else if (data?.isList) {
html = transListHtml(data)
}
switch (layername) { if (!html) return
//可根据图层名称对应不同操作,构造对应的信息面板内容
case 'jingmo':
const buildingName = result.features[0].attributes.NAME
//根据buildingName查询接口,获取信息
//组装html中的内容
html = '<div>根据接口获取信息,构造弹出内容' + '</div>' // switch (layername) {
title = '获取到的楼名' // //可根据图层名称对应不同操作,构造对应的信息面板内容
// case 'jingmo':
// const buildingName = result.features[0].attributes.NAME
// //根据buildingName查询接口,获取信息
// //组装html中的内容
break // html = '<div>根据接口获取信息,构造弹出内容' + '</div>'
case '党组织撒点图层': // title = '获取到的楼名'
console.log('click-data: ', result)
const poiName = result.features[0].attributes['党组织名称']
//根据poiName查询接口,获取信息
//组装html中的内容
html = // break
'<div class="pop-container">根据接口获取信息,构造弹出内容' + // case '党组织撒点图层':
'</div>' // console.log('click-data: ', result)
title = '获取到的poi名称' // const poiName = result.features[0].attributes['党组织名称']
break // //根据poiName查询接口,获取信息
default: // //组装html中的内容
break
}
const contentParam = { // html =
dockpoint: response.ground.mapPoint, // '<div class="pop-container">根据接口获取信息,构造弹出内容' +
title: title, // '</div>'
content: { // title = '获取到的poi名称'
type: 'html', // break
html: html, // default:
}, // break
} // }
const contentParam = {
dockpoint: response.ground.mapPoint,
title: title,
content: {
type: 'html',
html: html,
},
}
togglePopupTemplate(false) togglePopupTemplate(false)
setPopupContent(contentParam) setPopupContent(contentParam)
if (window.modelHighlight) { if (window.modelHighlight) {
window.modelHighlight.remove() window.modelHighlight.remove()
}
window.modelHighlight = layerView.highlight(objectId)
} }
window.modelHighlight = layerView.highlight(objectId)
}) })
.catch(console.error) .catch(console.error)
}) })
......
...@@ -42,13 +42,7 @@ export default { ...@@ -42,13 +42,7 @@ export default {
SET_FILTER_PATH(state: GlobalStateProps, val: string) { SET_FILTER_PATH(state: GlobalStateProps, val: string) {
state.filterPath = val state.filterPath = val
}, },
SET_MAP_POINTS( SET_MAP_POINTS(state: GlobalStateProps, data: any[] = []) {
state: GlobalStateProps, state.mapPoints = data
data: { labelKey?: string; result: any[] },
) {
state.mapPoints = {
labelKey: data.labelKey || '_labelKey',
result: data.result || [],
}
}, },
} }
...@@ -57,9 +57,6 @@ export default { ...@@ -57,9 +57,6 @@ export default {
}, },
}, },
filterPath: '', // 地理筛选路径 filterPath: '', // 地理筛选路径
mapPoints: { mapPoints: [{}],
labelKey: '党组织名称',
result: [{}],
},
menus: [], menus: [],
} }
import useJsApi from '@/hooks/useJsApi' import useJsApi from '@/hooks/useJsApi'
export default { export default {
async displayJSONData( async displayJSONData(layerName: string, Parameters: { result: any[] }) {
layerName: string,
Parameters: { result: any[] },
labelKey: string = '_labelKey',
) {
if (!Parameters.result || Parameters.result.length === 0) return if (!Parameters.result || Parameters.result.length === 0) return
const [ const [
LabelClass, LabelClass,
...@@ -37,7 +33,7 @@ export default { ...@@ -37,7 +33,7 @@ export default {
}) })
return new Graphic({ return new Graphic({
geometry: point, geometry: point,
attributes: item, attributes: { ...item }, // TODO 把数据塞入点位中?
}) })
}) })
...@@ -81,7 +77,7 @@ export default { ...@@ -81,7 +77,7 @@ export default {
const statesLabelClass = new LabelClass({ const statesLabelClass = new LabelClass({
labelExpressionInfo: { labelExpressionInfo: {
expression: `$feature['${labelKey}']`, expression: '$feature["_labelKey"]', // label取值
}, },
symbol: { symbol: {
type: 'text', type: 'text',
......
import { organization, member } from '@/util/tags'
import switchOrgLevel from '@/util/switchOrgLevel'
import dayjs from 'dayjs'
const trans = (val: string) => {
if (!val) return '无'
return (val && val.replace(/(\w{3})\w*(\w{4})/, '$1******$2')) || '无'
}
const transAddress = (a: string, b: string, c: string) => {
let result = ''
a && (result += a)
b && (result += b)
c && (result += c)
return result || '无'
}
const style = `
<style>
.pop-container {
background: rgba(249,250,250,.9);
border-radius: .04rem;
box-sizing: border-box;
padding: .1rem;
width: 3rem;
}
.title {
font-size: .13rem;
font-family: PingFangMedium, 'Avenir', Helvetica, Arial, sans-serif;
}
.tag-wrapper {
display:flex;
flex-wrap: wrap;
margin: .05rem 0;
}
.tag {
display: inline-block;
border-radius: .04rem;
font-size: .09rem;
padding: .02rem .04rem;
margin: 0 .05rem .05rem 0;
}
.tag.primary {
color: #DD505E;
background: #FCF4F5;
}
.tag.info {
color: #3D7FE9;
background: #ECEFFA;
}
.tag.success {
color: #2BB480;
background: #E9F7F0;
}
.tag.warning {
color: #E59B00;
background: #FFF4E6;
}
.tag.error {
color: #AC60CA;
background: #F5F0F9;
}
.box {
background: #fcfcfc;
border-radius: .03rem;
margin-top: .05rem;
box-sizing: border-box;
padding: .1rem;
}
.box.flex {
display: flex;
flex-wrap: wrap;
}
.box.inline > div {
display: flex;
}
.box.inline > div > span {
width: 25%;
white-space: nowrap;
}
.box.flex > div {
margin-right: .05rem;
}
.box.flex > div:nth-of-type(1),
.box.flex > div:nth-of-type(4) {
width: 25%;
}
.box.flex > div:nth-of-type(2),
.box.flex > div:nth-of-type(5) {
width: 40%;
}
.box span {
color: rgba(0,0,0,.6);
}
.box p {
margin-bottom: .03rem;
font-family: PingFangMedium, 'Avenir', Helvetica, Arial, sans-serif;
}
.box img {
width: 25%;
}
.pop-container .wrapper {
max-height: 50vh;
padding-bottom: .1rem;
margin-top: .05rem;
overflow-y:auto;
border-top: .01rem solid rgba(0,0,0,.06);
}
.pop-container .wrapper > .item {
border-radius: .03rem;
position: relative;
background: transparent;
cursor: pointer;
box-sizing: border-box;
padding: .05rem .08rem;
}
.pop-container .wrapper > .item:hover {
background: #FCF4F5;
}
.pop-container .wrapper > .item p,
.pop-container .wrapper > .item span {
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.pop-container .wrapper > .item p {
font-family: PingFangMedium, 'Avenir', Helvetica, Arial, sans-serif;
}
.pop-container .wrapper > .item span {
color: rgba(0,0,0,.6);
}
</style>
`
const getOrgTags = (tags: string) => {
if (!tags || !tags.split) return ''
return `
<div class="tag-wrapper">
${tags
.split(',')
.map(
(tag: string) => `
<span class="tag ${
organization.find((e) => e.name === tag)?.type
}">${tag}</span>
`,
)
.join('')}
</div>
`
}
const getMemberTags = (tags: string[]) => {
if (!tags || tags.length === 0) return ''
return `
<div class="tag-wrapper">
${tags
.map(
(tag: string) => `
<span class="tag ${
member.find((e) => e.name === tag)?.type
}">${tag}</span>
`,
)
.join('')}
</div>
`
}
export const transOrgHtml = (data: any) => {
return `
${style}
<div class="pop-container">
<p class="title">${data?.['党组织名称']}</p>
${getOrgTags(data?.['标签'])}
<p>${data['党组织地址']}</p>
<div class="box flex">
<div>
<span>${switchOrgLevel(data, '书记')}</span>
<p>${data['书记']}</p>
</div>
<div>
<span>党员数量</span>
<p>${data['党员数量'] || '无'}</p>
</div>
</div>
<div class="box">
<div>
<span>${switchOrgLevel(data, '副书记')}</span>
<p>${data['副书记'] || '无'}</p>
</div>
<div>
<span>上级党组织名称</span>
<p>${data['上级党组织名称'] || '无'}</p>
</div>
<div>
<span>联系电话</span>
<p>${trans(data['联系方式_座机'] || data['联系方式_手机'])}</p>
</div>
</div>
</div>
`
}
export const transMemberHtml = (data: any) => {
return `
${style}
<div class="pop-container">
<p class="title">${data['姓名']}</p>
${getMemberTags(data?.['标签'])}
<p>${data['所属党组织名称']}</p>
<div class="box flex">
<div>
<span>性别</span>
<p>${data['性别']}</p>
</div>
<div>
<span>出生日期</span>
<p>${dayjs(data['出生日期']).format('ll')}</p>
</div>
<div>
<span>学历</span>
<p>${data['学历'] || '无'}</p>
</div>
<div>
<span>党员身份</span>
<p>${data['党员身份']}</p>
</div>
<div>
<span>入党日期</span>
<p>${dayjs(data['加入中共党组织日期']).format('ll')}</p>
</div>
</div>
<div class="box">
<div>
<span>身份证号码</span>
<p>${trans(data['身份证号码'])}</p>
</div>
<div>
<span>居住地址</span>
<p>${transAddress(
data['所属小区'],
data['所属楼宇'],
data['所属房间'],
)}</p>
</div>
<div>
<span>联系电话</span>
<p>${trans(data['联系方式_手机'])}</p>
</div>
</div>
</div>
`
}
export const transActivityHtml = (data: any) => {
return `
${style}
<div class="pop-container">
<p class="title">${data['活动名称']}</p>
<p>${data['党组织名称']}</p>
<div class="wrapper">
<div class="box inline">
<div>
<span>活动日期:</span>
<p>${dayjs(+(data['活动日期'] + '000')).format('ll')}</p>
</div>
<div>
<span>活动地址:</span>
<p>${data['活动地址']}</p>
</div>
<div>
<span>参与人数:</span>
<p>${data['实际参与人数']}人</p>
</div>
<div>
<span>出席率:</span>
<p>${data['出席率']}%</p>
</div>
</div>
<div class="box">
<div>
<span>活动内容描述</span>
<p>${data['活动内容描述'] || '无'}</p>
</div>
</div>
<div class="box">
<div>
<span>活动照片</span>
<p>${data['活动照片']
.map((item) => `<img src="${item}"/>`)
.join('')}</p>
</div>
</div>
</div>
</div>
`
}
export const transListHtml = (data: any) => {
const { list } = data
let pointName = '数据'
if (list[0]['活动名称']) {
pointName = '活动'
} else if (list[0]['党组织名称']) {
pointName = '党组织'
}
return `
${style}
<div class="pop-container">
<p class="title">此处${list.length}个${pointName}</p>
<div class="wrapper">
${list
.map(
(item: any) => `<div class="item" >
<p>${item['活动名称'] || item['党组织名称']}</p>
<span>${item['活动地址'] || item['党组织地址'] || '无'}</span>
</div>
`,
)
.join('')}
</div>
</div>
`
}
export default function switchOrgLevel(data: any, label: string) {
const level = data?.['等级']
console.log(label)
switch (label) {
case '书记':
if (level === '党工委') return '党工委书记'
if (level === '党组') return '书记'
if (level === '党总支') return '党总支书记'
if (level === '党委') return '党委书记'
if (level === '党支部' || level === '联合党支部') return '党支部书记'
case '副书记':
if (level === '党工委') return '党工委副书记'
if (level === '党组') return '副书记'
if (level === '党总支') return '党总支副书记'
if (level === '党委') return '党委副书记'
if (level === '党支部' || level === '联合党支部') return '党支部副书记'
case '委员':
if (level === '党工委') return '党工委委员'
if (level === '党组') return '成员'
if (level === '党总支') return '党总支委员'
if (level === '党委') return '党委成员'
if (level === '党支部' || level === '联合党支部') return '支委会成员'
default:
return null
}
}
...@@ -99,15 +99,44 @@ const closeDrawer = () => { ...@@ -99,15 +99,44 @@ const closeDrawer = () => {
store.commit('SET_SHOW_BASIC_INFO', true) store.commit('SET_SHOW_BASIC_INFO', true)
store.commit('SET_SHOW_TAG', true) store.commit('SET_SHOW_TAG', true)
dateRange.value = [] dateRange.value = []
store.commit('SET_MAP_POINTS')
} }
const dateRange = ref<number[]>([]) const dateRange = ref<number[]>([])
const list = ref([ const list = ref([
{ title: '支部党员大会', count: 0, people: 0, ratio: 0, onMap: false }, {
{ title: '支部委员会', count: 0, people: 0, ratio: 0, onMap: false }, title: '支部党员大会',
{ title: '楼宇党建相关会议', count: 0, people: 0, ratio: 0, onMap: false }, count: 0,
{ title: '党课', count: 0, people: 0, ratio: 0, onMap: false }, people: 0,
{ title: '主题党日活动', count: 0, people: 0, ratio: 0, onMap: false }, ratio: 0,
onMap: false,
list: [{}],
},
{
title: '支部委员会',
count: 0,
people: 0,
ratio: 0,
onMap: false,
list: [{}],
},
{
title: '楼宇党建相关会议',
count: 0,
people: 0,
ratio: 0,
onMap: false,
list: [{}],
},
{ title: '党课', count: 0, people: 0, ratio: 0, onMap: false, list: [{}] },
{
title: '主题党日活动',
count: 0,
people: 0,
ratio: 0,
onMap: false,
list: [{}],
},
]) ])
onMounted(() => { onMounted(() => {
...@@ -119,10 +148,12 @@ async function getList(query?: string) { ...@@ -119,10 +148,12 @@ async function getList(query?: string) {
result.forEach(async (item) => { result.forEach(async (item) => {
let q = `paths @ "标签类别" && string == "${item.title}",paths @ "党组织编号" && string @ "${store.state.auth.code}"` let q = `paths @ "标签类别" && string == "${item.title}",paths @ "党组织编号" && string @ "${store.state.auth.code}"`
query && (q += `,${query}`) query && (q += `,${query}`)
const data = await useFetchActivity({ const data =
keys: '实际参与人数,出席率', (
q, await useFetchActivity({
}) q,
})
)?.map((item) => item.extra) || []
const activityAmount = data.length || 0 const activityAmount = data.length || 0
let personAmount = 0 let personAmount = 0
let rateAmount = 0 let rateAmount = 0
...@@ -133,6 +164,7 @@ async function getList(query?: string) { ...@@ -133,6 +164,7 @@ async function getList(query?: string) {
item.count = activityAmount item.count = activityAmount
item.people = personAmount item.people = personAmount
item.ratio = activityAmount ? rateAmount / activityAmount : 0 item.ratio = activityAmount ? rateAmount / activityAmount : 0
item.list = [...data]
}) })
list.value = [...result] list.value = [...result]
} }
...@@ -173,6 +205,18 @@ const disableDateEnd = (ts: number) => { ...@@ -173,6 +205,18 @@ const disableDateEnd = (ts: number) => {
} }
return !cur.isAfter(start) return !cur.isAfter(start)
} }
watch(
() => list.value,
async (list) => {
const points: any[] = []
list
.filter((item) => item.onMap)
.forEach((item) => points.push(...item.list))
store.commit('SET_MAP_POINTS', points)
},
{ deep: true },
)
</script> </script>
<style lang="stylus" scoped> <style lang="stylus" scoped>
......
...@@ -194,10 +194,12 @@ const clickTag = async (key: string) => { ...@@ -194,10 +194,12 @@ const clickTag = async (key: string) => {
q: `paths @ "类别" && string == "${key}"`, q: `paths @ "类别" && string == "${key}"`,
}) })
console.log(`类别-${key}-撒点:`, res) console.log(`类别-${key}-撒点:`, res)
store.commit('SET_MAP_POINTS', { store.commit(
labelKey: '党组织名称', 'SET_MAP_POINTS',
result: res.map((item: any) => item.extra), res
}) .map((item: any) => item.extra)
.filter((item: any) => !item?.['是否虚拟组织']),
)
} }
</script> </script>
......
...@@ -373,16 +373,12 @@ watch( ...@@ -373,16 +373,12 @@ watch(
extra['上海2000经度'] || extra['上海2000经度'] ||
extra['居住地上海2000经度'] || extra['居住地上海2000经度'] ||
extra['党组织上海2000经度'], extra['党组织上海2000经度'],
_labelKey: extra['党组织名称'] || extra['姓名'],
...extra, ...extra,
})), })),
) )
}) })
console.log('标签筛选撒点数据:', pointData) console.log('标签筛选撒点数据:', pointData)
store.commit('SET_MAP_POINTS', { store.commit('SET_MAP_POINTS', pointData)
result: pointData,
})
}, },
{ deep: true }, { deep: true },
) )
...@@ -510,16 +506,30 @@ function setBuildingBoundary(building: string) { ...@@ -510,16 +506,30 @@ function setBuildingBoundary(building: string) {
} }
watch( watch(
[() => curArea.value, () => curCommittee.value, () => curCommunity.value], [() => curArea.value, () => curCommittee.value, () => curCommunity.value],
([area, committee, community]) => { async ([area, committee, community]) => {
checkPathThenFetchInfo() checkPathThenFetchInfo()
let points: any[] = []
if (community) { if (community) {
emit('boundary', { type: 'community', name: community }) emit('boundary', { type: 'community', name: community })
} else if (committee) { } else if (committee) {
points =
(
await useFetchOrg({
q: `paths @ "所属居委" && string == "${committee}"`,
})
)?.map((item: any) => item.extra) || []
emit('boundary', { type: 'committee', name: committee }) emit('boundary', { type: 'committee', name: committee })
} else if (area) { } else if (area) {
points =
(
await useFetchOrg({
q: `paths @ "所属社区" && string == "${area}"`,
})
)?.map((item: any) => item.extra) || []
emit('boundary', { type: 'area', name: area }) emit('boundary', { type: 'area', name: area })
} }
// TODO 地图落点 // TODO 地图落点
store.commit('SET_MAP_POINTS', points)
}, },
) )
</script> </script>
......
...@@ -206,11 +206,8 @@ function showBuilding(name: string) { ...@@ -206,11 +206,8 @@ function showBuilding(name: string) {
}) })
} }
async function addPoints( async function addPoints(name: string, data: any[]) {
name: string, await clientLayersOperate.displayJSONData(name, { result: data })
data: { labelKey: string; result: any[] },
) {
await clientLayersOperate.displayJSONData(name, data, data.labelKey)
} }
function clearPoints(name?: string) { function clearPoints(name?: string) {
...@@ -221,25 +218,6 @@ function clearPoints(name?: string) { ...@@ -221,25 +218,6 @@ function clearPoints(name?: string) {
}) })
} }
function setPopupContent(Parameters) {
window.sceneView.popup.open({
actions: [],
location: Parameters.dockpoint,
title: Parameters.title,
collapseEnabled: false,
dockEnabled: false,
content: sceneViewPopup.createCustompopup(Parameters.content),
})
}
function togglePopupTemplate(trueOrFalse) {
if (trueOrFalse === true) {
window.sceneView.popup.autoOpenEnabled = true
} else {
window.sceneView.popup.autoOpenEnabled = false
}
}
defineExpose({ defineExpose({
resetMap, resetMap,
switchBM, switchBM,
......
...@@ -246,7 +246,7 @@ const handleSelect = ({ extra }: any) => { ...@@ -246,7 +246,7 @@ const handleSelect = ({ extra }: any) => {
...extra, ...extra,
}, },
] ]
store.commit('SET_MAP_POINTS', { labelKey: '党组织名称', result: point }) store.commit('SET_MAP_POINTS', point)
showResult.value = false showResult.value = false
} }
......
...@@ -12,8 +12,11 @@ ...@@ -12,8 +12,11 @@
<StructModal /> <StructModal />
<!-- <InforModal class="fix1" /> --> <!-- <InforModal class="fix1" /> -->
<!-- <ListModal class="fix2" pagination /> --> <ListModal class="fix1" />
<!-- <ActivityDetail class="fix1" /> --> <!-- <ActivityDetail class="fix1" /> -->
<div class="fix2">
<div v-html="html" />
</div>
</template> </template>
<script lang="ts" setup> <script lang="ts" setup>
...@@ -29,6 +32,12 @@ import ListModal from './components/list-modal.vue' ...@@ -29,6 +32,12 @@ import ListModal from './components/list-modal.vue'
import ActivityDetail from './components/activity-detail.vue' import ActivityDetail from './components/activity-detail.vue'
import reset from '@images/reset.svg' import reset from '@images/reset.svg'
import store from '@/store' import store from '@/store'
import {
transOrgHtml,
transMemberHtml,
transListHtml,
transActivityHtml,
} from '@/util/data2html'
store.dispatch('getAuth') store.dispatch('getAuth')
store.dispatch('getMenus') store.dispatch('getMenus')
...@@ -55,19 +64,80 @@ const setBoundary = ({ type, name }: { type: string; name: string }) => { ...@@ -55,19 +64,80 @@ const setBoundary = ({ type, name }: { type: string; name: string }) => {
break break
} }
} }
const html = transActivityHtml({
出席率: 67,
标签类别: '主题党日活动',
活动名称: '牡丹活动',
活动地址:
'中共浦东新区花木街道牡丹社区第一居民区第一支部委员会中共浦东新区花木街道牡丹社区第一居民区第一支部委员会',
活动日期: 1632240000,
活动照片: [
'http://mdt-open-public.oss-cn-hangzhou.aliyuncs.com/collector/988fc63e-fa55-4729-851d-24c4355213f2/huamu_a3a63d618b9464b87c0691a77f4274c3_%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202021-09-15%20%E4%B8%8A%E5%8D%8811.30.47.png',
'http://mdt-open-public.oss-cn-hangzhou.aliyuncs.com/collector/988fc63e-fa55-4729-851d-24c4355213f2/huamu_a3a63d618b9464b87c0691a77f4274c3_%E5%B1%8F%E5%B9%95%E5%BF%AB%E7%85%A7%202021-09-15%20%E4%B8%8A%E5%8D%8811.30.47.png',
],
党组织名称: '中共浦东新区花木街道牡丹社区第一居民区第一支部委员会',
党组织编号: '001.001.031.014.205.002.001.601.701',
签到表文件: [
'http://mdt-open-public.oss-cn-hangzhou.aliyuncs.com/collector/988fc63e-fa55-4729-851d-24c4355213f2/huamu_87f69f9e37eab53fd2e974adbb36cfc9_%E8%8E%B7%E5%BE%97%E5%8C%BA%E7%BA%A7%E5%A5%96%E9%A1%B9%E5%85%9A%E7%BB%84%E7%BB%87.xlsx',
],
签到表照片: [],
上海2000纬度: -2581.95914975792,
上海2000经度: 7037.33995731356,
台账记录照片: [],
实际参与人数: 40,
活动内容描述: '描述',
不计入参与活动党员人数: 3,
})
// 塞入统一标题字段名_labelKey, 收集同一坐标点位
function checkSamePositionPoints(arr: any[]) {
const points: any[] = []
const len = arr.length || 0
for (let i = 0; i < len; i++) {
for (let j = i + 1; j < len; j++) {
if (
arr[i]['上海2000纬度'] === arr[j]['上海2000纬度'] &&
arr[i]['上海2000经度'] === arr[j]['上海2000经度']
) {
j = ++i
}
}
points.push(arr[i])
}
return points.map((item) => {
const samePoints = arr.filter(
(e) =>
e['上海2000纬度'] === item['上海2000纬度'] &&
e['上海2000经度'] === item['上海2000经度'],
)
if (samePoints && samePoints.length > 1) {
return {
_labelKey: samePoints.length,
isList: true,
list: [...samePoints],
上海2000纬度: samePoints[0]['上海2000纬度'],
上海2000经度: samePoints[0]['上海2000经度'],
}
} else {
return {
_labelKey: item['党组织名称'] ? '党组织名称' : '姓名',
...item,
}
}
})
}
watch( watch(
() => store.state.mapPoints, () => store.state.mapPoints,
(points: any) => { (points: any) => {
map.value.clearPoints() map.value.clearPoints()
console.log('开始撒点:') console.log('开始撒点:')
if (!points || points.result?.length === 0) return if (!points || points.length === 0) return
const data = { const data = checkSamePositionPoints(
labelKey: points.labelKey, points.map((point) => JSON.parse(JSON.stringify(point))) || [],
result: points.result?.map((point) => JSON.parse(JSON.stringify(point))), )
// result: points.result?.map((point) => Object.assign({}, point)),
}
console.log(data) console.log(data)
map.value.addPoints('党组织撒点图层', data) map.value.addPoints('撒点', data)
}, },
) )
</script> </script>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment