<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 label="案件状态" prop="caseStatus">
        <el-select :disabled="caseStatusType" v-model="queryParams.caseStatus" placeholder="请选择案件状态" clearable @keyup.enter.native="handleQuery">
          <el-option v-for="dict in caseStatus" :key="dict.dictSort" :label="dict.dictLabel"
            :value="dict.dictSort"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否完成" prop="selectCaseStatus">
        <el-select v-model="queryParams.selectCaseStatus" placeholder="请选择状态" clearable @keyup.enter.native="handleQuery">
          <el-option v-for="dict in selectCaseStatusList" :key="dict.value" :label="dict.label"
            :value="dict.value"></el-option>
        </el-select>
      </el-form-item>
      <!-- <el-form-item label="立案日期" prop="registerDate">
        <el-date-picker
          v-model="queryParams.registerDate"
          type="daterange"
          range-separator="至"
          start-placeholder="开始日期"
          end-placeholder="结束日期"
        >
        </el-date-picker>
      </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="dataList" 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="caseSubjectAmount" />
      <el-table-column label="立案日期" align="center" prop="registerDate" :show-overflow-tooltip="true" />
      <!-- 缴费人 -->
      <!-- <el-table-column label="缴费人" align="center" prop="caseArbitrator" /> -->
      <el-table-column label="案件状态" align="center" prop="caseStatusName">
        <template slot-scope="scope">
          <el-tag type="warning">{{ scope.row.caseStatusName }}</el-tag>
        </template>
      </el-table-column>
      <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="paymentconfirmationRow(scope.row)" 
          v-if="checkPermi(['paymentManagement:list:payconfirm']) && btnStatus">缴费确认</el-button>
          <el-button size="mini" type="text" icon="el-icon-edit" @click="viewpaymentformRow(scope.row)"
            v-hasPermi="['paymentManagement:list:detail']">查看缴费单</el-button>
        </template>
      </el-table-column>
    </el-table>
    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
      @pagination="getList" />
    <!-- 缴费确认数据详情 -->
    <paymentdetailsDialog :openDialog="openDialog" :detailform="detailform" :title="title" :flag="flag" :getList="getList"
      @cancelpaymentdetails="cancelpaymentdetails"></paymentdetailsDialog>
  </div>
</template>

<script>
import {
  caseApplicationList,
  selectCaseApplicationConfirm,
  casePay,
} from "@/api/pay/pay";
import paymentdetailsDialog from "./components/paymentdetailsDialog.vue";
import { getDicts } from '@/api/system/dict/data.js'
export default {
  name: "paymentList",
  // dicts: ["case_status"],
  components: { paymentdetailsDialog },
  data() {
    return {
      queryParams: {
        caseNum: undefined,
        pageNum: 1,
        caseStatusList: [3],
        registerDate: "",
        pageSize: 10,
      },
      // 付款二维码
      paySrc: "",
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      pageNum: 1,
      pageSize: 10,
      // 弹出层标题
      title: "",
      payTitle: "",
      // 是否显示弹出层
      open: false,
      openPay: false,
      // 弹出层内容
      form: {},
      // 校验表单
      rules: {},
      dataList: [],
      // 支付文字
      payMain: "",
      // 支付元素显示
      payFlag: false,
      // 案件id，案件实付金额
      payForm: {},
      detailform: {}, //缴费详情数据
      openDialog: false, //缴费详情数据弹框
      flag: null,
      caseStatus: [],
      selectCaseStatusList: [
        {
          label: "待办案件",
          value: 0
        },
        {
          label: "已办案件",
          value: 1
        }
      ],
      caseStatusType:false,
      btnStatus:true,
    };
  },
  created() {
    getDicts("case_status").then(res => {
      this.caseStatus = res.data;
      let params = this.$route.params.status;
      if (params >= 0) {
        this.queryParams.caseStatus = params;
      }
      this.getList();
    })
  },
  methods: {
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList();
      if (this.queryParams.selectCaseStatus == 1) {
        this.queryParams.caseStatus = null;
        this.caseStatusType = true;
        this.btnStatus = false;
      } else if (this.queryParams.selectCaseStatus == 0) {
        this.caseStatusType = false;
        this.btnStatus = true;
      }
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 查询列表数据
    getList() {
      this.loading = true;
      caseApplicationList(this.queryParams).then((response) => {
        this.dataList = response.rows;
        this.dataList.forEach((item) => {
          if (item.caseStatus == 1) {
            item.caseStatusName = "待缴费";
          }
          if (item.arbitratMethod == "1") {
            item.arbitratMethodName = "视频仲裁";
          } else if (item.arbitratMethod == "2") {
            item.arbitratMethodName = "书面仲裁";
          }
        });
        this.total = response.total;
        this.loading = false;
      });
    },
    // 缴费确认
    paymentconfirmationRow(row) {
      //   console.log("缴费确认", row);
      this.getDetail({ id: row.id });
      this.openDialog = true;
      this.title = "缴费确认";
      this.flag = 0;
      this.detailform = {}
    },
    // 查看缴费单
    viewpaymentformRow(row) {
      //   console.log("查看缴费单", row);
      this.getDetail({ id: row.id });
      this.openDialog = true;
      this.title = "缴费单详情";
      this.flag = 1;
      this.detailform = {}
    },
    // 关闭弹窗
    cancelpaymentdetails() {
      this.openDialog = false;
    },
    /** 查询详情 */
    getDetail(parms) {
      selectCaseApplicationConfirm(parms).then((res) => {
        // console.log(res,'resesrrsrrsrrsrsr');
        // if (res.data.caseStatus == 2) {
        //   res.data.caseStatusName = "待缴费确认";
        // }
        this.detailform = res.data;
      });
    },
  },
};
</script>

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