<template>
  <div id="scroll-board">
    <cmpTitle title="企业报修工单" visitMoreBtn="true" @onMore="clickMore"></cmpTitle>
    <dv-scroll-board :config="config" style="flex:1;cursor: pointer;" @click="jump"/>
  </div>
</template>
<script>
import {getList} from "../../../api/order/publicevent.js"
import cmpTitle from "../common/cmpTitle.vue"
export default {
  components:{
    cmpTitle
  },
  data () {
    return {
      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:''
      },
      dataList:[]
    }
  },
  props:{
     showType:{
          type:String,
          default:"2"
        }
  },
  mounted() {
    this.getDataList()
  },
  methods:{
    clickMore(){
      this.$router.push({path:'/jobs/reportjob'})
    },
    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.jobNo)
            arr.push(item.jobStatus)
            arr.push(item.reportor)
            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 = this.dataList[row.rowIndex]
        let params = {
          title:'报事信息',
          type:'matterInfo'
        }
        this.$emit("onEmit",data,params)
      }
    },

  }
}
</script>

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