<template>
  <div class="box-center">
    <!-- 头 -->
    <div class="app-top">
      <div class="app-titel">
        <div
          class="label"
          style="color: #32363d; font-weight: 400; font-size: 16px"
        >
          楼盘选择：
        </div>
        <div>
          <el-select v-model="searchForm.houseId" placeholder="请选择">
            <el-option
              v-for="item in houseList"
              :key="item.id"
              :label="item.propertyName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>
      </div>
      <div class="app-titel" style="margin-top: 15px">
        <div class="label">时间：</div>
        <div class="toptimeqhuan">
          <div
            :class="{ tophove: searchForm.residueTime == 7 }"
            @click="tabtimetap(7)"
          >
            7天内
          </div>
          <div
            :class="{ tophove: searchForm.residueTime == 15 }"
            @click="tabtimetap(15)"
          >
            15天内
          </div>
          <div
            :class="{ tophove: searchForm.residueTime == 30 }"
            @click="tabtimetap(30)"
          >
            30天内
          </div>
        </div>
        <div>
          <el-date-picker
            v-model="time"
            type="daterange"
            class="div-inp"
            range-separator="-"
            start-placeholder="开始日期"
            end-placeholder="结束日期"
          >
          </el-date-picker>
        </div>
      </div>

      <div class="app-titel" style="margin-top: 15px">
        <div class="div-lab">
          <div class="label">客户名称：</div>
          <el-input class="div-inp" v-model="value"></el-input>
        </div>

        <div class="div-lab">
          <div class="label">客户意向：</div>
          <el-select class="div-inp" v-model="value" placeholder="请选择">
            <el-option
              v-for="item in houseList"
              :key="item.id"
              :label="item.propertyName"
              :value="item.id"
            >
            </el-option>
          </el-select>
        </div>

        <div class="div-lab">
          <div class="label">录音类型：</div>
          <el-select v-model="value" placeholder="请选择" class="div-inp">
            <el-option
              v-for="item in options2"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>

        <div class="div-lab">
          <div class="label">置业顾问：</div>
          <el-select v-model="value" placeholder="请选择" class="div-inp">
            <el-option
              v-for="item in options"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>

        <div class="div-lab">
          <div class="label">标注顾问：</div>
          <el-select v-model="value" placeholder="请选择" class="div-inp">
            <el-option
              v-for="item in options5"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>

        <div class="div-lab">
          <div class="label">接待时长：</div>
          <el-select v-model="value" placeholder="请选择" class="div-inp">
            <el-option
              v-for="item in options3"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>

        <div class="div-lab">
          <div class="label">到访次数：</div>
          <el-select v-model="value" placeholder="请选择" class="div-inp">
            <el-option
              v-for="item in options4"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </div>
      </div>

      <div class="app-titel" style="margin-top: 15px"></div>

      <div class="app-titel" style="margin-top: 15px">
        <div class="label" style="color: #ffffff">筛选相关：</div>
        <div style="margin-left: 20px">
          <el-button style="background: #2671e2; color: #ffffff"
            >筛选</el-button
          >
        </div>
        <div style="margin-left: 20px">
          <el-button>清空筛选条件</el-button>
        </div>
      </div>
    </div>

    <!-- 表格 -->
    <div class="cen-tab">
      <el-table :data="tableData" stripe height="400" style="width: 100%">
        <el-table-column prop="staTime" label="接待开始时间" align="center">
        </el-table-column>
        <el-table-column prop="agentName" label="顾问" align="center">
        </el-table-column>
        <el-table-column prop="name" label="客户" align="center">
        </el-table-column>

        <el-table-column prop="mm" label="录音时长" align="center">
        </el-table-column>
        <el-table-column prop="name" label="录音类型" align="center">
        </el-table-column>
        <el-table-column prop="address" label="标注顾问" align="center">
        </el-table-column>

        <el-table-column prop="date" label="客户意向" align="center">
        </el-table-column>
        <el-table-column prop="name" label="执行率" align="center">
        </el-table-column>
        <el-table-column prop="address" label="禁忌执行率" align="center">
        </el-table-column>
        <!--  scope -->
        <el-table-column label="操作" align="center">
          <template slot-scope="{row}">
            <el-button type="text">查看</el-button>
            <el-button type="text">下载文本</el-button>
            <el-button type="text">下载录音</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div style="display: flex; justify-content: flex-end; margin-top: 10px">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="10"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        >
        </el-pagination>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      TimetoAhoose: 2,
      time: [],
      houseList: [],
      options: [],
      options2: [
        {
          value: "1",
          label: "有效录音",
        },
        {
          value: "2",
          label: "无效录音",
        },
      ],
      options3: [
        {
          value: "1",
          label: "0-15分钟",
        },
        {
          value: "2",
          label: "16-30分钟",
        },
        {
          value: "3",
          label: "31-60分钟",
        },
        {
          value: "4",
          label: "61-90分钟",
        },
        {
          value: "5",
          label: "90分钟以上",
        },
      ],
      options4: [
        {
          value: "1",
          label: "首次到访",
        },
        {
          value: "2",
          label: "2次到访",
        },
        {
          value: "3",
          label: "3次到访",
        },
        {
          value: "4",
          label: "三次以上",
        },
      ],
      options5: [
        {
          value: "1",
          label: "已标注",
        },
        {
          value: "2",
          label: "未标注",
        },
        {
          value: "3",
          label: "全部",
        },
      ],
      currentPage: 1,
      size: "",
      total: 10,
      value: "",
      input: "",
      tableData: [],
      tophove: "",
      searchForm: {
        corporateName: "",
        propertyName: "",
        serviceStatus: "",
        houseType: "",
        residueTime: 7,
        startWorking: "",
        endWorking: "",
        agentName: "",
        operationalPeople: "",
      },
    };
  },
  mounted() {
    // 获取楼盘列表
    this.zkhousePage();
    // 获取接待记录列表
    this.findbypage();
  },
  methods: {
    // 接待记录列表
    findbypage() {
      let obj = {
        current: this.currentPage,
        size: this.size,
        ...this.searchForm,
      };

      this.$api.api.findbypage(obj).then((res) => {
        // console.log(res)
        this.tableData = res.data.records;
        this.total = res.data.total;
      });
    },
    zkhousePage() {
      let obj = {
        current: 1,
        size: 999,
      };
      this.$api.api.zkhousePage(obj).then((res) => {
        // console.log(res)
        this.houseList = res.data.records;
        this.searchForm.houseId = res.data.records[0].id;
      });
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
      this.size = val;
      this.findbypage();
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      his.currentPage = val;
      this.findbypage();
    },
    tabtimetap(idx) {
      this.searchForm.residueTime = idx;
    },
  },
};
</script>

<style scoped="scoped" lang="scss" >
.box-center {
  width: 100%;
  padding: 15px;
  min-width: 1200px;
  padding-bottom: 100px;
}
.cen-tab {
  width: 100%;
  padding: 15px;
  background: #ffffff;
  margin-top: 15px;
}
.tophove {
  color: #ffffff;
  background: #2671e2;
}
.app-top {
  width: 100%;
  background: #ffffff;
  box-shadow: 0px 0px 12px 0px rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  padding-top: 15px;
  padding-bottom: 15px;
  .app-titel {
    width: 100%;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    .label {
      font-size: 14px;
      font-weight: 400;
      color: #32363d;
      line-height: 32px;
      margin-left: 15px;
      min-width: 100px;
    }
    .toptimeqhuan {
      height: 30px;
      background: #ffffff;
      display: flex;
      align-items: center;
    }
    .toptimeqhuan div {
      padding-left: 20px;
      padding-right: 20px;
      text-align: center;
      line-height: 30px;
      font-size: 14px;
      margin-right: 15px;
      border-radius: 4px;
      border: 1px solid #e0e0e0;
    }
  }
}
.div-lab {
  display: flex;
  margin: 5px;
}
.div-inp {
  width: 250px;
}
</style>
