<template>
  <el-dialog :title="title" :visible.sync="dialogFormVisible" width="500px" @close="close">
    <el-form ref="form" label-width="80px" :model="form" :rules="rules">
       <template v-if="form.status == '2' ">
      <el-form-item label="车辆ID" prop="车辆ID">
        <el-input v-model.trim="form.车辆ID" autocomplete="off" />
      </el-form-item>
      <el-form-item label="小哇ID" prop="小哇ID">
        <el-input v-model.trim="form.小哇ID" autocomplete="off" />
      </el-form-item>
       <el-form-item label="时段ID" prop="时段ID">
        <el-input v-model.trim="form.时段ID" autocomplete="off" />
      </el-form-item>
          <el-form-item label="预约日期" prop="预约日期">
             <el-date-picker
      v-model="form.预约日期"
      style="width:350px;"
      type="date"
      value-format="yyyy-MM-dd"
      placeholder="选择日期">
    </el-date-picker>
        <!-- <el-input v-model.trim="form.预约日期" autocomplete="off" /> -->
      </el-form-item>
       </template>
         <el-form-item v-else label="订单状态" prop="订单状态">
             <el-select v-model="form.订单状态" placeholder="请选择">
             <el-option
               v-for="item in options"
               :key="item.value"
               :label="item.label"
               :value="item.value">
             </el-option>
           </el-select>
      </el-form-item>
    </el-form>
     
    <div slot="footer" class="dialog-footer">
      <el-button @click="close">取 消</el-button>
      <el-button type="primary" @click="save">确 定</el-button>
    </div>
  </el-dialog>
</template>

<script>
  import { doEdit } from '@/api/table'

  export default {
    name: 'TableEdit',
    data() {
      return {
          options: [{
          value: '已支付',
          label: '已支付'
        },
        ],
        form: {
          title: '',
          author: '',
          smallWow:'',
          time:'',
          author:''
        },
        rules: {
          车辆ID: [{ required: true, trigger: 'blur', message: '请输入车辆ID' }],
            小哇ID: [{ required: true, trigger: 'blur', message: '请输入小哇ID' }],
             时段ID: [{ required: true, trigger: 'blur', message: '请输入时段ID' }],
          预约日期: [{ required: true, trigger: 'blur', message: '请选择时间' }],
          订单状态: [{ required: true, trigger: 'blur', message: '请选择状态' }],
        },
        title: '',
        dialogFormVisible: false,
      }
    },
    created() {},
    methods: {
      showEdit(row) {
        if (!row) {
          this.title = '添加'
        } else {
          this.title = '编辑'
          this.form = Object.assign({}, row)
        }
        this.dialogFormVisible = true
      },
      close() {
        // this.$refs['form'].resetFields()
        // this.form = this.$options.data().form
        this.dialogFormVisible = false
        // this.$emit('fetch-data')
      },
      save() {
        // console.log(this.form,'--=')
        this.$refs['form'].validate(async (valid) => {
          if (valid) {
            const { msg } = await doEdit(this.form)
            this.$baseMessage(msg, 'success')
            this.$refs['form'].resetFields()
            this.$parent.fetchData();
            this.dialogFormVisible = false
            this.form = this.$options.data().form
          } else {
            return false
          }
        })
      },
    },
  }
</script>
