<template>
  <el-dialog
    v-dialogDrag
    title="查看退料详情"
    :visible.sync="open"
    width="1200px"
    append-to-body
    @open="dialogOpen"
    @close="dialogClose"
  >

    <!-- 列表 -->
    <el-table v-loading="loading" :data="list" border>
      <el-table-column label="退料单号" align="center" prop="returnOrderNo" />
      <el-table-column label="物料编号" align="center" prop="materialNo" />
      <el-table-column label="物料名称" align="center" prop="materialName" />
      <el-table-column label="物料批次" align="center" prop="materialBatch" />
      <el-table-column label="供应商编号" align="center" prop="supplierCode" />
      <el-table-column label="退料数量" align="center" prop="returnQty" />
      <el-table-column
        label="创建时间"
        align="center"
        prop="createTime"
        width="180"
      >
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime) }}</span>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </el-dialog>
</template>

<script>
import { getReturnWorkOrderPreDetailPage } from '@/api/wms/output/materialReturn'

export default {
  name: 'ReturnDetails',
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // wms来料退货单明细列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        wmsReturnWorkOrderPreId: null,
        returnOrderNo: null,
        materialNo: null,
        materialName: null,
        materialBatch: null,
        supplierCode: null,
        returnQty: null,
        createTime: []
      },
      // 表单参数
      form: {}
    }
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      getReturnWorkOrderPreDetailPage(this.queryParams).then(response => {
        this.list = response.data.list
        this.total = response.data.total
      }).finally(() => {
        this.loading = false
      })
    },
    /** 取消按钮 */
    cancel() {
      this.open = false
      this.reset()
    },
    /** 表单重置 */
    reset() {
      this.form = {
        id: undefined,
        purchaseOrderNo: undefined,
        wmsIncomingReceiptId: undefined,
        materialNo: undefined,
        returnQty: undefined,
        returnStatus: undefined,
        remark: undefined
      }
      this.resetForm('form')
    },
    dialogOpen() {
      this.$nextTick(() => {
        this.getList()
      })
    },
    dialogClose() {
      this.reset()
      this.queryParams.returnStatus = undefined
      this.queryParams.remark = undefined
    }
  }
}
</script>

