master
lion 4 months ago
parent cd2c0b8b67
commit a8bbdde89c

@ -47,5 +47,10 @@ export function soCharts(params) {
params: params params: params
}) })
} }
export function finishCharts(params) {
return request({
url: '/api/admin/chart/finish',
method: 'get',
params: params
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 261 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 498 B

@ -1,5 +1,5 @@
<template> <template>
<div ref="chart1" style="width:350px" class="bar3d-chart" /> <div ref="chart1" style="width:400px" class="bar3d-chart" />
</template> </template>
<script> <script>
@ -10,38 +10,88 @@ export default {
props: { props: {
xData: { xData: {
type: Array, type: Array,
default: [] default: () => []
}, },
yData: { yData: {
type: Array, type: Array,
default: [] default: () => []
} }
}, },
watch: { watch: {
xData(newVal) { xData: {
if (newVal) { handler(newVal) {
console.log('Bar3DChart xData 变化:', newVal)
console.log('Bar3DChart 当前 yData:', this.yData)
// 使
this.initChart() this.initChart()
this.resizeChart() this.resizeChart()
} },
immediate: true,
deep: true
},
yData: {
handler(newVal) {
console.log('Bar3DChart yData 变化:', newVal)
console.log('Bar3DChart 当前 xData:', this.xData)
// 使
this.initChart()
this.resizeChart()
},
immediate: true,
deep: true
} }
}, },
mounted() { mounted() {
console.log('Bar3DChart 组件挂载')
console.log('DOM 元素:', this.$refs.chart1)
this.chart = echarts.init(this.$refs.chart1) this.chart = echarts.init(this.$refs.chart1)
console.log('ECharts 实例创建:', this.chart)
//
this.initChart()
}, },
beforeDestroy() { beforeDestroy() {
if (this.chart) this.chart.dispose() if (this.chart) this.chart.dispose()
}, },
methods: { methods: {
initChart() { initChart() {
// this.chart = echarts.init(this.$refs.chart1) console.log('Bar3DChart initChart 被调用')
console.log('当前 xData:', this.xData)
console.log('当前 yData:', this.yData)
//
const xData = this.xData && this.xData.length > 0 ? this.xData : ['暂无数据']
const yData = this.yData && this.yData.length > 0 ? this.yData : [
{
name: '盘点',
type: 'bar',
data: [0],
itemStyle: { color: '#6ec6ff' }
},
{
name: '维护',
type: 'bar',
data: [0],
itemStyle: { color: '#4be3c1' }
}
]
const option = { const option = {
backgroundColor: 'transparent', backgroundColor: 'transparent',
title: { // title: {
text: '待办任务', // text: '',
left: 'center', // left: 'center',
top: 0, // top: 0,
// textStyle: {
// color: '#6dcde6'
// }
// },
legend: {
data: yData.map(item => item.name),
top: 30,
textStyle: { textStyle: {
color: '#6dcde6' color: '#fff'
} }
}, },
grid: { grid: {
@ -50,9 +100,15 @@ export default {
bottom: 140, bottom: 140,
top: 80 top: 80
}, },
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'shadow'
}
},
xAxis: { xAxis: {
type: 'category', type: 'category',
data: this.xData, data: xData,
axisLine: { axisLine: {
lineStyle: { lineStyle: {
color: '#6ec6ff' color: '#6ec6ff'
@ -60,7 +116,12 @@ export default {
}, },
axisLabel: { axisLabel: {
color: '#fff', color: '#fff',
fontSize: 16 fontSize: 16,
interval: 0, //
rotate: 45, // 45
textStyle: {
fontSize: 12 //
}
} }
}, },
yAxis: { yAxis: {
@ -81,11 +142,12 @@ export default {
fontSize: 16 fontSize: 16
} }
}, },
series: [{ series: yData.map(item => ({
name: item.name,
type: 'bar', type: 'bar',
barWidth: 40, barWidth: 40,
data: this.yData, data: item.data,
itemStyle: { itemStyle: item.itemStyle || {
color: { color: {
type: 'linear', type: 'linear',
x: 0, x: 0,
@ -106,15 +168,20 @@ export default {
shadowBlur: 10 shadowBlur: 10
}, },
label: { label: {
show: true, show: false
position: 'top',
color: '#fff',
fontSize: 18
} }
}] }))
} }
console.log('ECharts 配置:', option)
this.$nextTick(() => { this.$nextTick(() => {
this.chart.setOption(option) if (this.chart) {
this.chart.setOption(option)
console.log('图表配置已应用')
} else {
console.warn('图表实例不存在')
}
}) })
}, },
resizeChart() { resizeChart() {

@ -48,7 +48,7 @@ export default {
props: { props: {
mapStyle:{ mapStyle:{
type:String, type:String,
default:()=>{return 'width:700px;height:500px;position: relative;'} default:()=>{return 'width:650px;height:500px;position: relative;'}
} }
// mapData: { // mapData: {
// type: Array, // type: Array,
@ -66,6 +66,7 @@ export default {
wuziList:[], wuziList:[],
wuziTotal:0, wuziTotal:0,
cangkuObj:{}, cangkuObj:{},
warehouseData: [], //
table: [{ table: [{
label: '序号', label: '序号',
type: 'index', type: 'index',
@ -486,24 +487,43 @@ export default {
}); });
}, },
async zoomToArea(areaObj) { async zoomToArea(areaObj) {
console.log('点击区域:', areaObj);
// 1. // 1.
const warehouseList = await this.getList(areaObj.id); const warehouseList = await this.getList(areaObj.id);
console.log('获取到的仓库列表:', warehouseList);
// 2. // 2.
this.warehousePoints = (warehouseList || []).map(item => ({ this.warehousePoints = (warehouseList || []).map(item => {
name: item.cangkumingcheng, const jingdu = Number(item.jingdu);
value: [Number(item.jingdu), Number(item.weidu)], const weidu = Number(item.weidu);
id: item.id,
item:item //
})); 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],
id: item.id,
item: item
};
}).filter(point => point !== null); //
console.log('生成的仓库点位:', this.warehousePoints);
console.log('有效仓库点位数量:', this.warehousePoints.length);
// 3. geocenterzoom // 3. geocenterzoom
console.log('设置地图配置,仓库点位数量:', this.warehousePoints.length);
this.myChart.setOption({ this.myChart.setOption({
series: [ series: [
{ {
name: '区域', name: '区域',
type: 'map', type: 'map',
mapType: 'china', map: 'GX',
geoIndex: 0, geoIndex: 0,
markPoint: { markPoint: {
symbol: '', symbol: '',
@ -526,16 +546,18 @@ export default {
} }
}, },
{ {
name: '仓库点位',
type: 'scatter', type: 'scatter',
coordinateSystem: 'geo', coordinateSystem: 'geo',
data: this.warehousePoints, data: this.warehousePoints,
symbolSize: 12, symbol: 'pin',
itemStyle: { color: '#f00' }, symbolSize: [16, 20],
itemStyle: { color: 'orange' },
label: { label: {
show: true, show: true,
formatter: '{b}', formatter: '{b}',
position: 'top', position: 'top',
color: 'red', color: 'orange',
fontSize: 12 fontSize: 12
} }
} }
@ -546,6 +568,9 @@ export default {
} }
}); });
//
this.myChart.resize();
// //
this.myChart.off('click'); this.myChart.off('click');
this.myChart.on('click', params => { this.myChart.on('click', params => {
@ -570,13 +595,46 @@ export default {
this.cangkuObj = {} this.cangkuObj = {}
this.wuziTotal = 0 this.wuziTotal = 0
this.showData = false this.showData = false
// geoseries
this.myChart.setOption({ console.log('resetToFullMap - warehouseData:', this.warehouseData);
series: [ console.log('resetToFullMap - warehouseData.length:', this.warehouseData ? this.warehouseData.length : 0);
{
// drawChart
this.drawChart();
//
if (this.warehouseData && this.warehouseData.length > 0) {
this.updateWarehouseData(this.warehouseData);
}
//
this.myChart.resize();
console.log('返回全图完成,仓库点位已清除,仓库数量应显示');
},
updateWarehouseData(warehouseData) {
//
this.warehouseData = warehouseData;
//
const updatedStreetList = this.streetNameList.map(street => {
const warehouseInfo = warehouseData.find(w => w.name === street.name);
if (warehouseInfo) {
return {
...street,
warehouseCount: warehouseInfo.warehouseCount
};
}
return street;
});
//
if (this.myChart) {
this.myChart.setOption({
series: [{
name: '区域', name: '区域',
type: 'map', type: 'map',
mapType: 'china', map: 'GX',
geoIndex: 0, geoIndex: 0,
markPoint: { markPoint: {
symbol: '', symbol: '',
@ -592,40 +650,29 @@ export default {
borderColor: '#096dd9', borderColor: '#096dd9',
backgroundColor: '#fff', backgroundColor: '#fff',
formatter(val) { formatter(val) {
return val.data.name const street = updatedStreetList.find(s => s.name === val.data.name);
if (street && street.warehouseCount !== undefined) {
return `{name|${street.name}}\n{warehouse|仓库: ${street.warehouseCount}}`;
}
return val.data.name;
},
rich: {
name: {
color: '#333',
fontSize: 12,
fontWeight: 'bold'
},
warehouse: {
color: 'orange',
fontSize: 12
}
} }
}, },
data: this.streetNameList data: updatedStreetList
} }
}, }]
{ });
type: 'scatter', }
coordinateSystem: 'geo',
data: [] //
}
],
geo: {
center: [120.585294, 31.299758], //
zoom: 1 //
}
});
//
this.myChart.off('click');
this.myChart.on('click', params => {
if (params.seriesType === 'scatter') {
this.getWuzi(params.data);
} else if (params.componentType === 'series' && params.seriesType === 'map') {
const areaName = params.name;
const areaObj = this.streetNameList.find(item => item.name === areaName);
if (areaObj) {
this.currentArea = areaObj;
this.zoomToArea(areaObj);
}
} else if (params.componentType === 'geo') {
this.resetToFullMap();
}
});
}, },
async getWuzi(cangku) { async getWuzi(cangku) {
console.log("warehouseId",cangku) console.log("warehouseId",cangku)

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save