<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="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="stockOutConfirm">确 定</el-button>
    </span>
  </el-dialog>
</template>

<script>
import crud from '@/mixins/crud'
import pointUrl from '@/api/point'
import CRUD from '@crud/crud'

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


    };
  },
  methods: {
    //关闭
    handleClose(done) {
      done();
    },
    stockOutClick(data){
    this.form.pointCode=data.code;
    },
    stockOutConfirm() {
      this.$refs['form'].validate((valid) => {
        if (valid) {
          this.FullStockOut.pointCode = this.form.pointCode
          this.FullStockOut.itemCode = this.form.itemCode
          this.FullStockOut.agvScene="ZC"
          pointUrl.fullStockOut(this.FullStockOut).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>
