index.vue 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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. :disabled-dates="options.disabledDates || []"
  15. :show-now-button="options.showToday"
  16. now-button-label="今天"
  17. :enable-time-picker="options.enableTimePicker ?? false"
  18. :clearable="options.clearable ?? true"
  19. :day-names="['一', '二', '三', '四', '五', '六', '七']"
  20. v-bind="$attrs"
  21. :time-picker-inline="true"
  22. select-text="确认"
  23. cancel-text="取消"
  24. @update:model-value="options?.change"
  25. ></VueDatePicker>
  26. </div>
  27. </template>
  28. <script setup>
  29. defineOptions({ name: 'date-picker'})
  30. import { computed } from 'vue';
  31. const props = defineProps({
  32. width: {
  33. type: [String, Number],
  34. default: 300
  35. },
  36. options: {
  37. type: Object,
  38. default: () => {}
  39. }
  40. })
  41. const year = computed(() => {
  42. return props.options.type === 'year'
  43. })
  44. const month = computed(() => {
  45. return props.options.type === 'month'
  46. })
  47. const time = computed(() => {
  48. return props.options.type === 'time'
  49. })
  50. </script>
  51. <style scoped lang="scss">
  52. :deep(.dp__input_icon_pad) {
  53. font-size: 14px;
  54. }
  55. :deep(.dp__input) {
  56. border: 1px solid #ababab;
  57. padding: 7px 30px;
  58. &:hover {
  59. border: 1px solid #444;
  60. }
  61. &:focus {
  62. border: 1px solid var(--v-primary-base);
  63. }
  64. }
  65. </style>