<template>
  <div>
    <el-form ref="form" :rules="rule" :model="propForm" label-width="120px">
      <el-form-item label="控件类型" prop="label">
        <el-select v-model="propForm.type" placeholder="请选择控件类型">
          <el-option label="时间" :value="timeType.time"></el-option>
          <el-option label="日期" :value="timeType.date"></el-option>
          <el-option label="时间及日期" :value="timeType.datetime"></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="是否为时间段" prop="value">
        <el-switch v-model="propForm.range" :disabled="editModel" />
      </el-form-item>
      <!-- <el-form-item label="最早时间" prop="min">
        <el-time-picker
          v-model="value1"
          :disabled-hours="disabledHours"
          :disabled-minutes="disabledMinutes"
          :disabled-seconds="disabledSeconds"
          placeholder="Arbitrary time"
        >
        </el-time-picker>
        <el-date-picker v-model="value1" type="date" placeholder="Pick a day">
      </el-date-picker>
      </el-form-item>
      <el-form-item label="最晚时间" prop="max">
        <el-switch v-model="propForm.max" />
      </el-form-item> -->
      <!-- <el-form-item label="时间格式" prop="format">
        <el-input
          v-model="propForm.format"
          placeholder="请输入时间格式"
        ></el-input>
      </el-form-item> -->
    </el-form>
  </div>
</template>
<script lang="ts">
import { Options, Vue } from "vue-class-component";
import { Prop, Watch } from "vue-property-decorator";
import SwtionElement from "@/plugins/element";
import { TimeProp } from "@/model/UILibrary";
import { timeType } from "@/enums/uilibrary";
import SwtionAttribute from "@/plugins/attribute";
import { AttributeValue } from "@/model/Attribute";
@Options({})
export default class time extends Vue {
  @Prop({
    default: new TimeProp(),
    type: TimeProp,
  })
  public prop!: ITimeProp;
  @Prop({
    default: new AttributeValue(),
    type: AttributeValue,
  })
  public attributeValue!: IAttributeValue;

  public timeType = timeType;
  public propForm = new TimeProp();
  public rule = TimeProp.rules();
  public swtionAttr = new SwtionAttribute();
  public swtionEle = new SwtionElement();
  // public editModel = false;
  created() {
    this.propForm = new TimeProp(this.prop);
  }
  public getProp() {
    const _this = this as any;
    let result = null;
    _this.$refs["form"].validate(async (valid: Boolean) => {
      if (valid) {
        result = _this.propForm;
      }
    });
    return result;
  }
  get editModel() {
    return this.attributeValue.id ? true : false;
  }
}
</script>
