<template>
  <div>
    <!-- <div class="crumbs">
      <el-breadcrumb separator="/">
        <el-breadcrumb-item>数据</el-breadcrumb-item>
      </el-breadcrumb>
    </div> -->
    <!-- <el-tabs type="border-card">
      <el-tab-pane label="门店违规三率"> -->
        <!-- 查询和其他操作 -->
        <div class="filter-container">
          <el-form :inline="true" size="small" v-model="listQuery">
            <el-form-item label="加盟商名称">
              <el-input v-model="listQuery.fraName" clearable placeholder="请输入加盟商名称" />
            </el-form-item>

            <el-form-item label="门店名称">
              <el-input v-model="listQuery.shopName" clearable placeholder="请输入门店名称" />
            </el-form-item>

            <el-form-item label="门店POI">
              <el-input v-model="listQuery.poiId" clearable placeholder="请输入POI" />
            </el-form-item>
            <el-form-item label="指标大于0">
              <el-select v-model="listQuery.goals" multiple filterable>
                <el-option label="门店投诉率" value="1" />
                <el-option label="门店差评率" value="2" />
                <el-option label="门店退款率" value="3" />
              </el-select>
            </el-form-item>

            <el-form-item>
              <el-button class="filter-item" type="primary" icon="el-icon-search" @click="getList(false)">查找</el-button>
              <el-button :loading="listLoading" class="filter-item" type="primary" icon="el-icon-download"
                @click="getList(true)">导出</el-button>
            </el-form-item>
          </el-form>
        </div>

        <!-- 查询结果 -->
        <el-table :data="list" element-loading-text="正在查询中。。。" border fit highlight-current-row>
          <el-table-column align="center" label="城市" prop="cityName" />
          <el-table-column align="center" label="开始日期" prop="startDate" />
          <el-table-column align="center" label="结束日期" prop="endDate" />
          <el-table-column align="center" label="门店POI" prop="shopPoiId" />
          <el-table-column align="center" label="门店名称" prop="shopName" />
          <el-table-column align="center" label="加盟商id" prop="fraId" />
          <el-table-column align="center" label="加盟名称" prop="fraName" />

          <el-table-column align="center" label="门店投诉率,0-100" prop="complaintRate" />
          <el-table-column align="center" label="门店差评率,0-100" prop="badRate" />
          <el-table-column align="center" label="门店退款率,0-100" prop="refundRate" />
          <el-table-column align="center" label="抖音评价更新时间" prop="evaUpdateTime" />

        </el-table>

        <pagination v-show="total > 0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit"
          @pagination="getList(false)" />

      <!-- </el-tab-pane>   -->
    <!-- </el-tabs> -->

  </div>
</template>

<script>
import Pagination from "./../common/Pagination";
import service from "../../script/api/service";
import "@/script/table2excel";

export default {
  name: "douyinFiance",
  components: { Pagination },
  data() {
    return {
      timeArray: [
        this.formateDay(new Date(new Date() - 3600 * 1000 * 24 * 7)),
        this.formateDay(new Date()),
      ],
      salesTimeArray: [],
      list: [],
      total: 0,
      listLoading: false,
      listQuery: {
        page: 1,
        limit: 50,
        fraName:'',
        shopName:'',
        poiId:'',
        goals:''
      },
    };
  },
  computed: {},
  created() {
  },
  methods: {

     isArray(obj) {
  return Object.prototype.toString.call(obj) === '[object Array]';
},

    getList(isExport) {
      if (this.isArray(this.listQuery.goals)){
        //如果是数组，转换成字符串
        this.listQuery.goals = this.listQuery.goals.join(",");
      }
      if (isExport === false) {
        this.listQuery.isExport=false;
        service
          .$axiosGetStoreThreeRate(this.listQuery)
          .then((response) => {
            this.list = response.data.data.list;
            this.total = response.data.data.total;
            let strings = this.listQuery.goals.split(",");

            this.listQuery.goals =strings &&strings>0?strings:null;
          })
          .catch(() => {
            this.list = [];
            this.total = 0;
          });
      }
      else {
        this.listQuery.isExport=true;
        service.$axiosGetStoreThreeRateExport(this.listQuery);
      }

    },
    handleFilter() {
      this.listQuery.page = 1;
      this.getList();
    },
  },
};
</script>

<style>
.detail-container {
  width: 80%;
  padding: 20px 20px 20px 20px;
  margin: 20px auto;
}

.panel-group {
  display: flex;
  flex-flow: wrap;
}

.panel-group .card-panel {
  min-height: 130px;
  border-radius: 6px;
  padding: 10px 10px 0px;
  cursor: pointer;
  font-size: 12px;
  position: relative;
  overflow: hidden;
  color: #666;
  background: #fff;
  -webkit-box-shadow: 2px 2px 10px rgb(0 0 0 / 10%);
  box-shadow: 2px 2px 10px rgb(0 0 0 / 10%);
  border-color: rgba(0, 0, 0, .05);
  margin: 10px
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #ccc;
  /*dashed*/
  padding: 10px 0;
}

.card-data {
  display: flex;
  flex-direction: column;
  padding-top: 10px;
}

.card-item {
  display: flex;
  line-height: 20px;
  font-size: 13px;
}

.card-sub-item {
  margin-right: 20px;
  border-right: 1px dashed #ccc;
  width: 150px;
}

.card-sub-item .title {
  font-weight: 600;
}

.card-footer {
  height: 40px;
  line-height: 40px;
  border-top: 1px dashed #ccc;
  text-align: center;
  margin-top: 10px;
  color: #36a3f7;
}
</style>
