<template>
  <div>
    <div v-show="$route.name === 'kitTaskPaList'">
      <head-todo
      @getList="getList"
      :selectedIds="selectedIds">
      </head-todo>
      <center-list
      :tableData="tableData"
      :pageSize="pageSize"
      :currentPage="currentPage"
      :total="total"
      @selecChange="selecChange"
      @handleClickTabs="handleClickTabs">
       </center-list>
    </div>
    <router-view></router-view>
  </div>
</template>
<script>
import HeadTodo from './components/head-todo'
import CenterList from './components/center-list'
export default {
  name: 'KitTaskPaList',
  components: {
    HeadTodo,
    CenterList
  },
  data () {
    return {
      query: {
        'page.currentPage': 1,
        'page.limitCount': 10,
        taskOrigin: 'KIT_CREATE_TASK_PA'
      },
      tableData: [],
      currentPage: 1,
      pageSize: 10,
      total: 0,
      selectedIds: []
    }
  },
  mounted () {
    this.getList()
  },
  methods: {
    selecChange (val) {
      this.selectedIds = val
    },
    getList (query) {
      const url = this.$API.maintain.KitTaskPaList.getList
      const param = { ...this.query, ...query }
      this.$https.post(url, param).then(res => {
        this.tableData = res.rows
        this.total = res.total
        this.currentPage = res.currentPage
        this.pageSize = res.limit
      })
    },

    handleClickTabs (tab, event) {
      switch (tab.paneName) {
        case '0':
          this.getList({ 'taskOrigin': 'KIT_CREATE_TASK_PA' })
          break
        case '1':
          this.getList({ 'taskOrigin': 'KIT_CANCELPICKING' })
          break
        default:
          break
      }
    }
  }
}
</script>
