+
+
+
重要防汛物资
@@ -57,17 +60,21 @@
import Bar3DChart from '../jsc/components/barChart.vue'
import fenleiChart from '../jsc/components/fenleiChart.vue'
import Pie3DChart from '../jsc/components/pieChart.vue'
-import echartsMap from './components/mapChart.vue'
+import echartsMap from './components/mapChart.vue'
+import WarehouseTable from './components/WarehouseTable.vue'
+
import {
fenleiCharts,
- homeCharts
+ homeCharts,
+
} from '@/api/charts.js'
export default {
components: {
Bar3DChart,
Pie3DChart,
echartsMap,
- fenleiChart
+ fenleiChart,
+ WarehouseTable
},
data() {
return {
@@ -169,7 +176,7 @@ export default {
'移动泵车':require('@/assets/bengche.jpg'),
'桩类':require('@/assets/zhuanglei.jpg'),
'砂石类':require('@/assets/shashi.jpg'),
- }
+ },
}
},
computed: {
@@ -190,7 +197,6 @@ export default {
this.calculateScreenSize()
window.addEventListener('resize', this.calculateScreenSize)
- this.startAutoSwitch()
},
beforeRouteLeave(to, from, next) {
this.$store.dispatch('app/toggleSideBar')
@@ -218,18 +224,7 @@ export default {
this.xData.push(item.value)
this.yData.push(home.rate[item.id])
})
- console.log(this.xData, this.yData)
- //
- // this.apiData = res.fenleiLevel1
- // this.chartDataMap = this.convertFenleiToChartDataMap(this.apiData)
- // let arr = []
- // res.upList.map(item=>{
- // arr.push({
- // name:item.name,
- // value:item.total,
- // unit:item.unit
- // })
- // })
+ console.log(this.xData, this.yData)
res.upList.map(item=>{
item.img = this.imgList[item.name]
})
@@ -278,79 +273,7 @@ export default {
return Array.from(resultMap.values());
},
- // 处理分类数据
- convertFenleiToChartDataMap(fenleiLevel1) {
- const chartDataMap = {}
- this.typeList = []
- fenleiLevel1.forEach(level1 => {
- const level1Name = level1.value
- // 一级
- this.typeList.push(level1Name)
- const level1Arr = [{
- value: level1.details.reduce((sum, d) => sum + (d.total_count || 0), 0), // 或自定义总数
- name: level1Name
- }]
-
- // 二级
- const level2Arr = []
- // 三级
- const level3Arr = [];
-
- (level1.details || []).forEach(level2 => {
- // 二级 value 为其所有 inventorys 的 total_count 之和
- let level2Value = 0;
- (level2.inventorys || []).forEach(inv => {
- level2Value += Number(inv.total_count) || 0
- })
- // 如果没有三级,直接用 total_count 字段
- if (level2Value === 0) level2Value = level2.total_count || 0
-
- level2Arr.push({
- value: level2Value,
- name: level2.value
- });
-
- // 三级
- (level2.inventorys || []).forEach(inv => {
- level3Arr.push({
- value: inv.total_count,
- name: inv.jiliangdanwei,
- parent: level2.value
- })
- })
- })
- chartDataMap[level1Name] = {
- level1: level1Arr,
- level2: level2Arr,
- level3: level3Arr
- }
- })
-
- return chartDataMap
- },
- // 启动自动切换
- startAutoSwitch() {
- clearInterval(this.autoTimer)
- let idx = this.typeList.indexOf(this.activeType)
- this.autoTimer = setInterval(() => {
- idx = (idx + 1) % this.typeList.length
- this.activeType = this.typeList[idx]
- }, 5000) // 10秒
- },
- // 停止自动切换,并在20秒后恢复
- stopAutoSwitchAndResumeLater() {
- clearInterval(this.autoTimer)
- clearTimeout(this.resumeTimer)
- this.resumeTimer = setTimeout(() => {
- this.startAutoSwitch()
- }, 10000) // 20秒
- },
- // 按钮点击事件
- handleTypeClick(type) {
- this.activeType = type
- this.stopAutoSwitchAndResumeLater()
- },
setRem() {
// 默认使用100px作为基准大小
const baseSize = 100
@@ -444,7 +367,7 @@ export default {
// flex-wrap: wrap;
&-left {
- height: 400px;
+ // height: 400px;
&-title {
color: #6dcde6;
text-align: center;