<template>
<div class="mv-task">
  <div v-show="$route.name === 'movementTask'">
    <Query
      class="mv-task__query"
      :selection="selection"
      @getList="getList"
    ></Query>
    <List
      :currentNo="currentNo"
      :pageSize="pageSize"
      :list="mvTaskList"
      :total="total"
      @getList="getList"
      @selectionChange="cacheSelection"
    ></List>
  </div>
  <router-view></router-view>
</div>
</template>

<script>
import Query from './components/Query'
import List from './components/List'
import routerMixins from '../routerMixins'

export default {
  name: 'MovementTask',
  mixins: [routerMixins],
  components: { Query, List },
  created () {
  },
  mounted () {
    this.getList()
  },

  data () {
    return {
      query: {
        'page.currentPage': 1,
        'page.limitCount': 10,
      }, // 查询条件
      mvTaskList: [], // 盘点列表
      total: 0, // 总数据量
      selection: '', // 选中的id字符串序列 (','隔开)
      currentNo: 1,
      pageSize: 10
    }
  },
  methods: {
    // 获取盘点列表
    getList (query = {}) {
      const url = this.$API.inventory.mvTask.getList
      const param = { ...this.query, ...query }
      param.mvNo !== undefined && (param.mvNo = `%${param.mvNo}%`)
      param.mvId !== undefined && (param.mvId = `%${param.mvId}%`)
      // param.quickCondition !== undefined && (param.quickCondition = `%${param.quickCondition}%`) // 避免传空值只能查到部分数据
      this.$https.post(url, param)
        .then(data => {
          this.mvTaskList = data.rows
          this.total = data.total
          this.currentNo = data.currentPage
          this.pageSize = data.limit
        })
    },
    // 勾选变化, 缓存id
    cacheSelection (selection) {
      this.selection = selection
    }
  },
}
</script>

<style lang="scss" scoped>
.mv-task__query {
  margin-bottom: 20px;
}
</style>
