|
1 | 1 | <script lang="ts"> |
2 | | -import { defineComponent } from 'vue'; |
3 | | -import DatePicker from 'vue-datepicker-next'; |
4 | | -import { format, parse } from 'date-format-parse'; |
| 2 | + import { format, parse } from "date-format-parse" |
| 3 | + import { defineComponent } from "vue" |
| 4 | + import DatePicker from "vue-datepicker-next" |
5 | 5 |
|
6 | | -export default defineComponent({ |
7 | | - components: { |
8 | | - DatePicker, |
9 | | - }, |
10 | | - data() { |
11 | | - return { |
12 | | - inputProps: { |
13 | | - clearable: false, |
14 | | - editable: false, |
15 | | - placeholder: 'test placeholder', |
16 | | - inputAttr: { |
17 | | - name: 'test', |
18 | | - id: 'test', |
| 6 | + export default defineComponent({ |
| 7 | + components: { |
| 8 | + DatePicker, |
19 | 9 | }, |
20 | | - }, |
21 | | - shortcuts: [ |
22 | | - { |
23 | | - text: 'range', |
24 | | - onClick() { |
25 | | - return [new Date(), new Date()]; |
26 | | - }, |
| 10 | + data() { |
| 11 | + return { |
| 12 | + inputProps: { |
| 13 | + clearable: false, |
| 14 | + editable: false, |
| 15 | + placeholder: "test placeholder", |
| 16 | + inputAttr: { |
| 17 | + name: "test", |
| 18 | + id: "test", |
| 19 | + }, |
| 20 | + }, |
| 21 | + shortcuts: [ |
| 22 | + { |
| 23 | + text: "range", |
| 24 | + onClick() { |
| 25 | + return [new Date(), new Date()] |
| 26 | + }, |
| 27 | + }, |
| 28 | + ], |
| 29 | + value: new Date(), |
| 30 | + append: false, |
| 31 | + rangeValue: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)], |
| 32 | + formatter: { |
| 33 | + stringify(date: Date) { |
| 34 | + return format(date, "DD/MMM/YYYY") |
| 35 | + }, |
| 36 | + parse(value: string) { |
| 37 | + return parse(value, "DD/MMM/YYYY") |
| 38 | + }, |
| 39 | + getWeek(date: Date) { |
| 40 | + return date.getDate() |
| 41 | + }, |
| 42 | + }, |
| 43 | + } |
27 | 44 | }, |
28 | | - ], |
29 | | - value: new Date(), |
30 | | - append: false, |
31 | | - rangeValue: [new Date(2019, 9, 4, 8, 30, 0), new Date(2019, 9, 4, 18, 30, 0)], |
32 | | - formatter: { |
33 | | - stringify(date: Date) { |
34 | | - return format(date, 'DD/MMM/YYYY'); |
| 45 | + methods: { |
| 46 | + handleChange() { |
| 47 | + console.log("change") |
| 48 | + }, |
| 49 | + handleUpdate(val: Date) { |
| 50 | + this.value = val |
| 51 | + }, |
35 | 52 | }, |
36 | | - parse(value: string) { |
37 | | - return parse(value, 'DD/MMM/YYYY'); |
38 | | - }, |
39 | | - getWeek(date: Date) { |
40 | | - return date.getDate(); |
41 | | - }, |
42 | | - }, |
43 | | - }; |
44 | | - }, |
45 | | - methods: { |
46 | | - handleChange() { |
47 | | - console.log('change'); |
48 | | - }, |
49 | | - handleUpdate(val: Date) { |
50 | | - this.value = val; |
51 | | - }, |
52 | | - }, |
53 | | -}); |
| 53 | + }) |
54 | 54 | </script> |
55 | 55 |
|
56 | 56 | <template> |
57 | | - <div> |
58 | | - <button @click="append = !append">ass</button> |
59 | | - <DatePicker |
60 | | - v-model:value="value" |
61 | | - v-bind="inputProps" |
62 | | - :clearable="false" |
63 | | - :append-to-body="append" |
64 | | - type="datetime" |
65 | | - :time-picker-options="{ start: '00:00', end: '09:00', step: '00:30' }" |
66 | | - :disabled-date="(date) => date < new Date(2021, 10, 9)" |
67 | | - :open="true" |
68 | | - ></DatePicker> |
69 | | - <DatePicker |
70 | | - v-model:value="rangeValue" |
71 | | - :append-to-body="false" |
72 | | - range |
73 | | - :shortcuts="shortcuts" |
74 | | - :editable="false" |
75 | | - ></DatePicker> |
76 | | - </div> |
| 57 | + <div> |
| 58 | + <button @click="append = !append">ass</button> |
| 59 | + <DatePicker |
| 60 | + v-model:value="value" |
| 61 | + v-bind="inputProps" |
| 62 | + :clearable="false" |
| 63 | + :append-to-body="append" |
| 64 | + type="datetime" |
| 65 | + :time-picker-options="{ start: '00:00', end: '09:00', step: '00:30' }" |
| 66 | + :disabled-date="(date) => date < new Date(2021, 10, 9)" |
| 67 | + :holiday-clickable="false" |
| 68 | + :holiday-date="(date)=>date > new Date()" |
| 69 | + :open="true" |
| 70 | + ></DatePicker> |
| 71 | + <DatePicker |
| 72 | + v-model:value="rangeValue" |
| 73 | + :append-to-body="false" |
| 74 | + range |
| 75 | + :shortcuts="shortcuts" |
| 76 | + :disabled-date="(date) => date < new Date(2021, 10, 9)" |
| 77 | + :editable="false" |
| 78 | + :holiday-clickable="false" |
| 79 | + :holiday-date="(date)=>date > new Date()" |
| 80 | + ></DatePicker> |
| 81 | + <DatePicker v-model:value="value" |
| 82 | + :holiday-clickable="true" |
| 83 | + :holiday-date="(date)=>date > new Date()"> |
| 84 | + </DatePicker> |
| 85 | + </div> |
77 | 86 | </template> |
78 | 87 |
|
79 | 88 | <style> |
80 | | -#app { |
81 | | - font-family: Avenir, Helvetica, Arial, sans-serif; |
82 | | - -webkit-font-smoothing: antialiased; |
83 | | - -moz-osx-font-smoothing: grayscale; |
84 | | - /* color: #2c3e50; */ |
85 | | - margin-top: 60px; |
86 | | - margin-left: 60px; |
87 | | -} |
| 89 | + #app { |
| 90 | + font-family: Avenir, Helvetica, Arial, sans-serif; |
| 91 | + -webkit-font-smoothing: antialiased; |
| 92 | + -moz-osx-font-smoothing: grayscale; |
| 93 | + /* color: #2c3e50; */ |
| 94 | + margin-top: 60px; |
| 95 | + margin-left: 60px; |
| 96 | + } |
| 97 | +
|
| 98 | + .holiday { |
| 99 | + color: #ff0000; |
| 100 | + } |
88 | 101 | </style> |
0 commit comments