vxe-pc-ui 4.1.3 → 4.1.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (225) hide show
  1. package/es/calendar/src/calendar.js +1002 -11
  2. package/es/calendar/style.css +248 -0
  3. package/es/calendar/style.min.css +1 -0
  4. package/es/card/src/card.js +9 -2
  5. package/es/carousel/src/carousel.js +19 -11
  6. package/es/components.js +3 -0
  7. package/es/countdown/index.js +12 -0
  8. package/es/countdown/src/countdown.js +215 -0
  9. package/es/countdown/style.css +38 -0
  10. package/es/countdown/style.min.css +1 -0
  11. package/es/date-picker/src/date-picker.js +9 -53
  12. package/es/date-picker/style.css +1 -33
  13. package/es/date-picker/style.min.css +1 -1
  14. package/es/form/src/form.js +0 -1
  15. package/es/form-design/src/form-view.js +3 -1
  16. package/es/form-design/style.css +4 -2
  17. package/es/form-design/style.min.css +1 -1
  18. package/es/icon/style/{iconfont.1724314499043.ttf → iconfont.1724479717870.ttf} +0 -0
  19. package/es/icon/style/iconfont.1724479717870.woff +0 -0
  20. package/es/icon/style/iconfont.1724479717870.woff2 +0 -0
  21. package/es/icon/style.css +5 -1
  22. package/es/icon/style.min.css +1 -1
  23. package/{lib/icon/style/iconfont.1724314499043.ttf → es/iconfont.1724479717870.ttf} +0 -0
  24. package/es/iconfont.1724479717870.woff +0 -0
  25. package/es/iconfont.1724479717870.woff2 +0 -0
  26. package/es/input/src/input.js +6 -6
  27. package/es/language/en-US.js +10 -0
  28. package/es/language/es-ES.js +10 -0
  29. package/es/language/hu-HU.js +14 -0
  30. package/es/language/ja-JP.js +10 -0
  31. package/es/language/ko-KR.js +10 -0
  32. package/es/language/pt-BR.js +10 -0
  33. package/es/language/ru-RU.js +10 -0
  34. package/es/language/vi-VN.js +10 -0
  35. package/es/language/zh-CN.js +10 -0
  36. package/es/language/zh-TC.js +10 -0
  37. package/es/list-design/src/default-setting-form.js +30 -7
  38. package/es/list-design/src/list-view.js +1 -1
  39. package/es/list-design/style.css +25 -1
  40. package/es/list-design/style.min.css +1 -1
  41. package/es/number-input/src/number-input.js +1 -9
  42. package/es/style.css +1 -1
  43. package/es/style.min.css +1 -1
  44. package/es/tabs/src/tabs.js +6 -2
  45. package/es/ui/index.js +22 -10
  46. package/es/ui/src/log.js +1 -1
  47. package/es/vxe-calendar/style.css +248 -0
  48. package/es/vxe-calendar/style.min.css +1 -0
  49. package/es/vxe-countdown/index.js +3 -0
  50. package/es/vxe-countdown/style.css +38 -0
  51. package/es/vxe-countdown/style.min.css +1 -0
  52. package/es/vxe-date-picker/style.css +1 -33
  53. package/es/vxe-date-picker/style.min.css +1 -1
  54. package/es/vxe-form-design/style.css +4 -2
  55. package/es/vxe-form-design/style.min.css +1 -1
  56. package/es/vxe-icon/style.css +5 -1
  57. package/es/vxe-icon/style.min.css +1 -1
  58. package/es/vxe-list-design/style.css +25 -1
  59. package/es/vxe-list-design/style.min.css +1 -1
  60. package/lib/calendar/src/calendar.js +1085 -10
  61. package/lib/calendar/src/calendar.min.js +1 -1
  62. package/lib/calendar/style/style.css +248 -0
  63. package/lib/calendar/style/style.min.css +1 -0
  64. package/lib/card/src/card.js +11 -1
  65. package/lib/card/src/card.min.js +1 -1
  66. package/lib/carousel/src/carousel.js +18 -9
  67. package/lib/carousel/src/carousel.min.js +1 -1
  68. package/lib/components.js +13 -1
  69. package/lib/components.min.js +1 -1
  70. package/lib/countdown/index.js +19 -0
  71. package/lib/countdown/index.min.js +1 -0
  72. package/lib/countdown/src/countdown.js +228 -0
  73. package/lib/countdown/src/countdown.min.js +1 -0
  74. package/lib/countdown/style/index.js +1 -0
  75. package/lib/countdown/style/style.css +38 -0
  76. package/lib/countdown/style/style.min.css +1 -0
  77. package/lib/date-picker/src/date-picker.js +12 -57
  78. package/lib/date-picker/src/date-picker.min.js +1 -1
  79. package/lib/date-picker/style/style.css +1 -33
  80. package/lib/date-picker/style/style.min.css +1 -1
  81. package/lib/form/src/form.js +0 -1
  82. package/lib/form/src/form.min.js +1 -1
  83. package/lib/form-design/src/form-view.js +3 -1
  84. package/lib/form-design/src/form-view.min.js +1 -1
  85. package/lib/form-design/style/style.css +4 -2
  86. package/lib/form-design/style/style.min.css +1 -1
  87. package/lib/{iconfont.1724314499043.ttf → icon/style/iconfont.1724479717870.ttf} +0 -0
  88. package/lib/icon/style/iconfont.1724479717870.woff +0 -0
  89. package/lib/icon/style/iconfont.1724479717870.woff2 +0 -0
  90. package/lib/icon/style/style.css +5 -1
  91. package/lib/icon/style/style.min.css +5 -1
  92. package/{es/iconfont.1724314499043.ttf → lib/iconfont.1724479717870.ttf} +0 -0
  93. package/lib/iconfont.1724479717870.woff +0 -0
  94. package/lib/iconfont.1724479717870.woff2 +0 -0
  95. package/lib/index.umd.js +1967 -635
  96. package/lib/index.umd.min.js +1 -1
  97. package/lib/input/src/input.js +14 -14
  98. package/lib/input/src/input.min.js +1 -1
  99. package/lib/language/en-US.js +10 -0
  100. package/lib/language/en-US.min.js +1 -1
  101. package/lib/language/en-US.umd.js +10 -0
  102. package/lib/language/es-ES.js +10 -0
  103. package/lib/language/es-ES.min.js +1 -1
  104. package/lib/language/es-ES.umd.js +10 -0
  105. package/lib/language/hu-HU.js +14 -0
  106. package/lib/language/hu-HU.min.js +1 -1
  107. package/lib/language/ja-JP.js +10 -0
  108. package/lib/language/ja-JP.min.js +1 -1
  109. package/lib/language/ja-JP.umd.js +10 -0
  110. package/lib/language/ko-KR.js +10 -0
  111. package/lib/language/ko-KR.min.js +1 -1
  112. package/lib/language/pt-BR.js +10 -0
  113. package/lib/language/pt-BR.min.js +1 -1
  114. package/lib/language/pt-BR.umd.js +10 -0
  115. package/lib/language/ru-RU.js +10 -0
  116. package/lib/language/ru-RU.min.js +1 -1
  117. package/lib/language/vi-VN.js +10 -0
  118. package/lib/language/vi-VN.min.js +1 -1
  119. package/lib/language/zh-CN.js +10 -0
  120. package/lib/language/zh-CN.min.js +1 -1
  121. package/lib/language/zh-CN.umd.js +10 -0
  122. package/lib/language/zh-HK.min.js +1 -1
  123. package/lib/language/zh-HK.umd.js +10 -0
  124. package/lib/language/zh-MO.min.js +1 -1
  125. package/lib/language/zh-MO.umd.js +10 -0
  126. package/lib/language/zh-TC.js +10 -0
  127. package/lib/language/zh-TC.min.js +1 -1
  128. package/lib/language/zh-TC.umd.js +10 -0
  129. package/lib/language/zh-TW.min.js +1 -1
  130. package/lib/language/zh-TW.umd.js +10 -0
  131. package/lib/list-design/src/default-setting-form.js +27 -7
  132. package/lib/list-design/src/default-setting-form.min.js +1 -1
  133. package/lib/list-design/src/list-view.js +1 -1
  134. package/lib/list-design/src/list-view.min.js +1 -1
  135. package/lib/list-design/style/style.css +25 -1
  136. package/lib/list-design/style/style.min.css +1 -1
  137. package/lib/number-input/src/number-input.js +6 -16
  138. package/lib/number-input/src/number-input.min.js +1 -1
  139. package/lib/style.css +1 -1
  140. package/lib/style.min.css +1 -1
  141. package/lib/tabs/src/tabs.js +6 -2
  142. package/lib/tabs/src/tabs.min.js +1 -1
  143. package/lib/ui/index.js +22 -10
  144. package/lib/ui/index.min.js +1 -1
  145. package/lib/ui/src/log.js +1 -1
  146. package/lib/ui/src/log.min.js +1 -1
  147. package/lib/vxe-calendar/style/style.css +248 -0
  148. package/lib/vxe-calendar/style/style.min.css +1 -0
  149. package/lib/vxe-countdown/index.js +22 -0
  150. package/lib/vxe-countdown/index.min.js +1 -0
  151. package/lib/vxe-countdown/style/index.js +1 -0
  152. package/lib/vxe-countdown/style/style.css +38 -0
  153. package/lib/vxe-countdown/style/style.min.css +1 -0
  154. package/lib/vxe-date-picker/style/style.css +1 -33
  155. package/lib/vxe-date-picker/style/style.min.css +1 -1
  156. package/lib/vxe-form-design/style/style.css +4 -2
  157. package/lib/vxe-form-design/style/style.min.css +1 -1
  158. package/lib/vxe-icon/style/style.css +5 -1
  159. package/lib/vxe-icon/style/style.min.css +1 -1
  160. package/lib/vxe-list-design/style/style.css +25 -1
  161. package/lib/vxe-list-design/style/style.min.css +1 -1
  162. package/package.json +1 -1
  163. package/packages/calendar/src/calendar.ts +1044 -13
  164. package/packages/card/src/card.ts +14 -3
  165. package/packages/carousel/src/carousel.ts +21 -11
  166. package/packages/components.ts +3 -0
  167. package/packages/countdown/index.ts +16 -0
  168. package/packages/countdown/src/countdown.ts +251 -0
  169. package/packages/date-picker/src/date-picker.ts +24 -110
  170. package/packages/form/src/form.ts +0 -1
  171. package/packages/form-design/src/form-view.ts +3 -1
  172. package/packages/input/src/input.ts +21 -63
  173. package/packages/language/en-US.ts +10 -0
  174. package/packages/language/es-ES.ts +10 -0
  175. package/packages/language/hu-HU.ts +14 -0
  176. package/packages/language/ja-JP.ts +10 -0
  177. package/packages/language/ko-KR.ts +10 -0
  178. package/packages/language/pt-BR.ts +10 -0
  179. package/packages/language/ru-RU.ts +10 -0
  180. package/packages/language/vi-VN.ts +10 -0
  181. package/packages/language/zh-CN.ts +10 -0
  182. package/packages/language/zh-TC.ts +10 -0
  183. package/packages/list-design/src/default-setting-form.ts +31 -7
  184. package/packages/list-design/src/list-view.ts +1 -1
  185. package/packages/number-input/src/number-input.ts +1 -11
  186. package/packages/{input/src/number.ts → number-input/src/util.ts} +1 -1
  187. package/packages/tabs/src/tabs.ts +6 -2
  188. package/packages/ui/index.ts +22 -9
  189. package/styles/all.scss +1 -0
  190. package/styles/components/calendar.scss +271 -0
  191. package/styles/components/countdown.scss +36 -0
  192. package/styles/components/date-picker.scss +1 -36
  193. package/styles/components/icon.scss +6 -1
  194. package/styles/components/list-item/field-column.scss +5 -1
  195. package/styles/components/list-item/field-search.scss +23 -0
  196. package/styles/components/widget-form/row.scss +4 -2
  197. package/styles/icon/iconfont.ttf +0 -0
  198. package/styles/icon/iconfont.woff +0 -0
  199. package/styles/icon/iconfont.woff2 +0 -0
  200. package/styles/theme/base.scss +6 -0
  201. package/styles/theme/dark.scss +1 -1
  202. package/types/all.d.ts +3 -0
  203. package/types/components/calendar.d.ts +51 -2
  204. package/types/components/card.d.ts +2 -1
  205. package/types/components/countdown.d.ts +94 -0
  206. package/types/components/date-picker.d.ts +42 -1
  207. package/types/components/form-design.d.ts +0 -1
  208. package/types/components/icon.d.ts +1 -1
  209. package/types/ui/global-config.d.ts +2 -0
  210. package/types/ui/global-icon.d.ts +1 -0
  211. package/es/icon/style/iconfont.1724314499043.woff +0 -0
  212. package/es/icon/style/iconfont.1724314499043.woff2 +0 -0
  213. package/es/iconfont.1724314499043.woff +0 -0
  214. package/es/iconfont.1724314499043.woff2 +0 -0
  215. package/lib/icon/style/iconfont.1724314499043.woff +0 -0
  216. package/lib/icon/style/iconfont.1724314499043.woff2 +0 -0
  217. package/lib/iconfont.1724314499043.woff +0 -0
  218. package/lib/iconfont.1724314499043.woff2 +0 -0
  219. /package/es/{input/src/date.js → date-picker/src/util.js} +0 -0
  220. /package/es/{input/src/number.js → number-input/src/util.js} +0 -0
  221. /package/lib/{input/src/date.js → date-picker/src/util.js} +0 -0
  222. /package/lib/{input/src/date.min.js → date-picker/src/util.min.js} +0 -0
  223. /package/lib/{input/src/number.js → number-input/src/util.js} +0 -0
  224. /package/lib/{input/src/number.min.js → number-input/src/util.min.js} +0 -0
  225. /package/packages/{input/src/date.ts → date-picker/src/util.ts} +0 -0
