2024-08-25 16:18:49 +08:00
|
|
|
|
<script>
|
|
|
|
|
|
export default {
|
|
|
|
|
|
name: "AppMap",
|
|
|
|
|
|
label: "地图",
|
|
|
|
|
|
data() {
|
|
|
|
|
|
return {
|
|
|
|
|
|
map: null,
|
|
|
|
|
|
layers: [],
|
|
|
|
|
|
geoJson: null
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
computed: {
|
|
|
|
|
|
search: v => v.$marketBoard.search
|
|
|
|
|
|
},
|
|
|
|
|
|
watch: {
|
|
|
|
|
|
search: {
|
|
|
|
|
|
deep: true, handler() {
|
2024-08-25 16:28:54 +08:00
|
|
|
|
this.getData().then(() => this.refreshData())
|
2024-08-25 16:18:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
methods: {
|
|
|
|
|
|
loadLib() {
|
|
|
|
|
|
return Promise.all([
|
|
|
|
|
|
'/presource/datascreen/js/turf.min.js',
|
|
|
|
|
|
].map(e => $loadScript('js', e)))
|
|
|
|
|
|
},
|
|
|
|
|
|
getData() {
|
|
|
|
|
|
const {$http, $waitFor} = window
|
|
|
|
|
|
const {groupCodeList, currentDate, hourNum} = this.search
|
2024-08-26 10:52:17 +08:00
|
|
|
|
const maps = []
|
2024-08-25 16:18:49 +08:00
|
|
|
|
return $waitFor($http).then(() => Promise.all([
|
|
|
|
|
|
$http.post("/data-boot/la/screen/marketBoard/storeReport", {
|
|
|
|
|
|
groupCodeList, currentDate, hourNum
|
|
|
|
|
|
}).then(res => {
|
|
|
|
|
|
if (res?.data) {
|
|
|
|
|
|
return this.layers = res.data || []
|
|
|
|
|
|
}
|
|
|
|
|
|
}),
|
|
|
|
|
|
axios.get('http://10.0.97.209/blade-visual/map/data?id=1456').then(res => {
|
|
|
|
|
|
if (res?.data) {
|
2024-08-26 10:52:17 +08:00
|
|
|
|
return maps.push(res.data.features)
|
|
|
|
|
|
}
|
|
|
|
|
|
}),
|
|
|
|
|
|
axios.get('http://10.0.97.209/blade-visual/map/data?id=1469').then(res => {
|
|
|
|
|
|
if (res?.data) {
|
|
|
|
|
|
return maps.push(res.data.features)
|
2024-08-25 16:18:49 +08:00
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-26 10:52:17 +08:00
|
|
|
|
])).then(() => {
|
|
|
|
|
|
return this.geoJson = {type: 'FeatureCollection', features: maps.flat(1)}
|
|
|
|
|
|
})
|
2024-08-25 16:18:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
initMap() {
|
|
|
|
|
|
const {echarts, turf} = window
|
|
|
|
|
|
const boundary = turf.union(this.geoJson)
|
|
|
|
|
|
boundary.properties.name = "boundary"
|
|
|
|
|
|
this.geoJson.features.unshift(boundary)
|
|
|
|
|
|
echarts.registerMap('zhengzhou', this.geoJson)
|
|
|
|
|
|
this.map = echarts.init(this.$el)
|
|
|
|
|
|
const areaColor = {
|
|
|
|
|
|
type: 'linear', x: 0, y: 0, x2: 0, y2: 1, colorStops: [
|
|
|
|
|
|
{offset: 0, color: 'rgba(61,127,255,0.35)'},
|
|
|
|
|
|
{offset: 1, color: '#09E2F8'},
|
|
|
|
|
|
]
|
|
|
|
|
|
}
|
2024-08-27 23:09:28 +08:00
|
|
|
|
const label = {
|
|
|
|
|
|
show: true,
|
|
|
|
|
|
backgroundColor: {type: 'linear', x: 0, y: 0, x2: 1, y2: 0, colorStops: [{offset: 0, color: 'rgba(9,63,107,0.79)'}, {offset: 1, color: 'rgba(13,58,99,0.03)'}]},
|
|
|
|
|
|
borderRadius: 2,
|
|
|
|
|
|
padding: 8,
|
|
|
|
|
|
position: 'right',
|
|
|
|
|
|
formatter: params => {
|
|
|
|
|
|
const {name, value: [x, y, bakeStockAmt = 0, preSaleNum = 0]} = params
|
|
|
|
|
|
return `{a|${name}\n现烤库存金额:${bakeStockAmt}\n现烤销售机会:${preSaleNum}}`
|
|
|
|
|
|
},
|
|
|
|
|
|
rich: {
|
2024-09-02 09:40:39 +08:00
|
|
|
|
a: {color: '#fff', fontSize: 12, lineHeight: 14}
|
2024-08-27 23:09:28 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|
2024-08-25 16:18:49 +08:00
|
|
|
|
this.map.setOption({
|
|
|
|
|
|
geo: {
|
|
|
|
|
|
map: 'zhengzhou', roam: true, emphasis: {disabled: true},
|
|
|
|
|
|
itemStyle: {areaColor: "transparent", borderColor: '#97CAE6'},
|
|
|
|
|
|
silent: true,
|
|
|
|
|
|
label: {show: true, color: '#fff'},
|
|
|
|
|
|
regions: [
|
|
|
|
|
|
{name: "boundary", itemStyle: {areaColor, shadowColor: "#1A80BF", shadowOffsetY: 2}, label: {show: false}}
|
|
|
|
|
|
],
|
|
|
|
|
|
},
|
|
|
|
|
|
series: [
|
2024-08-27 23:09:28 +08:00
|
|
|
|
{type: 'scatter', coordinateSystem: 'geo', itemStyle: {color: '#66FFFF'}, label},
|
|
|
|
|
|
{type: 'effectScatter', coordinateSystem: 'geo', itemStyle: {color: '#FFD15C'}, label}
|
2024-08-25 16:18:49 +08:00
|
|
|
|
],
|
|
|
|
|
|
tooltip: {
|
|
|
|
|
|
trigger: 'item', formatter: params => {
|
|
|
|
|
|
const {name, marker, value: [x, y, bakeStockAmt = 0, preSaleNum = 0]} = params
|
|
|
|
|
|
return `${marker} ${name}<br/>现烤库存金额:${bakeStockAmt}<br/>现烤销售机会:${preSaleNum}`
|
2024-08-27 23:09:28 +08:00
|
|
|
|
},
|
2024-08-25 16:18:49 +08:00
|
|
|
|
},
|
|
|
|
|
|
})
|
2024-08-25 16:28:54 +08:00
|
|
|
|
this.map.on('click', evt => {
|
|
|
|
|
|
const storeCode = evt.data.storeCode
|
|
|
|
|
|
if (storeCode) {
|
|
|
|
|
|
this.$storeBoard.search.storeCode = storeCode
|
|
|
|
|
|
this.$marketBoard.screenId = 'a90522ef-869b-40ea-8542-d1fc9674a1e8'
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
2024-08-25 16:18:49 +08:00
|
|
|
|
this.refreshData()
|
|
|
|
|
|
},
|
|
|
|
|
|
convertData(layers) {
|
|
|
|
|
|
const result = {normal: [], abnormal: []}
|
|
|
|
|
|
layers.forEach(e => {
|
2024-08-25 16:28:54 +08:00
|
|
|
|
const item = {name: e.storeName, storeCode: e.storeCode, value: [e.longitude, e.latitude, e.bakeStockAmt, e.preSaleNum]}
|
2024-08-25 16:18:49 +08:00
|
|
|
|
if (e.bakeStockAmt > 0) {
|
|
|
|
|
|
result.normal.push(item)
|
|
|
|
|
|
} else {
|
|
|
|
|
|
result.abnormal.push(item)
|
|
|
|
|
|
}
|
|
|
|
|
|
})
|
|
|
|
|
|
return Object.values(result).map(data => ({data}))
|
|
|
|
|
|
},
|
|
|
|
|
|
refreshData() {
|
|
|
|
|
|
this.map.setOption({series: this.convertData(this.layers)})
|
|
|
|
|
|
}
|
|
|
|
|
|
},
|
|
|
|
|
|
mounted() {
|
|
|
|
|
|
this.loadLib().then(() => Promise.all([
|
|
|
|
|
|
this.getData(),
|
|
|
|
|
|
])).then(() => this.initMap())
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
</script>
|
|
|
|
|
|
|
|
|
|
|
|
<template>
|
|
|
|
|
|
<div class="AppMap"/>
|
|
|
|
|
|
</template>
|
|
|
|
|
|
|
|
|
|
|
|
<style>
|
|
|
|
|
|
</style>
|