<template>
  <el-dialog
    v-dialogDrag
    :visible.sync="codeOpen"
    title="签收"
    width="600px"
    append-to-body
    @close="issueCodeClose"
  >
    <el-form
      ref="queryForm"
      :model="queryParams"
      size="small"
      label-width="68px"
      @submit.native.prevent
    >
      <el-form-item label="签收人" prop="encodedEmployeeId">
        <el-input
          v-model="form.encodedEmployeeId"
          placeholder="请输入/扫入签收人"
          clearable
        />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button
        :loading="buttonLoading"
        type="primary"
        @click="handleEnsure"
      >确定</el-button>
    </div>
  </el-dialog>
</template>

<script>
import { syntheticalSign } from '@/api/wms/orders/productMaterials'

export default {
  data() {
    return {
      // 遮罩层
      loading: false,
      buttonLoading: false,
      // 总条数
      total: 0,
      // WMS 生产发料 主列表
      list: [],
      // 弹出层标题
      title: '',
      // 是否显示弹出层
      open: false,
      codeOpen: false,
      // 显示搜索条件
      showSearch: true,
      searching: false,
      signId: '',
      currentData: [],
      // 查询参数
      queryParams: {
        pageNo: 1,
        pageSize: 10,
        encodedEmployeeId: null
      },
      form: {
        encodedEmployeeId: null
      }
    }
  },
  methods: {

    // 重置
    reset() {
      this.list = []
      this.queryParams = {
        encodedEmployeeId: null
      }
      this.open = false
      this.resetForm('form')
    },
    // 取消操作
    cancel() {
      this.reset()
      this.open = false
    },
    // 发料
    handleEnsure() {
      if (this.form.encodedEmployeeId === undefined || this.form.encodedEmployeeId === '') {
        this.$modal.msgWarning('请先输入/扫入签收人工号')
        return
      }
      const params = {
        id: this.signId,
        encodedEmployeeId: this.form.encodedEmployeeId
      }
      this.buttonLoading = true
      syntheticalSign(params).then(res => {
        this.$modal.msgSuccess('操作成功')
        this.open = false
        this.codeOpen = false
        this.buttonLoading = false
        this.$emit('complete')
        this.getList()
      }).finally(() => {
        this.buttonLoading = false
      })
    },
    issueCodeClose() {
      this.form.encodedEmployeeId = undefined
    }
  }
}
</script>

    <style>

    </style>

