<template>
  <div class="container">
    <!-- 查询配置 -->
    <div style="padding: 0px 20px">
      <div ref="lxHeader">
        <LxHeader icon="md-apps" text="归档查看" style="margin-bottom: 10px; border: 0px;">
          <div slot="content"></div>
          <slot>
            <div>
              <Input style="width: 200px; margin-right: 10px" v-model="searchFields.KeyWord" placeholder="关键字搜索" />
              <Button type="primary" @click="load" style="margin-left: 10px">查询</Button>
            </div>
          </slot>
        </LxHeader>
      </div>

      <el-row :gutter="20">
        <el-col :span="24">
          <div class="table-tree">
            <el-table :data="tableData" class="v-table" :height="tableHeight" border style="width: 100%">
              <el-table-column type="index" align="center">
              </el-table-column>
              <el-table-column prop="title" label="标题">
                <template slot-scope="scope">
                  {{scope.row.title}}
                </template>
              </el-table-column>
              <el-table-column prop="created_at" align="center" label="创建日期" width="180">
              </el-table-column>
              <el-table-column prop="" align="center" label="归档人" width="180">
                <template slot-scope="scope">
                  {{scope.row.admin?scope.row.admin.name:''}}
                </template>
              </el-table-column>
              <el-table-column fixed="right" label="操作" width="120">
                <template slot-scope="scope">
                  <Button ghost size="small" @click="showBack(scope.row.id,scope.row.mission_id,'show')" type="primary"
                    style="margin-left: 10px;">查看</Button>
                </template>
              </el-table-column>
            </el-table>
            <div class="pagination">
              <el-pagination background @current-change="handleCurrentChange" :current-page="pagination.page"
                :page-size="pagination.page_size" layout="total,prev, pager, next" :total="pagination.total">
              </el-pagination>
            </div>
          </div>

        </el-col>
      </el-row>

    </div>
    <showBackPlan ref="showBackPlan"></showBackPlan>
  </div>

</template>

<script>
  import LxHeader from "@/components/LxHeader/index.vue";
  import showBackPlan from '../list/components/showBackPlan.vue'
  import {
    listarticle,
    get
  } from "@/api/lawsfile/article.js";

  export default {
    components: {
      LxHeader,
      showBackPlan
    },
    created() {
      var that = this;
      that.initLoad();
      that.load();
    },
    mounted() {},
    data() {
      return {
        fileUrl: "",
        dialogViewVisible: false,
        tableHeight: 0,
        //查询条件字段
        searchFields: {
          KeyWord: "",
          menu_id: ""
        },
        tableData: [],
        pagination: {
          page: 1,
          page_size: 15,
          total: 0
        },
        clientHeight: 0,
      }
    },
    methods: {
      initLoad() {
        var that = this;
        var clientHeight = document.documentElement.clientHeight
        var lxHeader_height = 96.5; //查询 头部
        var paginationHeight = 37; //分页的高度
        var topHeight = 50; //页面 头部
        let tableHeight = clientHeight - lxHeader_height - topHeight - paginationHeight - 20;
        that.tableHeight = tableHeight;
      },
      handleCurrentChange(val) {
        this.pagination.page = val;
        this.load();
      },
      showBack(id, mission_id,type) {
        this.$refs.showBackPlan.id = id
        this.$refs.showBackPlan.mission_id = mission_id
        this.$refs.showBackPlan.type = type
        this.$refs.showBackPlan.isShow = true
      },
      load(istrue) {
        var that = this;
        let type = parseInt(this.$route.path.split("_")[1]);
        let type1 = parseInt(this.$route.path.split("_")[2]);
        that.searchFields.menu_id = type1
        listarticle(that.pagination.page, that.searchFields.menu_id, that.searchFields.KeyWord, that.pagination
          .page_size, type).then(response => {
          that.tableData = response.data;
          that.pagination.total = response.total;
        }).catch(error => {
          console.log(error)
        })
      },
    }
  };
</script>

<style>
  .dialogConcent {
    overflow-y: auto;
  }
  .el-tree-node__label{
    text-wrap:wrap;
  }
  .el-tree-node__content{
    height:auto;
  }
</style>
