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

<script>
export default {
  name: 'SimpleBlock',
  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: 'black' }
      }
    }

  },
  props: {
    fontFamily: {
      type: String,
      default: ''
    },
    options: {
      type: Object,
      default: () => {
        return {
          bgColor: '', // 背景颜色,
          color: '' // 数值颜色
        }
      }
    },
    size: {
      type: String,
      default: ''
    }, // 大小
    color: {
      type: String,
      default: '@ffffff'
    },
    data: {
      type: Object,
      default: () => {
        return {
          name: '拥堵指数', // 标题
          value: '341', // 数值
          unit: ''
        }
      }
    }
  },
  data() {
    return {
      titleColor: '#ffffff'
    }
  }
}
</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;
      display: flex;
      justify-content: space-between;
      align-items: center;
      height:100%;
      border-left: 2px solid #03EFFF;
      .index-name{
        color:white;
        padding-left: 0.2rem;
        font-size:0.12rem;
        /*font-weight: bold;*/
        margin-bottom: 0.1rem;
        width:6rem;
        vertical-align: center;

      }
      .index-data{
        background-color:#66b2ff;
        padding-right: 0.4rem;
        flex:1;
        display: flex;
        justify-content: flex-end;
        align-items: center;
        text-align: right;
        height: 100%;
        .index-value{
          font-size:0.27rem;
          font-weight: bolder;
          text-align: right;
        }
      }

    }
  }
</style>