Newer
Older
smartwell_front_dz / src / components / BigData / Card / index.vue
wangxitong on 8 Jul 2 KB 达州变更
<template>
  <el-card :body-style="{ padding: '0px' }" :shadow="shadow">
    <div class="card-panel">
      <div :style="backgroundColor" class="card-panel-icon-wrapper">
        <svg-icon :icon-class="icon" class-name="card-panel-icon" />
      </div>
      <div class="card-panel-description">
        <div class="card-panel-text">
          {{ title }}
        </div>
        <div class="card-panel-num">
          <span>{{ context }}</span>
          <span>{{ flags }}</span>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: 'Card',
  props: {
    title: {
      type: String,
      default: '标题'
    }, // 标题
    flags: {
      type: String,
      default: '单位'
    }, // 单位
    subtitle: {
      type: String,
      default: ''
    }, // 小标题
    icon: {
      type: String,
      default: ''
    }, // 图标
    context: {
      type: [String, Number],
      default: ''
    }, // 内容
    color: {
      type: String,
      default: '#40c9c6'
    }, // 图标颜色
    shadow: {
      type: String,
      default: 'always'
    } // 卡片阴影
  },
  computed: {
    backgroundColor() {
      return {
        color: this.color
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .card-panel {
    height: 108px;
    cursor: pointer;
    font-size: 12px;
    position: relative;
    overflow: hidden;
    color: #666;
    background: #fff;
    box-shadow: 4px 4px 40px rgba(0, 0, 0, .05);
    border-color: rgba(0, 0, 0, .05);

    &:hover {
      .card-panel-icon-wrapper {
        color: #fff;
      }
    }

    .card-panel-icon-wrapper {
      float: left;
      margin: 14px 0 0 14px;
      padding: 16px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

    .card-panel-icon {
      float: left;
      font-size: 48px;
    }

    .card-panel-description {
      float: left;
      font-weight: bold;
      margin: 26px;
      margin-left: 10px;

      .card-panel-text {
        line-height: 18px;
        color: rgba(0, 0, 0, 0.45);
        font-size: 16px;
        margin-bottom: 12px;
      }

      .card-panel-num {
        font-size: 20px;
      }
    }
  }
</style>