<template>
  <div class="card_waybill_head">
    <div class="card_waybill_item" v-for="(item,index) in list" :key="index">
      <div class="title_count" :style="{color:item.color,}">{{item.count}}</div>
      <div class="title_item" :style="{color:item.color,}">{{item.title}}</div>
    </div>
    <div class="card_currentCity" v-if="currentCity">
      <div class="currentCity_title center_in"><span>{{currentCity}}</span></div>
      <div class="back_title" @click="goBackil">
        <i class="icon-fanhui iconfont back_icon"></i>
      </div>
    </div>
  </div>
</template>

<script>
  export default {
    props: {
      listData: {
        type: Object,
        default: () => {},
      },
      currentCity: {
        type: String,
        default: () => '',
      },
    },
    data() {
      return {
        list: [{
          id: 1,
          color: '#ffbf00',
          count: 0,
          title: '今日运单量',
        }, {
          id: 2,
          color: '#67C23A',
          count: 0,
          title: '本月运单量',
        }, {
          id: 3,
          color: '#409EFF',
          count: 0,
          title: '本年运单量',
        }, {
          id: 4,
          color: '#00ff68',
          count: 0,
          title: '累计运单量',
        }]
      }
    },
    watch: {
      listData: {
        handler(newVal) {
          if (newVal) {
            this.list.forEach(item => {
              if (item.id == 1) {
                item.count = newVal.todayNum
              } else if (item.id == 2) {
                item.count = newVal.thisMonthNum
              } else if (item.id == 3) {
                item.count = newVal.thisYearNum
              } else if (item.id == 4) {
                item.count = newVal.todayNum + newVal.thisMonthNum + newVal.thisYearNum
              }
            })
          }
        },
        deep: true,
        immediate: true
      }
    },
    methods: {
      goBackil() {
        this.$emit('goback')
      }
    }
  }
</script>

<style lang="scss">
  .card_waybill_head {
    display: flex;
    align-items: center;
    height: 100px;
    width: 100%;
    position: relative;
  }

  .card_currentCity {
    position: absolute;
    z-index: 2;
    right: 10px;
    bottom: -45px;
    height: 40px;
    display: flex;
    align-items: center;
    // background-color: red;
  }

  .currentCity_title {
    color: #fff;
    min-width: 100px;
    height: 100%;

    span {
      position: relative;
      z-index: 2;
    }
  }

  .currentCity_title::after {
    z-index: 1;
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    width: 110%;
    background: url(../../assets/images/pitch.png);
    background-size: 100% 100%;
    background-repeat: no-repeat;
  }

  .back_title {
    z-index: 3;
    margin-left: 15px;
  }

  .back_icon {
    cursor: pointer;
    font-size: 30px;
    color: #fff;
  }

  .card_waybill_item {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    margin: 0px 10px;
    flex: 1;
    height: 80px;
    background-image: radial-gradient(circle 248px at center, rgba(0, 0, 0, 0) 10%, #037cd5 100%, );
    border: 1px solid #1a51b9;
  }

  .card_waybill_item::after {
    content: '';
    position: absolute;
    top: -1px;
    left: -1px;
    width: 40px;
    height: 40px;
    border-top: 2px solid #00e5ff;
    border-left: 2px solid #00e5ff;
  }

  .title_count {
    color: #fff;
    font-size: 34px;
  }

  .title_item {
    color: #fff;
    font-size: 16px;
  }
</style>
