<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="returnOrderNo"
        width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="出货单号"
        align="center"
        prop="saleOutNo"
        min-width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="物料编码"
        align="center"
        prop="materialNo"
        width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="物料名称"
        align="center"
        prop="materialName"
        width="120"
        show-overflow-tooltip
      />
      <el-table-column
        label="箱号"
        align="center"
        prop="boxNo"
        width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="新箱号"
        align="center"
        prop="boxNoNew"
        width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="销售单号"
        align="center"
        prop="erpOrderNo"
        width="130"
        show-overflow-tooltip
      />
      <el-table-column
        label="发货数量"
        align="center"
        prop="sendQty"
        width="80"
        show-overflow-tooltip
      />
      <el-table-column
        label="退货数量"
        align="center"
        prop="returnQty"
        width="80"
        show-overflow-tooltip
      />
      <el-table-column
        label="客户名称"
        align="center"
        prop="customerName"
        width="100"
        show-overflow-tooltip
      />
    </el-table>
    <!-- 分页组件 -->
    <pagination
      v-show="total > 0"
      :total="total"
      :page.sync="queryParams.pageNo"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </el-dialog>
</template>

<script>
import { salesReturnDetailPage } from '@/api/wms/output/salesReturn'

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
      },
      // 表单参数
      form: {},
      // 表单校验
      rules: {
      }
    }
  },
  created() {
    // this.getList()
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      salesReturnDetailPage(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>

