<template>
  <div class="corePersonnel">
    <head-form
      title="经营异常"
      :form-data="formData"
      :query-params="queryParams"
      :total="tableDataTotal"
      :isExcel="true"
      @handle-search="handleSearch"
    />
    <skeleton v-if="isSkeleton" style="padding: 16px"></skeleton>
    <tables
      v-if="!isSkeleton"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
    />

  </div>
</template>

<script>
import {
  abnormalPage,
  abnormalYears
} from '@/api/detail/party-a/riskInformation'
import mixin from '../mixins/mixin'
import skeleton from '../component/skeleton'
export default {
  name: 'BusinessAnomaly',
  mixins: [mixin],
  components: {
    skeleton
  },
  props: ['companyId'],
  data() {
    return {
      queryParams: {
        cid: this.companyId,//382724726
        pageNum: 1,
        pageSize: 20
      },
      forData: [
        {label: '列入原因', prop: 'inReason'},
        {label: '列入日期', prop: 'inDate', width: '95'},
        {label: '做出决定机关（移入）', prop: 'department', width: '264'},
        {label: '移出经营异常名录原因', prop: 'outReason', width: '320'},
        {label: '移出日期', prop: 'outDate', width: '95'},
        {label: '做出决定机关（移出）', prop: 'outDepartment', width: '264'}
      ],
      formData: [
        { type: 4, fieldName: 'years', value: '', placeholder: '列入时间', options: []}
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
      isSkeleton:true
    }
  },
  created() {
    this.handleQuery()
    this.years()
  },
  computed: {

  },
  methods: {
    handleQuery(params) {
      let data = params ? params : this.queryParams
      this.isSkeleton = true
      abnormalPage(data).then(res => {
        this.tableData = res.rows
        this.tableDataTotal = res.total
        this.isSkeleton = false
      })
    },
    years(){
      abnormalYears({cid: this.queryParams.cid}).then(res => {
        let data = res.data
        if(data.length > 0){
          for (var i=0;i<data.length;i++){
            this.formData[0].options.push({
              name: data[i].year + '（' + data[i].count + '）',
              value: data[i].year,
            })
          }
        }
      })
    }
  }
}
</script>
<style lang="scss" scoped>
.corePersonnel{
  background: #ffffff;
  border-radius: 4px;
  padding: 16px;
  .query-box{
    margin: 10px 0 20px;
  }
}
</style>
