<template>
  <!-- 监测点报告 -->
  <div>
    <div class="BOXbutton">
      <el-button type="primary" icon="el-icon-notebook-2" @click="$emit('flag')"
        >报告字典管理2</el-button
      >
      <el-button type="primary" icon="el-icon-plus" @click="addTemplate"
        >新增模板</el-button
      >
      <el-button type="primary" icon="el-icon-upload2">导出</el-button>
    </div>
    <el-table
      stripe
      v-loading="loading"
      :data="tableData.slice((pageNum - 1) * pageSize, pageNum * pageSize)"
      header-cell-class-name="table_header"
      style="width: 100%; margin: 10px 0"
      border
      :height="vh"
    >
      <el-table-column type="index" width="50" label="序号">
        <template scope="scope">
          <span>{{ (pageNum - 1) * pageSize + scope.$index + 1 }}</span>
        </template></el-table-column
      >

      <el-table-column prop="date" label="模板名称"> </el-table-column>
      <el-table-column prop="name" label="模板描述"> </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="scope">
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-edit"
            @click="modify(scope.row)"
            >修改</el-button
          >
          <el-button
            type="primary"
            size="mini"
            icon="el-icon-delete"
            @click="deletes(scope.row)"
            >删除</el-button
          >
        </template>
      </el-table-column>
    </el-table>
    <el-pagination
      background
      align="right"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="pageNum"
      :page-sizes="[20, 30, 40, 50, 100]"
      :page-size="pageSize"
      layout="total, sizes, prev, pager, next, jumper"
      :total="tableData.length"
    >
    </el-pagination>
    <Template
      v-if="dialogVisible"
      @close="close"
      :title="title"
      :dialogVisible="dialogVisible"
      :TemplateTree="TemplateTree"
    />
  </div>
</template>
<script>
import Template from "./Template.vue";
export default {
  components: { Template },
  props: {},
  data() {
    return {
      loading: true,
      vh: undefined,
      pageNum: 1,
      pageSize: 20,
      tableData: [
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
        {
          date: "默认报告模板",
          name: "默认报告模板",
          address: "上海市普陀区金沙江路 1518 弄",
        },
      ],
      dialogVisible: false,
      title: "",
      TemplateTree: [],
    };
  },
  created() {
    this.info();
  },
  mounted() {
    
    this.setHeight()
        window.addEventListener('resize', this.setHeight)
    },
    beforeDestroy() {
        window.removeEventListener('resize', this.setHeight)
    },
    methods: {
        setHeight() {
          this.vh = window.sessionStorage.getItem("appheight") - 165;
          
        },
    info() {
      this.loading = false;
    },
    // 新增
    addTemplate() {
      this.title = "新增模板";
      this.dialogVisible = true;
    },
    // 修改
    modify() {
      this.title = "修改模板";

      this.dialogVisible = true;
    },
    // 关闭弹框
    close() {
      this.dialogVisible = false;
    },
    // 删除
    deletes(id) {
      this.$confirm("是否确认删除?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      }).then(() => {
        this.$message({
          type: "success",
          message: "删除成功!",
        });
      });
    },
    handleSizeChange(val) {
      this.pageSize = val;
    },
    handleCurrentChange(val) {
      this.pageNum = val;
    },
  },

  computed: {},

  watch: {},
};
</script>
<style lang="less" scoped>
@import url("../../../../styles/comStyle.less");
</style>

<style lang="scss" scoped>
.BOXbutton {
  display: flex;
  justify-content: end;

  .el-button + .el-button,
  .el-checkbox.is-bordered + .el-checkbox.is-bordered {
    margin-left: 15px;
  }
}
</style>
