<!-- 销售出库单 -->
<template>
  <el-dialog
    title="回签明细"
    :visible.sync="detailVisible"
    width="1000px"
    @open="dialogOpen"
  >
    <!-- 搜索工作栏 -->
    <el-form
      v-show="showSearch"
      ref="queryForm"
      :model="queryParams"
      size="small"
      label-width="98px"
    >
      <QueryFormWrapper>
        <el-col :span="8">
          <el-form-item label="出货通知单" prop="saleOutNo">
            <el-input
              v-model="queryParams.saleOutNo"
              placeholder="请输入出货通知单"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="销售订单" prop="saleOrderNo">
            <el-input
              v-model="queryParams.saleOrderNo"
              placeholder="请输入出货通知单"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="物料编码" prop="materialNo">
            <el-input
              v-model="queryParams.materialNo"
              placeholder="请输入物料编码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <div slot="right">
          <el-form-item label-width="0" class="text-right" style="word">
            <el-button type="primary" icon="el-icon-search" @click="handleQuery">搜索</el-button>
            <el-button icon="el-icon-refresh" @click="resetQuery">重置</el-button>
          </el-form-item>
        </div>
      </QueryFormWrapper>
    </el-form>

    <!-- 列表 -->
    <AutoResizer :given-height="190">
      <template #default="{height}">
        <el-table
          v-loading="loading"
          :data="list"
          :height="height"
          border
        >
          <el-table-column
            label="销售出库单号"
            align="center"
            prop="saleOutNo"
            width="190"
            fixed="left"
          />
          <el-table-column
            label="销售单号"
            align="center"
            prop="saleOrderNo"
            width="120"
            show-overflow-tooltip
          />
          <el-table-column
            label="物料编码"
            align="center"
            prop="materialNo"
            width="120"
            show-overflow-tooltip
          />
          <el-table-column
            label="物料名称"
            align="center"
            prop="materialName"
            width="100"
            show-overflow-tooltip
          />
          <el-table-column
            label="箱号"
            align="center"
            prop="boxNo"
            width="170"
          />
          <el-table-column label="计划数量" align="center" prop="planQty" />
          <el-table-column label="装箱数量" align="center" prop="boxQty" />
          <el-table-column
            label="单位"
            align="center"
            prop="unitCode"
            width="100"
          />
          <el-table-column label="创建人" align="center" prop="creator" />
          <el-table-column
            label="创建时间"
            align="center"
            prop="createTime"
            width="160"
          >
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.createTime) }}</span>
            </template>
          </el-table-column>
        </el-table>
      </template>
    </AutoResizer>

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

  </el-dialog>
</template>

<script>
import { getSaleOutDetailPage } from '@/api/wms/inquirePurchase/complexDocuments'

export default {
  components: {
  },
  data() {
    return {
      // 遮罩层
      loading: true,
      // 导出遮罩层
      exportLoading: false,
      detailVisible: false,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // WMS补料申请单主列表
      list: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        saleOrderNo: null,
        saleOutNo: null,
        materialNo: null
      },
      // 表单参数
      form: {}
    }
  },
  methods: {
    /** 查询列表 */
    getList() {
      this.loading = true
      // 执行查询
      const params = {
        ...this.queryParams,
        ...this.paramsQuery
      }
      getSaleOutDetailPage(params).then(response => {
        this.list = response.data.list
        this.total = response.data.total
      }).finally(() => {
        this.loading = false
      })
    },
    /** 搜索按钮操作 */
    handleQuery() {
      this.queryParams.pageNo = 1
      this.getList()
    },
    dialogOpen() {
      this.getList()
    },
    /** 重置按钮操作 */
    resetQuery() {
      this.resetForm('queryForm')
      this.handleQuery()
    }
  }
}
</script>
