<template>
  <div id="scroll-board">
    <cmpTitle title="人员异常告警" visitMoreBtn="true" @onMore="clickMore"></cmpTitle>
    <div style="display: inline-block;">
      <div style="display: flex;border: 1px solid #0099FF;font-size: 12px;color: #fff;margin: 5px 0;">
        <div @click="switchData(0)" :style="current==0?'background:#0099FF;':''" style="padding:2px 5px;cursor: pointer;">基础数据</div>
        <div @click="switchData(1)" :style="current==1?'background:#0099FF;':''" style="padding:2px 5px;cursor: pointer;">异常数据</div>
      </div>
    </div>
    <dv-scroll-board v-if="current==0" :config="config2" style="flex:1;cursor: pointer;" @click="jump"/>
    <dv-scroll-board v-if="current==1" :config="config" style="flex:1;cursor: pointer;" @click="jump"/>
  </div>
</template>
<script>
// import {getList} from "../../../api/jobs/personjob.js"
// import {desensitizeList} from "../../../api/community/houseuser.js"
import cmpTitle from "../common/cmpTitle.vue"
export default {
  components:{
    cmpTitle
  },
  data () {
    return {
      showtitle:true,
      config: {
        header: ['姓名', '状态', '类型', '时间'],
        data:[],
        index: false,
        align: ['center'],
        rowNum: 5,
        headerBGC: 'rgba(6, 30, 93, 0.1)',
        headerHeight: 30,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)',
        // path:'/jobs/personjob'
        path:''
      },
      config2:{
        header: ['姓名', '身份证', '电话', '时间'],
        data:[],
        index: false,
        align: ['center'],
        rowNum: 5,
        headerBGC: 'rgba(6, 30, 93, 0.1)',
        headerHeight: 30,
        oddRowBGC: 'rgba(0, 44, 81, 0.8)',
        evenRowBGC: 'rgba(10, 29, 50, 0.8)',
        // path:'/jobs/personjob'
        path:''
      },
      dataList:[],
      dataList2:[],
      current:0,
    }
  },
  props:{
    showType:{
      type:String,
      default:"2"
    }
  },
  mounted() {
    this.getDataList2()
    this.getDataList()
  },
  methods:{
    switchData(current){
      this.current = current
    },
    clickMore(){
      this.$router.push({path:'/jobs/personjob'})
    },
    getDataList2(){
          var _this = this;
          let current = 1;
          let size = 20;
          let params = {};
          if(this.showType=="1"){
            this.agencies = JSON.parse(localStorage.getItem('agencies1'))
            params['agencyId'] = this.agencies.id
          }else{
            this.agencies = JSON.parse(localStorage.getItem('agencies2'))
            params['residentialId'] = this.agencies.id
          }
          return desensitizeList(current,size,params).then((res)=>{
            let list = []
            _this.dataList2 = res.data.data.records
            res.data.data.records.map((item)=>{
                let arr = [];
                if(item.jobStatus==1){
                  item.jobStatus = "已处理"
                }else{
                  item.jobStatus = "未处理"
                }
               arr.push(item.name)
               arr.push(item.idCard)
               arr.push(item.tel)
               arr.push(item.updateTime)
              list.push(arr)
            })
            _this.config2.data = list;
            _this.$set(_this.config2)
          }).catch((err)=>{
            console.log(err)
          })
        },
    getDataList(){
      var _this = this;
      let current = 1;
      let size = 20;
      let params = {};
      if(this.showType=="1"){
        this.agencies = JSON.parse(localStorage.getItem('agencies1'))
        params['agencyId'] = this.agencies.id
      }else{
        this.agencies = JSON.parse(localStorage.getItem('agencies2'))
        params['residentialId'] = this.agencies.id
      }
      return getList(current,size,params).then((res)=>{
        let list = []
        _this.dataList = res.data.data.records
        res.data.data.records.map((item)=>{
            let arr = [];
            if(item.jobStatus==1){
              item.jobStatus = "已处理"
            }else{
              item.jobStatus = "未处理"
            }
           arr.push(item.person)
           arr.push(item.jobStatus)
           arr.push(item.jobContent)
           arr.push(item.reportTime)
          list.push(arr)
        })
        _this.config.data = list;
        _this.$set(_this.config)
      }).catch((err)=>{
        console.log(err)
      })
    },
    jump(row){
      if(this.config.path!==''){
        this.$router.push({path:this.config.path})
      }else{
        let data;
        let params ;
        if(this.current==0){
          data = this.dataList2[row.rowIndex]
          params = {
            title:'人员信息',
            type:'peopleInfo2'
          }
        }else{
          data = this.dataList[row.rowIndex]
          params = {
            title:'人员信息',
            type:'peopleInfo'
          }
        }
        this.$emit("onEmit",data,params)
      }
    },

  }
}
</script>

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