Newer
Older
CloudBrainNew / src / components / block / simpleBlock.vue
StephanieGitHub on 4 Feb 2021 2 KB first commit
<!--
 * @Description: 数值显示
 * @Author: 王晓颖
 * @Date: 2020-09-06 16:17:37
 -->
<template>
  <div class="index-container">
    <!--左边图标-->
    <div class="index-left" :style="{'width':size=='small'?'0.6rem':'0.47rem'}">
      <slot></slot>
    </div>
    <!--右边内容-->
    <div class="index-right">
      <!--标题-->
      <div class="index-name" :style="{'color':color,'font-size':size=='small'?'0.08rem':'0.09rem'}">{{data.name}}</div>
      <!--数值 & 单位-->
      <div class="index-data">
        <div class="index-value" :style="{'color':color,'font-size':size=='small'?'0.15rem':'0.2rem','font-family':fontFamily}">{{data.value}}</div>
        <div class="data-right" :style="{'color':color,'font-size':size=='small'?'0.05rem':'0.07rem'}">
          {{data.unit}}
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'simpleBlock',
  props: {
    fontFamily: {
      type: String,
      default: ''
    },
    options: {
      type: Object,
      default: () => {
        return {
          bgColor: '', // 背景颜色,
          color: '' // 数值颜色
        }
      }
    },
    size: {
      type: String,
      default: ''
    }, // 大小
    color: {
      type: String,
      default: 'white'
    },
    data: {
      type: Object,
      default: () => {
        return {
          name: '拥堵指数', // 标题
          value: '341', // 数值
          unit: ''
        }
      }
    }
  },
  filters: {
    valueColor: (status) => {
      if (status === 'normal') {
        return {color: '#38ffc1'}
      } else if (status === 'danger') {
        return {color: '#ff226d'}
      } else if (status === 'warning') {
        return {color: '#ffd43f'}
      } else {
        return {color: 'white'}
      }
    }

  },
  data () {
    return {
    }
  }
}
</script>

<style rel="stylesheet/scss" lang="scss" scoped>
  .index-container{
    width:100%;
    height:100%;
    padding:0.05rem;
    display:flex;
    justify-content: space-between;
    align-items: center;
    .index-left{
      /*width:2rem;*/
      width:0.47rem;
      height:100%;
      display: flex;
      justify-content: center;
      align-items: center;
      img{
        /*width:68%;*/
        width:0.32rem;
        height:0.32rem;
      }
    }
    .index-right{
      color:white;
      flex:1;
      .index-name{
        color:white;
        font-size:0.09rem;
        font-weight: bold;
        margin-bottom: 0.03rem;
      }
      .index-data{
        width: 100%;
        display: flex;
        justify-content: start;
        align-items: flex-end;
        text-align: right;
        .index-value{
          font-size:0.20rem;
          font-weight: bolder;
        }
        .data-right{
          display: flex;
          justify-content: start;
          font-size:0.07rem;
          margin-bottom: 0.02rem;
        }
      }

    }
  }
</style>