@@ -1,34 +1,1025 @@
1
- import { defineComponent, ref, h, reactive } from 'vue';
1
+ import { defineComponent, h, ref, computed, reactive, watch, onMounted } from 'vue';
2
+ import { getConfig, getI18n, createEvent, useSize } from '../../ui';
3
+ import { getDateQuarter } from '../../date-picker/src/util';
4
+ import { toCssUnit } from '../..//ui/src/dom';
5
+ import VxeButtonComponent from '../../button/src/button';
2
6
  import XEUtils from 'xe-utils';
3
7
  export default defineComponent({
4
8
  name: 'VxeCalendar',
5
- props: {},
6
- emits: [],
9
+ props: {
10
+ modelValue: [String, Number, Date],
11
+ type: { type: String, default: 'date' },
12
+ className: String,
13
+ size: { type: String, default: () => getConfig().calendar.size || getConfig().size },
14
+ multiple: Boolean,
15
+ width: [String, Number],
16
+ height: [String, Number],
17
+ // date、week、month、quarter、year
18
+ minDate: { type: [String, Number, Date], default: () => getConfig().calendar.minDate },
19
+ maxDate: { type: [String, Number, Date], default: () => getConfig().calendar.maxDate },
20
+ startDay: { type: [String, Number], default: () => getConfig().calendar.startDay },
21
+ labelFormat: String,
22
+ valueFormat: String,
23
+ festivalMethod: { type: Function, default: () => getConfig().calendar.festivalMethod },
24
+ disabledMethod: { type: Function, default: () => getConfig().calendar.disabledMethod },
25
+ // week
26
+ selectDay: { type: [String, Number], default: () => getConfig().calendar.selectDay }
27
+ },
28
+ emits: [
29
+ 'update:modelValue',
30
+ 'change',
31
+ 'click',
32
+ 'date-prev',
33
+ 'date-today',
34
+ 'date-next'
35
+ ],
7
36
  setup(props, context) {
8
- const { slots } = context;
37
+ const { emit } = context;
9
38
  const xID = XEUtils.uniqueId();
39
+ const { computeSize } = useSize(props);
40
+ const yearSize = 12;
41
+ const monthSize = 20;
42
+ const quarterSize = 8;
43
+ const reactData = reactive({
44
+ panelIndex: 0,
45
+ panelStyle: null,
46
+ panelPlacement: '',
47
+ isActivated: false,
48
+ selectValue: props.modelValue,
49
+ inputValue: props.modelValue,
50
+ datePanelValue: null,
51
+ datePanelLabel: '',
52
+ datePanelType: 'day',
53
+ selectMonth: null,
54
+ currentDate: null
55
+ });
10
56
  const refElem = ref();
11
- const reactData = reactive({});
57
+ const computeCalendarStyle = computed(() => {
58
+ const { height, width } = props;
59
+ const stys = {};
60
+ if (width) {
61
+ stys.width = toCssUnit(width);
62
+ }
63
+ if (height) {
64
+ stys.height = toCssUnit(height);
65
+ }
66
+ return stys;
67
+ });
12
68
  const refMaps = {
13
69
  refElem
14
70
  };
15
- const computeMaps = {};
16
71
  const $xeCalendar = {
17
72
  xID,
18
73
  props,
19
74
  context,
20
75
  reactData,
21
- getRefMaps: () => refMaps,
22
- getComputeMaps: () => computeMaps
76
+ getRefMaps: () => refMaps
77
+ };
78
+ let calendarMethods = {};
79
+ const parseDate = (value, format) => {
80
+ return XEUtils.toStringDate(value, format);
81
+ };
82
+ const computeIsDisabled = computed(() => {
83
+ return false;
84
+ });
85
+ const computeIsCalendarType = computed(() => {
86
+ return ['date', 'week', 'month', 'quarter', 'year'].indexOf(props.type) > -1;
87
+ });
88
+ const computeDateStartTime = computed(() => {
89
+ return props.minDate ? XEUtils.toStringDate(props.minDate) : null;
90
+ });
91
+ const computeDateEndTime = computed(() => {
92
+ return props.maxDate ? XEUtils.toStringDate(props.maxDate) : null;
93
+ });
94
+ const computeSupportMultiples = computed(() => {
95
+ return ['date', 'week', 'month', 'quarter', 'year'].indexOf(props.type) > -1;
96
+ });
97
+ const computeDateListValue = computed(() => {
98
+ const { multiple } = props;
99
+ const { selectValue } = reactData;
100
+ const isCalendarType = computeIsCalendarType.value;
101
+ const dateValueFormat = computeDateValueFormat.value;
102
+ if (multiple && selectValue && isCalendarType) {
103
+ return XEUtils.toValueString(selectValue).split(',').map(item => {
104
+ const date = parseDate(item, dateValueFormat);
105
+ if (XEUtils.isValidDate(date)) {
106
+ return date;
107
+ }
108
+ return null;
109
+ });
110
+ }
111
+ return [];
112
+ });
113
+ const computeDateMultipleValue = computed(() => {
114
+ const dateListValue = computeDateListValue.value;
115
+ const dateValueFormat = computeDateValueFormat.value;
116
+ return dateListValue.map(date => XEUtils.toDateString(date, dateValueFormat));
117
+ });
118
+ const computeDateMultipleLabel = computed(() => {
119
+ const dateListValue = computeDateListValue.value;
120
+ const dateLabelFormat = computeDateLabelFormat.value;
121
+ return dateListValue.map(date => XEUtils.toDateString(date, dateLabelFormat)).join(', ');
122
+ });
123
+ const computeDateValueFormat = computed(() => {
124
+ const { valueFormat } = props;
125
+ if (valueFormat) {
126
+ return valueFormat;
127
+ }
128
+ return 'yyyy-MM-dd';
129
+ });
130
+ const computeDateValue = computed(() => {
131
+ const { selectValue } = reactData;
132
+ const isCalendarType = computeIsCalendarType.value;
133
+ const dateValueFormat = computeDateValueFormat.value;
134
+ let val = null;
135
+ if (selectValue && isCalendarType) {
136
+ const date = parseDate(selectValue, dateValueFormat);
137
+ if (XEUtils.isValidDate(date)) {
138
+ val = date;
139
+ }
140
+ }
141
+ return val;
142
+ });
143
+ const computeIsDisabledPrevDateBtn = computed(() => {
144
+ const dateStartTime = computeDateStartTime.value;
145
+ const { selectMonth } = reactData;
146
+ if (selectMonth && dateStartTime) {
147
+ return selectMonth <= dateStartTime;
148
+ }
149
+ return false;
150
+ });
151
+ const computeIsDisabledNextDateBtn = computed(() => {
152
+ const dateEndTime = computeDateEndTime.value;
153
+ const { selectMonth } = reactData;
154
+ if (selectMonth && dateEndTime) {
155
+ return selectMonth >= dateEndTime;
156
+ }
157
+ return false;
158
+ });
159
+ const computeDateHMSTime = computed(() => {
160
+ const dateValue = computeDateValue.value;
161
+ return dateValue ? (dateValue.getHours() * 3600 + dateValue.getMinutes() * 60 + dateValue.getSeconds()) * 1000 : 0;
162
+ });
163
+ const computeDateLabelFormat = computed(() => {
164
+ const { labelFormat } = props;
165
+ const isCalendarType = computeIsCalendarType.value;
166
+ const dateValueFormat = computeDateValueFormat.value;
167
+ if (isCalendarType) {
168
+ return labelFormat || dateValueFormat || getI18n(`vxe.input.date.labelFormat.${props.type}`);
169
+ }
170
+ return null;
171
+ });
172
+ const computeYearList = computed(() => {
173
+ const { selectMonth, currentDate } = reactData;
174
+ const years = [];
175
+ if (selectMonth && currentDate) {
176
+ const currFullYear = currentDate.getFullYear();
177
+ const selectFullYear = selectMonth.getFullYear();
178
+ const startYearDate = new Date(selectFullYear - selectFullYear % yearSize, 0, 1);
179
+ for (let index = -4; index < yearSize + 4; index++) {
180
+ const date = XEUtils.getWhatYear(startYearDate, index, 'first');
181
+ const itemFullYear = date.getFullYear();
182
+ years.push({
183
+ date,
184
+ isCurrent: true,
185
+ isPrev: index < 0,
186
+ isNow: currFullYear === itemFullYear,
187
+ isNext: index >= yearSize,
188
+ year: itemFullYear
189
+ });
190
+ }
191
+ }
192
+ return years;
193
+ });
194
+ const computeSelectDatePanelLabel = computed(() => {
195
+ const isCalendarType = computeIsCalendarType.value;
196
+ if (isCalendarType) {
197
+ const { datePanelType, selectMonth } = reactData;
198
+ const yearList = computeYearList.value;
199
+ let year = '';
200
+ let month;
201
+ if (selectMonth) {
202
+ year = selectMonth.getFullYear();
203
+ month = selectMonth.getMonth() + 1;
204
+ }
205
+ if (datePanelType === 'quarter') {
206
+ return getI18n('vxe.input.date.quarterLabel', [year]);
207
+ }
208
+ else if (datePanelType === 'month') {
209
+ return getI18n('vxe.input.date.monthLabel', [year]);
210
+ }
211
+ else if (datePanelType === 'year') {
212
+ return yearList.length ? `${yearList[0].year} - ${yearList[yearList.length - 1].year}` : '';
213
+ }
214
+ return getI18n('vxe.input.date.dayLabel', [year, month ? getI18n(`vxe.input.date.m${month}`) : '-']);
215
+ }
216
+ return '';
217
+ });
218
+ const computeFirstDayOfWeek = computed(() => {
219
+ const { startDay } = props;
220
+ return XEUtils.toNumber(startDay);
221
+ });
222
+ const computeWeekDatas = computed(() => {
223
+ const weeks = [];
224
+ const isCalendarType = computeIsCalendarType.value;
225
+ if (isCalendarType) {
226
+ let sWeek = computeFirstDayOfWeek.value;
227
+ weeks.push(sWeek);
228
+ for (let index = 0; index < 6; index++) {
229
+ if (sWeek >= 6) {
230
+ sWeek = 0;
231
+ }
232
+ else {
233
+ sWeek++;
234
+ }
235
+ weeks.push(sWeek);
236
+ }
237
+ }
238
+ return weeks;
239
+ });
240
+ const computeDateHeaders = computed(() => {
241
+ const isCalendarType = computeIsCalendarType.value;
242
+ if (isCalendarType) {
243
+ const weekDatas = computeWeekDatas.value;
244
+ return weekDatas.map((day) => {
245
+ return {
246
+ value: day,
247
+ label: getI18n(`vxe.input.date.weeks.w${day}`)
248
+ };
249
+ });
250
+ }
251
+ return [];
252
+ });
253
+ const computeWeekHeaders = computed(() => {
254
+ const isCalendarType = computeIsCalendarType.value;
255
+ if (isCalendarType) {
256
+ const dateHeaders = computeDateHeaders.value;
257
+ return [{ label: getI18n('vxe.input.date.weeks.w') }].concat(dateHeaders);
258
+ }
259
+ return [];
260
+ });
261
+ const computeYearDatas = computed(() => {
262
+ const yearList = computeYearList.value;
263
+ return XEUtils.chunk(yearList, 4);
264
+ });
265
+ const computeQuarterList = computed(() => {
266
+ const { selectMonth, currentDate } = reactData;
267
+ const quarters = [];
268
+ if (selectMonth && currentDate) {
269
+ const currFullYear = currentDate.getFullYear();
270
+ const currQuarter = getDateQuarter(currentDate);
271
+ const firstYear = XEUtils.getWhatYear(selectMonth, 0, 'first');
272
+ const selFullYear = firstYear.getFullYear();
273
+ for (let index = -2; index < quarterSize - 2; index++) {
274
+ const date = XEUtils.getWhatQuarter(firstYear, index);
275
+ const itemFullYear = date.getFullYear();
276
+ const itemQuarter = getDateQuarter(date);
277
+ const isPrev = itemFullYear < selFullYear;
278
+ quarters.push({
279
+ date,
280
+ isPrev,
281
+ isCurrent: itemFullYear === selFullYear,
282
+ isNow: itemFullYear === currFullYear && itemQuarter === currQuarter,
283
+ isNext: !isPrev && itemFullYear > selFullYear,
284
+ quarter: itemQuarter
285
+ });
286
+ }
287
+ }
288
+ return quarters;
289
+ });
290
+ const computeQuarterDatas = computed(() => {
291
+ const quarterList = computeQuarterList.value;
292
+ return XEUtils.chunk(quarterList, 2);
293
+ });
294
+ const computeMonthList = computed(() => {
295
+ const { selectMonth, currentDate } = reactData;
296
+ const months = [];
297
+ if (selectMonth && currentDate) {
298
+ const currFullYear = currentDate.getFullYear();
299
+ const currMonth = currentDate.getMonth();
300
+ const selFullYear = XEUtils.getWhatYear(selectMonth, 0, 'first').getFullYear();
301
+ for (let index = -4; index < monthSize - 4; index++) {
302
+ const date = XEUtils.getWhatYear(selectMonth, 0, index);
303
+ const itemFullYear = date.getFullYear();
304
+ const itemMonth = date.getMonth();
305
+ const isPrev = itemFullYear < selFullYear;
306
+ months.push({
307
+ date,
308
+ isPrev,
309
+ isCurrent: itemFullYear === selFullYear,
310
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth,
311
+ isNext: !isPrev && itemFullYear > selFullYear,
312
+ month: itemMonth
313
+ });
314
+ }
315
+ }
316
+ return months;
317
+ });
318
+ const computeMonthDatas = computed(() => {
319
+ const monthList = computeMonthList.value;
320
+ return XEUtils.chunk(monthList, 4);
321
+ });
322
+ const computeDayList = computed(() => {
323
+ const { selectMonth, currentDate } = reactData;
324
+ const days = [];
325
+ if (selectMonth && currentDate) {
326
+ const dateHMSTime = computeDateHMSTime.value;
327
+ const weekDatas = computeWeekDatas.value;
328
+ const currFullYear = currentDate.getFullYear();
329
+ const currMonth = currentDate.getMonth();
330
+ const currDate = currentDate.getDate();
331
+ const selFullYear = selectMonth.getFullYear();
332
+ const selMonth = selectMonth.getMonth();
333
+ const selDay = selectMonth.getDay();
334
+ const prevOffsetDate = -weekDatas.indexOf(selDay);
335
+ const startDayDate = new Date(XEUtils.getWhatDay(selectMonth, prevOffsetDate).getTime() + dateHMSTime);
336
+ for (let index = 0; index < 42; index++) {
337
+ const date = XEUtils.getWhatDay(startDayDate, index);
338
+ const itemFullYear = date.getFullYear();
339
+ const itemMonth = date.getMonth();
340
+ const itemDate = date.getDate();
341
+ const isPrev = date < selectMonth;
342
+ days.push({
343
+ date,
344
+ isPrev,
345
+ isCurrent: itemFullYear === selFullYear && itemMonth === selMonth,
346
+ isNow: itemFullYear === currFullYear && itemMonth === currMonth && itemDate === currDate,
347
+ isNext: !isPrev && selMonth !== itemMonth,
348
+ label: itemDate
349
+ });
350
+ }
351
+ }
352
+ return days;
353
+ });
354
+ const computeDayDatas = computed(() => {
355
+ const dayList = computeDayList.value;
356
+ return XEUtils.chunk(dayList, 7);
357
+ });
358
+ const computeWeekDates = computed(() => {
359
+ const dayDatas = computeDayDatas.value;
360
+ const firstDayOfWeek = computeFirstDayOfWeek.value;
361
+ return dayDatas.map((list) => {
362
+ const firstItem = list[0];
363
+ const item = {
364
+ date: firstItem.date,
365
+ isWeekNumber: true,
366
+ isPrev: false,
367
+ isCurrent: false,
368
+ isNow: false,
369
+ isNext: false,
370
+ label: XEUtils.getYearWeek(firstItem.date, firstDayOfWeek)
371
+ };
372
+ return [item].concat(list);
373
+ });
374
+ });
375
+ const emitModel = (value, evnt) => {
376
+ reactData.inputValue = value;
377
+ emit('update:modelValue', value);
378
+ if (XEUtils.toValueString(props.modelValue) !== value) {
379
+ calendarMethods.dispatchEvent('change', { value }, evnt);
380
+ }
381
+ };
382
+ const dateParseValue = (value) => {
383
+ const { type } = props;
384
+ const dateLabelFormat = computeDateLabelFormat.value;
385
+ const dateValueFormat = computeDateValueFormat.value;
386
+ const firstDayOfWeek = computeFirstDayOfWeek.value;
387
+ let dValue = null;
388
+ let dLabel = '';
389
+ if (value) {
390
+ dValue = parseDate(value, dateValueFormat);
391
+ }
392
+ if (XEUtils.isValidDate(dValue)) {
393
+ dLabel = XEUtils.toDateString(dValue, dateLabelFormat, { firstDay: firstDayOfWeek });
394
+ // 由于年份和第几周是冲突的行为,所以需要特殊处理,判断是否跨年
395
+ if (dateLabelFormat && type === 'week') {
396
+ const firstWeekDate = XEUtils.getWhatWeek(dValue, 0, firstDayOfWeek, firstDayOfWeek);
397
+ if (firstWeekDate.getFullYear() < dValue.getFullYear()) {
398
+ const yyIndex = dateLabelFormat.indexOf('yyyy');
399
+ if (yyIndex > -1) {
400
+ const yyNum = Number(dLabel.substring(yyIndex, yyIndex + 4));
401
+ if (yyNum && !isNaN(yyNum)) {
402
+ dLabel = dLabel.replace(`${yyNum}`, `${yyNum - 1}`);
403
+ }
404
+ }
405
+ }
406
+ }
407
+ }
408
+ else {
409
+ dValue = null;
410
+ }
411
+ reactData.datePanelValue = dValue;
412
+ reactData.datePanelLabel = dLabel;
413
+ };
414
+ /**
415
+ * 值变化时处理
416
+ */
417
+ const changeValue = () => {
418
+ const isCalendarType = computeIsCalendarType.value;
419
+ const { inputValue } = reactData;
420
+ if (isCalendarType) {
421
+ dateParseValue(inputValue);
422
+ reactData.inputValue = props.multiple ? computeDateMultipleLabel.value : reactData.datePanelLabel;
423
+ }
424
+ };
425
+ /**
426
+ * 检查初始值
427
+ */
428
+ const initValue = () => {
429
+ const isCalendarType = computeIsCalendarType.value;
430
+ if (isCalendarType) {
431
+ changeValue();
432
+ }
433
+ };
434
+ const dateCheckMonth = (date) => {
435
+ const month = XEUtils.getWhatMonth(date, 0, 'first');
436
+ if (!XEUtils.isEqual(month, reactData.selectMonth)) {
437
+ reactData.selectMonth = month;
438
+ }
439
+ };
440
+ const dateChange = (date) => {
441
+ const { modelValue, multiple } = props;
442
+ const dateValueFormat = computeDateValueFormat.value;
443
+ const firstDayOfWeek = computeFirstDayOfWeek.value;
444
+ if (props.type === 'week') {
445
+ const sWeek = XEUtils.toNumber(props.selectDay);
446
+ date = XEUtils.getWhatWeek(date, 0, sWeek, firstDayOfWeek);
447
+ }
448
+ const inpVal = XEUtils.toDateString(date, dateValueFormat, { firstDay: firstDayOfWeek });
449
+ dateCheckMonth(date);
450
+ reactData.selectValue = date;
451
+ if (multiple) {
452
+ // 如果为多选
453
+ const dateMultipleValue = computeDateMultipleValue.value;
454
+ // 如果是日期类型
455
+ if (dateMultipleValue.some(val => XEUtils.isEqual(val, inpVal))) {
456
+ emitModel(dateMultipleValue.filter(val => !XEUtils.isEqual(val, inpVal)).join(','), { type: 'update' });
457
+ }
458
+ else {
459
+ emitModel(dateMultipleValue.concat([inpVal]).join(','), { type: 'update' });
460
+ }
461
+ }
462
+ else {
463
+ // 如果为单选
464
+ if (!XEUtils.isEqual(modelValue, inpVal)) {
465
+ emitModel(inpVal, { type: 'update' });
466
+ }
467
+ }
468
+ };
469
+ const dateMonthHandle = (date, offsetMonth) => {
470
+ reactData.selectMonth = XEUtils.getWhatMonth(date, offsetMonth, 'first');
471
+ };
472
+ const dateNowHandle = () => {
473
+ const currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first');
474
+ reactData.currentDate = currentDate;
475
+ dateMonthHandle(currentDate, 0);
476
+ };
477
+ const dateToggleTypeEvent = () => {
478
+ let { datePanelType } = reactData;
479
+ if (datePanelType === 'month' || datePanelType === 'quarter') {
480
+ datePanelType = 'year';
481
+ }
482
+ else {
483
+ datePanelType = 'month';
484
+ }
485
+ reactData.datePanelType = datePanelType;
486
+ };
487
+ const datePrevEvent = (evnt) => {
488
+ const { type } = props;
489
+ const { datePanelType, selectMonth } = reactData;
490
+ const isDisabledPrevDateBtn = computeIsDisabledPrevDateBtn.value;
491
+ if (!isDisabledPrevDateBtn) {
492
+ if (type === 'year') {
493
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
494
+ }
495
+ else if (type === 'month' || type === 'quarter') {
496
+ if (datePanelType === 'year') {
497
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
498
+ }
499
+ else {
500
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first');
501
+ }
502
+ }
503
+ else {
504
+ if (datePanelType === 'year') {
505
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -yearSize, 'first');
506
+ }
507
+ else if (datePanelType === 'month') {
508
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, -1, 'first');
509
+ }
510
+ else {
511
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, -1, 'first');
512
+ }
513
+ }
514
+ calendarMethods.dispatchEvent('date-prev', { type }, evnt);
515
+ }
516
+ };
517
+ const dateTodayMonthEvent = (evnt) => {
518
+ dateNowHandle();
519
+ if (!props.multiple) {
520
+ dateChange(reactData.currentDate);
521
+ }
522
+ calendarMethods.dispatchEvent('date-today', { type: props.type }, evnt);
523
+ };
524
+ const dateNextEvent = (evnt) => {
525
+ const { type } = props;
526
+ const { datePanelType, selectMonth } = reactData;
527
+ const isDisabledNextDateBtn = computeIsDisabledNextDateBtn.value;
528
+ if (!isDisabledNextDateBtn) {
529
+ if (type === 'year') {
530
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
531
+ }
532
+ else if (type === 'month' || type === 'quarter') {
533
+ if (datePanelType === 'year') {
534
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
535
+ }
536
+ else {
537
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first');
538
+ }
539
+ }
540
+ else {
541
+ if (datePanelType === 'year') {
542
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, yearSize, 'first');
543
+ }
544
+ else if (datePanelType === 'month') {
545
+ reactData.selectMonth = XEUtils.getWhatYear(selectMonth, 1, 'first');
546
+ }
547
+ else {
548
+ reactData.selectMonth = XEUtils.getWhatMonth(selectMonth, 1, 'first');
549
+ }
550
+ }
551
+ calendarMethods.dispatchEvent('date-next', { type }, evnt);
552
+ }
553
+ };
554
+ const isDateDisabled = (item) => {
555
+ const { disabledMethod } = props;
556
+ const { datePanelType } = reactData;
557
+ return disabledMethod && disabledMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $calendar: $xeCalendar });
558
+ };
559
+ const dateSelectItem = (date) => {
560
+ const { type } = props;
561
+ const { datePanelType } = reactData;
562
+ if (type === 'month') {
563
+ if (datePanelType === 'year') {
564
+ reactData.datePanelType = 'month';
565
+ dateCheckMonth(date);
566
+ }
567
+ else {
568
+ dateChange(date);
569
+ }
570
+ }
571
+ else if (type === 'year') {
572
+ dateChange(date);
573
+ }
574
+ else if (type === 'quarter') {
575
+ if (datePanelType === 'year') {
576
+ reactData.datePanelType = 'quarter';
577
+ dateCheckMonth(date);
578
+ }
579
+ else {
580
+ dateChange(date);
581
+ }
582
+ }
583
+ else {
584
+ if (datePanelType === 'month') {
585
+ reactData.datePanelType = type === 'week' ? type : 'day';
586
+ dateCheckMonth(date);
587
+ }
588
+ else if (datePanelType === 'year') {
589
+ reactData.datePanelType = 'month';
590
+ dateCheckMonth(date);
591
+ }
592
+ else {
593
+ dateChange(date);
594
+ }
595
+ }
596
+ };
597
+ const dateSelectEvent = (item) => {
598
+ if (!isDateDisabled(item)) {
599
+ dateSelectItem(item.date);
600
+ }
601
+ };
602
+ const dateMoveDay = (offsetDay) => {
603
+ if (!isDateDisabled({ date: offsetDay })) {
604
+ const dayList = computeDayList.value;
605
+ if (!dayList.some((item) => XEUtils.isDateSame(item.date, offsetDay, 'yyyyMMdd'))) {
606
+ dateCheckMonth(offsetDay);
607
+ }
608
+ dateParseValue(offsetDay);
609
+ }
610
+ };
611
+ const dateMoveYear = (offsetYear) => {
612
+ if (!isDateDisabled({ date: offsetYear })) {
613
+ const yearList = computeYearList.value;
614
+ if (!yearList.some((item) => XEUtils.isDateSame(item.date, offsetYear, 'yyyy'))) {
615
+ dateCheckMonth(offsetYear);
616
+ }
617
+ dateParseValue(offsetYear);
618
+ }
619
+ };
620
+ const dateMoveQuarter = (offsetQuarter) => {
621
+ if (!isDateDisabled({ date: offsetQuarter })) {
622
+ const quarterList = computeQuarterList.value;
623
+ if (!quarterList.some((item) => XEUtils.isDateSame(item.date, offsetQuarter, 'yyyyq'))) {
624
+ dateCheckMonth(offsetQuarter);
625
+ }
626
+ dateParseValue(offsetQuarter);
627
+ }
628
+ };
629
+ const dateMoveMonth = (offsetMonth) => {
630
+ if (!isDateDisabled({ date: offsetMonth })) {
631
+ const monthList = computeMonthList.value;
632
+ if (!monthList.some((item) => XEUtils.isDateSame(item.date, offsetMonth, 'yyyyMM'))) {
633
+ dateCheckMonth(offsetMonth);
634
+ }
635
+ dateParseValue(offsetMonth);
636
+ }
637
+ };
638
+ const dateMouseenterEvent = (item) => {
639
+ if (!isDateDisabled(item)) {
640
+ const { datePanelType } = reactData;
641
+ if (datePanelType === 'month') {
642
+ dateMoveMonth(item.date);
643
+ }
644
+ else if (datePanelType === 'quarter') {
645
+ dateMoveQuarter(item.date);
646
+ }
647
+ else if (datePanelType === 'year') {
648
+ dateMoveYear(item.date);
649
+ }
650
+ else {
651
+ dateMoveDay(item.date);
652
+ }
653
+ }
654
+ };
655
+ const dateConfirmEvent = () => {
656
+ };
657
+ const dateOpenPanel = () => {
658
+ const { type } = props;
659
+ const dateValue = computeDateValue.value;
660
+ if (['year', 'quarter', 'month', 'week'].indexOf(type) > -1) {
661
+ reactData.datePanelType = type;
662
+ }
663
+ else {
664
+ reactData.datePanelType = 'day';
665
+ }
666
+ reactData.currentDate = XEUtils.getWhatDay(Date.now(), 0, 'first');
667
+ if (dateValue) {
668
+ dateMonthHandle(dateValue, 0);
669
+ dateParseValue(dateValue);
670
+ }
671
+ else {
672
+ dateNowHandle();
673
+ }
674
+ };
675
+ const renderDateLabel = (item, label) => {
676
+ const { festivalMethod } = props;
677
+ if (festivalMethod) {
678
+ const { datePanelType } = reactData;
679
+ const festivalRest = festivalMethod({ type: datePanelType, viewType: datePanelType, date: item.date, $calendar: $xeCalendar });
680
+ const festivalItem = festivalRest ? (XEUtils.isString(festivalRest) ? { label: festivalRest } : festivalRest) : {};
681
+ const extraItem = festivalItem.extra ? (XEUtils.isString(festivalItem.extra) ? { label: festivalItem.extra } : festivalItem.extra) : null;
682
+ const labels = [
683
+ h('span', {
684
+ class: ['vxe-calendar--date-label', {
685
+ 'is-notice': festivalItem.notice
686
+ }]
687
+ }, extraItem && extraItem.label
688
+ ? [
689
+ h('span', label),
690
+ h('span', {
691
+ class: ['vxe-calendar--date-label--extra', extraItem.important ? 'is-important' : '', extraItem.className],
692
+ style: extraItem.style
693
+ }, XEUtils.toValueString(extraItem.label))
694
+ ]
695
+ : label)
696
+ ];
697
+ const festivalLabel = festivalItem.label;
698
+ if (festivalLabel) {
699
+ // 默认最多支持3个节日重叠
700
+ const festivalLabels = XEUtils.toValueString(festivalLabel).split(',');
701
+ labels.push(h('span', {
702
+ class: ['vxe-calendar--date-festival', festivalItem.important ? 'is-important' : '', festivalItem.className],
703
+ style: festivalItem.style
704
+ }, [
705
+ festivalLabels.length > 1
706
+ ? h('span', {
707
+ class: ['vxe-calendar--date-festival--overlap', `overlap--${festivalLabels.length}`]
708
+ }, festivalLabels.map(label => h('span', label.substring(0, 3))))
709
+ : h('span', {
710
+ class: 'vxe-calendar--date-festival--label'
711
+ }, festivalLabels[0].substring(0, 3))
712
+ ]));
713
+ }
714
+ return labels;
715
+ }
716
+ return label;
717
+ };
718
+ const renderDateDayTable = () => {
719
+ const { multiple } = props;
720
+ const { datePanelType, datePanelValue } = reactData;
721
+ const dateValue = computeDateValue.value;
722
+ const dateHeaders = computeDateHeaders.value;
723
+ const dayDatas = computeDayDatas.value;
724
+ const dateListValue = computeDateListValue.value;
725
+ const matchFormat = 'yyyyMMdd';
726
+ return [
727
+ h('table', {
728
+ class: `vxe-calendar--date-${datePanelType}-view`,
729
+ cellspacing: 0,
730
+ cellpadding: 0,
731
+ border: 0
732
+ }, [
733
+ h('tr', dateHeaders.map((item) => {
734
+ return h('th', {
735
+ class: 'vxe-calendar--view-th'
736
+ }, item.label);
737
+ })),
738
+ ...dayDatas.map((rows) => {
739
+ return h('tr', rows.map((item) => {
740
+ return h('td', {
741
+ class: ['vxe-calendar--view-td', {
742
+ 'is--prev': item.isPrev,
743
+ 'is--current': item.isCurrent,
744
+ 'is--now': item.isNow,
745
+ 'is--next': item.isNext,
746
+ 'is--disabled': isDateDisabled(item),
747
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
748
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
749
+ }],
750
+ onClick: () => dateSelectEvent(item),
751
+ onMouseenter: () => dateMouseenterEvent(item)
752
+ }, renderDateLabel(item, item.label));
753
+ }));
754
+ })
755
+ ])
756
+ ];
757
+ };
758
+ const renderDateWeekTable = () => {
759
+ const { multiple } = props;
760
+ const { datePanelType, datePanelValue } = reactData;
761
+ const dateValue = computeDateValue.value;
762
+ const weekHeaders = computeWeekHeaders.value;
763
+ const weekDates = computeWeekDates.value;
764
+ const dateListValue = computeDateListValue.value;
765
+ const matchFormat = 'yyyyMMdd';
766
+ return [
767
+ h('table', {
768
+ class: `vxe-calendar--date-${datePanelType}-view`,
769
+ cellspacing: 0,
770
+ cellpadding: 0,
771
+ border: 0
772
+ }, [
773
+ h('tr', weekHeaders.map((item) => {
774
+ return h('td', {
775
+ class: 'vxe-calendar--view-th'
776
+ }, item.label);
777
+ })),
778
+ ...weekDates.map((rows) => {
779
+ const isSelected = multiple ? rows.some((item) => dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat))) : rows.some((item) => XEUtils.isDateSame(dateValue, item.date, matchFormat));
780
+ const isHover = rows.some((item) => XEUtils.isDateSame(datePanelValue, item.date, matchFormat));
781
+ return h('tr', rows.map((item) => {
782
+ return h('td', {
783
+ class: ['vxe-calendar--view-td', {
784
+ 'is--prev': item.isPrev,
785
+ 'is--current': item.isCurrent,
786
+ 'is--now': item.isNow,
787
+ 'is--next': item.isNext,
788
+ 'is--disabled': isDateDisabled(item),
789
+ 'is--selected': isSelected,
790
+ 'is--hover': isHover
791
+ }],
792
+ // event
793
+ onClick: () => dateSelectEvent(item),
794
+ onMouseenter: () => dateMouseenterEvent(item)
795
+ }, renderDateLabel(item, item.label));
796
+ }));
797
+ })
798
+ ])
799
+ ];
800
+ };
801
+ const renderDateMonthTable = () => {
802
+ const { multiple } = props;
803
+ const { datePanelType, datePanelValue } = reactData;
804
+ const dateValue = computeDateValue.value;
805
+ const monthDatas = computeMonthDatas.value;
806
+ const dateListValue = computeDateListValue.value;
807
+ const matchFormat = 'yyyyMM';
808
+ return [
809
+ h('table', {
810
+ class: `vxe-calendar--date-${datePanelType}-view`,
811
+ cellspacing: 0,
812
+ cellpadding: 0,
813
+ border: 0
814
+ }, [
815
+ h('tbody', monthDatas.map((rows) => {
816
+ return h('tr', rows.map((item) => {
817
+ return h('td', {
818
+ class: ['vxe-calendar--view-td', {
819
+ 'is--prev': item.isPrev,
820
+ 'is--current': item.isCurrent,
821
+ 'is--now': item.isNow,
822
+ 'is--next': item.isNext,
823
+ 'is--disabled': isDateDisabled(item),
824
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
825
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
826
+ }],
827
+ onClick: () => dateSelectEvent(item),
828
+ onMouseenter: () => dateMouseenterEvent(item)
829
+ }, renderDateLabel(item, getI18n(`vxe.input.date.months.m${item.month}`)));
830
+ }));
831
+ }))
832
+ ])
833
+ ];
834
+ };
835
+ const renderDateQuarterTable = () => {
836
+ const { multiple } = props;
837
+ const { datePanelType, datePanelValue } = reactData;
838
+ const dateValue = computeDateValue.value;
839
+ const quarterDatas = computeQuarterDatas.value;
840
+ const dateListValue = computeDateListValue.value;
841
+ const matchFormat = 'yyyyq';
842
+ return [
843
+ h('table', {
844
+ class: `vxe-calendar--date-${datePanelType}-view`,
845
+ cellspacing: 0,
846
+ cellpadding: 0,
847
+ border: 0
848
+ }, [
849
+ h('tbody', quarterDatas.map((rows) => {
850
+ return h('tr', rows.map((item) => {
851
+ return h('td', {
852
+ class: ['vxe-calendar--view-td', {
853
+ 'is--prev': item.isPrev,
854
+ 'is--current': item.isCurrent,
855
+ 'is--now': item.isNow,
856
+ 'is--next': item.isNext,
857
+ 'is--disabled': isDateDisabled(item),
858
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
859
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
860
+ }],
861
+ onClick: () => dateSelectEvent(item),
862
+ onMouseenter: () => dateMouseenterEvent(item)
863
+ }, renderDateLabel(item, getI18n(`vxe.input.date.quarters.q${item.quarter}`)));
864
+ }));
865
+ }))
866
+ ])
867
+ ];
868
+ };
869
+ const renderDateYearTable = () => {
870
+ const { multiple } = props;
871
+ const { datePanelType, datePanelValue } = reactData;
872
+ const dateValue = computeDateValue.value;
873
+ const yearDatas = computeYearDatas.value;
874
+ const dateListValue = computeDateListValue.value;
875
+ const matchFormat = 'yyyy';
876
+ return [
877
+ h('table', {
878
+ class: `vxe-calendar--date-${datePanelType}-view`,
879
+ cellspacing: 0,
880
+ cellpadding: 0,
881
+ border: 0
882
+ }, [
883
+ h('tbody', yearDatas.map((rows) => {
884
+ return h('tr', rows.map((item) => {
885
+ return h('td', {
886
+ class: ['vxe-calendar--view-td', {
887
+ 'is--prev': item.isPrev,
888
+ 'is--current': item.isCurrent,
889
+ 'is--now': item.isNow,
890
+ 'is--next': item.isNext,
891
+ 'is--disabled': isDateDisabled(item),
892
+ 'is--selected': multiple ? dateListValue.some(val => XEUtils.isDateSame(val, item.date, matchFormat)) : XEUtils.isDateSame(dateValue, item.date, matchFormat),
893
+ 'is--hover': XEUtils.isDateSame(datePanelValue, item.date, matchFormat)
894
+ }],
895
+ onClick: () => dateSelectEvent(item),
896
+ onMouseenter: () => dateMouseenterEvent(item)
897
+ }, renderDateLabel(item, item.year));
898
+ }));
899
+ }))
900
+ ])
901
+ ];
902
+ };
903
+ const renderDateTable = () => {
904
+ const { datePanelType } = reactData;
905
+ switch (datePanelType) {
906
+ case 'week':
907
+ return renderDateWeekTable();
908
+ case 'month':
909
+ return renderDateMonthTable();
910
+ case 'quarter':
911
+ return renderDateQuarterTable();
912
+ case 'year':
913
+ return renderDateYearTable();
914
+ }
915
+ return renderDateDayTable();
916
+ };
917
+ const renderDatePanel = () => {
918
+ const { multiple } = props;
919
+ const { datePanelType } = reactData;
920
+ const isDisabledPrevDateBtn = computeIsDisabledPrevDateBtn.value;
921
+ const isDisabledNextDateBtn = computeIsDisabledNextDateBtn.value;
922
+ const selectDatePanelLabel = computeSelectDatePanelLabel.value;
923
+ return [
924
+ h('div', {
925
+ class: 'vxe-calendar--header'
926
+ }, [
927
+ h('div', {
928
+ class: 'vxe-calendar--type-wrapper'
929
+ }, [
930
+ h(VxeButtonComponent, {
931
+ disabled: datePanelType === 'year',
932
+ content: selectDatePanelLabel,
933
+ onClick: dateToggleTypeEvent
934
+ })
935
+ ]),
936
+ h('div', {
937
+ class: 'vxe-calendar--btn-wrapper'
938
+ }, [
939
+ h(VxeButtonComponent, {
940
+ disabled: isDisabledPrevDateBtn,
941
+ icon: 'vxe-icon-caret-left',
942
+ onClick: datePrevEvent
943
+ }),
944
+ h(VxeButtonComponent, {
945
+ icon: 'vxe-icon-dot',
946
+ onClick: dateTodayMonthEvent
947
+ }),
948
+ h(VxeButtonComponent, {
949
+ disabled: isDisabledNextDateBtn,
950
+ icon: 'vxe-icon-caret-right',
951
+ onClick: dateNextEvent
952
+ }),
953
+ multiple && computeSupportMultiples.value
954
+ ? h('span', {
955
+ class: 'vxe-calendar--btn vxe-calendar--confirm-btn'
956
+ }, [
957
+ h('button', {
958
+ class: 'vxe-calendar--confirm',
959
+ type: 'button',
960
+ onClick: dateConfirmEvent
961
+ }, getI18n('vxe.button.confirm'))
962
+ ])
963
+ : null
964
+ ])
965
+ ]),
966
+ h('div', {
967
+ class: 'vxe-calendar--body'
968
+ }, renderDateTable())
969
+ ];
970
+ };
971
+ calendarMethods = {
972
+ dispatchEvent(type, params, evnt) {
973
+ emit(type, createEvent(evnt, { $input: $xeCalendar }, params));
974
+ }
23
975
  };
