<template>
  <div class="xl-panel" :style="{'background': 'linear-gradient(to right, '+ startColor +' 0%, ' + stopColor +' 100%)'}">
    <div v-if="title" class="title" style="padding-bottom:10px;">
      <icon :name="icon" class="m-icon" /><span >{{ title }}</span>
    </div>
    <div class="content">
      <div class="wrapper">
        <div class="panel-content" v-if="direction==='column'">
          <div class="wrapper2">
            <p v-for="(item, index) in list" :key="index"><span>{{item.label}}</span><span>{{item.value + item.unit}}</span></p>
          </div>
        </div>
        <template v-else>
          <number-unit v-for="(item, index) in list" :key="index" :count="item.value" :unit="item.unit" label="主变台数" />
        </template>
      </div>
    </div>
  </div>
</template>

<script>
import { Icon } from 'vant'
// import NumberUnit from '../numberUnit'
export default {
  components: {
    Icon
  },
  props: {
    backgroundColor: {
      type: [String, Array],
      default: 'transparent'
    },
    icon: {
      type: String,
      default: ''
    },
    title: {
      type: String,
      default: ''
    },
    direction: {
      type: String,
      default: ''
    },
    list: {
      type: Array,
      default: () => []
    }
  },
  computed: {
    backgroundColorTrans() {
      if (typeof this.backgroundColor === 'string') {
        return [this.backgroundColor, this.backgroundColor]
      }
      return this.backgroundColor || ['transparent', 'transparent']
    },
    startColor() {
      return this.backgroundColorTrans[0] || 'transparent'
    },
    stopColor() {
      return this.backgroundColorTrans[1] || 'transparent'
    }
  }
}
</script>

<style scoped>
.xl-panel {
    position: relative;
    border-radius: 5px;
    box-shadow: 0 1px 1px rgba(0,0,0,0.1);
    padding: 8px 0;
    width: 100%;
}
.xl-panel .title{
    font-weight: bold;
    font-size: 16px;
    color: #ffffff;
    padding: 0 14px;
}
.xl-panel .content {
  margin: 0 14px;
}
.xl-panel .m-icon {
  margin-right: 2px;
}
.panel-content {
  margin: 5px 0 15px 0;
}
.wrapper {
  display: flex;
  justify-content: space-around;
  align-items: center;
}
.wrapper2 p {
  display: flex;
  justify-content: space-between;
  align-items: center;
  line-height: 38px;
  color:#fff;
  font-size: 12px;
  border-bottom: 1px solid #f0f0f0;
}
.wrapper > div {
  position: relative;
  flex: 1;
}
.wrapper > div:after{
  content: '';
  position: absolute;
  width: 1px;
  transform: scale(0.5);
  right: 0;
  background: #fff;;
  height: 200%;
}
.wrapper > div:last-child::after {
  display: none;
}
.tank {
  margin-top: 12px;
  display: flex;
  justify-content: space-between;
}
.tank > div {
  margin: 2px;
}
.number-unit-wrap .number-and-unit .count {
  font-size: 22px!important;
}
</style>
