<template>
  <div class="home-container">
    <el-card class="home-container__card">
      <div class="title">
        <span>
          业务看板
        </span>
        <span>
          <i
            class="el-icon-refresh-right"
            style="cursor: pointer;font-size:20px"
            @click="refresh"
          ></i>
        </span>
      </div>
      <div class="content" v-loading="loading">
        <div class="content-item" v-for="(item, index) in list" :key="index">
          <div class="card">
            <i :class="item.icon" style="font-size:30px;color:#409EFF"></i>
            <div class="card-content">
              <span class="card-content-num">{{ item.qty }}</span>
              <span class="card-content-text">{{ item.text }}</span>
            </div>
          </div>
        </div>
      </div>
    </el-card>
  </div>
</template>

<script>
import {
  checkDate,
  shipCheckDate,
  financeCheck,
  count
} from "@/api/wel";
export default {
  name: "basicContainer",
  props: {
    sysType: Number
  },
  data() {
    return {
      loading: false,
      list: [
        { icon: "el-icon-s-order", qty: "0", text: "今日新增柜数" },
        { icon: "el-icon-s-order", qty: "0", text: "未安排柜数" },
        { icon: "el-icon-s-goods", qty: "0", text: "今日派车数" },
        { icon: "el-icon-s-home", qty: "0", text: "可用车辆数" }
      ],
      tradeType: null
    };
  },
  created() {
    this.getSysType();
  },
  methods: {
    getCheckDate() {
      this.loading = true;
      count({ tradeType: this.tradeType })
        .then(res => {
          console.log(res.data.data)
          this.list.forEach(e => {
            if(e.text == "今日新增柜数")e.qty = res.data.data.newly
            if(e.text == "未安排柜数")e.qty = res.data.data.inactive
            if(e.text == "今日派车数")e.qty = res.data.data.send
            if(e.text == "可用车辆数")e.qty = res.data.data.usable
          });
        })
        .finally(() => {
          this.loading = false;
        });
    },
    refresh() {
      this.getCheckDate()
    }
  }
};
</script>

<style lang="scss" scoped>
.home-container {
  padding: 0px 5px 5px 5px;
  box-sizing: border-box;
  height: 100%;
  ::v-deep .el-card__body {
    padding: 10px 15px;
    font-size: 14px;
  }
  &__card {
    width: 100%;
    height: 100%;
  }
  .title {
    display: flex;
    justify-content: space-between;
  }
}
.content {
  display: flex;
  &-item {
    background-color: #f4f8ff;
    margin-top: 0.5vh;
    margin-right: 0.5vw;
    height: 13vh;
    width: 15vw;
    display: flex;
    align-items: center;
    padding-left: 1.5vw;
    .card {
      display: flex;
      align-items: center;
      &-content {
        padding-left: 1vw;
        display: flex;
        flex-direction: column;
        //justify-content: space-around;
        &-num {
          font-size: 20px;
          font-weight: 600;
        }
        &-text {
          color: #909399;
        }
      }
    }
  }
}
</style>
