<template>
  <el-dialog
    v-dialogDrag
    :title="title"
    :visible.sync="open"
    width="800px"
    append-to-body
  >
    <el-table
      v-loading="loading"
      :data="list"
      border
      size="mini"
    >
      <el-table-column
        label="物料编码"
        align="center"
        prop="materialNo"
        width="150"
        show-overflow-tooltip
      />
      <el-table-column
        label="物料名称"
        align="center"
        prop="materialName"
        width="150"
        show-overflow-tooltip
      />
      <el-table-column label="规格型号" align="center" prop="materialModels" />
      <el-table-column label="是否主料" align="center" prop="mainMaterial">
        <template slot-scope="scope">
          <dict-tag :type="DICT_TYPE.WMS_IS_MAIN_MATERIALS" :value="scope.row.mainMaterial" />
        </template>
      </el-table-column>
      <el-table-column label="物料类别" align="center" prop="categoryNumber" />
      <el-table-column label="需求数量" align="center" prop="needQty" />
      <el-table-column label="单位" align="center" prop="unitCode" />
    </el-table>
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </el-dialog>
</template>

<script>
import { getMaterialDetailPage } from '@/api/wms/output/productionIssue'

export default {
  data() {
    return {
      // 遮罩层
      loading: true,
      // 总条数
      total: 0,
      // WMS 生产发料 主列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        masterId: null
      }
    }
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      getMaterialDetailPage(this.queryParams).then(response => {
        this.list = response.data.list
        this.total = response.data.total
      }).finally(() => {
        this.loading = false
      })
    }
  }
}
</script>

<style>

</style>
