<template>
<div>
  <el-drawer
      title="我是标题"
      :visible.sync="drawer"
      :with-header="false"
      direction="rtl"
      size="600px"
      append-to-body
      @close="closeDrawer">
      <div>
        <router-view/>
      </div>
    </el-drawer>
    <normalLayout class="normal-card" @onRefresh="getSubmitEditAction">
    <div slot="content" class="container">
      <time-select @timeChange="timeChange" @clearSelect="clearSelect" v-if="tool.checkAuth($route.name,'read')"></time-select>
      <list :list="oneData" type="more" v-if="tool.checkAuth($route.name,'read')"></list>
      <!--分页-->
      <pagination :total="total" :pageSize="param.content.pageSize" :currentPage="param.content.pageNumber" @pageChange="pageChange">
      </pagination>
    </div>
  </normalLayout>
</div>

</template>

<script>
import {mapGetters} from 'vuex'

import Pagination from '@/components/pagination/Pagination'
import SelectPanl from '@/SManagement/submitedit_one/components/SelectPanl'
import TimeSelect from '@/SManagement/submitedit_one/components/TimeSelect'

import list from '@/SManagement/submitedit_one/components/list'
export default {
  name: 'index',
  data () {
    return {
      param: {
          "id":20221102094702,
          "content": {
              "nocache":true,
              "onceonly":0,
              "pageNumber": 1,
              "pageSize": 4,
              "where":{
                  "begdate":"",
                  "enddate":""
              }
          }
      },
      oneData:[],
      total: 0,
      drawer:false
    }
  },
  components: {
    Pagination,
    SelectPanl,
    list,
    TimeSelect
  },
  computed: {
    ...mapGetters({
      DrawerShow:'DrawerShow'
    })
  },
  watch: {
    $route (val) {
      if (val.path == '/submitedit_more') {
        this.getSubmitEditAction()
      }
    },
    DrawerShow (val) {
      val ? this.drawer = true : this.drawer = false
    }
  },
  created () {
    this.getSubmitEditAction()
  },
  methods: {
    closeDrawer () {
      this.$store.dispatch('DrawerShowChange',false)
      this.$router.back()
    },
    //获取所有一事一报
    async getSubmitEditAction () {
      let res = await this.$api.requested(this.param)
      this.oneData = res.data
      this.total = res.total
    },
    pageChange (n) {
      this.param.content.pageNumber = n
      this.getSubmitEditAction() 
    },
    timeChange(time) {
      this.param.content.where.begdate = time[0]
      this.param.content.where.enddate = time[1]
      this.param.content.pageNumber = 1
      this.getSubmitEditAction()
    },
    clearSelect() {
      this.param.content.where.begdate = ''
      this.param.content.where.enddate = ''
      this.param.content.pageNumber = 1
      this.getSubmitEditAction()
    }
  },
};
</script>

<style scoped>
* {
  box-sizing: border-box;
}
.container {
  min-height: calc(100vh - 200px);
}
.normal-card {
  min-height: calc(100vh - 136px);
  padding: 0 20px 30px 10px;
  position: relative;
}
.el-pagination {
  position: absolute;
  right: 16px;
  bottom: 0;
}
/deep/.el-empty {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%,-50%);
}
</style>