Newer
Older
CloudBrainNew / src / views / cityManage / components / wisdomTraffic / trafficBase.vue
<!--
 * @Description: 交通整体概况
 * @Author: 王晓颖
 * @Date: 2020-11-30 15:20:49
 -->
<template>
  <chart-layout title="交通基本设施">
    <div class="block-container">
      <div class="block" v-for="(value,key,index) in data" :key="index">
        <simple-block :data="value" size="small" :color="value.color">
          <img :src="value.icon">
        </simple-block>
      </div>
    </div>
    <corner1 slot="corner"/>
  </chart-layout>
</template>

<script>
import SimpleBlock from '@/components/block/simpleBlock'
import SingleLayout from '@/components/layout/singleLayout'
import mockData from '../../../../../static/plan.json'
// import {fetchInfrastructure} from '@/api/jgzl'
export default {
  name: 'TrafficBase',
  components: {SingleLayout, SimpleBlock},
  data () {
    return {
      data: {
        jgzl: {name: '交通路口', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/road.png')},
        cscl: {name: '公交车站', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/bus.png')},
        stgy: {name: '桥梁', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/bridge.png')},
        csgy: {name: '隧道', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/tunnel.png')},
        hp: {name: '加油站', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/gas.png')},
        hl: {name: '交通枢纽', value: '', unit: '个', color: '', icon: require('@/assets/images/traffic/traffic.png')}
      }
    }
  },
  mounted () {
    this.getData()
  },
  methods: {
    getData () {
      // for (const item of Object.keys(this.data)) {
      //   this.getItemData(item)
      // }
      this.data.jgzl.value = mockData.traffic.intersection
      this.data.cscl.value = mockData.traffic.bus
      this.data.stgy.value = mockData.traffic.bridge
      this.data.csgy.value = mockData.traffic.tunnel
      this.data.hp.value = mockData.traffic.gas
      this.data.hl.value = mockData.traffic.hub
    },
    // item,传参数
    getItemData (item) {
      console.log(item)
      // fetchInfrastructure(item).then(response => {
      //   if (response.code === 200) {
      //     this.data.item.value = response.data.total
      //   }
      // }).catch((e) => {
      //   this.data[item.value = 7
      // })
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .block-container{
    height: 100%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    flex-wrap: wrap;
    margin: 0.04rem;
    padding-top:0.04rem;
    .block{
      width: 33%;
      height: 45%;
    }
  }
</style>