<template>
  <div class="dialog-h-content scroll-h ">
    <div class="div_dialog_table">

      <el-table class="table"
                :data="tableData"
                border
                :height="tableHeight"
                v-loading="tableLoading"
                :header-cell-style="{background:'#2195FE',color:'#FFFFFF'}"
                style="width: 100%">
        <el-table-column label="序号"
                         header-align="center"
                         align="center"
                         type="index"
                         width="50">
        </el-table-column>

        <el-table-column prop="createdTime"
                         header-align="center"
                         align="center"
                         label="通知时间"
                         width="150">

        </el-table-column>
        <el-table-column prop="channel"
                         header-align="center"
                         align="center"
                         label="渠道"
                         width="180">

        </el-table-column>

        <el-table-column prop="content"
                         header-align="center"
                         align="center"
                         label="内容"
                         min-width="380">

        </el-table-column>

      </el-table>
      <div>
        <el-pagination @size-change="handleSizeChange"
                       @current-change="handleCurrentChange"
                       :current-page.sync="pageNo"
                       :page-sizes="[20, 50, 100, 200]"
                       :page-size="pageSize"
                       layout="sizes, prev, pager, next, total"
                       :total="total">
        </el-pagination>
      </div>
    </div>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
import { Loading } from 'element-ui' // 引入Loading服务
import { requestPost } from '@/js/dai/request'

let loading // 加载动画
export default {
  data () {
    return {
      tableLoading: false,
      total: 0,
      idCard: '',
      tableData: [],
      pageSize: 20,
      pageNo: 1,

    }
  },
  components: {},
  mounted () {

  },

  methods: {

    async initTable (idCard) {
      this.idCard = idCard
      await this.loadTable()

    },

    //加载form
    async loadTable () {
      this.tableLoading = true
      // const url = "/epmetuser/icNotice/page"
      const url = "http://yapi.elinkservice.cn/mock/245/epmetuser/icNotice/page"
      let params = {
        idCard: this.idCard,
        pageNo: this.pageNo,
        pageSize: this.pageSize,
        origin: '1'
      }

      const { data, code, msg } = await requestPost(url, params)
      this.tableLoading = false
      if (code === 0) {
        this.total = data.total
        this.tableData = data.list

        // data.list.forEach(item => {
        //   item.isEdit = false
        //   item.isNew = false
        //   let arrayInspectors = item.inspectors.split(',')
        //   item.inspectorArray = [...arrayInspectors]

        //   let arrayReviewTime = item.reviewTime.split(' ')
        //   item.reviewTime = arrayReviewTime[0]
        // });

        // this.tableData = [...data.list]


      } else {
        this.$message.error(msg)
      }
    },

    handleSizeChange (val) {
      this.pageSize = val
      this.pageNo = 1
      this.loadTable()
    },
    handleCurrentChange (val) {
      this.pageNo = val
      this.loadTable()
    },


    // 开启加载动画
    startLoading () {
      loading = Loading.service({
        lock: true, // 是否锁定
        text: '正在加载……', // 加载中需要显示的文字
        background: 'rgba(0,0,0,.7)' // 背景颜色
      })
    },
    // 结束加载动画
    endLoading () {
      // clearTimeout(timer);
      if (loading) {
        loading.close()
      }
    }
  },
  computed: {
    tableHeight () {

      return (this.clientHeight - 460)

    },

    ...mapGetters(['clientHeight'])

  },
  props: {

  }
}
</script>


<style lang="scss" scoped >
@import "@/assets/scss/modules/management/epidemic.scss";
</style>
