<template>
  <div id="scroll-board">
    <cmpTitle title="查询列表"></cmpTitle>
    <dv-scroll-board :config="config" style="flex:1;cursor: pointer;" @click="jump"/>
  </div>
</template>

<script>
  import cmpTitle from "../common/cmpTitle.vue"
  import {getUserInfo} from "../../../util/util";
export default {
  components:{
    cmpTitle
  },
  data () {
    return {
      config:{
        header: [],
        data:[],
        index: false,
        align: ['center'],
        rowNum: 4,
        headerBGC: 'rgba(6, 30, 93, 0.1)',
        headerHeight: 30,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)',
      },
      dataList:[],
      headerData:[]
    }
  },
  props:{
    showType:{
      type:String
    }
  },
  mounted(){
    if(this.showType=='estate'){
      this.headerData = ['姓名', '身份证', '车牌']
    }else if(this.showType=='people'){
      this.headerData = ['姓名', '楼栋单元', '房间']
    }else if(this.showType=='car'){
      this.headerData = ['姓名', '车牌号', '手机号']
    }else if(this.showType=='parkPeople'){
      this.headerData = ['姓名', '公司', '园区']
    }
    this.config.header = this.headerData
  },
  methods:{
    loadData(data){
      this.dataList = data;
      var str1 = function(p){
        let val = p.substring(0,p.length-1)
        return val+"*"
      }
      var str2 = function(p){
        let val = p.substring(0,p.length-4)
        return val+"****"
      }
      let list = []
      data.map((item)=>{
        let arr = []
        if(this.showType=='estate'){
          arr.push(str1(item.name))
          arr.push(str2(item.idCard))
          arr.push(item.carNumber)
        }else if(this.showType=='people'){
          arr.push(str1(item.name))
          arr.push(item.unitName)
          arr.push(item.roomName)
        }else if(this.showType=='car'){
          arr.push(str1(item.name))
          arr.push(item.carNumber)
          arr.push(str2(item.tel))
        }else if(this.showType=='parkPeople'){
          arr.push(str1(item.realName))
          arr.push(item.enterpriseName)
          arr.push(str2(item.residentialName))
        }
        list.push(arr)
      })
      this.config = {
        header: this.headerData,
        data:list,
        index: false,
        align: ['center'],
        rowNum: 4,
        headerBGC: 'rgba(6, 30, 93, 0.1)',
        headerHeight: 30,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)',
      }
    },
    jump(row){
      let data = this.dataList[row.rowIndex]
      let type = ''
      if(getUserInfo()){
        type = 'parkSearchInfo'
      }else{
        type = 'searchInfo'
      }
      let params = {
        title:'查询信息',
        type:type
      }
      this.$emit("onEmit",data,params)
    }
  }
}
</script>

<style lang="less">
#scroll-board {
  box-sizing: border-box;
  height: 100%;
  width: 100%;
  overflow: hidden;
}
</style>
