<template>
  <div>
    <el-form ref="trailerForm" :rules="rules" :model="trailer" label-width="120px" class="trailer-form">
      <el-form-item label="状态">
        <el-select v-model="trailer.status" placeholder="请选择状态">
          <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="拖车公司">
        <el-select v-model="trailer.trailerCompany" placeholder="请选择拖车公司">
          <el-option v-for="item in status" :key="item.value" :label="item.label" :value="item.value"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="拖车时间" prop="time">
        <el-date-picker type="date" placeholder="请选择日期" v-model="trailer.trailerTime"></el-date-picker>
      </el-form-item>
      <el-form-item label="车牌">
        <el-input v-model="trailer.licensePlate"></el-input>
      </el-form-item>
      <el-form-item label="司机">
        <el-input v-model="trailer.driver"></el-input>
      </el-form-item>
      <el-form-item label="司机联系方式">
        <el-input v-model="trailer.telephone"></el-input>
      </el-form-item>
      <el-form-item label="货柜号">
        <el-input v-model="trailer.containerNumber"></el-input>
      </el-form-item>
      <el-form-item label="封条">
        <el-input v-model="trailer.seal"></el-input>
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit">提交</el-button>
      <el-button @click="cancel">取消</el-button>
    </el-row>
  </div>
</template>

<script>
export default {
  name: "trailer",
  data() {
    return {
      status: [
        {
          value: "1",
          label: "已派车，待提柜",
        },
        {
          value: "2",
          label: "已提柜，待还柜",
        },
        {
          value: "3",
          label: "已还柜",
        },
      ],
      trailer: {},
      rules: {
        time: [{ required: true, message: "请选择时间", trigger: "change" }],
      },
    };
  },
  methods: {
    onSubmit() {
      this.$refs["trailerForm"].validate((valid) => {
        if (valid) {
          alert("submit!");
        }
      });
    },
    cancel() {
      this.$emit("closeDialog");
    },
  },
};
</script>
