<template>
  <div>
    <el-form ref="cabinetForm" :rules="rules" :model="cabinet" label-width="80px">
      <el-form-item label="到仓时间">
        <el-date-picker type="date" placeholder="请选择日期" v-model="cabinet.arrivalTime"></el-date-picker>
      </el-form-item>
      <el-form-item label="仓库">
        <el-select v-model="cabinet.warehouse" placeholder="请选择仓库">
        </el-select>
      </el-form-item>
      <el-form-item label="装柜时间" prop="time">
        <el-date-picker type="date" placeholder="请选择日期" v-model="cabinet.cabinetTime"></el-date-picker>
      </el-form-item>
      <el-form-item label="出仓时间">
        <el-date-picker type="date" placeholder="请选择日期" v-model="cabinet.outTime"></el-date-picker>
      </el-form-item>
      <el-form-item label="装柜图片">
        <el-upload action="" :limit="1" :file-list="cabinet.fileList">
          <el-button size="small" type="primary">选择文件</el-button>
        </el-upload>
      </el-form-item>
    </el-form>

    <!-- 开始装柜 -->
    <el-dialog title="开始装柜" :visible.sync="dialogVisible" fullscreen :modal-append-to-body=false append-to-body destroy-on-close>
      <startPacking />
    </el-dialog>

    <!-- 操作 -->
    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button type="success">封柜</el-button>
      <el-button @click="cancel">关闭</el-button>
      <el-button type="danger" @click="startCabinet">开始装柜</el-button>
    </el-row>
  </div>
</template>

<script>
import startPacking from "./startPacking.vue";

/**
 * 装柜
 */
export default {
  name: "cabinet",
  components: { startPacking },
  props: {
    boxId: String,
  },
  data() {
    return {
      // 弹窗
      dialogVisible: false,
      // 装柜对象
      cabinet: {
        fileList: [],
      },
      // 校验
      rules: {
        time: [{ required: true, message: "请选择时间", trigger: "change" }],
      },
    };
  },
  methods: {
    /** 提交 */
    onSubmit() {
      this.$refs["cabinetForm"].validate((valid) => {
        if (valid) {
          alert("submit!");
        }
      });
    },
    /** 取消 */
    cancel() {
      this.$emit("closeDialog");
    },
    /** 开始装柜 */
    startCabinet() {
      this.dialogVisible = true;
    },
  },
};
</script>

<style lang="scss" scoped>
</style>
