<template>
  <div>
    <!-- <el-input v-model="result" placeholder="测试双向绑定"></el-input> -->
    <el-date-picker
      v-if="type === 'year'"
      v-model="result"
      :disabled="disable || false"
      type="year"
      :placeholder="placeholder || '请选择时间'"
    >
    </el-date-picker>
    <el-date-picker
      v-model="result"
      type="date"
      value-format="YYYY-MM-DD"
      :disabled="disable || false"
      v-else
      :placeholder="placeholder || '请选择时间'"
    >
    </el-date-picker>
    <!-- <Field
    v-model="result"
    readonly
    name="datetimePicker"
    is-link
    :placeholder="props.placeholder || '点击选择时间'"
    @click="visible = true"
  />
    <template v-if="props.type === 'year'">
      <Picker
        v-model="pickerOptions.year"
        title="选择年份"
        :columns="years"
        :default-index="80"
        @confirm="onConfirm"
        @cancel="visible = false"
      />
    </template>
    <DatetimePicker
      v-else
      v-model="pickerOptions.currentDate"
      :type="props.type || 'date'"
      title="选择时间"
      :min-date="pickerOptions.minDate"
      :max-date="pickerOptions.maxDate"
      @confirm="onConfirm"
      @cancel="visible = false"
    /> -->
  </div>
</template>

<script>
// import { ref, defineProps, defineEmits, computed } from "vue";
// const props = defineProps(["label", "type", "value", "placeholder", "disable"]);
// const emits = defineEmits(["update:time"]);
// const pickerOptions = ref({
//   minDate: new Date("1900-01-01"),
//   maxDate: new Date(),
//   currentDate: new Date("1980-01-01")
// });
// const result = computed({
//   get() {
//     return props.value;
//   },
//   set(n) {
//     emits("update:time", n);
//   }
// });
export default {
  props: ["label", "type", "value", "placeholder", "disable"],
  data() {
    return {};
  },
  computed: {
    result: {
      get() {
        return this.value;
      },
      set(n) {
        this.$emit("update:value", n);
      }
    }
  }
};
</script>

<style></style>
