@kengic/uni 0.5.1 → 0.5.2-beta.1

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 (146) hide show
  1. package/dist/uni/uni-ui/uni-badge/uni-badge.vue +222 -219
  2. package/dist/uni/uni-ui/uni-breadcrumb/uni-breadcrumb.vue +29 -29
  3. package/dist/uni/uni-ui/uni-breadcrumb-item/uni-breadcrumb-item.vue +88 -88
  4. package/dist/uni/uni-ui/uni-calendar/calendar.js +936 -532
  5. package/dist/uni/uni-ui/uni-calendar/i18n/en.json +10 -10
  6. package/dist/uni/uni-ui/uni-calendar/i18n/index.js +8 -7
  7. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hans.json +10 -10
  8. package/dist/uni/uni-ui/uni-calendar/i18n/zh-Hant.json +10 -10
  9. package/dist/uni/uni-ui/uni-calendar/uni-calendar-item.vue +190 -168
  10. package/dist/uni/uni-ui/uni-calendar/uni-calendar.vue +459 -459
  11. package/dist/uni/uni-ui/uni-calendar/util.js +324 -340
  12. package/dist/uni/uni-ui/uni-card/uni-card.vue +8 -1
  13. package/dist/uni/uni-ui/uni-col/uni-col.vue +294 -287
  14. package/dist/uni/uni-ui/uni-collapse/uni-collapse.vue +139 -140
  15. package/dist/uni/uni-ui/uni-collapse-item/uni-collapse-item.vue +381 -378
  16. package/dist/uni/uni-ui/uni-combox/uni-combox.vue +280 -272
  17. package/dist/uni/uni-ui/uni-countdown/i18n/en.json +4 -4
  18. package/dist/uni/uni-ui/uni-countdown/i18n/index.js +8 -7
  19. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hans.json +4 -4
  20. package/dist/uni/uni-ui/uni-countdown/i18n/zh-Hant.json +4 -4
  21. package/dist/uni/uni-ui/uni-countdown/uni-countdown.vue +249 -257
  22. package/dist/uni/uni-ui/uni-data-checkbox/uni-data-checkbox.vue +832 -813
  23. package/dist/uni/uni-ui/uni-data-picker/keypress.js +42 -42
  24. package/dist/uni/uni-ui/uni-data-picker/uni-data-picker.vue +535 -516
  25. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-picker.js +623 -618
  26. package/dist/uni/uni-ui/uni-data-pickerview/uni-data-pickerview.vue +293 -288
  27. package/dist/uni/uni-ui/uni-data-select/uni-data-select.vue +495 -509
  28. package/dist/uni/uni-ui/uni-dateformat/date-format.js +181 -184
  29. package/dist/uni/uni-ui/uni-dateformat/uni-dateformat.vue +81 -82
  30. package/dist/uni/uni-ui/uni-datetime-picker/calendar-item.vue +176 -170
  31. package/dist/uni/uni-ui/uni-datetime-picker/calendar.vue +926 -920
  32. package/dist/uni/uni-ui/uni-datetime-picker/i18n/en.json +20 -20
  33. package/dist/uni/uni-ui/uni-datetime-picker/i18n/index.js +8 -7
  34. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hans.json +21 -21
  35. package/dist/uni/uni-ui/uni-datetime-picker/i18n/zh-Hant.json +21 -21
  36. package/dist/uni/uni-ui/uni-datetime-picker/time-picker.vue +921 -926
  37. package/dist/uni/uni-ui/uni-datetime-picker/uni-datetime-picker.vue +1059 -1012
  38. package/dist/uni/uni-ui/uni-datetime-picker/util.js +366 -377
  39. package/dist/uni/uni-ui/uni-drawer/keypress.js +42 -42
  40. package/dist/uni/uni-ui/uni-drawer/uni-drawer.vue +176 -167
  41. package/dist/uni/uni-ui/uni-easyinput/common.js +40 -42
  42. package/dist/uni/uni-ui/uni-easyinput/uni-easyinput.vue +628 -547
  43. package/dist/uni/uni-ui/uni-fab/uni-fab.vue +507 -483
  44. package/dist/uni/uni-ui/uni-fav/i18n/en.json +2 -2
  45. package/dist/uni/uni-ui/uni-fav/i18n/index.js +8 -7
  46. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hans.json +2 -2
  47. package/dist/uni/uni-ui/uni-fav/i18n/zh-Hant.json +2 -2
  48. package/dist/uni/uni-ui/uni-fav/uni-fav.vue +155 -147
  49. package/dist/uni/uni-ui/uni-file-picker/choose-and-upload-file.js +172 -198
  50. package/dist/uni/uni-ui/uni-file-picker/uni-file-picker.vue +636 -634
  51. package/dist/uni/uni-ui/uni-file-picker/upload-file.vue +294 -293
  52. package/dist/uni/uni-ui/uni-file-picker/upload-image.vue +267 -270
  53. package/dist/uni/uni-ui/uni-file-picker/utils.js +81 -82
  54. package/dist/uni/uni-ui/uni-forms/uni-forms.vue +360 -372
  55. package/dist/uni/uni-ui/uni-forms/utils.js +170 -174
  56. package/dist/uni/uni-ui/uni-forms/validate.js +447 -456
  57. package/dist/uni/uni-ui/uni-forms-item/uni-forms-item.vue +497 -497
  58. package/dist/uni/uni-ui/uni-goods-nav/i18n/en.json +4 -4
  59. package/dist/uni/uni-ui/uni-goods-nav/i18n/index.js +8 -7
  60. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hans.json +4 -4
  61. package/dist/uni/uni-ui/uni-goods-nav/i18n/zh-Hant.json +4 -4
  62. package/dist/uni/uni-ui/uni-goods-nav/uni-goods-nav.vue +238 -222
  63. package/dist/uni/uni-ui/uni-grid/uni-grid.vue +134 -134
  64. package/dist/uni/uni-ui/uni-grid-item/uni-grid-item.vue +121 -119
  65. package/dist/uni/uni-ui/uni-group/uni-group.vue +121 -121
  66. package/dist/uni/uni-ui/uni-icons/icons.js +1170 -1168
  67. package/dist/uni/uni-ui/uni-icons/uni-icons.vue +91 -86
  68. package/dist/uni/uni-ui/uni-icons/uniicons.css +166 -166
  69. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list-item.vue +129 -129
  70. package/dist/uni/uni-ui/uni-indexed-list/uni-indexed-list.vue +352 -347
  71. package/dist/uni/uni-ui/uni-link/uni-link.vue +134 -119
  72. package/dist/uni/uni-ui/uni-list/uni-list.vue +119 -110
  73. package/dist/uni/uni-ui/uni-list/uni-refresh.vue +14 -14
  74. package/dist/uni/uni-ui/uni-list/uni-refresh.wxs +14 -14
  75. package/dist/uni/uni-ui/uni-list-ad/uni-list-ad.vue +101 -95
  76. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.scss +18 -18
  77. package/dist/uni/uni-ui/uni-list-chat/uni-list-chat.vue +602 -586
  78. package/dist/uni/uni-ui/uni-list-item/uni-list-item.vue +507 -503
  79. package/dist/uni/uni-ui/uni-load-more/i18n/en.json +3 -3
  80. package/dist/uni/uni-ui/uni-load-more/i18n/index.js +8 -7
  81. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hans.json +3 -3
  82. package/dist/uni/uni-ui/uni-load-more/i18n/zh-Hant.json +3 -3
  83. package/dist/uni/uni-ui/uni-load-more/uni-load-more.vue +402 -392
  84. package/dist/uni/uni-ui/uni-nav-bar/uni-nav-bar.vue +328 -330
  85. package/dist/uni/uni-ui/uni-nav-bar/uni-status-bar.vue +17 -17
  86. package/dist/uni/uni-ui/uni-notice-bar/uni-notice-bar.vue +422 -401
  87. package/dist/uni/uni-ui/uni-number-box/uni-number-box.vue +211 -205
  88. package/dist/uni/uni-ui/uni-pagination/i18n/en.json +3 -3
  89. package/dist/uni/uni-ui/uni-pagination/i18n/es.json +3 -3
  90. package/dist/uni/uni-ui/uni-pagination/i18n/fr.json +3 -3
  91. package/dist/uni/uni-ui/uni-pagination/i18n/index.js +12 -11
  92. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hans.json +3 -3
  93. package/dist/uni/uni-ui/uni-pagination/i18n/zh-Hant.json +3 -3
  94. package/dist/uni/uni-ui/uni-pagination/uni-pagination.vue +450 -433
  95. package/dist/uni/uni-ui/uni-popup/uni-popup.vue +404 -404
  96. package/dist/uni/uni-ui/uni-popup-dialog/keypress.js +42 -42
  97. package/dist/uni/uni-ui/uni-popup-dialog/uni-popup-dialog.vue +1 -0
  98. package/dist/uni/uni-ui/uni-popup-message/uni-popup-message.vue +126 -125
  99. package/dist/uni/uni-ui/uni-popup-share/uni-popup-share.vue +172 -172
  100. package/dist/uni/uni-ui/uni-rate/uni-rate.vue +343 -347
  101. package/dist/uni/uni-ui/uni-row/uni-row.vue +180 -182
  102. package/dist/uni/uni-ui/uni-scss/changelog.md +11 -4
  103. package/dist/uni/uni-ui/uni-scss/package.json +73 -73
  104. package/dist/uni/uni-ui/uni-scss/readme.md +2 -1
  105. package/dist/uni/uni-ui/uni-scss/styles/setting/_border.scss +2 -2
  106. package/dist/uni/uni-ui/uni-scss/styles/setting/_color.scss +46 -47
  107. package/dist/uni/uni-ui/uni-scss/styles/setting/_radius.scss +49 -49
  108. package/dist/uni/uni-ui/uni-scss/styles/setting/_space.scss +52 -53
  109. package/dist/uni/uni-ui/uni-scss/styles/setting/_styles.scss +142 -147
  110. package/dist/uni/uni-ui/uni-scss/styles/setting/_text.scss +20 -20
  111. package/dist/uni/uni-ui/uni-scss/styles/setting/_variables.scss +111 -95
  112. package/dist/uni/uni-ui/uni-scss/styles/tools/functions.scss +28 -18
  113. package/dist/uni/uni-ui/uni-scss/theme.scss +10 -7
  114. package/dist/uni/uni-ui/uni-scss/variables.scss +42 -24
  115. package/dist/uni/uni-ui/uni-search-bar/i18n/en.json +3 -3
  116. package/dist/uni/uni-ui/uni-search-bar/i18n/index.js +8 -7
  117. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hans.json +2 -2
  118. package/dist/uni/uni-ui/uni-search-bar/i18n/zh-Hant.json +2 -2
  119. package/dist/uni/uni-ui/uni-search-bar/uni-search-bar.vue +290 -281
  120. package/dist/uni/uni-ui/uni-section/uni-section.vue +149 -146
  121. package/dist/uni/uni-ui/uni-segmented-control/uni-segmented-control.vue +141 -131
  122. package/dist/uni/uni-ui/uni-steps/uni-steps.vue +255 -236
  123. package/dist/uni/uni-ui/uni-swipe-action/uni-swipe-action.vue +51 -51
  124. package/dist/uni/uni-ui/uni-swipe-action-item/bindingx.js +276 -282
  125. package/dist/uni/uni-ui/uni-swipe-action-item/isPC.js +10 -10
  126. package/dist/uni/uni-ui/uni-swipe-action-item/mpalipay.js +182 -187
  127. package/dist/uni/uni-ui/uni-swipe-action-item/mpother.js +235 -244
  128. package/dist/uni/uni-ui/uni-swipe-action-item/mpwxs.js +70 -75
  129. package/dist/uni/uni-ui/uni-swipe-action-item/render.js +238 -247
  130. package/dist/uni/uni-ui/uni-swipe-action-item/uni-swipe-action-item.vue +387 -313
  131. package/dist/uni/uni-ui/uni-swipe-action-item/wx.wxs +206 -215
  132. package/dist/uni/uni-ui/uni-swiper-dot/uni-swiper-dot.vue +241 -197
  133. package/dist/uni/uni-ui/uni-table/uni-table.vue +445 -447
  134. package/dist/uni/uni-ui/uni-tag/uni-tag.vue +234 -244
  135. package/dist/uni/uni-ui/uni-tbody/uni-tbody.vue +20 -23
  136. package/dist/uni/uni-ui/uni-td/uni-td.vue +79 -80
  137. package/dist/uni/uni-ui/uni-th/filter-dropdown.vue +510 -503
  138. package/dist/uni/uni-ui/uni-th/uni-th.vue +289 -273
  139. package/dist/uni/uni-ui/uni-thead/uni-thead.vue +115 -114
  140. package/dist/uni/uni-ui/uni-title/uni-title.vue +151 -154
  141. package/dist/uni/uni-ui/uni-tooltip/uni-tooltip.vue +55 -60
  142. package/dist/uni/uni-ui/uni-tr/table-checkbox.vue +162 -163
  143. package/dist/uni/uni-ui/uni-tr/uni-tr.vue +158 -157
  144. package/dist/uni/uni-ui/uni-transition/createAnimation.js +130 -113
  145. package/dist/uni/uni-ui/uni-transition/uni-transition.vue +274 -272
  146. package/package.json +1 -1
