<template>
  <div class="m-subbox m-sq12345">
    <div class="table" v-if="pmList.length > 0">
      <div class="tr">
        <div class="th">排名</div>
        <div class="th">社区</div>
        <div class="th">事件数</div>
        <div class="th">处理中</div>
        <div class="th">已办结</div>
      </div>
      <div style="overflow: hidden">
        <div ref="animation4">
          <div class="tr" v-for="(item, index) in pmList" :key="index">
            <div :class="index - 0 + 1 < 4 ? `td tdbg${index - 0 + 1}` : 'td'">
              {{ index - 0 + 1 }}
            </div>
            <div class="td">{{ item.orgName }}</div>
            <div class="td">{{ item.sumNum }}</div>
            <div class="td td-or">{{ item.processNum }}</div>
            <div class="td td-gr">{{ item.closedNum }}</div>
          </div>
          <!-- 无缝滚动 -->
          <div v-if="pmList.length > 7">
            <div class="tr" v-for="(item, index) in pmList" :key="index">
              <div
                :class="index - 0 + 1 < 4 ? `td tdbg${index - 0 + 1}` : 'td'"
              >
                {{ index - 0 + 1 }}
              </div>
              <div class="td">{{ item.orgName }}</div>
              <div class="td">{{ item.sumNum }}</div>
              <div class="td td-or">{{ item.processNum }}</div>
              <div class="td td-gr">{{ item.closedNum }}</div>
            </div>
          </div>
        </div>
      </div>
    </div>
    <div
      v-else
      style="
        width: 100%;
        height: 100%;
        text-align: center;
        padding-top: 100px;
        color: #ffffff;
      "
    >
      <img
        width="268px"
        height="128px"
        src="~@/assets/images/overview/zanwu.png"
      />
      <div class="zanwuText">暂无数据</div>
    </div>
  </div>
</template>
<script>
export default {
  name: "sq12345",
  props: {
    currentLevelData: {
      type: Object,
      default: {},
    },
    date: {
      type: String,
      default: "",
    },
  },
  data() {
    return {
      org: this.$store.state.chooseArea.chooseName,
      pmList: [],
    };
  },
  watch: {
    currentLevelData(val) {
      if (val.orgId) {
        this.getList(val);
      }
    },
    date() {
      this.getList(this.currentLevelData);
    },
  },
  mounted() {
    if (this.currentLevelData.orgId) {
      this.getList(this.currentLevelData);
    }
  },
  methods: {
    getList(item) {
      this.$http
        .get(
          "/actual/base/streetOverview/eventAgencyGroup?month=" +
            this.date +
            "&level=" +
            item.orgLevel +
            "&orgId=" +
            item.orgId
        )
        .then(({ data: { data } }) => {
          this.pmList = data;
          if (this.pmList.length > 7) {
            this.$nextTick(() => {
              const aniHeight =
                this.$refs.animation4.querySelector(".tr").offsetHeight *
                this.pmList.length;
              console.log(aniHeight);
              this.$refs.animation4.style.animation = `move4 ${this.pmList.length}s linear infinite`;
              document.styleSheets[0].insertRule(
                `@keyframes move4{0% {transform: translateY(0px);}100% {transform: translateY(-${aniHeight}px);}`,
                0
              );
            });
          } else {
            this.$refs.animation4.style.animation = null;
          }
        });
    },
  },
};
</script>

<style
  lang="scss"
  src="@/assets/scss/dataBoard/overview/index.scss"
  scoped
></style>
<style lang="scss" scoped>
.zanwuText {
  margin-top: -34px;
  font-size: 14px;
  font-family: PingFang SC;
  font-weight: 500;
  color: #a3b9da;
}
</style>
