<template>
  <div style="width: 100%">
    <VueDatePicker
      locale="zh-CN"
      :disabled="options?.disabled || false"
      :range="options?.range || false"
      :model-type="options?.format || 'yyyy.MM.dd'"
      :month-picker="month"
      :time-picker="time"
      :year-picker="year"
      :placeholder="options.placeholder ?? '请选择'"
      auto-apply
      text-input
      :show-now-button="options.showToday"
      now-button-label="今天"
      :enable-time-picker="options.enableTimePicker ?? false"
      :clearable="options.clearable ?? true"
      :day-names="['一', '二', '三', '四', '五', '六', '七']"
      v-bind="$attrs"
    ></VueDatePicker>
  </div>
</template>

<script setup>
defineOptions({ name: 'date-picker'})
import { computed } from 'vue';

const props = defineProps({
  width: {
    type: [String, Number],
    default: 300
  },
  options: {
    type: Object,
    default: () => {}
  }
})

const year = computed(() => {
  return props.options.type === 'year'
})
const month = computed(() => {
  return props.options.type === 'month'
})
const time = computed(() => {
  return props.options.type === 'time'
})
</script>

<style scoped lang="scss">

</style>
