<template>
  <div class="equity-freezing-container">

    <el-tabs v-model="queryParams.type" @tab-click="handleClick" class="detail-tab">
      <el-tab-pane label="股权冻结" name="0"></el-tab-pane>
      <el-tab-pane label="历史股权冻结" :disabled="tableDataTotal==0" name="1"></el-tab-pane>
    </el-tabs>

    <head-form-new ref="headFormNew" 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" :indexFixed="true" :tableData="tableData" :forData="forData" :tableDataTotal="tableDataTotal"
      :queryParams="queryParams" @handle-current-change="handleCurrentChange">
      <!-- 冻结起止日期 -->
      <template slot="freezeStartDate" slot-scope="scope">
        <span v-if="scope.row.freezeStartDate || scope.row.freezeEndDate">
          {{`${scope.row.freezeStartDate ? scope.row.freezeStartDate : "-"}至${scope.row.freezeEndDate ? scope.row.freezeEndDate : "-"}`}}
        </span>
        <span v-else>-</span>
      </template>
      <!-- 操作 -->
      <template slot="operation-table" slot-scope="scope">
        <span style="color: #0081FF;cursor: pointer;" @click="viewDetail(scope.row)">操作</span>
      </template>
    </tables>

    <!-- 股权冻结详情 -->
    <el-dialog title="股权冻结详情" :visible.sync="equityFreezingDetailDialog" width="720px" @close="dialogClose" class="equity-freezing-dialog-container"
      custom-class="equity-freezing-dialog">
      <div class="equity-freezing-dialog-inner">
        <table>
          <tr>
            <td class="table-key">执行通知书文号</td>
            <td colspan="3">{{detailTemp.number ? detailTemp.number : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">执行裁定书文号</td>
            <td>{{detailTemp.adjudicateNo ? detailTemp.adjudicateNo : "-"}}</td>
            <td class="table-key">执行事项</td>
            <td>{{detailTemp.assistItem ? detailTemp.assistItem : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">被执行人</td>
            <td>{{detailTemp.beExecutedPerson ? detailTemp.beExecutedPerson : "-"}}</td>
            <td class="table-key">被执行人证件种类</td>
            <td>{{detailTemp.assistIdentType ? detailTemp.assistIdentType : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">被执行人证照号</td>
            <td>{{detailTemp.assistIdentNo ? detailTemp.assistIdentNo : "-"}}</td>
            <td class="table-key">冻结状态</td>
            <td>{{detailTemp.status ? detailTemp.status : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">被执行人持有股权、其他收益的数额</td>
            <td>{{detailTemp.freezeAmount ? detailTemp.freezeAmount : "-"}}</td>
            <td class="table-key">执行法院</td>
            <td>{{detailTemp.executiveCourt ? detailTemp.executiveCourt : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">冻结日期自</td>
            <td>{{detailTemp.freezeStartDate ? detailTemp.freezeStartDate : "-"}}</td>
            <td class="table-key">冻结日期至</td>
            <td>{{detailTemp.freezeEndDate ? detailTemp.freezeEndDate : "-"}}</td>
          </tr>
          <tr>
            <td class="table-key">冻结期限</td>
            <td>{{detailTemp.freezeYearMonth ? detailTemp.freezeYearMonth : "-"}}</td>
            <td class="table-key">公示日期</td>
            <td>{{detailTemp.publicDate ? detailTemp.publicDate : "-"}}</td>
          </tr>
        </table>
      </div>
    </el-dialog>

  </div>
</template>
<script>
import skeleton from '../component/skeleton';
import mixin from '@/views/detail/party-a/mixins/mixin';
import { getEquityFreezingApi } from "@/api/detail/party-a/riskInformation";
export default {
  name: "equityFreezingContainer",
  mixins: [mixin],
  components: {
    skeleton
  },
  props: ['companyId'],
  data() {
    return {
      queryParams: {
        cid: this.companyId,
        pageNum: 1,
        pageSize: 10,
        type: "0"
      },
      forData: [
        { label: '执行通知书文号', prop: 'number', width: '164' },
        { label: '被执行人', prop: 'beExecutedPerson', minWidth: '146' },
        { label: '股权数额', prop: 'amount', width: '113' },
        { label: '执行法院', prop: 'executiveCourt', minWidth: '146' },
        { label: '状态', prop: 'status', width: '50' },
        { label: '冻结起止日期', prop: 'freezeStartDate', width: '171', slot: true },
        { label: '公式时间', prop: 'source', width: '93' },
        { label: '操作', prop: 'operation-table', width: '50', slot: true },
      ],
      formData: [
        { type: 5, fieldName: 'time', value: '', placeholder: '选择日期', startTime: 'dateFrom', endTime: 'dateTo', uid: this.getUid() },
      ],
      //列表
      tableLoading: false,
      tableData: [],
      tableDataTotal: 0,
      showList: [],
      isSkeleton: false,
      resetStatus: false,
      // 股权冻结详情
      equityFreezingDetailDialog: false,
      // 详情缓存
      detailTemp: {}
    };
  },
  //可访问data属性
  created() {
    this.initDetail();
  },
  //计算集
  computed: {

  },
  //方法集
  methods: {
    async initDetail() {
      try {
        await this.handleQuery();
      } catch (error) {

      }
    },
    resetQueryParams() {
      const data = this.$options.data.call(this);
      this.queryParams = { ...data.queryParams, type: this.queryParams.type };
      this.formData[0].value = "";
    },
    async handleQuery(params) {
      try {
        let data = params ? { ...params, type: parseInt(params.type) } : { ...this.queryParams, type: parseInt(this.queryParams.type) };
        this.isSkeleton = true;
        const res = await getEquityFreezingApi(data);
        this.tableData = res.rows ? res.rows : [];
        this.tableDataTotal = res.total ? res.total : 0;
      } catch (error) {
        console.log(error);
      } finally {
        this.isSkeleton = false;
      }
    },
    handleClick(v) {
      if (v.name == this.queryParams.type) return;
      this.resetQueryParams();
      this.handleQuery();
    },
    // 查看详情
    viewDetail(row) {
      this.detailTemp = row;
      this.equityFreezingDetailDialog = true;
    },
    dialogClose() {
      this.detailTemp = {};
    }
  },
}
</script>
<style lang="scss" scoped>
.equity-freezing-container {
  padding: 16px;
  background: #ffffff;
  border-radius: 4px;
  input {
    border: 1px solid #efefef;
  }
  ::v-deep .el-form-item {
    margin-right: 8px !important;
  }

  .query-box {
    margin: 10px 0 20px;
  }
  .cell-span {
    display: inline-block;
    position: relative;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 4;
    cursor: pointer;

    > span {
      display: inline-block;
      width: 37px;
      position: absolute;
      right: 0;
      bottom: 0;
      background-color: #fff;
      z-index: 1;
    }
  }

  .detail-tab {
    margin: 0 0 0 -16px;
    ::v-deep .el-tabs__nav-wrap::after {
      display: none;
    }
    ::v-deep .el-tabs__item {
      font-size: 16px;
      height: 30px;
      line-height: 30px;
      padding: 0 16px;
      &.is-active {
        font-weight: bold;
      }
    }
  }
  @import "@/assets/styles/search-common.scss";

  ::v-deep .equity-freezing-dialog-container {
    .equity-freezing-dialog {
      position: absolute;
      left: 50%;
      top: 50%;
      transform: translate(-50%, -50%);
      border-radius: 4px;
      margin: 0px !important;

      .el-dialog__header {
        padding: 20px;
        height: 56px;
        display: flex;
        align-items: center;
        justify-content: space-between;
        box-sizing: border-box;
        border-bottom: 1px solid #eeeeee;

        .el-dialog__title {
          color: #232323;
          font-weight: bold;
          line-height: 16px;
        }

        .el-dialog__headerbtn {
          position: static;
          width: 16px;
          height: 16px;
        }
      }

      .el-dialog__body {
        padding: 24px 20px;
        box-sizing: border-box;

        .equity-freezing-dialog-inner {
          width: 100%;
          height: 100%;

          & > table {
            width: 100%;
            border-spacing: 0;
            border-collapse: collapse;
            &,
            th,
            td {
              border: 1px solid #e6eaf1;
              box-sizing: border-box;
            }

            td {
              padding: 9px 12px;
              line-height: 22px;
              color: #232323;
              font-size: 12px;
            }

            .table-key {
              width: 140px;
              background: #f0f3fa;
              color: rgba(35, 35, 35, 0.8);
            }
          }
        }
      }
    }
  }
}
</style>
