<template>
  <div class="app-container">
    <el-form
      :model="queryParams"
      ref="queryForm"
      size="small"
      :inline="true"
      label-width="68px"
    >
      <el-form-item label="案件编号" prop="caseNum">
        <el-input
          v-model="queryParams.caseNum"
          placeholder="请输入案件编号"
          clearable
          @keyup.enter.native="handleQuery"
        />
      </el-form-item>
      <el-form-item>
        <el-button
          type="primary"
          icon="el-icon-search"
          size="mini"
          @click="handleQuery"
          >搜索</el-button
        >
        <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
          >重置</el-button
        > -->
      </el-form-item>
    </el-form>
    <el-table v-loading="loading" :data="formationData" style="width: 100%">
      <el-table-column label="序号" type="index" align="center">
        <template slot-scope="scope">
          <span>{{
            (queryParams.pageNum - 1) * queryParams.pageSize + scope.$index + 1
          }}</span>
        </template>
      </el-table-column>
      <el-table-column
        label="案件编号"
        align="center"
        prop="caseNum"
        :show-overflow-tooltip="true"
      />
      <!-- <el-table-column
        label="申请人"
        align="center"
        prop="name"
        :show-overflow-tooltip="true"
      /> -->
      <el-table-column
        label="案件标的"
        align="center"
        prop="caseSubjectAmount"
      />
      <!-- <el-table-column
        label="立案日期"
        align="center"
        prop="registerDate"
        :show-overflow-tooltip="true"
      /> -->
      <!-- 开庭日期 -->
      <!-- <el-table-column
        label="开庭日期"
        align="center"
        prop="hearDate"
        :show-overflow-tooltip="true"
      /> -->
      <!-- 案件仲裁员 -->
      <!-- <el-table-column
        label="案件仲裁员"
        align="center"
        prop="arbitratorName"
      /> -->
      <el-table-column label="案件状态" align="center" prop="caseStatus" />
      <el-table-column
        label="操作"
        align="center"
        class-name="small-padding fixed-width"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-zoom-in"
            @click="viewdetails(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
            >案件详情</el-button
          >
          <el-button
            size="mini"
            type="text"
            icon="el-icon-shopping-bag-1"
            @click="formateCourt(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
            >组庭</el-button
          >
          <!-- <el-button
            size="mini"
            type="text"
            icon="el-icon-delete"
            @click="deleteRow(scope.row)"
            v-hasPermi="['monitor:online:forceLogout']"
            >删除</el-button
          > -->
        </template>
      </el-table-column>
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getformationData"
    />
    <!-- 详情页面 -->
    <formateCourtdetailDaiog
      :showDetails="showDetails"
      @cancelDetails="cancelDetails"
      :formateListdata="formateListdata"
      :initpaymentArr="initpaymentArr"
      :initpaymentArr1="initpaymentArr1"
    ></formateCourtdetailDaiog>
    <!-- 组庭页面 -->
    <formateCourtDialog
      :showformateCourt="showformateCourt"
      @cancelcourtDialog="cancelcourtDialog"
      :formateCourtData="formateCourtData"
      @getformationData="getformationData"
    ></formateCourtDialog>
  </div>
</template>

<script>
import { caseApply, selectCaseApply } from "@/api/caseAccess/caseEntry";
import formateCourtdetailDaiog from "./components/formateCourtdetailDaiog.vue";
import formateCourtDialog from "./components/formateCourtDialog.vue";
export default {
  name: "formationCourtlist",
  components: {
    formateCourtdetailDaiog,
    formateCourtDialog,
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      queryParams: {
        // caseNum: undefined,
        caseStatus: 6,
        pageNum: 1,
        pageSize: 10,
      },
      formationData: [],
      showDetails: false, //详情界面显示
      formateListdata: {},
      formateCourtData: {},
      showformateCourt: false, //组庭界面显示
      initpaymentArr:[],
      initpaymentArr1:[],
    };
  },
  created() {
    this.getformationData();
  },
  methods: {
    // 搜索
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getformationData();
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 查询列表数据
    getformationData() {
      this.loading = true;
      caseApply(this.queryParams).then((response) => {
        this.formationData = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // 详情
    viewdetails(val) {
      this.showDetails = true;
      this.formateListdata = val;
      this.getInfo(val);
    },
    // 查找主体信息数据
    getInfo(row) {
      const id = row.id;
      selectCaseApply({ id }).then((res) => {
        this.visible = true;
        this.formData = res.data;
        this.initpaymentArr = [];
        this.initpaymentArr1 = [];
        res.data.caseAffiliates.forEach((item) => {
          if (item.identityType == 1) {
            this.initpaymentArr.push(item);
          } else {
            this.initpaymentArr1.push(item);
          }
        });
      });
    },
    // 关闭详情
    cancelDetails() {
      this.showDetails = false;
    },
    // 组庭
    formateCourt(val) {
      this.formateCourtData = val;
      this.showformateCourt = true;
    },
    // 关闭组庭页面
    cancelcourtDialog() {
      this.showformateCourt = false;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>