<template>
  <div>
    <div class="mrg-b">
      <!--<drop-filter-->
        <!--:columns="wholeLabels"-->
        <!--:storeKey="storeKey"-->
        <!--:storeLabels="storeLables"-->
        <!--@doFilter="labels => storeLables = labels"-->
      <!--&gt;</drop-filter>-->
      <el-table
        ref="table"
        stripe
        border
        :data="tableData"
        :filteredLabels="storeLables"
        @selection-change="handleSelectChange"
      >
        <table-column type="selection" width="45" align="center"></table-column>
        <table-column label="货主">
          <template slot-scope="scope">
            <p>{{scope.row.ownerCode}}</p>
            <p>{{scope.row.ownerName}}</p>
          </template>
        </table-column>
        <table-column label="商品">
          <template slot-scope="scope">
              <p>{{scope.row.skuCode}}</p>
              <p>{{scope.row.skuName}}</p>
          </template>
        </table-column>
        <table-column label="库存数" prop="qty"></table-column>
        <table-column label="入库单数" prop="asnNum"></table-column>
        <table-column label="计划收获数" prop="qtyPlanEa"></table-column>
        <table-column label="预计到货时间" prop="qtyPlanEa">
          <template slot-scope="scope">
            <p>从：{{scope.row.fmEta}}</p>
            <p>到：{{scope.row.toEta}}</p>
          </template>
        </table-column>
        <table-column label="出库单数" prop="soNum"></table-column>
        <table-column label="计划发货数" prop="qtySoEa"></table-column>
        <table-column label="计划收获时间">
          <template slot-scope="scope">
            <p>从：{{scope.row.fmEtd}}</p>
            <p>到：{{scope.row.toEtd}}</p>
          </template>
        </table-column>
        <table-column label="操作" width="100" fixed="right">
          <template slot-scope="scope">
            <el-tooltip content="编辑" placement="top">
              <el-button
                size="mini"
                type="primary"
                icon="el-icon-edit"
                plain
                circle
                @click="handleEdit(scope.$index, scope.row)"
              ></el-button>
            </el-tooltip>
          </template>
        </table-column>
      </el-table>
    </div>
    <div>
      <el-pagination
        @size-change="handleSizeChange"
        @current-change="handleCurrentChange"
        :current-page="currentPage"
        :page-sizes="[10, 20, 50, 100]"
        :page-size="pageSize"
        layout="total, sizes, prev, pager, next, jumper"
        :total="total"
      ></el-pagination>
    </div>
  </div>
</template>
<script>
export default {
  data () {
    return {

      removeSkuIds: [],
      headData: {},
      goodsData: [],
      storeKey: 'libraryGoods'
    }
  },
  props: {
    tableData: {
      type: Array,
      default: () => []
    },
    total: Number,
    pageSize: Number,
    currentPage: Number,
  },
  methods: {

    // 每页显示条数
    handleSizeChange (pageSize) {
      const query = { 'page.limitCount': pageSize, 'page.currentPage': this.currentPage }
      this.$emit('getList', query)
    },

    // 当前页码
    handleCurrentChange (currentPage) {
      const query = { 'page.limitCount': this.pageSize, 'page.currentPage': currentPage }
      this.$emit('getList', query)
    },
    getData (url, param) {
      return this.$https.post(url, param)
    },
    // 编辑行
    handleEdit (index, row) {
      const headUrl = this.$API.CrossDock.CrossDockTaskGenerateList.getHead
      const asnUrl = this.$API.CrossDock.CrossDockTaskGenerateList.getAsn
      const sonUrl = this.$API.CrossDock.CrossDockTaskGenerateList.getSon
      const wmCrossDockEntity = { ...row, ...{ '0': true, '_index': index, '_status': 0 } }
      const param = {
        wmCrossDockEntity: JSON.stringify(wmCrossDockEntity),
        wmCrossDockEntityBean: JSON.stringify(wmCrossDockEntity),
        queryMoreCondition: JSON.stringify({}) }
      this.$https.all([this.getData(headUrl, param), this.getData(asnUrl, param), this.getData(sonUrl, param)]).then(res => {
        const head = res[0].data
        const asn = res[1].rows
        const son = res[2].rows
        this.$emit('handleOpenEditForm', 'edit', head, asn, son, wmCrossDockEntity)
      })
    },

    // checkbox勾选
    handleSelectChange (selection) {
      this.$emit('handleSelectChange', selection)
    }
  }
}
</script>
<style lang="scss" scoped>
.mrg-b {
  margin-bottom: 20px;
}
.mrg-l {
  margin-left: 10px;
}
.blue {
  cursor: pointer;
  color: #0682ea;
}
</style>
