index.vue 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. <template>
  2. <div style="width: 100%">
  3. <VueDatePicker
  4. locale="zh-CN"
  5. :disabled="options?.disabled || false"
  6. :range="options?.range || false"
  7. :model-type="options?.format || 'yyyy.MM.dd'"
  8. :month-picker="month"
  9. :time-picker="time"
  10. :year-picker="year"
  11. :placeholder="options.placeholder ?? '请选择'"
  12. auto-apply
  13. text-input
  14. :show-now-button="options.showToday"
  15. now-button-label="今天"
  16. :enable-time-picker="options.enableTimePicker ?? false"
  17. :clearable="options.clearable ?? true"
  18. :day-names="['一', '二', '三', '四', '五', '六', '七']"
  19. v-bind="$attrs"
  20. @update:model-value="options?.change"
  21. ></VueDatePicker>
  22. </div>
  23. </template>
  24. <script setup>
  25. defineOptions({ name: 'date-picker'})
  26. import { computed } from 'vue';
  27. const props = defineProps({
  28. width: {
  29. type: [String, Number],
  30. default: 300
  31. },
  32. options: {
  33. type: Object,
  34. default: () => {}
  35. }
  36. })
  37. const year = computed(() => {
  38. return props.options.type === 'year'
  39. })
  40. const month = computed(() => {
  41. return props.options.type === 'month'
  42. })
  43. const time = computed(() => {
  44. return props.options.type === 'time'
  45. })
  46. </script>
  47. <style scoped lang="scss">
  48. :deep(.dp__input_icon_pad) {
  49. font-size: 14px;
  50. }
  51. </style>