<template>
  <el-dialog
    title="满车入库"
    :visible.sync="dialogVisible"
    width="400px"
    :before-close="handleClose">

    <el-form ref="form" :model="form" :rules="rules" size="small" label-width="80px">

      <el-form-item label="容器" prop="containerCode">
        <el-input v-model="form.stockCode" placeholder="请输入容器号"></el-input>
      </el-form-item>

      <el-form-item label="点位" prop="pointCode">
        <el-input v-model="form.pointCode" placeholder="请输入点位"></el-input>
      </el-form-item>

      <el-form-item label="物料" prop="itemCode">
        <el-input v-model="form.itemCode" placeholder="请输入物料"></el-input>
      </el-form-item>
    </el-form>


    <span slot="footer" class="dialog-footer">
    <el-button @click="cancelForm">取 消</el-button>
    <el-button type="primary" @click="stockInConfirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import crud from '@/mixins/crud'
import pointUrl, { fullStockIn } from '@/api/point'
import CRUD from '@crud/crud'

export default {
  mixins: [crud],
  data() {
    return {
      dialogVisible: false,
      FullStockIn: {
        itemCode: '',
        stockCode: '',
        agvScene: '',
        pointCode: ''
      },
      rules: {
        pointCode: [
          {required: true, message: '点位必填', trigger: 'blur'}
        ],
        stockCode: [
          {required: true, message: '容器必填', trigger: 'blur'}
        ],
        itemCode: [
          {required: true, message: '物料必填', trigger: 'blur'}
        ]
      }


    };
  },
  methods: {
    //关闭
    handleClose(done) {
      done();
    },
    stockInClick(data){
    this.form.pointCode=data.code;
    },
    stockInConfirm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.FullStockIn.stockCode = this.form.stockCode
          this.FullStockIn.pointCode = this.form.pointCode
          this.FullStockIn.itemCode = this.form.itemCode
          this.FullStockIn.agvScene="ZC"
          pointUrl.fullStockIn(this.FullStockIn).then(res => {
            if(res.status==200){
              this.dialogVisible = false
              this.$parent.crud.notify(res.message, CRUD.NOTIFICATION_TYPE.SUCCESS);
              this.$parent.shuaxinContainerList()
              this.$refs['form'].resetFields();
            }else{
              this.$parent.crud.notify(res.message, CRUD.NOTIFICATION_TYPE.ERROR);
            }
          }).catch(() => {

          })
        } else {
          return false;
        }
      });
    },
    cancelForm() {
      this.dialogVisible = false
      this.$refs['form'].resetFields();
    }
  }

};
</script>


<style scoped>

</style>
