Newer
Older
qd_cnooc_front / src / components / BigData / Card1 / index.vue
Stephanie on 15 Nov 2022 2 KB fix<views>: 动力管线首页修改
<template>
  <el-card :body-style="{ padding: '0px' }" shadow="always">
    <div class="card-panel">
      <div v-if="icon" :style="backgroundColor" class="card-panel-icon-wrapper">
        <svg-icon :icon-class="icon" class-name="card-panel-icon"/>
      </div>
      <!--      <div v-else style="float:left; width: 10px;height: 100%;"/>-->
      <div class="card-panel-description" style="padding: 0px 15px;">
        <div v-if="title.length>1" class="two">
          <div v-for="(name, index) of title" :key="name" class="card-panel-text">
            {{ name }} <span class="card-panel-num">{{ context[index] }}<span
              style="font-size: 10px;color:#888;margin-left: 5px">{{ unit }}</span></span>
          </div>
        </div>
        <div v-else class="only">
          <div class="card-panel-text">
            {{ title[0] }}
          </div>
          <div class="card-panel-num">
            {{ context[0] }}<span style="font-size: 10px;color:#888">{{ unit }}</span>
          </div>
        </div>
      </div>
    </div>
  </el-card>
</template>

<script>
export default {
  name: 'Card1',
  props: {
    title: {
      type: Array,
      default: function() {
        return ['标题', '标题']
      }
    },
    subtitle: {
      type: String,
      default: ''
    },
    icon: {
      type: String,
      default: ''
    },
    context: {
      type: Array,
      default: function() {
        return ['--', '--']
      }
    },
    color: {
      type: String,
      default: '#40c9c6'
    },
    unit: {
      type: String,
      default: ''
    }
  },
  computed: {
    backgroundColor() {
      return {
        color: this.color
      }
    }
  }
}
</script>

<style lang="scss" scoped>
  .card-panel {
    height: 108px;
    font-size: 12px;
    position: relative;
    display: flex;
    align-items: center;
    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 {
      margin: 14px 0 0 10px;
      padding: 16px 2px;
      transition: all 0.38s ease-out;
      border-radius: 6px;
    }

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

    .card-panel-description {
      flex:1;
      font-weight: bold;
      overflow: auto;
      margin-left: 5px;

      .two {
        .card-panel-text {
          line-height: 26px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 14px;
          display: flex;
          justify-content: space-between;
        }
        .card-panel-num {
          font-size: 18px;
          color: #666;
        }
      }
      .only {
        .card-panel-text {
          line-height: 18px;
          color: rgba(0, 0, 0, 0.45);
          font-size: 14px;
          margin-bottom: 12px;
          padding-top: 0;
        }

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