<template>
  <el-dialog
    v-dialogDrag
    title="来料退货明细"
    :visible.sync="open"
    width="1200px"
    append-to-body
    @open="dialogOpen"
  >

    <!-- 列表 -->
    <el-table
      v-loading="loading"
      :data="list"
      border
      size="mini"
    >
      <el-table-column label="采购订单号" align="center" prop="purchaseOrderNo" />
      <el-table-column label="物料编码" align="center" prop="materialNo" />
      <el-table-column label="退料数量" align="center" prop="returnQty" />
      <el-table-column label="退料原因" align="center" prop="remark" />
      <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 { getPurchaseReturnOrderDetailPage } from '@/api/wms/output/purchaseReturnOrder'

export default {
  name: 'PurchaseReturnOrderDetail',
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // wms来料退货单明细列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        masterId: null,
        purchaseOrderNo: null,
        wmsIncomingReceiptId: null,
        materialNo: null,
        returnQty: null,
        returnStatus: null,
        remark: null,
        createTime: []
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
        masterId: [{ required: true, message: '主表id不能为空', trigger: 'blur' }],
        purchaseOrderNo: [{ required: true, message: '采购订单号不能为空', trigger: 'blur' }],
        wmsIncomingReceiptId: [{ required: true, message: '来料登记记录id不能为空', trigger: 'blur' }]
      }
    }
  },
  created() {
    // this.getList()
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      getPurchaseReturnOrderDetailPage(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,
        masterId: undefined,
        purchaseOrderNo: undefined,
        wmsIncomingReceiptId: undefined,
        materialNo: undefined,
        returnQty: undefined,
        returnStatus: undefined,
        remark: undefined
      }
      this.resetForm('form')
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    },
    dialogOpen() {
      this.$nextTick(() => {
        this.getList()
      })
    }
  }
}
</script>