@@ -1,360 +1,344 @@
1
- import CALENDAR from './calendar.js'
1
+ import CALENDAR from './calendar.js';
2
2
 
3
3
  class Calendar {
4
- constructor({
5
- date,
6
- selected,
7
- startDate,
8
- endDate,
9
- range
10
- } = {}) {
11
- // 当前日期
12
- this.date = this.getDate(new Date()) // 当前初入日期
13
- // 打点信息
14
- this.selected = selected || [];
15
- // 范围开始
16
- this.startDate = startDate
17
- // 范围结束
18
- this.endDate = endDate
19
- this.range = range
20
- // 多选状态
21
- this.cleanMultipleStatus()
22
- // 每周日期
23
- this.weeks = {}
24
- // this._getWeek(this.date.fullDate)
25
- }
26
- /**
27
- * 设置日期
28
- * @param {Object} date
29
- */
30
- setDate(date) {
31
- this.selectDate = this.getDate(date)
32
- this._getWeek(this.selectDate.fullDate)
33
- }
4
+ constructor({ date, selected, startDate, endDate, range } = {}) {
5
+ // 当前日期
6
+ this.date = this.getDate(new Date()); // 当前初入日期
7
+ // 打点信息
8
+ this.selected = selected || [];
9
+ // 范围开始
10
+ this.startDate = startDate;
11
+ // 范围结束
12
+ this.endDate = endDate;
13
+ this.range = range;
14
+ // 多选状态
15
+ this.cleanMultipleStatus();
16
+ // 每周日期
17
+ this.weeks = {};
18
+ // this._getWeek(this.date.fullDate)
19
+ }
20
+ /**
21
+ * 设置日期
22
+ * @param {Object} date
23
+ */
24
+ setDate(date) {
25
+ this.selectDate = this.getDate(date);
26
+ this._getWeek(this.selectDate.fullDate);
27
+ }
34
28
 
35
- /**
36
- * 清理多选状态
37
- */
38
- cleanMultipleStatus() {
39
- this.multipleStatus = {
40
- before: '',
41
- after: '',
42
- data: []
43
- }
44
- }
29
+ /**
30
+ * 清理多选状态
31
+ */
32
+ cleanMultipleStatus() {
33
+ this.multipleStatus = {
34
+ before: '',
35
+ after: '',
36
+ data: [],
37
+ };
38
+ }
45
39
 
46
- /**
47
- * 重置开始日期
48
- */
49
- resetSatrtDate(startDate) {
50
- // 范围开始
51
- this.startDate = startDate
40
+ /**
41
+ * 重置开始日期
42
+ */
43
+ resetSatrtDate(startDate) {
44
+ // 范围开始
45
+ this.startDate = startDate;
46
+ }
52
47
 
53
- }
48
+ /**
49
+ * 重置结束日期
50
+ */
51
+ resetEndDate(endDate) {
52
+ // 范围结束
53
+ this.endDate = endDate;
54
+ }
54
55
 
55
- /**
56
- * 重置结束日期
57
- */
58
- resetEndDate(endDate) {
59
- // 范围结束
60
- this.endDate = endDate
61
- }
56
+ /**
57
+ * 获取任意时间
58
+ */
59
+ getDate(date, AddDayCount = 0, str = 'day') {
60
+ if (!date) {
61
+ date = new Date();
62
+ }
63
+ if (typeof date !== 'object') {
64
+ date = date.replace(/-/g, '/');
65
+ }
66
+ const dd = new Date(date);
67
+ switch (str) {
68
+ case 'day':
69
+ dd.setDate(dd.getDate() + AddDayCount); // 获取AddDayCount天后的日期
70
+ break;
71
+ case 'month':
72
+ if (dd.getDate() === 31 && AddDayCount > 0) {
73
+ dd.setDate(dd.getDate() + AddDayCount);
74
+ } else {
75
+ const preMonth = dd.getMonth();
76
+ dd.setMonth(preMonth + AddDayCount); // 获取AddDayCount天后的日期
77
+ const nextMonth = dd.getMonth();
78
+ // 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
79
+ if (AddDayCount < 0 && preMonth !== 0 && nextMonth - preMonth > AddDayCount) {
80
+ dd.setMonth(nextMonth + (nextMonth - preMonth + AddDayCount));
81
+ }
82
+ // 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
83
+ if (AddDayCount > 0 && nextMonth - preMonth > AddDayCount) {
84
+ dd.setMonth(nextMonth - (nextMonth - preMonth - AddDayCount));
85
+ }
86
+ }
87
+ break;
88
+ case 'year':
89
+ dd.setFullYear(dd.getFullYear() + AddDayCount); // 获取AddDayCount天后的日期
90
+ break;
91
+ }
92
+ const y = dd.getFullYear();
93
+ const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1; // 获取当前月份的日期,不足10补0
94
+ const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate(); // 获取当前几号,不足10补0
95
+ return {
96
+ fullDate: y + '-' + m + '-' + d,
97
+ year: y,
98
+ month: m,
99
+ date: d,
100
+ day: dd.getDay(),
101
+ };
102
+ }
62
103
 
63
- /**
64
- * 获取任意时间
65
- */
66
- getDate(date, AddDayCount = 0, str = 'day') {
67
- if (!date) {
68
- date = new Date()
69
- }
70
- if (typeof date !== 'object') {
71
- date = date.replace(/-/g, '/')
72
- }
73
- const dd = new Date(date)
74
- switch (str) {
75
- case 'day':
76
- dd.setDate(dd.getDate() + AddDayCount) // 获取AddDayCount天后的日期
77
- break
78
- case 'month':
79
- if (dd.getDate() === 31 && AddDayCount>0) {
80
- dd.setDate(dd.getDate() + AddDayCount)
81
- } else {
82
- const preMonth = dd.getMonth()
83
- dd.setMonth(preMonth + AddDayCount) // 获取AddDayCount天后的日期
84
- const nextMonth = dd.getMonth()
85
- // 处理 pre 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
86
- if(AddDayCount<0 && preMonth!==0 && nextMonth-preMonth>AddDayCount){
87
- dd.setMonth(nextMonth+(nextMonth-preMonth+AddDayCount))
88
- }
89
- // 处理 next 切换月份目标月份为2月没有当前日(30 31) 切换错误问题
90
- if(AddDayCount>0 && nextMonth-preMonth>AddDayCount){
91
- dd.setMonth(nextMonth-(nextMonth-preMonth-AddDayCount))
92
- }
93
- }
94
- break
95
- case 'year':
96
- dd.setFullYear(dd.getFullYear() + AddDayCount) // 获取AddDayCount天后的日期
97
- break
98
- }
99
- const y = dd.getFullYear()
100
- const m = dd.getMonth() + 1 < 10 ? '0' + (dd.getMonth() + 1) : dd.getMonth() + 1 // 获取当前月份的日期,不足10补0
101
- const d = dd.getDate() < 10 ? '0' + dd.getDate() : dd.getDate() // 获取当前几号,不足10补0
102
- return {
103
- fullDate: y + '-' + m + '-' + d,
104
- year: y,
105
- month: m,
106
- date: d,
107
- day: dd.getDay()
108
- }
109
- }
104
+ /**
105
+ * 获取上月剩余天数
106
+ */
107
+ _getLastMonthDays(firstDay, full) {
108
+ let dateArr = [];
109
+ for (let i = firstDay; i > 0; i--) {
110
+ const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate();
111
+ dateArr.push({
112
+ date: beforeDate,
113
+ month: full.month - 1,
114
+ lunar: this.getlunar(full.year, full.month - 1, beforeDate),
115
+ disable: true,
116
+ });
117
+ }
118
+ return dateArr;
119
+ }
120
+ /**
121
+ * 获取本月天数
122
+ */
123
+ _currentMonthDys(dateData, full) {
124
+ let dateArr = [];
125
+ let fullDate = this.date.fullDate;
126
+ for (let i = 1; i <= dateData; i++) {
127
+ let nowDate = full.year + '-' + (full.month < 10 ? full.month : full.month) + '-' + (i < 10 ? '0' + i : i);
128
+ // 是否今天
129
+ let isDay = fullDate === nowDate;
130
+ // 获取打点信息
131
+ let info =
132
+ this.selected &&
133
+ this.selected.find((item) => {
134
+ if (this.dateEqual(nowDate, item.date)) {
135
+ return item;
136
+ }
137
+ });
110
138
 
139
+ // 日期禁用
140
+ let disableBefore = true;
141
+ let disableAfter = true;
142
+ if (this.startDate) {
143
+ // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
144
+ // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
145
+ disableBefore = this.dateCompare(this.startDate, nowDate);
146
+ }
111
147
 
112
- /**
113
- * 获取上月剩余天数
114
- */
115
- _getLastMonthDays(firstDay, full) {
116
- let dateArr = []
117
- for (let i = firstDay; i > 0; i--) {
118
- const beforeDate = new Date(full.year, full.month - 1, -i + 1).getDate()
119
- dateArr.push({
120
- date: beforeDate,
121
- month: full.month - 1,
122
- lunar: this.getlunar(full.year, full.month - 1, beforeDate),
123
- disable: true
124
- })
125
- }
126
- return dateArr
127
- }
128
- /**
129
- * 获取本月天数
130
- */
131
- _currentMonthDys(dateData, full) {
132
- let dateArr = []
133
- let fullDate = this.date.fullDate
134
- for (let i = 1; i <= dateData; i++) {
135
- let nowDate = full.year + '-' + (full.month < 10 ?
136
- full.month : full.month) + '-' + (i < 10 ?
137
- '0' + i : i)
138
- // 是否今天
139
- let isDay = fullDate === nowDate
140
- // 获取打点信息
141
- let info = this.selected && this.selected.find((item) => {
142
- if (this.dateEqual(nowDate, item.date)) {
143
- return item
144
- }
145
- })
148
+ if (this.endDate) {
149
+ // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
150
+ // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
151
+ disableAfter = this.dateCompare(nowDate, this.endDate);
152
+ }
153
+ let multiples = this.multipleStatus.data;
154
+ let checked = false;
155
+ let multiplesStatus = -1;
156
+ if (this.range) {
157
+ if (multiples) {
158
+ multiplesStatus = multiples.findIndex((item) => {
159
+ return this.dateEqual(item, nowDate);
160
+ });
161
+ }
162
+ if (multiplesStatus !== -1) {
163
+ checked = true;
164
+ }
165
+ }
166
+ let data = {
167
+ fullDate: nowDate,
168
+ year: full.year,
169
+ date: i,
170
+ multiple: this.range ? checked : false,
171
+ beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
172
+ afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
173
+ month: full.month,
174
+ lunar: this.getlunar(full.year, full.month, i),
175
+ disable: !(disableBefore && disableAfter),
176
+ isDay,
177
+ };
178
+ if (info) {
179
+ data.extraInfo = info;
180
+ }
146
181
 
147
- // 日期禁用
148
- let disableBefore = true
149
- let disableAfter = true
150
- if (this.startDate) {
151
- // let dateCompBefore = this.dateCompare(this.startDate, fullDate)
152
- // disableBefore = this.dateCompare(dateCompBefore ? this.startDate : fullDate, nowDate)
153
- disableBefore = this.dateCompare(this.startDate, nowDate)
154
- }
182
+ dateArr.push(data);
183
+ }
184
+ return dateArr;
185
+ }
186
+ /**
187
+ * 获取下月天数
188
+ */
189
+ _getNextMonthDays(surplus, full) {
190
+ let dateArr = [];
191
+ for (let i = 1; i < surplus + 1; i++) {
192
+ dateArr.push({
193
+ date: i,
194
+ month: Number(full.month) + 1,
195
+ lunar: this.getlunar(full.year, Number(full.month) + 1, i),
196
+ disable: true,
197
+ });
198
+ }
199
+ return dateArr;
200
+ }
155
201
 
156
- if (this.endDate) {
157
- // let dateCompAfter = this.dateCompare(fullDate, this.endDate)
158
- // disableAfter = this.dateCompare(nowDate, dateCompAfter ? this.endDate : fullDate)
159
- disableAfter = this.dateCompare(nowDate, this.endDate)
160
- }
161
- let multiples = this.multipleStatus.data
162
- let checked = false
163
- let multiplesStatus = -1
164
- if (this.range) {
165
- if (multiples) {
166
- multiplesStatus = multiples.findIndex((item) => {
167
- return this.dateEqual(item, nowDate)
168
- })
169
- }
170
- if (multiplesStatus !== -1) {
171
- checked = true
172
- }
173
- }
174
- let data = {
175
- fullDate: nowDate,
176
- year: full.year,
177
- date: i,
178
- multiple: this.range ? checked : false,
179
- beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
180
- afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
181
- month: full.month,
182
- lunar: this.getlunar(full.year, full.month, i),
183
- disable: !(disableBefore && disableAfter),
184
- isDay
185
- }
186
- if (info) {
187
- data.extraInfo = info
188
- }
202
+ /**
203
+ * 获取当前日期详情
204
+ * @param {Object} date
205
+ */
206
+ getInfo(date) {
207
+ if (!date) {
208
+ date = new Date();
209
+ }
210
+ const dateInfo = this.canlender.find((item) => item.fullDate === this.getDate(date).fullDate);
211
+ return dateInfo;
212
+ }
189
213
 
190
- dateArr.push(data)
191
- }
192
- return dateArr
193
- }
194
- /**
195
- * 获取下月天数
196
- */
197
- _getNextMonthDays(surplus, full) {
198
- let dateArr = []
199
- for (let i = 1; i < surplus + 1; i++) {
200
- dateArr.push({
201
- date: i,
202
- month: Number(full.month) + 1,
203
- lunar: this.getlunar(full.year, Number(full.month) + 1, i),
204
- disable: true
205
- })
206
- }
207
- return dateArr
208
- }
214
+ /**
215
+ * 比较时间大小
216
+ */
217
+ dateCompare(startDate, endDate) {
218
+ // 计算截止时间
219
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'));
220
+ // 计算详细项的截止时间
221
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'));
222
+ if (startDate <= endDate) {
223
+ return true;
224
+ } else {
225
+ return false;
226
+ }
227
+ }
209
228
 
210
- /**
211
- * 获取当前日期详情
212
- * @param {Object} date
213
- */
214
- getInfo(date) {
215
- if (!date) {
216
- date = new Date()
217
- }
218
- const dateInfo = this.canlender.find(item => item.fullDate === this.getDate(date).fullDate)
219
- return dateInfo
220
- }
229
+ /**
230
+ * 比较时间是否相等
231
+ */
232
+ dateEqual(before, after) {
233
+ // 计算截止时间
234
+ before = new Date(before.replace('-', '/').replace('-', '/'));
235
+ // 计算详细项的截止时间
236
+ after = new Date(after.replace('-', '/').replace('-', '/'));
237
+ if (before.getTime() - after.getTime() === 0) {
238
+ return true;
239
+ } else {
240
+ return false;
241
+ }
242
+ }
221
243
 
222
- /**
223
- * 比较时间大小
224
- */
225
- dateCompare(startDate, endDate) {
226
- // 计算截止时间
227
- startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
228
- // 计算详细项的截止时间
229
- endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
230
- if (startDate <= endDate) {
231
- return true
232
- } else {
233
- return false
234
- }
235
- }
244
+ /**
245
+ * 获取日期范围内所有日期
246
+ * @param {Object} begin
247
+ * @param {Object} end
248
+ */
249
+ geDateAll(begin, end) {
250
+ var arr = [];
251
+ var ab = begin.split('-');
252
+ var ae = end.split('-');
253
+ var db = new Date();
254
+ db.setFullYear(ab[0], ab[1] - 1, ab[2]);
255
+ var de = new Date();
256
+ de.setFullYear(ae[0], ae[1] - 1, ae[2]);
257
+ var unixDb = db.getTime() - 24 * 60 * 60 * 1000;
258
+ var unixDe = de.getTime() - 24 * 60 * 60 * 1000;
259
+ for (var k = unixDb; k <= unixDe; ) {
260
+ k = k + 24 * 60 * 60 * 1000;
261
+ arr.push(this.getDate(new Date(parseInt(k))).fullDate);
262
+ }
263
+ return arr;
264
+ }
265
+ /**
266
+ * 计算阴历日期显示
267
+ */
268
+ getlunar(year, month, date) {
269
+ return CALENDAR.solar2lunar(year, month, date);
270
+ }
271
+ /**
272
+ * 设置打点
273
+ */
274
+ setSelectInfo(data, value) {
275
+ this.selected = value;
276
+ this._getWeek(data);
277
+ }
236
278
 
237
- /**
238
- * 比较时间是否相等
239
- */
240
- dateEqual(before, after) {
241
- // 计算截止时间
242
- before = new Date(before.replace('-', '/').replace('-', '/'))
243
- // 计算详细项的截止时间
244
- after = new Date(after.replace('-', '/').replace('-', '/'))
245
- if (before.getTime() - after.getTime() === 0) {
246
- return true
247
- } else {
248
- return false
249
- }
250
- }
279
+ /**
280
+ * 获取多选状态
281
+ */
282
+ setMultiple(fullDate) {
283
+ let { before, after } = this.multipleStatus;
251
284
 
285
+ if (!this.range) return;
286
+ if (before && after) {
287
+ this.multipleStatus.before = '';
288
+ this.multipleStatus.after = '';
289
+ this.multipleStatus.data = [];
290
+ } else {
291
+ if (!before) {
292
+ this.multipleStatus.before = fullDate;
293
+ } else {
294
+ this.multipleStatus.after = fullDate;
295
+ if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
296
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
297
+ } else {
298
+ this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
299
+ }
300
+ }
301
+ }
302
+ this._getWeek(fullDate);
303
+ }
252
304
 
