<template>
  <el-dialog
    :title="'任务列表'"
    :visible.sync="dialogVisible"
    class="notice-pop"
    @opened="popOpen"
    width="50%">
    <div class="np-bd">
      <el-tabs v-model="activeName" type="card" @tab-click="handleClick">
        <el-tab-pane label="已处理" name="0">
          <noticePoplist ref="noticeDid" :getList="getListDid"></noticePoplist>
        </el-tab-pane>
        <el-tab-pane label="未处理" name="1">
          <noticePoplist ref="noticeUndid" :getList="getListDid"></noticePoplist>
        </el-tab-pane>
      </el-tabs>
    </div>
  </el-dialog>
</template>

<script>
import noticePoplist from './notice-pop-list'
export default {
  components: {
    noticePoplist
  },
  props: {

  },
  watch: {

  },
  data () {
    return {
      firstPop: true,
      dialogVisible: false,
      activeName: '',
      tabsFirst: [false, false]
    }
  },
  mounted () {
  },
  methods: {
    getListData () {
      let noGet = this.tabsFirst[this.activeName]
      if (!noGet) {
        this.tabsFirst[this.activeName] = true
        if (this.activeName === '0') {
          this.$refs.noticeDid.getData()
        } else {
          this.$refs.noticeUndid.getData()
        }
      }
    },
    handleClick () {
      this.getListData()
    },
    popOpen () {
      if (this.firstPop) {
        this.firstPop = false
        this.activeName = '0'
        this.getListData()
      }
    },
    showPop () {
      this.dialogVisible = true
    },
    closePop () {
      this.dialogVisible = false
    },
    getListDid (pageConfig, cb) {
      let config = {
        isDid: true
      }
      this.getList(config, pageConfig, cb)
    },
    ceshi (pageConfig, cb) {
      pageConfig.totalNum = 14
      let d = [{
        title: '常常的标题补平常',
        time: '2020-09-09 08:09:09'
      }]
      d = d.concat(d)
      d = d.concat(d)
      d = d.concat(d)
      cb(d)
    },
    getList (config, pageConfig, cb) {
      this.ceshi(pageConfig, cb)
      return
      this.$http.get('/monitor/selectBkSearchInfo', { params: { queryParam: config } }).then(({ data: res }) => {
        if (res.code !== '0') {
          return this.$message.error(res.msg)
        }
        let data = res.list
        pageConfig.totalNum = res.total
        cb(data)
      }).catch(() => {

      })
    }
  }
}
</script>

<style lang="scss">
</style>
