<template>
  <div class="bbsl-common-page">
    <div class="bbsl-table-search">
      <el-form v-model="queryParam" :inline="true">
        <el-form-item label="年份：">
          <el-date-picker
            v-model="querys[0].value"
            placeholder="选择年份"
            type="year"
            value-format="yyyy"
          >
          </el-date-picker>
        </el-form-item>
        <el-form-item>
          <el-button icon="el-icon-search" type="primary" @click="handleSearch"
            >搜索
          </el-button>
        </el-form-item>
      </el-form>
    </div>
    <div ref="contentPanel" class="bbsl-table-content">
      <div ref="btnPanel" class="bbsl-btn-content">
        <el-button icon="el-icon-plus" type="success" @click="handleAdd"
          >新增
        </el-button>
        <el-popconfirm title="确定删除选中数据吗？" @confirm="handleDelete">
          <el-button
            slot="reference"
            :disabled="!multipleSelection.length"
            icon="el-icon-delete"
            style="margin-left: 10px"
            type="danger"
            >删除
          </el-button>
        </el-popconfirm>
      </div>
      <el-table
        ref="multipleSelection"
        v-loading="loading"
        :cell-style="{'text-align': 'center'}"
        :data="tableData"
        :header-cell-style="{'text-align': 'center'}"
        :max-height="tableMaxHeight"
        :style="{width: '100%'}"
        size="mini"
        @row-dblclick="handleDbClick"
        @selection-change="handleSelectionChange"
      >
        <el-table-column type="selection" width="55"></el-table-column>
        <el-table-column
          fixed
          label="序号"
          type="index"
          width="55"
        ></el-table-column>
        <el-table-column
          label="年份"
          min-width="100"
          prop="year"
          show-overflow-tooltip
        >
        </el-table-column>
        <el-table-column
          label="创建时间"
          min-width="200"
          prop="createTime"
          show-overflow-tooltip
        >
        </el-table-column>
      </el-table>
      <el-pagination
        ref="paginationPanel"
        :current-page="queryParam.pageBean.page"
        :page-size="queryParam.pageBean.pageSize"
        :page-sizes="[20, 30, 40, 50]"
        :total="total"
        align="right"
        background
        class="bbsl-pagination"
        layout="prev, pager, next,total, sizes, jumper"
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
      ></el-pagination>
    </div>
    <ndsbDialog ref="formModal"></ndsbDialog>
  </div>
</template>

<script>
import {TableMixin} from '@/mixins/tableMixin'
import moment from 'moment'
import ndsbMenu from '@/api/examination/ndsbMenu.js'
import ndsbDialog from './components/ndsbDialog.vue'

export default {
  name: 'ndsbMenu',
  mixins: [TableMixin],
  components: {
    ndsbDialog
  },
  data() {
    return {
      url: {
        delete: '/exam/year/report/'
      },
      search: '',
      tableData: [],
      querys: [
        {
          group: 'main',
          operation: 'LIKE',
          parentGroup: '',
          property: 'year_',
          relation: 'AND',
          value: moment().format('YYYY')
        },
        {
          group: 'main',
          operation: 'EQUAL',
          parentGroup: '',
          property: 'e.level_',
          relation: 'AND',

          value: ''
        }
      ]
    }
  },
  created() {},

  mounted() {
    // this.loadData()
  },
  methods: {
    // 获取list
    loadData(page) {
      if (page) {
        this.queryParam.pageBean.page = page
      }
      this.loading = true
      this.tableData = []
      this.queryParam.querys = []

      if (this.querys[0].value) {
        this.queryParam.querys.push(this.querys[0])
      }
      if (this.querys[1].value) {
        this.queryParam.querys.push(this.querys[1])
      }

      ndsbMenu.queryReport(this.queryParam, res => {
        this.total = res.total
        this.tableData = res.rows
        this.$set(this.tableData)
        this.loading = false
      })
    },
    reload() {
      this.loadData(1)
    }
  }
}
</script>
<style lang="scss" scoped>
a {
  text-decoration: none;
  color: #ffffff;
}

.type-tag {
  margin: 0 2px;
}

.common-tree-container {
  height: calc(100% - 70px);
  margin-top: 0.52083vw;
  padding: 1.04167vw 1.04167vw;
  background-color: #fff;
  position: relative;
  overflow-y: auto;
  box-sizing: border-box;
  border-radius: 20px;
  box-shadow: 0px 0px 0.625vw 0 rgba(92, 102, 83, 0.2);
}

.avatar-uploader {
  display: inline-block;
  margin-left: 10px;
}

.title {
  width: 100%;
  margin-bottom: 10px;

  i {
    color: #1289fe;
    font-size: 25px;
  }

  span {
    font-size: 25px;
  }
}

::v-deep .el-tree {
  border: none;
}

::v-deep .el-tree-node__content {
  padding: 5px 0;
}
</style>