253
- /**
254
- * 获取日期范围内所有日期
255
- * @param {Object} begin
256
- * @param {Object} end
257
- */
258
- geDateAll(begin, end) {
259
- var arr = []
260
- var ab = begin.split('-')
261
- var ae = end.split('-')
262
- var db = new Date()
263
- db.setFullYear(ab[0], ab[1] - 1, ab[2])
264
- var de = new Date()
265
- de.setFullYear(ae[0], ae[1] - 1, ae[2])
266
- var unixDb = db.getTime() - 24 * 60 * 60 * 1000
267
- var unixDe = de.getTime() - 24 * 60 * 60 * 1000
268
- for (var k = unixDb; k <= unixDe;) {
269
- k = k + 24 * 60 * 60 * 1000
270
- arr.push(this.getDate(new Date(parseInt(k))).fullDate)
271
- }
272
- return arr
273
- }
274
- /**
275
- * 计算阴历日期显示
276
- */
277
- getlunar(year, month, date) {
278
- return CALENDAR.solar2lunar(year, month, date)
279
- }
280
- /**
281
- * 设置打点
282
- */
283
- setSelectInfo(data, value) {
284
- this.selected = value
285
- this._getWeek(data)
286
- }
305
+ /**
306
+ * 获取每周数据
307
+ * @param {Object} dateData
308
+ */
309
+ _getWeek(dateData) {
310
+ const { year, month } = this.getDate(dateData);
311
+ let firstDay = new Date(year, month - 1, 1).getDay();
312
+ let currentDay = new Date(year, month, 0).getDate();
313
+ let dates = {
314
+ lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
315
+ currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
316
+ nextMonthDays: [], // 下个月开始几天
317
+ weeks: [],
318
+ };
319
+ let canlender = [];
320
+ const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length);
321
+ dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData));
322
+ canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays);
323
+ let weeks = {};
324
+ // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
325
+ for (let i = 0; i < canlender.length; i++) {
326
+ if (i % 7 === 0) {
327
+ weeks[parseInt(i / 7)] = new Array(7);
328
+ }
329
+ weeks[parseInt(i / 7)][i % 7] = canlender[i];
330
+ }
331
+ this.canlender = canlender;
332
+ this.weeks = weeks;
333
+ }
287
334
 
