This commit is contained in:
bb_pan 2026-02-04 14:07:01 +08:00
parent 2997bf170f
commit 0cad9ed7a2
1 changed files with 46 additions and 52 deletions

View File

@ -82,12 +82,13 @@ export default {
configuration: 0, // configuration: 0, //
mechanization: 0, // mechanization: 0, //
}, },
checkList:[], checkList: [],
checkList2: [], checkList2: [],
checkList3: [], checkList3: [],
radio: 1, radio: 1,
// //
mechanizationTotal: 0, mechanizationTotal: 0,
requestId: 0,
} }
}, },
created() { created() {
@ -109,75 +110,68 @@ export default {
this.getInfo() this.getInfo()
}, },
async getInfo() { async getInfo() {
const currentId = ++this.requestId // id
try { try {
this.cityData = []
const { data } = await getTotalEquipmentApi() const { data } = await getTotalEquipmentApi()
if (currentId !== this.requestId) return
this.equipData.total = data.totalEquipmentQuantity || 0 this.equipData.total = data.totalEquipmentQuantity || 0
this.equipData.totalPrice = data.totalValue || 0 this.equipData.totalPrice = data.totalValue || 0
this.equipData.configuration = data.configuration || 0 this.equipData.configuration = data.configuration || 0
this.equipData.mechanization = data.mechanization || 0 this.equipData.mechanization = data.mechanization || 0
let res = null let res = null
if (this.btnIndex == 1) { if (this.btnIndex == 1) {
res = await getUnitEquipmentConfigurationApi() res = await getUnitEquipmentConfigurationApi()
if (!res.data) return if (currentId !== this.requestId || !res.data) return
res.data = res.data.filter((item) => item.location)
this.cityData = res.data.map((item) => { this.cityData = res.data
let value = item.location.split(',') .filter((item) => item.location)
value.push(item.totalValue) .map((item) => ({
// console.log('🚀 ~ getInfo ~ value:', value)
return {
...item, ...item,
value, value: [...item.location.split(','), item.totalValue],
} }))
})
} }
if (this.btnIndex == 4) {
let type = '' if (this.btnIndex == 2 || this.btnIndex == 3) {
switch (this.radio) {
case 1:
type = '线路'
break
case 2:
type = '变电'
break
case 3:
type = '电缆'
break
}
res = await getMechanizationRateApi({ type })
if (!res.data) return
this.mechanizationTotal = res.data.find((item) => item.dataType == 'total')?.mechanizationRate
res.data = res.data.filter((item) => item.cityName)
this.cityData = res.data.map((item) => {
return {
cityName: item.cityName,
mechanizationRate: item.mechanizationRate,
dataType: item.dataType,
companyName: item.companyName,
}
})
} else if (this.btnIndex == 2 || this.btnIndex == 3) {
// res = await getEquipmentNumberApi()
res = await getUnitEquipmentConfigurationApi() res = await getUnitEquipmentConfigurationApi()
if (!res.data) return if (currentId !== this.requestId || !res.data) return
res.data = res.data.filter((item) => item.location)
this.cityData = res.data.map((item) => { this.cityData = res.data
let value = item.location.split(',') .filter((item) => item.location)
value.push(item.num) .map((item) => ({
// console.log('🚀 ~ getInfo ~ value:', value)
return {
...item, ...item,
value, value: [...item.location.split(','), item.num],
} }))
})
} }
if (this.btnIndex == 4) {
const typeMap = {
1: '线路',
2: '变电',
3: '电缆',
}
res = await getMechanizationRateApi({ type: typeMap[this.radio] })
if (currentId !== this.requestId || !res.data) return
this.mechanizationTotal = res.data.find((item) => item.dataType === 'total')?.mechanizationRate
this.cityData = res.data.filter((item) => item.cityName)
}
this.$nextTick(() => { this.$nextTick(() => {
console.log('🚀 ~ 地图数据 ~ this.cityData:', this.cityData) if (currentId !== this.requestId) return
this.initChart() this.initChart()
}) })
console.log('🚀 ~ 地图数据 ~ res:', res)
} catch (error) { } catch (error) {
console.log('🚀 ~ 地图数据 ~ error:', error) if (currentId === this.requestId) {
// this.initChart() console.error(error)
}
} }
}, },
initChart(jsonData = mapJson) { initChart(jsonData = mapJson) {