<template>
  <el-form
    ref="elForm"
    :model="formData"
    :rules="rules"
    size="medium"
    label-width="100px"
  >
    <el-form-item label="事件标题" prop="title">
      <el-input
        v-model="formData.title"
        placeholder="请输入设备名称事件标题"
        clearable
        :style="{ width: '100%' }"
      >
      </el-input>
    </el-form-item>
    <el-form-item label="开始时间" prop="start_time">
      <el-date-picker
        type="datetime"
        v-model="formData.start_time"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        :style="{ width: '100%' }"
        placeholder="请选择开始时间"
        clearable
      >
      </el-date-picker>
    </el-form-item>
    <el-form-item label="结束时间" prop="end_time">
      <el-date-picker
        type="datetime"
        v-model="formData.end_time"
        format="yyyy-MM-dd HH:mm:ss"
        value-format="yyyy-MM-dd HH:mm:ss"
        :style="{ width: '100%' }"
        placeholder="请选择结束时间"
        clearable
      >
      </el-date-picker>
    </el-form-item>
    <el-form-item size="large">
      <el-button type="primary" @click="submitForm">提交</el-button>
      <el-button @click="resetForm">重置</el-button>
    </el-form-item>
  </el-form>
</template>

<script>
export default {
  inheritAttrs: false,
  components: {},
  props: {
    data: {
      type: Object,
    },
    isReadOnly: {
      type: Boolean,
      default: false,
    },
  },
  data() {
    return {
      formData: {
        title: undefined,
        start_time: null,
        end_time: null,
      },
      rules: {
        title: [
          {
            required: true,
            message: "请输入设备名称事件标题",
            trigger: "blur",
          },
        ],
        start_time: [
          {
            required: true,
            message: "请选择开始时间",
            trigger: "change",
          },
        ],
        end_time: [
          {
            required: true,
            message: "请选择结束时间",
            trigger: "change",
          },
        ],
      },
    };
  },
  computed: {},
  watch: {},
  created() {},
  mounted() {
    if (this.data) this.formData = this.data;
  },
  methods: {
    submitForm() {
      this.$refs["elForm"].validate((valid) => {
        if (!valid) return false;
      });
    },
    resetForm() {
      this.$refs["elForm"].resetFields();
    },
  },
};
</script>

<style>
</style>
