<template>
  <!-- 接收数据详情 -->
  <el-dialog :title="detailType=='detail'?'查看接收数据':'查看失败数据'" :visible.sync="visible" v-dialogDrag width="75%" :before-close="cancel">
    <el-table border :data="tableData" max-height="500px">
      <el-table-column prop="archive_file_num" width="100" label="原文数量" align="center">
        <template slot-scope="scope">
          <span>{{scope.row.archive_file_num?scope.row.archive_file_num:0}}</span>
        </template>
      </el-table-column>
      <el-table-column 
        v-for="(ele, index) in JSON.parse(Alltable.tableShow)" 
        :prop="ele.columnName"
        :label="ele.columnChnName"
        :min-width="ele.width" 
        :key="index+'_apply'" 
        align="center" show-overflow-tooltip>
        <template slot-scope="scope">
          <span>{{ scope.row[ele.columnName] }}</span>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      @current-change="handleCurrentChange"
      @size-change="handleSizeChange"
      layout="total, prev, pager, next, sizes"
      :page-size="pagination.pageSize"
      :page-sizes="[10, 20, 30, 50]"
      :current-page="pagination.pageNum"
      :total="pagination.total"
    >
  </el-pagination>
  </el-dialog>
</template>

<script>
import {receivingDetails} from "@/api/archives-management/ungroupedManagement/receive.js";
import {getTable,} from "@/api/archives-management/fileManagement/notStoredArchives.js";
import { message } from "@/utils/common";

export default {
  props: {
    visible: {
      type: Boolean,
      default: () => false,
    },
    detailType:{
      type:String,
      default:()=>''
    }
  },
  
  data() {
    return {
      pagination: {
        pageSize: 10,
        pageNum: 1,
        total: 0,
      },
      currentTableRow:'', // 门类id
      Alltable: {
          tableShow: "[]",
      },
      tableData:[],
    };
  },
  methods: {
      handleNodeClick(row){
        this.currentTableRow = row;
        let params = {
            classId: row.classid
        };
        getTable(params).then((res) => {
            
            this.Alltable = res.body.InterfaceSystem[0]; // 表格header配置
        }).then((res) => {
            //this.getViewData(row.id); // 表格数据
            this.receivingDetails();
        })
      },
      receivingDetails(){
        console.log(this.currentTableRow);
        let params = {
            classId:this.currentTableRow.classid,
            limit:10,
            page:1,
            tempId:this.currentTableRow.tempid,
            tableType:1,
            receiveId:this.currentTableRow.receiveid,
            is_process:this.detailType=='detail'? 0: -1, // 失败数据，或者接收数据
        }
        receivingDetails(params).then((res)=>{
            if(res.code == 100){
                this.tableData = res.body.list;
                this.pagination.total = res.body.total;   
            }else{
              message('warning',res.msg,3000)
            }
        })
      },
      handleCurrentChange(val){
        this.pagination.pageNum = val;
        this.receivingDetails()
      },
      handleSizeChange(val){
        this.pagination.pageSize = val;
        this.pagination.pageNum = 1;
        this.receivingDetails();
      },
      cancel() {
        this.$emit("clickCancel");
      },
  },
};
</script>

<style></style>
