<template>
  <div class="corePersonnel hearing-notice">
    <head-form-new title="开庭公告" :form-data="formData" :query-params="queryParams" :total="tableDataTotal" :isExcel="false"
      @handle-search="handleSearch" />
    <skeleton v-if="isSkeleton" style="padding: 16px"></skeleton>
    <tables :index-fixed="true" v-if="!isSkeleton" :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';
import skeleton from '../component/skeleton';
export default {
  name: 'OpenacourtsessionNotice',
  mixins: [mixin],
  components: {
    skeleton
  },
  props: ['companyId'],
  data() {
    return {
      queryParams: {
        cid: this.companyId,//20734
        pageNum: 1,
        pageSize: 20
      },
      forData: [
        { label: '案由', prop: 'causeAction', fixed: true, width: "240" },
        { 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: '110' }
      ],
      formData: [
        { type: 1, fieldName: 'causeAction', value: '', placeholder: '案由', options: [], uid: this.getUid() },
        { type: 1, fieldName: 'pureRole', value: '', placeholder: '身份', options: [], uid: this.getUid() },
        { type: 2, fieldName: 'time', value: '', placeholder: '', startTime: 'dateFrom', endTime: 'dateTo', uid: this.getUid() },
        { type: 3, fieldName: 'keys', value: '', placeholder: '请输入案号', uid: this.getUid() },
      ],
      //列表
      tableLoading: false,
      tableData: [],
      tableDataTotal: 0,
      isSkeleton: true
    };
  },
  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.isSkeleton = 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.isSkeleton = 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;
  }
}

.hearing-notice {
  @import "@/assets/styles/search-common.scss";
}
</style>
