<template>
<div class="list">
  <!--<drop-filter :columns="wholeLabels" :storeKey="storeKey" :storeLabels="storeLables" @doFilter="labels => storeLables = labels"></drop-filter>-->
  <el-table
    ref="table"
    stripe
    border
    :max-height="tableMaxHeight"
    :data="list"
    :filteredLabels="storeLables"
    @selection-change="selectionChange"
    @row-click="toCheck"
  >
    <table-column type="selection" fixed align="center"></table-column>
    <table-column label="任务ID" prop="mvId">
      <template slot-scope="scope">
        <span class="detail-no" @click.stop="toDetail(scope.row)">{{scope.row.mvId}}</span>
      </template>
    </table-column>
    <table-column label="行号" prop="lineNo"></table-column>
    <table-column label="状态" prop="status">
      <template slot-scope="scope">
        <div>{{ $utils.keyMatcher(scope.row.status, $keys.inventory.mvTask.status).name }}</div>
      </template>
    </table-column>
    <table-column label="货主" prop="ebcuNameCn"></table-column>
    <table-column label="商品" prop="skuName"></table-column>
    <table-column label="批次号" prop="lotNum"></table-column>
    <table-column label="原库位" prop="fmLoc"></table-column>
    <table-column label="计划目标库位" prop="planToLoc"></table-column>
    <table-column label="包装单位" prop="uomDesc"></table-column>
    <table-column label="移动数" prop="qtyMvEa"></table-column>
    <table-column label="操作" width="100" fixed="right">
      <template slot-scope="scope">
        <el-button
          v-auth="50300060112"
          title="编辑"
          size="mini"
          type="primary"
          icon="el-icon-edit"
          plain
          circle
          @click.stop="toEdit(scope.row)"
        ></el-button>
      </template>
    </table-column>
  </el-table>
  <el-pagination
    class="pagination"
    @size-change="sizeChange"
    @current-change="currentChange"
    :current-page="currentNo"
    :page-sizes="[10, 20, 30, 40, 50]"
    :page-size="pageSize"
    layout="total, sizes, prev, pager, next, jumper"
    :total="total"
  ></el-pagination>
</div>
</template>

<script>
export default {
  props: ['list', 'total', 'currentNo', 'pageSize'],
  created () {
  },
  mounted () {
  },

  data () {
    return {
      storeKey: 'mvTask',
    }
  },
  methods: {
    // 点击表格行
    toCheck (row) {
      this.$refs.table.toggleRowSelection(row)
    },
    // 页码变化
    currentChange (currentNo) {
      const query = { 'page.currentPage': currentNo, 'page.limitCount': this.pageSize }
      this.$emit('getList', query)
    },
    // 每页条数变化
    sizeChange (pageSize) {
      const query = { 'page.limitCount': pageSize, 'page.currentPage': this.currentNo }
      this.$emit('getList', query)
    },
    // 详情
    toDetail (row) {
      this.$router.push({
        name: 'mvTaskCreator',
        params: {
          detailData: row,
          mode: 'detail',
        }
      })
    },
    // 编辑
    toEdit (row) {
      this.$router.push({
        name: 'mvTaskCreator',
        params: {
          detailData: row,
          mode: 'edit',
        }
      })
    },
    // 勾选变化
    selectionChange (selection) {
      this.$emit('selectionChange', selection)
    }
  },
}
</script>

<style lang="scss" scoped>
.pagination {
  margin-top: 20px;
}
.detail-no {
  color: #0682ea;
  &:hover {
    cursor: pointer;
  }
}
</style>
