<template>
  <!-- 列表 -->
  <div>
    <el-table
      v-loading="loading"
      :data="list"
      border
    >
      <el-table-column
        type="selection"
        width="55"
        fixed="left"
      />
      <el-table-column
        label="领料单号"
        align="center"
        width="160"
        prop="erpOrderNo"
      />
      <el-table-column
        label="生产订单"
        align="center"
        width="120"
        prop="workOrderNo"
      />
      <el-table-column
        label="产品编码"
        min-width="150"
        align="center"
        prop="productCode"
      />
      <el-table-column
        label="产品名称"
        min-width="150"
        align="center"
        show-overflow-tooltip
        prop="productName"
      />
      <el-table-column
        label="BOM版本"
        align="center"
        width="120"
        prop="mesBomVersion"
      />
      <el-table-column
        label="单据状态"
        align="center"
        prop="status"
        min-width="120"
      >
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.MES_RECEIVE_MATERIALS_ORDER_STATUS" :value="scope.row.status" />
        </template>
      </el-table-column>
      <el-table-column
        label="领料状态"
        align="center"
        prop="receiveStatus"
        min-width="120"
      >
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.WMS_RECEIVE_MATERIALS_STATUS" :value="scope.row.receiveStatus" />
        </template>
      </el-table-column>
      <el-table-column
        label="发料状态"
        align="center"
        prop="sendStatus"
        min-width="150"
      >
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.WMS_DELIVERY_STATUS" :value="scope.row.sendStatus" />
        </template>
      </el-table-column>
      <el-table-column
        label="操作"
        align="center"
        fixed="right"
        width="150"
      >
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            icon="el-icon-view"
            @click="handleView(scope.row)"
          >领退明细</el-button>
        </template>
      </el-table-column>
    </el-table>

    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
    <!-- 明细 -->
    <PickingDetail ref="pickingDetail" />
  </div>

</template>

<script>
import {
  getProductionMaterialOrderPage
} from '@/api/wms/orders/productPicking'
import PickingDetail from '../../components/PickingDetail.vue'

export default {
  components: {
    PickingDetail
  },
  inject: ['paramsQuery'],
  data() {
    return {
      // 遮罩层
      loading: false,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 领料单列表
      list: [],
      // 弹出层标题
      title: '',
      reasonTitle: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        status: 1
      }
    }
  },
  created() {
    this.getList()
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      const params = {
        ...this.paramsQuery,
        ...this.queryParams
      }
      // 执行查询
      getProductionMaterialOrderPage(params).then((response) => {
        this.list = response.data.list
        this.total = response.data.total
      }).finally(() => {
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    // 领退明细查看
    handleView(row) {
      const { id } = row
      this.$refs.pickingDetail.queryParams.workId = id
      this.$refs.pickingDetail.open = true
    }
  }
}
</script>

