<template>
  <div>
    <el-dialog
      :title="dialogTitle"
      :visible.sync="dialogVisible"
      width="50%"
    >
      <el-form ref="formList" label-position="right" label-width="80px" :model="formList">
        <el-form-item label="入库单号" prop="receiptNo">
          <el-input v-model="formList.receiptNo" />
        </el-form-item>
        <el-form-item label="托盘号" prop="trayID">
          <el-input v-model="formList.trayID" />
        </el-form-item>
        <el-form-item label="成品内控码" prop="internalControlCode">
          <el-input v-model="formList.internalControlCode" />
        </el-form-item>
        <el-form-item label="客户标签号" prop="customerCode">
          <el-input v-model="formList.customerCode" />
        </el-form-item>
        <el-form-item label="成品规格" prop="productDpec">
          <el-input v-model="formList.productDpec" />
        </el-form-item>
        <el-form-item label="数量" prop="num">
          <el-input v-model="formList.num" />
        </el-form-item>
        <el-form-item label="批次" prop="batch">
          <el-input v-model="formList.batch" />
        </el-form-item>
        <el-form-item label="包装机号" prop="packCode">
          <el-input v-model="formList.packCode" />
        </el-form-item>
      </el-form>
      <span slot="footer" class="dialog-footer">
        <el-button @click="resetForm('formList')">取 消</el-button>
        <el-button type="primary" @click="submitForm('formList')">确 定</el-button>
      </span>
    </el-dialog>
  </div>
</template>
<script>
export default {
  name: 'InStoreDocumentsAdd',
  props: {
    dialogTitle: {
      type: String,
      required: true
    }
  },
  data() {
    return {
      dialogVisible: false,
      formList: {
        receiptNo: '',
        trayID: '',
        internalControlCode: '',
        customerCode: '',
        productDpec: '',
        num: '',
        batch: '',
        packCode: ''
      }
    }
  },
  mounted() {},
  methods: {
    init(val) {
      if (val) {
        console.log(val)
        this.$nextTick(() => {
          this.formList.receiptNo = val.receiptNo
          this.formList.trayID = val.trayID
          this.formList.internalControlCode = val.internalControlCode
          this.formList.customerCode = val.customerCode
          this.formList.productDpec = val.productDpec
          this.formList.num = val.num
          this.formList.batch = val.batch
          this.formList.packCode = val.packCode
        })
      }
      this.dialogVisible = true
    },
    submitForm(formName) {
      this.$refs[formName].resetFields()
      this.dialogVisible = false
      this.$message({
        type: 'success',
        message: this.dialogTitle + '成功'
      })
    },
    resetForm(formName) {
      this.$refs[formName].resetFields()
      this.dialogVisible = false
    }
  }
}
</script>
