Newer
Older
BigScreenDatav / src / components / block / simpleBlock.vue
StephanieGitHub on 19 Jul 2021 3 KB MOD: 调整1920*1080的屏幕适配
<!--
 * @Description: 数值显示
 * @Author: 王晓颖
 * @Date: 2020-09-06 16:17:37
 -->
<template>
  <dv-border-box-8>
  <div class="index-container">
    <!--右边内容-->
    <div class="index-right">
      <!--标题-->
      <div class="index-name" :style="{'color':options.titleColor,'font-size':options.titleSize}">{{data.name}}</div>
      <!--数值 & 单位-->
      <div class="index-data">
        <div class="index-value" :style="{'color':options.color,'font-size':options.valueSize,'font-family':fontFamily}">{{data.value}}</div>
        <div class="data-right" :style="{'color':options.unitColor,'font-size':options.unitSize}">
          {{data.unit}}
        </div>
      </div>
    </div>
    <!--左边图标-->
    <div class="index-left">
      <slot></slot>
    </div>
  </div>
  </dv-border-box-8>
</template>

<script>
export default {
  name: 'simpleBlock',
  props: {
    fontFamily: {
      type: String,
      default: ''
    },
    options: {
      type: Object,
      default: () => {
        return {
          titleSize:'0.25rem',
          valueSize:'0.4rem',
          unitSize:'0.1rem',
          bgColor: '', // 背景颜色,
          titleColor: '#99ccff', // 标题颜色
          color: '#fffff', // 数值颜色
          unitColor: '#99ccff' // 单位颜色
        }
      }
    },
    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: flex-end;
      img{
        /*width:68%;*/
        width:0.32rem;
        height:0.32rem;
      }
    }
    .index-right{
      color:white;
      flex:1;
      padding-left: 0.3rem;
      .index-name{
        color:white;
        font-size:0.09rem;
        font-weight: bold;
        margin-bottom: 0.03rem;
        line-height: 1.5;
      }
      .index-data{
        width: 100%;
        display: flex;
        justify-content: start;
        align-items: flex-end;
        text-align: right;
        line-height: 1.5;
        .index-value{
          font-weight: bolder;
        }
        .data-right{
          display: flex;
          justify-content: start;
          margin-left:0.01rem;
        }
      }

    }
  }
</style>