master
lion 4 months ago
parent 561140e651
commit f007675044

@ -550,7 +550,7 @@ export default {
},
'on-change': (e) => {
// action
this.selectOpt.page = e
this.selectOpt.page = e
if (this.action) {
this.getTableData()
}

File diff suppressed because it is too large Load Diff

@ -2455,7 +2455,7 @@
"type": "Feature",
"properties": {
"id": "320510",
"name": "园区",
"name": "工业园区",
"site": "www.poi86.com"
},
"geometry": {

File diff suppressed because it is too large Load Diff

@ -192,12 +192,12 @@ export default {
}, {
name: '姑苏区',
id: 21,
coord: [120.611498, 31.336451],
coord: [120.571498, 31.346451],
zoom: 4
}, {
name: '虎丘区',
id: 23,
coord: [120.331625, 31.32967],
coord: [120.331625, 31.35967],
zoom: 4
}, {
id:19,
@ -206,7 +206,7 @@ export default {
zoom: 4
}, {
id:22,
name: '园区',
name: '工业园区',
coord: [120.736747, 31.275494],
zoom: 4
}, {
@ -276,48 +276,48 @@ export default {
if (!warehousePoints || warehousePoints.length === 0) {
return warehousePoints
}
//
// 0.000115
const threshold = 0.0005 // 50
// -
// 0.003 3000.005 500
const offsetAmount = 0.005 // 500
//
warehousePoints.forEach((point) => {
point.labelPosition = 'top' //
point.labelOffset = [-15, -35] // 15px35px
point.processed = false //
})
//
warehousePoints.forEach((point, index) => {
//
if (point.processed) {
return
}
//
const nearbyPoints = []
for (let i = 0; i < warehousePoints.length; i++) {
if (i === index || warehousePoints[i].processed) continue
const otherPoint = warehousePoints[i]
const deltaLon = point.value[0] - otherPoint.value[0]
const deltaLat = point.value[1] - otherPoint.value[1]
const distance = Math.sqrt(deltaLon * deltaLon + deltaLat * deltaLat)
if (distance < threshold) {
nearbyPoints.push({ point: otherPoint, index: i, distance })
}
}
//
if (nearbyPoints.length > 0) {
//
const closest = nearbyPoints.sort((a, b) => a.distance - b.distance)[0]
//
const originalLon = point.value[0]
const originalLat = point.value[1]
@ -326,12 +326,12 @@ export default {
point.labelPosition = 'bottom'
point.labelOffset = [-15, 15] // 15px15px
point.processed = true
//
closest.point.labelPosition = 'top'
closest.point.labelOffset = [-15, -35] // 15px35px
closest.point.processed = true
console.log(`点位 ${point.name} 向右下偏移: 经度 ${originalLon} -> ${point.value[0]}, 纬度 ${originalLat} -> ${point.value[1]}, 标签在下方`)
console.log(`点位 ${closest.point.name} 保持原位置,标签在上方`)
} else {
@ -339,7 +339,7 @@ export default {
point.processed = true
}
})
return warehousePoints
},
//
@ -349,7 +349,7 @@ export default {
// 使 replaceMerge graphic
this.myChart.setOption({
graphic: []
}, {
}, {
notMerge: false,
replaceMerge: ['graphic'] // graphic
})
@ -362,10 +362,10 @@ export default {
this.clearLabels()
return
}
//
this.clearLabels()
//
this.$nextTick(() => {
setTimeout(() => {
@ -378,31 +378,31 @@ export default {
if (!this.myChart || !this.warehousePoints || this.warehousePoints.length === 0) {
return
}
const graphicElements = []
this.warehousePoints.forEach((point, index) => {
if (!point.name || !point.value || point.value.length !== 2) {
return
}
try {
//
const pixel = this.myChart.convertToPixel('geo', point.value)
if (!pixel || pixel.length !== 2 || isNaN(pixel[0]) || isNaN(pixel[1])) {
return
}
//
const labelOffset = point.labelOffset || [-15, -35]
//
let x = pixel[0] + labelOffset[0]
let y = pixel[1] + labelOffset[1]
//
const fontSize = 11
// 使
graphicElements.push({
type: 'text',
@ -427,12 +427,12 @@ export default {
console.error('绘制标签失败:', e, point)
}
})
// graphic
if (graphicElements.length > 0) {
this.myChart.setOption({
graphic: graphicElements
}, {
}, {
notMerge: false,
replaceMerge: ['graphic'] // graphic
})
@ -568,7 +568,7 @@ export default {
}
},
{
name: '园区',
name: '工业园区',
itemStyle: {
normal: {
areaColor: '#5d39e9'
@ -678,7 +678,7 @@ export default {
}
return
}
const areaName = params.name;
const areaObj = this.streetNameList.find(item => item.name === areaName);
if (areaObj) {
@ -698,13 +698,13 @@ export default {
}
return
}
const that = this // this label
console.log('点击区域:', areaObj);
//
this.clearLabels();
// 1.
const warehouseList = await this.getList(areaObj.id);
console.log('获取到的仓库列表:', warehouseList);
@ -713,13 +713,13 @@ export default {
this.warehousePoints = (warehouseList || []).map(item => {
const jingdu = Number(item.jingdu);
const weidu = Number(item.weidu);
//
if (isNaN(jingdu) || isNaN(weidu) || jingdu === 0 || weidu === 0) {
console.warn('仓库坐标无效:', item.cangkumingcheng, '经度:', item.jingdu, '纬度:', item.weidu);
return null;
}
return {
name: item.cangkumingcheng,
value: [jingdu, weidu],
@ -728,14 +728,14 @@ export default {
labelPosition: null //
};
}).filter(point => point !== null); //
// 3.
this.warehousePoints = this.assignLabelPositions(this.warehousePoints);
console.log('生成的仓库点位:', this.warehousePoints);
console.log('标签位置分配:', this.warehousePoints.map(p => ({
name: p.name,
position: p.labelPosition,
console.log('标签位置分配:', this.warehousePoints.map(p => ({
name: p.name,
position: p.labelPosition,
offset: p.labelOffset,
value: p.value,
hasName: !!p.name
@ -752,7 +752,7 @@ export default {
// 4. geocenterzoom
console.log('设置地图配置,仓库点位数量:', this.warehousePoints.length);
console.log('准备传递给 scatter 的数据:', this.warehousePoints.map(p => ({ name: p.name, value: p.value, labelPosition: p.labelPosition, labelOffset: p.labelOffset })));
// name
this.warehousePoints = this.warehousePoints.map(p => ({
name: p.name || '未知仓库',
@ -763,7 +763,7 @@ export default {
item: p.item
}))
console.log('处理后的 warehousePoints 数据:', this.warehousePoints.slice(0, 3)) // 3
this.myChart.setOption({
series: [
{
@ -806,7 +806,7 @@ export default {
formatter: function(params) {
// - warehousePoints
let name = ''
// 1 warehousePoints
if (that.warehousePoints && params.dataIndex !== undefined && params.dataIndex >= 0 && params.dataIndex < that.warehousePoints.length) {
const pointData = that.warehousePoints[params.dataIndex]
@ -814,19 +814,19 @@ export default {
name = pointData.name
}
}
// 2 params.data ECharts scatter
if (!name && params.data) {
if (typeof params.data === 'object' && params.data.name) {
name = params.data.name
}
}
// 3使 params.name
if (!name && params.name) {
name = params.name
}
//
if (!name) {
console.error('标签 formatter 无法获取名称:', {
@ -836,7 +836,7 @@ export default {
})
name = '仓库' + (params.dataIndex !== undefined ? (params.dataIndex + 1) : '')
}
return name
},
position: function(params) {
@ -887,16 +887,16 @@ export default {
zoom: areaObj.zoom ? areaObj.zoom * 1.5 : 4.5 // 50%
}
}, { notMerge: false, lazyUpdate: false });
//
this.myChart.resize();
// 使 graphic
this.drawLabelsWithGraphic();
//
this.hasLoadedWarehouses = true
//
this.myChart.off('georoam') //
this.myChart.on('georoam', () => {
@ -908,7 +908,7 @@ export default {
this.myChart.off('click');
this.myChart.on('click', params => {
console.log('地图点击事件:', params)
//
if (params.seriesName === '仓库点位' || (params.componentType === 'series' && params.seriesType === 'scatter')) {
// dataIndex
@ -923,7 +923,7 @@ export default {
// 使 data
if (params.data) {
// data
const warehouseData = this.warehousePoints.find(p =>
const warehouseData = this.warehousePoints.find(p =>
p.value[0] === params.data.value[0] && p.value[1] === params.data.value[1]
) || params.data
console.log('点击仓库图标:', warehouseData.name || warehouseData)
@ -952,22 +952,22 @@ export default {
this.wuziTotal = 0
this.showData = false
this.hasLoadedWarehouses = false //
//
this.clearLabels();
console.log('resetToFullMap - warehouseData:', this.warehouseData);
console.log('resetToFullMap - warehouseData.length:', this.warehouseData ? this.warehouseData.length : 0);
//
if (this.myChart) {
this.myChart.dispose(); //
}
//
this.myChart = echarts.init(document.getElementById('chart'));
echarts.registerMap('GX', jtmap);
//
this.myChart.setOption({
//
@ -1010,7 +1010,7 @@ export default {
{ name: '姑苏区', itemStyle: { normal: { areaColor: '#40a9ff' }, emphasis: { areaColor: '#40a9ff' } } },
{ name: '虎丘区', itemStyle: { normal: { areaColor: '#2f54eb' }, emphasis: { areaColor: '#2f54eb' } } },
{ name: '吴中区', itemStyle: { normal: { areaColor: '#1d39c4' }, emphasis: { areaColor: '#1d39c4' } } },
{ name: '园区', itemStyle: { normal: { areaColor: '#5d39e9' }, emphasis: { areaColor: '#5d39e9' } } },
{ name: '工业园区', itemStyle: { normal: { areaColor: '#5d39e9' }, emphasis: { areaColor: '#5d39e9' } } },
{ name: '太仓市', itemStyle: { normal: { areaColor: '#597ef7' }, emphasis: { areaColor: '#597ef7' } } },
{ name: '昆山市', itemStyle: { normal: { areaColor: '#10239e' }, emphasis: { areaColor: '#10239e' } } },
{ name: '常熟市', itemStyle: { normal: { areaColor: '#69c0ff' }, emphasis: { areaColor: '#69c0ff' } } },
@ -1044,12 +1044,12 @@ export default {
}
}]
});
//
if (this.warehouseData && this.warehouseData.length > 0) {
this.updateWarehouseData(this.warehouseData);
}
//
this.myChart.on('click', params => {
if (params.componentType === 'series' && params.seriesType === 'map') {
@ -1061,7 +1061,7 @@ export default {
}
}
});
console.log('返回全图完成,地图已完全重新加载,仓库点位已清除');
},
updateWarehouseData(warehouseData) {
@ -1077,7 +1077,7 @@ export default {
this.shibenjiWarehouseCount = null
this.shibenjiAreaId = null
}
//
const updatedStreetList = this.streetNameList.map(street => {
const warehouseInfo = warehouseData.find(w => w.name === street.name);
@ -1089,7 +1089,7 @@ export default {
}
return street;
});
//
if (this.myChart) {
this.myChart.setOption({
@ -1146,7 +1146,7 @@ export default {
}
return
}
//
if (!this.shibenjiAreaId) {
if (this.$message) {
@ -1168,10 +1168,10 @@ export default {
const that = this // this label
//
console.log('加载市本级仓库数据区域ID:', areaId);
//
this.clearLabels();
// 1.
const warehouseList = await this.getList(areaId);
console.log('获取到的仓库列表:', warehouseList);
@ -1180,13 +1180,13 @@ export default {
this.warehousePoints = (warehouseList || []).map(item => {
const jingdu = Number(item.jingdu);
const weidu = Number(item.weidu);
//
if (isNaN(jingdu) || isNaN(weidu) || jingdu === 0 || weidu === 0) {
console.warn('仓库坐标无效:', item.cangkumingcheng, '经度:', item.jingdu, '纬度:', item.weidu);
return null;
}
return {
name: item.cangkumingcheng,
value: [jingdu, weidu],
@ -1195,20 +1195,20 @@ export default {
labelPosition: null //
};
}).filter(point => point !== null); //
// 3.
this.warehousePoints = this.assignLabelPositions(this.warehousePoints);
console.log('生成的仓库点位:', this.warehousePoints);
console.log('标签位置分配:', this.warehousePoints.map(p => ({
name: p.name,
position: p.labelPosition,
console.log('标签位置分配:', this.warehousePoints.map(p => ({
name: p.name,
position: p.labelPosition,
offset: p.labelOffset,
value: p.value,
hasName: !!p.name
})));
console.log('有效仓库点位数量:', this.warehousePoints.length);
// name
this.warehousePoints.forEach((p, idx) => {
if (!p.name) {
@ -1227,7 +1227,7 @@ export default {
const sumLng = validPoints.reduce((sum, p) => sum + p.value[0], 0)
const sumLat = validPoints.reduce((sum, p) => sum + p.value[1], 0)
centerCoord = [sumLng / validPoints.length, sumLat / validPoints.length]
//
if (validPoints.length === 1) {
zoomLevel = 5.5 //
@ -1282,7 +1282,7 @@ export default {
formatter: function(params) {
// - warehousePoints
let name = ''
// 1 warehousePoints
if (that.warehousePoints && params.dataIndex !== undefined && params.dataIndex >= 0 && params.dataIndex < that.warehousePoints.length) {
const pointData = that.warehousePoints[params.dataIndex]
@ -1290,19 +1290,19 @@ export default {
name = pointData.name
}
}
// 2 params.data ECharts scatter
if (!name && params.data) {
if (typeof params.data === 'object' && params.data.name) {
name = params.data.name
}
}
// 3使 params.name
if (!name && params.name) {
name = params.name
}
//
if (!name) {
console.error('标签 formatter 无法获取名称:', {
@ -1312,7 +1312,7 @@ export default {
})
name = '仓库' + (params.dataIndex !== undefined ? (params.dataIndex + 1) : '')
}
return name
},
position: function(params) {
@ -1363,16 +1363,16 @@ export default {
zoom: zoomLevel
}
}, { notMerge: false, lazyUpdate: false });
//
this.myChart.resize();
// 使 graphic
this.drawLabelsWithGraphic();
//
this.hasLoadedWarehouses = true
//
this.myChart.off('georoam') //
this.myChart.on('georoam', () => {
@ -1384,7 +1384,7 @@ export default {
this.myChart.off('click');
this.myChart.on('click', params => {
console.log('地图点击事件:', params)
//
if (params.seriesName === '仓库点位' || (params.componentType === 'series' && params.seriesType === 'scatter')) {
// dataIndex
@ -1399,7 +1399,7 @@ export default {
// 使 data
if (params.data) {
// data
const warehouseData = this.warehousePoints.find(p =>
const warehouseData = this.warehousePoints.find(p =>
p.value[0] === params.data.value[0] && p.value[1] === params.data.value[1]
) || params.data
console.log('点击仓库图标:', warehouseData.name || warehouseData)

@ -132,7 +132,7 @@ export default {
return group[0]
})
.filter(Boolean)
console.log('filtered:', filtered)
console.log('filtered:', filtered)
// 湿 0.00
const validDevice = filtered.find(item => {
@ -174,17 +174,17 @@ export default {
}
return {
id: item.id,
name:
item.gas_config && item.gas_config.name
? item.gas_config.name
: `监控点${item.node_id}`,
status: item.status || '正常',
coConcentration:
item.co_concentration != null && item.co_concentration !== ''
? `${item.co_concentration} ppm`
: '-',
temperature:
id: item.id,
name:
item.gas_config && item.gas_config.name
? item.gas_config.name
: `监控点${item.node_id}`,
status: item.status || '正常',
coConcentration:
item.co_concentration != null && item.co_concentration !== ''
? `${item.co_concentration} ppm`
: '-',
temperature:
temperature != null && temperature !== '' && parseFloat(temperature) !== 0
? `${temperature}`
: '-',
@ -192,7 +192,7 @@ export default {
humidity != null && humidity !== '' && parseFloat(humidity) !== 0
? `${humidity} %`
: '-',
updateTime: item.record_time || ''
updateTime: item.record_time || ''
}
})
this.cameras = filtered.map(item => ({

Loading…
Cancel
Save