<template>
    <div>
      <div v-show="$route.name === 'deliverGoods'">
          <head-todo
            @getList="getList"
            :selectedIds="selectedIds">
        </head-todo>

        <center-list
            :tableData="tableList"
            :currentPage="currentPage"
            :pageSize="pageSize"
            :total="total"
            @getList="getList"
            @handleOpenDetail="handleOpenForm"
            @handleSelectChange="cacheSelectIds">
        </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: 'DeliverGoods',
  components: {
    HeadTodo,
    CenterList,
  },
  data () {
    return {
      tableList: [], // 查询列表
      total: 0, // 查询列表总条数
      query: {
        'page.currentPage': 1,
        'page.limitCount': 10
      },
      selectedIds: '',
      currentPage: 1,
      pageSize: 10
    }
  },
  created () {
    this.getList()
  },
  mounted () {

  },
  methods: {

    // 查询列表
    getList (query) {
      const url = this.$API.stockOut.deliverGoods.getList
      const param = { ...this.query, ...query }
      this.$https.post(url, param).then(res => {
        this.tableList = res.rows
        this.total = res.total
        this.currentPage = res.currentPage
        this.pageSize = res.limit
      })
    },

    //  详情
    handleOpenForm (mode, ...args) {
      this.mode = mode
      this.$router.push({
        name: 'deliverGoodsDetail',
        params: {
          mode,
          ...args
        }
      })
    },

    // checkbox勾选id储存
    cacheSelectIds (ids) {
      this.selectedIds = ids
    }
  }
}
</script>
