<template>
  <div class="corePersonnel">
    <head-form
      title="开庭公告"
      :form-data="formData"
      :query-params="queryParams"
      :total="tableDataTotal"
      :isExcel="false"
      @handle-search="handleSearch"
    />

    <tables
      :index-fixed="true"
      :tableLoading="tableLoading"
      :tableData="tableData"
      :forData="forData"
      :tableDataTotal="tableDataTotal"
      :queryParams="queryParams"
      @handle-current-change="handleCurrentChange"
    >
      <template slot="relatedCompanies" slot-scope="scope">
        <div v-for="item in scope.row.relatedCompanies">
          <span>{{ item.role }}：</span>{{ item.name }}
        </div>
      </template>
    </tables>

  </div>
</template>

<script>
import {
  kaitingPage,
  kaitingCauseAction,
  kaitingPureRole
} from '@/api/detail/party-a/riskInformation'
import mixin from '../mixins/mixin'
export default {
  name: 'OpenacourtsessionNotice',
  mixins: [mixin],
  components: {

  },
  props: ['companyId'],
  data() {
    return {
      queryParams: {
        cid: this.companyId,//20734
        pageNum: 1,
        pageSize: 10
      },
      forData: [
        {label: '案由', prop: 'causeAction', width: '240', fixed: true},
        {label: '开庭日期', prop: 'hearingDate', width: '95'},
        {label: '当事人', prop: 'relatedCompanies', width: '428', slot: true},
        {label: '身份', prop: 'pureRole', width: '120'},
        {label: '公告内容', prop: 'content', width: '508'},
        {label: '案号', prop: 'caseNo', width: '210'},
        {label: '法院', prop: 'court', width: '280'},
        {label: '法庭', prop: 'tribunal', width: '180'},
        {label: '承办部门', prop: 'department', width: '280'},
        {label: '审判长/主判人', prop: 'judge', width: '106'}
      ],
      formData: [
        { type: 1, fieldName: 'causeAction', value: '', placeholder: '案由', options: []},
        { type: 1, fieldName: 'pureRole', value: '', placeholder: '身份', options: []},
        { type: 2, fieldName: 'time', value: '', placeholder: '',startTime: 'dateFrom',endTime: 'dateTo'},
        { type: 3, fieldName: 'keys', value: '', placeholder: '请输入案号'},
      ],
      //列表
      tableLoading:false,
      tableData:[],
      tableDataTotal:0,
    }
  },
  created() {
    this.handleQuery()
    this.kaitingCauseActions()
    this.kaitingPureRoles()
  },
  computed: {

  },
  methods: {
    toDetail(){
      let Id = '111'
      this.$router.push({ path: '/project/projectList/detail', query: Id });
    },
    handleQuery(params) {
      let data = params ? params : this.queryParams
      this.tableLoading = true
      kaitingPage(data).then(res => {
        this.tableData = res.rows
        for (var i=0;i<this.tableData.length;i++){
          this.tableData[i].relatedCompanies = JSON.parse(this.tableData[i].relatedCompanies)
        }
        this.tableDataTotal = res.total
        this.tableLoading = false
      })
    },
    kaitingCauseActions(){
      kaitingCauseAction({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].causeAction + '（' + data[i].count + '）',
              value: data[i].causeAction,
            })
          }
        }
      })
    },
    kaitingPureRoles(){
      kaitingPureRole({cid: this.queryParams.cid}).then(res => {
        let data = res.data
        if(data.length > 0){
          for (var i=0;i<data.length;i++){
            this.formData[1].options.push({
              name: data[i].pureRole + '（' + data[i].count + '）',
              value: data[i].pureRole,
            })
          }
        }
      })
    },
  }
}
</script>
<style lang="scss" scoped>
.corePersonnel{
  background: #ffffff;
  border-radius: 4px;
  padding: 16px;
  .query-box{
    margin: 10px 0 20px;
  }
}
</style>
