<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
          v-model="queryParams.caseStatus"
          placeholder="请选择案件状态"
          clearable
          @keyup.enter.native="handleQuery"
        >
          <el-option
            v-for="dict in dict.type.case_status"
            :key="dict.value"
            :label="dict.label"
            :value="dict.value"
          ></el-option>
        </el-select>
      </el-form-item> -->
      <!-- <el-form-item label="开庭日期" prop="hearDate">
        <el-date-picker
          v-model="queryParams.hearDate"
          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-row style="margin-bottom:5px;">
         <el-button type="primary" size="mini" icon="el-icon-download" @click="downloadZips">案件归档</el-button>
    </el-row> -->
    <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="caseStatusName">
        <template slot-scope="scope">
          <el-tag type="success">{{ 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-reading"
            v-if="scope.row.filearbitraUrl && scope.row.filearbitraUrl !== ''"
            @click="showModel(scope.row)">查看裁决书</el-button>
          <el-button size="mini" type="text" icon="el-icon-reading" @click="showDetail(scope.row)">归档详情</el-button>
          <el-button type="text" size="mini" icon="el-icon-download" @click="downloadZips(scope.row)">下载案件压缩包</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(queryParams)" />
    <!-- 弹窗 -->
    <archiveDetailsDialog v-if="showarchiveDetails" :showarchiveDetails="showarchiveDetails" :caseDetail="caseDetail" :caseLog="caseLog" :videoList="videoList" :detailform="detailform"
      :flagLoading="flagLoading" @cancelpaymentdetails="cancelpaymentdetails" @updataList="updataList">
    </archiveDetailsDialog>
  </div>
</template>
  
<script>
import { caseApplicationList, selectSignSealUrl,caseApplicationDetail } from "@/api/awardManagement/awardManagement";
import { caseLogRecordList, logistics } from "@/api/caseManagement/caseManagement";
import { adjudicationArchives, videoList } from "@/api/caseFiling/caseFiling";
import archiveDetailsDialog from "./components/archiveDetailsDialog.vue";
export default {
  name: "archiveList",
  dicts: ["case_status"],
  components: { archiveDetailsDialog },
  data() {
    return {
      queryParams: {
        pageNum: 1,
        pageSize: 10,
      },
      // 遮罩层
      loading: false,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 是否显示弹出层
      // 弹出层内容
      form: {},
      // 校验表单
      rules: {},
      dataList: [],
      detailform: [], //详情数据
      showarchiveDetails: false, //详情数据弹框
      flagLoading: false, //详情弹框loading
      videoList:"",
      caseDetail:{},
      caseLog:null
    };
  },
  created() {
    this.queryParams.caseStatusList = [17];
    this.getList(this.queryParams);
  },
  methods: {
    showModel(row) {
      selectSignSealUrl({ id: row.id }).then(res => {
        let url = res.data.filearbitraUrl;
        window.open(url)
      })
    },
    updataList() {
      this.getList(this.queryParams);
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      this.getList(this.queryParams);
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm("queryForm");
      this.handleQuery();
    },
    // 下在案件归档压缩包
    downloadZips(row){
      //  console.log(this.download) 
    },
    // 查询列表数据
    getList(parms) {
      this.loading = true;
      caseApplicationList(parms).then((response) => {
        this.dataList = response.rows;
        this.total = response.total;
        this.loading = false;
      });
    },
    // model框显示
    showDetail(row) {
      // this.getDetail({ id: row.id });
      this.logisticsFn({ id: row.id })
      this.getvideoList({ caseId: row.id });
      this.getCaseDetail({ id: row.id })
      this.getCaseLog({caseAppliId :row.id})
      this.showarchiveDetails = true;
      this.flagLoading = true;
    },
    // 关闭弹窗
    cancelpaymentdetails() {
      this.showarchiveDetails = false;
    },
    // 根据id查询视频列表
    getvideoList(data) {
      videoList(data).then(res => {
        this.videoList = res.data;
      })
    },
    /** 查询详情 */
    // getDetail(parms) {
    //   adjudicationArchives(parms).then((res) => {
    //     console.log(res,"PPPPPPPPPPPPPPPPPPPPPPPPP");
    //     this.detailform = res.data.logisticsInfoVOList;
    //   });
    // },
    // 查询快递单号信息 logistics
    logisticsFn(params) {
      logistics(params).then((res) => {
        // console.log(res,"PPPPPPPPPPPPPPPPPPPPPPPPP");
        this.detailform = res.data;
      })
    },
    // 查询案件详情
    getCaseDetail(params){
      caseApplicationDetail(params).then(res=>{
        this.caseDetail = res.data;
        this.flagLoading = false;
      })
    },
    // 查看案件日志
    getCaseLog(params){
      caseLogRecordList(params).then(res=>{
        // console.log(res,"LLLLLLLLLLL");
        this.caseLog = res.data;
      })
    }
  },
};
</script>
  
<style lang="scss" scoped></style>