<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" placeholder="请输入车牌"></el-input>
      </el-form-item>
      <el-form-item label="司机">
        <el-input v-model="trailer.driver" placeholder="请输入司机"></el-input>
      </el-form-item>
      <el-form-item label="司机联系方式">
        <el-input v-model="trailer.telephone" placeholder="请输入司机联系方式"></el-input>
      </el-form-item>
      <el-form-item label="货柜号">
        <el-input v-model="trailer.containerNumber" placeholder="请输入货柜号"></el-input>
      </el-form-item>
      <el-form-item label="封条">
        <el-input v-model="trailer.seal" placeholder="请输入封条"></el-input>
      </el-form-item>
    </el-form>
    <el-row class="operate-button">
      <el-button type="primary" @click="onSubmit">保存</el-button>
      <el-button type="success" @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>
