<template>

  <div class="box-center">
    <!-- 头 -->
    <div class="app-top">
      <div class="app-titel" style="margin-top: 15px">
        <div class="label">时间：</div>
        <div class="toptimeqhuan">
          <div :class="{ tophove: TimetoAhoose == 0 }" @click="tabtimetap(0)">
            今日
          </div>
          <div :class="{ tophove: TimetoAhoose == 1 }" @click="tabtimetap(1)">
            昨日
          </div>
          <div :class="{ tophove: TimetoAhoose == 2 }" @click="tabtimetap(2)">
            近一周
          </div>
        </div>
        <div>
           <el-date-picker
            v-model="customtime"
            @change="confirmtime()"
            type="daterange"
            range-separator="-"
            :default-time="['00:00:00', '23:59:59']"
            value-format="yyyy-MM-dd"
            start-placeholder="开始日期"
            end-placeholder="结束日期">
          </el-date-picker>
        </div>
      </div>
      <div class="app-titel" style="margin-top: 15px">
        <div class="label">客户名称：</div>
        <div>
             <el-input v-model="fromobj.name"></el-input>
        </div>
        <div class="label">置业顾问：</div>
        <div>
             <el-input v-model="fromobj.agentName"></el-input>
        </div>
      </div>

      <div class="app-titel" style="margin-top: 15px">
        <div class="label">客户意向：</div>
        <div >
         <el-select v-model="fromobj.keywordIds" multiple filterable placeholder="请选择">
            <el-option
              v-for="item in options5"
              :key="item.keywordsId"
              :label="item.isInterval==0?item.name+'-'+item.endName+item.unit:item.name"
              :value="item.keywordsId">

            </el-option>
          </el-select>
        </div>
        <div style="margin-left: 20px">
          <el-button @click="screening()" style="background: #2671e2; color: #ffffff"
            >筛选</el-button
          >
        </div>
        <div style="margin-left: 20px">
          <el-button @click="Screeningofempty()">清空筛选条件</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="total"
            label="画像语义词触达次数"
             align="center"
           >
          </el-table-column>
          <el-table-column
            prop="fraction"
            label="接访得分"
             align="center">
          </el-table-column>
           <!--  scope -->
         <el-table-column label="操作" align="center">
            <template slot-scope="">
              <div style="color: #2671E2;">查看详情</div>
            </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="currentPage4"
              :page-sizes="[10, 20, 30, 30]"
              :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,
      customtime: [],
      currentPage4:1,
      value: "",
      input: "",
      tableData: [],
      fromobj: {
        starttime: "",
        endoftime: "",
        name:'',
        agentName:'',
        projectId:'',
        type:0,
        keywords:'',
        keywordIds:[]
      },
      pageNum:1,
      pageSize:10,
      options5:[],
      total:0,

    };
  },
  mounted() {
     var isnull=this.$route.query.flag;
      this.TimetoAhoose=isnull.TimetoAhoose;
      this.customtime=isnull.customtime;
      this.fromobj.starttime=isnull.starttime;
      this.fromobj.endoftime=isnull.endoftime;
      this.fromobj.projectId=isnull.houseId;
      this.fromobj.keywords=isnull.keywordsId;
      this.Accesstolevel()
  },
  methods: {
    //获取三级
     Accesstolevel(){
        this.options5=[];
        var datatype='';
        if(this.TimetoAhoose==6){
            datatype=''
        }else {
            datatype=this.TimetoAhoose
        }
        this.$api.http.findKeywords({
          type:this.fromobj.type,
          dateType:datatype,
          statDateStart:this.fromobj.starttime,
          statDateEnd:this.fromobj.endoftime,
          projectId:this.fromobj.projectId
        }).then((res) => {
          if(res.code==0){
              this.options5=res.data;
              this.receptionRecord()
          }
        })
    },
    receptionRecord(){
        var dateType='';
				if(this.TimetoAhoose==6){
					dateType='';
				}else {
					dateType=this.TimetoAhoose;
				}
        this.$api.http.receptionRecord({
          	dateType:dateType,
						staDate:this.fromobj.starttime,
						endDate:this.fromobj.endoftime,
            projectId:this.fromobj.projectId,
            name:this.fromobj.name,
            agentName:this.fromobj.agentName,
            type:this.fromobj.type,
            time:1,
            keywordIds:this.fromobj.keywordIds.length>0?this.fromobj.keywordIds.join(','):this.fromobj.keywords,
            current:this.pageNum,
            size:this.pageSize,
        }).then((res) => {
             if(res.code==0){
                  this.tableData=res.data.records;
                  this.total=res.data.total
             }
        });
    },
    //筛选
    screening(){
        this.fromobj.type=1;
        this.pageNum=1;
        this.receptionRecord()
    },
    //清空筛选条件
    Screeningofempty(){
        this.TimetoAhoose=2;
        this.fromobj.starttime = "";
        this.fromobj.endoftime = "";
        this.fromobj.name='';
        this.fromobj.agentName='';
        this.fromobj.keywords='';
        this.fromobj.type=0;
        this.fromobj.keywordIds=[];
        this.pageNum=1;
        this.customtime = [];
        this.receptionRecord()
    },
     //切换时间
    tabtimetap(index) {
      this.TimetoAhoose = index;
      this.fromobj.starttime = "";
      this.fromobj.endoftime = "";
      this.customtime = [];
      this.pageNum=1;
       this.receptionRecord()
    },
        //自定义时间
    confirmtime() {
      this.TimetoAhoose = 6;
        this.fromobj.starttime = this.customtime[0];
        this.fromobj.endoftime = this.customtime[1];
        this.pageNum=1;
         this.receptionRecord()
    },
    handleSizeChange(val) {
       this.pageSize=val;
        this.receptionRecord()
    },
    handleCurrentChange(val) {
      this.pageNum=val;
      this.receptionRecord()
    },

  },
};
</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;
    .label {
      font-size: 14px;
      font-weight: 400;
      color: #32363d;
      line-height: 14px;
      margin-left: 15px;
    }
    .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;
    }
  }
}
</style>