976
+ Object.assign($xeCalendar, calendarMethods);
24
977
  const renderVN = () => {
25
- const defaultSlot = slots.default;
978
+ const { className, type } = props;
979
+ const vSize = computeSize.value;
980
+ const isDisabled = computeIsDisabled.value;
981
+ const calendarStyle = computeCalendarStyle.value;
26
982
  return h('div', {
27
983
  ref: refElem,
28
- class: ['vxe-calendar']
29
- }, defaultSlot ? defaultSlot({}) : []);
984
+ class: ['vxe-calendar', `type--${type}`, className, {
985
+ [`size--${vSize}`]: vSize,
986
+ 'is--disabled': isDisabled
987
+ }],
988
+ style: calendarStyle
989
+ }, [
990
+ renderDatePanel()
991
+ ]);
30
992
  };
31
993
  $xeCalendar.renderVN = renderVN;
994
+ watch(() => props.modelValue, (val) => {
995
+ reactData.inputValue = val;
996
+ changeValue();
997
+ });
998
+ watch(() => props.type, () => {
999
+ // 切换类型是重置内置变量
1000
+ Object.assign(reactData, {
1001
+ selectValue: null,
1002
+ inputValue: null,
1003
+ datePanelValue: null,
1004
+ datePanelLabel: '',
1005
+ datePanelType: 'day',
1006
+ selectMonth: null,
1007
+ currentDate: null
1008
+ });
1009
+ initValue();
1010
+ dateOpenPanel();
1011
+ });
1012
+ watch(computeDateLabelFormat, () => {
1013
+ const isCalendarType = computeIsCalendarType.value;
1014
+ if (isCalendarType) {
1015
+ dateParseValue(reactData.datePanelValue);
1016
+ reactData.inputValue = props.multiple ? computeDateMultipleLabel.value : reactData.datePanelLabel;
1017
+ }
1018
+ });
1019
+ onMounted(() => {
1020
+ dateOpenPanel();
1021
+ });
1022
+ initValue();
32
1023
  return $xeCalendar;
33
1024
  },
34
1025
  render() {