288
- /**
289
- * 获取多选状态
290
- */
291
- setMultiple(fullDate) {
292
- let {
293
- before,
294
- after
295
- } = this.multipleStatus
296
-
297
- if (!this.range) return
298
- if (before && after) {
299
- this.multipleStatus.before = ''
300
- this.multipleStatus.after = ''
301
- this.multipleStatus.data = []
302
- } else {
303
- if (!before) {
304
- this.multipleStatus.before = fullDate
305
- } else {
306
- this.multipleStatus.after = fullDate
307
- if (this.dateCompare(this.multipleStatus.before, this.multipleStatus.after)) {
308
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.before, this.multipleStatus.after);
309
- } else {
310
- this.multipleStatus.data = this.geDateAll(this.multipleStatus.after, this.multipleStatus.before);
311
- }
312
- }
313
- }
314
- this._getWeek(fullDate)
315
- }
316
-
317
- /**
318
- * 获取每周数据
319
- * @param {Object} dateData
320
- */
321
- _getWeek(dateData) {
322
- const {
323
- year,
324
- month
325
- } = this.getDate(dateData)
326
- let firstDay = new Date(year, month - 1, 1).getDay()
327
- let currentDay = new Date(year, month, 0).getDate()
328
- let dates = {
329
- lastMonthDays: this._getLastMonthDays(firstDay, this.getDate(dateData)), // 上个月末尾几天
330
- currentMonthDys: this._currentMonthDys(currentDay, this.getDate(dateData)), // 本月天数
331
- nextMonthDays: [], // 下个月开始几天
332
- weeks: []
333
- }
334
- let canlender = []
335
- const surplus = 42 - (dates.lastMonthDays.length + dates.currentMonthDys.length)
336
- dates.nextMonthDays = this._getNextMonthDays(surplus, this.getDate(dateData))
337
- canlender = canlender.concat(dates.lastMonthDays, dates.currentMonthDys, dates.nextMonthDays)
338
- let weeks = {}
339
- // 拼接数组 上个月开始几天 + 本月天数+ 下个月开始几天
340
- for (let i = 0; i < canlender.length; i++) {
341
- if (i % 7 === 0) {
342
- weeks[parseInt(i / 7)] = new Array(7)
343
- }
344
- weeks[parseInt(i / 7)][i % 7] = canlender[i]
345
- }
346
- this.canlender = canlender
347
- this.weeks = weeks
348
- }
349
-
350
- //静态方法
351
- // static init(date) {
352
- // if (!this.instance) {
353
- // this.instance = new Calendar(date);
354
- // }
355
- // return this.instance;
356
- // }
335
+ //静态方法
336
+ // static init(date) {
337
+ // if (!this.instance) {
338
+ // this.instance = new Calendar(date);
339
+ // }
340
+ // return this.instance;
341
+ // }
357
342
  }
358
343
 
359
-
360
- export default Calendar
344
+ export default Calendar;