<template>
  <div class="container">
    <div class="title-box">
      <div class="one-box">
        <div class="react-box onebg"></div>
        <span>{{ day }}</span>
      </div>
      <div class="one-box">
        <div class="react-box twobg"></div>
        <span>{{ yesterday }}</span>
      </div>
    </div>
    <div class="content-box" v-for="(item, index) in dataList" :key="index">
      <div class="front-box">
        <div class="top-span">{{ item.orgname }}</div>
        <div class="bottom-tex" :style="{ color: item.hb <= 0 ? 'green' : 'red' }">
          环比:{{ item.hb }}
        </div>
      </div>
      <div class="center-box">
        <div class="center-x">
          <div class="line-box onebg" :style="'width:' +
            (
              item.count /
              (item.count + item.count1 == 0 ? 1 : item.count + item.count1)
            ).toFixed(2) *
            100 +
            '%;'
            "></div>
          <span>{{ item.count }}</span>
        </div>
        <div class="center-x">
          <div class="line-box twobg" :style="'width:' +
            (
              item.count1 /
              (item.count + item.count1 == 0 ? 1 : item.count + item.count1)
            ).toFixed(2) *
            100 +
            '%;'
            "></div>
          <span>{{ item.count1 }}</span>
        </div>
      </div>
      <div class="right-box">
        <div>占比</div>
        <span class="span-zhanb">{{ item.zb }}</span>
      </div>
    </div>
  </div>
</template>

<script>
import { compare } from "../../../utils/tools.js";
export default {
  props: {
    list: Array,
    day: String,
    yesterday: String,
  },
  watch: {
    list: {
      handler(val) {
        for (let i = 0; i < val.length; i++) {
          let item = val[i];
          item.zb = (
            (item.count / (item.count2 == 0 ? 1 : item.count2)) *
            100
          ).toFixed(2);
          item.hb = item.count - item.count1;
        }
        this.dataList = val.sort(compare("zb", true));
      },
      immediate: true,
      deep: true,
    },
  },
  data() {
    return {
      dataList: [],
    };
  },
  methods: {},
};
</script>

<style lang="scss" scoped>
@import "../../../assets/styles/mixin.scss";

.title-box {
  margin: 3vh 0;
  width: 100vw;
  display: flex;
  justify-content: center;
  @include font_color($font-color-theme);
}

.one-box {
  display: flex;
  margin-right: 2vw;
  height: 4vw;
  line-height: 4vw;
}

.react-box {
  width: 8vw;
  height: 4vw;
  border-radius: 1vw;
  margin-right: 1vw;
}

.onebg {
  background: linear-gradient(#0bbafb, #4285ec);
}

.twobg {
  background: linear-gradient(#98e05f, #0de3ac);
}

.content-box {
  font-size: 11px;
  margin: 3vw;
  border-bottom: 1px dashed #224465;
  display: flex;
  padding-bottom: 2vw;
  @include font_color($font-color-theme);
}

.center-x {
  display: flex;
  align-items: center;
}

.line-box {
  /* width: 10vw; */
  height: 2vw;
  border-radius: 1vw;
  margin-right: 1vw;
}

.front-box {
  flex: 1;
}

.center-box {
  flex: 3;
}

.right-box {
  flex: 1;
  margin-left: 2vw;
  text-align: right;
}

.span-zhanb {
  color: #ff7327;
  font-size: 18px;
  span-align: center;
  line-height: 6vw;
}

.bottom-tex {
  color: #e82929;
  font-size: 11px;
}
</style>
