<template>
  <div
    class="CustomerFeedback"
    @mousewheel.stop=""
  >
    <div class="Dashboard-SearchBar">
      <div class="CustomerFeedbackTitle">
        <span class="CustomerFeedback-icon"><img src="@/assets/images/dashboard/feedback.jpg"></span>
        <span class="CustomerFeedback-text">反馈未处理-</span>
        <span class="red">{{count}}条</span>
      </div>
    </div>
    <div
      class="CustomerFeedback-List"
      v-if="show"
      :style="`width:${width}px`"
      v-loading="loading"
    >
      <template v-if="feedbackList && feedbackList.length">
        <div
          class="CustomerFeedback-Item"
          v-for="(item, index) in feedbackList"
          :key="index"
        >
          <span class="CustomerFeedback-ItemNum">{{item.count}}条</span>
          <span
            class="CustomerFeedback-ItemName"
            @click="() => clickHandle(item)"
            :title="item.areaName"
          >{{item.areaName}}</span>
        </div>
      </template>
      <template v-else>
        <div class="noFeedbackText">
          没有需要处理的反馈
        </div>
      </template>

    </div>
  </div>
</template>

<script>
import { mapGetters, mapActions } from 'vuex';

export default {
  name: 'CustomerFeedback',
  computed: {
    ...mapGetters('Dashboard/customerFeedback', [
      'feedbackList',
      'count',
      'loading',
    ]),
    ...mapGetters(['feedbackPage']),
  },
  data() {
    return {
      show: false,
    };
  },
  created() {
    this.initData();
  },
  mounted() {
    let boxDom = document.querySelector('.CustomerFeedback');
    let listDom = document.querySelector('.CustomerFeedback-List');
    this.width = boxDom.clientWidth;

    this.show = true;
  },
  methods: {
    ...mapActions('Dashboard/customerFeedback', ['getFeedbackList']),
    initData() {
      this.getFeedbackList();
    },
    clickHandle(data) {
      const { areaId } = data;
      if (this.feedbackPage) {
        this.$router.push({ name: this.feedbackPage, query: { areaId } });
      } else {
        this.$message.error('无会员反馈页面权限');
      }
    },
  },
};
</script>

<style lang="scss">
@import '@/assets/styles/variables.scss';

.CustomerFeedback {
  display: flex;
  flex-direction: column;
  .CustomerFeedbackTitle {
    width: 100%;
    display: flex;
    align-items: center;
    padding: 0 20px;
    line-height: 34px;
    font-size: 18px;
    .CustomerFeedback-icon {
      width: 27px;
      height: 27px;
    }
    .CustomerFeedback-text {
      margin-left: 10px;
      margin-right: 5px;
    }
    .red {
      color: #ff0000;
    }
  }
  .CustomerFeedback-List {
    flex: 1;
    overflow-y: auto;
    .noFeedbackText {
      padding: 50px 20px;
    }
  }
  .CustomerFeedback-Item {
    display: flex;
    align-items: center;
    height: 60px;
    font-size: 18px;
    .CustomerFeedback-ItemNum {
      width: 70px;
      margin-right: 22px;
      text-align: right;
      color: #ff0000;
    }
    .CustomerFeedback-ItemName {
      flex: 1;
      padding-right: 20px;
      line-height: 28px;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
      cursor: pointer;
    }
  }
}
@media screen and (max-width: $bigScreenWidth) {
  .CustomerFeedback {
    .CustomerFeedbackTitle {
      padding: 0 10px;
      font-size: 14px;
    }
    .CustomerFeedback-Item {
      height: 40px;
      font-size: 14px;
      .CustomerFeedback-ItemNum {
        width: 70px;
        margin-right: 22px;
      }
      .CustomerFeedback-ItemName {
        padding-right: 20px;
        line-height: 28px;
      }
    }
  }
}
</style>