@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,1026 +1,1073 @@
1
1
  <template>
2
- <view class="uni-date">
3
- <view class="uni-date-editor" @click="show">
4
- <slot>
5
- <view
6
- class="uni-date-editor--x"
7
- :class="{'uni-date-editor--x__disabled': disabled,'uni-date-x--border': border}"
8
- >
9
- <view v-if="!isRange" class="uni-date-x uni-date-single">
10
- <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
11
- <view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view>
12
- </view>
13
-
14
- <view v-else class="uni-date-x uni-date-range">
15
- <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
16
- <view class="uni-date__x-input text-center">{{ displayRangeValue.startDate || startPlaceholderText }}</view>
17
-
18
- <view class="range-separator">{{rangeSeparator}}</view>
19
-
20
- <view class="uni-date__x-input text-center">{{ displayRangeValue.endDate || endPlaceholderText }}</view>
21
- </view>
22
-
23
- <view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
24
- <uni-icons type="clear" color="#c0c4cc" size="22"></uni-icons>
25
- </view>
26
- </view>
27
- </slot>
28
- </view>
29
-
30
- <view v-show="pickerVisible" class="uni-date-mask--pc" @click="close"></view>
31
-
32
- <view v-if="!isPhone" v-show="pickerVisible" ref="datePicker" class="uni-date-picker__container">
33
- <view v-if="!isRange" class="uni-date-single--x" :style="pickerPositionStyle">
34
- <view class="uni-popper__arrow"></view>
35
-
36
- <view v-if="hasTime" class="uni-date-changed popup-x-header">
37
- <input class="uni-date__input text-center" type="text" v-model="inputDate"
38
- :placeholder="selectDateText" />
39
-
40
- <time-picker type="time" v-model="pickerTime" :border="false" :disabled="!inputDate"
41
- :start="timepickerStartTime" :end="timepickerEndTime" :hideSecond="hideSecond" style="width: 100%;">
42
- <input class="uni-date__input text-center" type="text" v-model="pickerTime" :placeholder="selectTimeText"
43
- :disabled="!inputDate" />
44
- </time-picker>
45
- </view>
46
-
47
- <Calendar ref="pcSingle" :showMonth="false" :start-date="calendarRange.startDate"
48
- :end-date="calendarRange.endDate" :date="calendarDate" @change="singleChange"
49
- :default-value="defaultValue"
50
- style="padding: 0 8px;" />
51
-
52
- <view v-if="hasTime" class="popup-x-footer">
53
- <text class="confirm-text" @click="confirmSingleChange">{{okText}}</text>
54
- </view>
55
- </view>
56
-
57
- <view v-else class="uni-date-range--x" :style="pickerPositionStyle">
58
- <view class="uni-popper__arrow"></view>
59
- <view v-if="hasTime" class="popup-x-header uni-date-changed">
60
- <view class="popup-x-header--datetime">
61
- <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
62
- :placeholder="startDateText" />
63
-
64
- <time-picker type="time" v-model="tempRange.startTime" :start="timepickerStartTime" :border="false"
65
- :disabled="!tempRange.startDate" :hideSecond="hideSecond">
66
- <input class="uni-date__input uni-date-range__input" type="text"
67
- v-model="tempRange.startTime" :placeholder="startTimeText"
68
- :disabled="!tempRange.startDate" />
69
- </time-picker>
2
+ <view class="uni-date">
3
+ <view class="uni-date-editor" @click="show">
4
+ <slot>
5
+ <view class="uni-date-editor--x" :class="{ 'uni-date-editor--x__disabled': disabled, 'uni-date-x--border': border }">
6
+ <view v-if="!isRange" class="uni-date-x uni-date-single">
7
+ <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
8
+ <view class="uni-date__x-input">{{ displayValue || singlePlaceholderText }}</view>
9
+ </view>
10
+
11
+ <view v-else class="uni-date-x uni-date-range">
12
+ <uni-icons class="icon-calendar" type="calendar" color="#c0c4cc" size="22"></uni-icons>
13
+ <view class="uni-date__x-input text-center">{{ displayRangeValue.startDate || startPlaceholderText }}</view>
14
+
15
+ <view class="range-separator">{{ rangeSeparator }}</view>
16
+
17
+ <view class="uni-date__x-input text-center">{{ displayRangeValue.endDate || endPlaceholderText }}</view>
18
+ </view>
19
+
20
+ <view v-if="showClearIcon" class="uni-date__icon-clear" @click.stop="clear">
21
+ <uni-icons type="clear" color="#c0c4cc" size="22"></uni-icons>
22
+ </view>
23
+ </view>
24
+ </slot>
70
25
  </view>
71
26
 
72
- <uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons>
73
-
74
- <view class="popup-x-header--datetime">
75
- <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
76
- :placeholder="endDateText" />
77
-
78
- <time-picker type="time" v-model="tempRange.endTime" :end="timepickerEndTime" :border="false"
79
- :disabled="!tempRange.endDate" :hideSecond="hideSecond">
80
- <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime"
81
- :placeholder="endTimeText" :disabled="!tempRange.endDate" />
82
- </time-picker>
83
- </view>
84
- </view>
85
-
86
- <view class="popup-x-body">
87
- <Calendar ref="left" :showMonth="false" :start-date="calendarRange.startDate"
88
- :end-date="calendarRange.endDate" :range="true" :pleStatus="endMultipleStatus"
89
- @change="leftChange" @firstEnterCale="updateRightCale" style="padding: 0 8px;" />
90
- <Calendar ref="right" :showMonth="false" :start-date="calendarRange.startDate"
91
- :end-date="calendarRange.endDate" :range="true" @change="rightChange"
92
- :pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
93
- style="padding: 0 8px;border-left: 1px solid #F1F1F1;" />
94
- </view>
95
-
96
- <view v-if="hasTime" class="popup-x-footer">
97
- <text @click="clear">{{clearText}}</text>
98
- <text class="confirm-text" @click="confirmRangeChange">{{okText}}</text>
99
- </view>
100
- </view>
101
- </view>
102
-
103
- <Calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="calendarDate" :defTime="mobileCalendarTime"
104
- :start-date="calendarRange.startDate" :end-date="calendarRange.endDate" :selectableTimes="mobSelectableTime"
105
- :startPlaceholder="startPlaceholder" :endPlaceholder="endPlaceholder"
106
- :default-value="defaultValue"
107
- :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :hasTime="hasTime" :insert="false"
108
- :hideSecond="hideSecond" @confirm="mobileChange" @maskClose="close" />
109
- </view>
27
+ <view v-show="pickerVisible" class="uni-date-mask--pc" @click="close"></view>
28
+
29
+ <view v-if="!isPhone" v-show="pickerVisible" ref="datePicker" class="uni-date-picker__container">
30
+ <view v-if="!isRange" class="uni-date-single--x" :style="pickerPositionStyle">
31
+ <view class="uni-popper__arrow"></view>
32
+
33
+ <view v-if="hasTime" class="uni-date-changed popup-x-header">
34
+ <input class="uni-date__input text-center" type="text" v-model="inputDate" :placeholder="selectDateText" />
35
+
36
+ <time-picker
37
+ type="time"
38
+ v-model="pickerTime"
39
+ :border="false"
40
+ :disabled="!inputDate"
41
+ :start="timepickerStartTime"
42
+ :end="timepickerEndTime"
43
+ :hideSecond="hideSecond"
44
+ style="width: 100%"
45
+ >
46
+ <input class="uni-date__input text-center" type="text" v-model="pickerTime" :placeholder="selectTimeText" :disabled="!inputDate" />
47
+ </time-picker>
48
+ </view>
49
+
50
+ <Calendar
51
+ ref="pcSingle"
52
+ :showMonth="false"
53
+ :start-date="calendarRange.startDate"
54
+ :end-date="calendarRange.endDate"
55
+ :date="calendarDate"
56
+ @change="singleChange"
57
+ :default-value="defaultValue"
58
+ style="padding: 0 8px"
59
+ />
60
+
61
+ <view v-if="hasTime" class="popup-x-footer">
62
+ <text class="confirm-text" @click="confirmSingleChange">{{ okText }}</text>
63
+ </view>
64
+ </view>
65
+
66
+ <view v-else class="uni-date-range--x" :style="pickerPositionStyle">
67
+ <view class="uni-popper__arrow"></view>
68
+ <view v-if="hasTime" class="popup-x-header uni-date-changed">
69
+ <view class="popup-x-header--datetime">
70
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate" :placeholder="startDateText" />
71
+
72
+ <time-picker
73
+ type="time"
74
+ v-model="tempRange.startTime"
75
+ :start="timepickerStartTime"
76
+ :border="false"
77
+ :disabled="!tempRange.startDate"
78
+ :hideSecond="hideSecond"
79
+ >
80
+ <input
81
+ class="uni-date__input uni-date-range__input"
82
+ type="text"
83
+ v-model="tempRange.startTime"
84
+ :placeholder="startTimeText"
85
+ :disabled="!tempRange.startDate"
86
+ />
87
+ </time-picker>
88
+ </view>
89
+
90
+ <uni-icons type="arrowthinright" color="#999" style="line-height: 40px"></uni-icons>
91
+
92
+ <view class="popup-x-header--datetime">
93
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate" :placeholder="endDateText" />
94
+
95
+ <time-picker
96
+ type="time"
97
+ v-model="tempRange.endTime"
98
+ :end="timepickerEndTime"
99
+ :border="false"
100
+ :disabled="!tempRange.endDate"
101
+ :hideSecond="hideSecond"
102
+ >
103
+ <input
104
+ class="uni-date__input uni-date-range__input"
105
+ type="text"
106
+ v-model="tempRange.endTime"
107
+ :placeholder="endTimeText"
108
+ :disabled="!tempRange.endDate"
109
+ />
110
+ </time-picker>
111
+ </view>
112
+ </view>
113
+
114
+ <view class="popup-x-body">
115
+ <Calendar
116
+ ref="left"
117
+ :showMonth="false"
118
+ :start-date="calendarRange.startDate"
119
+ :end-date="calendarRange.endDate"
120
+ :range="true"
121
+ :pleStatus="endMultipleStatus"
122
+ @change="leftChange"
123
+ @firstEnterCale="updateRightCale"
124
+ style="padding: 0 8px"
125
+ />
126
+ <Calendar
127
+ ref="right"
128
+ :showMonth="false"
129
+ :start-date="calendarRange.startDate"
130
+ :end-date="calendarRange.endDate"
131
+ :range="true"
132
+ @change="rightChange"
133
+ :pleStatus="startMultipleStatus"
134
+ @firstEnterCale="updateLeftCale"
135
+ style="padding: 0 8px; border-left: 1px solid #f1f1f1"
136
+ />
137
+ </view>
138
+
139
+ <view v-if="hasTime" class="popup-x-footer">
140
+ <text @click="clear">{{ clearText }}</text>
141
+ <text class="confirm-text" @click="confirmRangeChange">{{ okText }}</text>
142
+ </view>
143
+ </view>
144
+ </view>
145
+
146
+ <Calendar
147
+ v-if="isPhone"
148
+ ref="mobile"
149
+ :clearDate="false"
150
+ :date="calendarDate"
151
+ :defTime="mobileCalendarTime"
152
+ :start-date="calendarRange.startDate"
153
+ :end-date="calendarRange.endDate"
154
+ :selectableTimes="mobSelectableTime"
155
+ :startPlaceholder="startPlaceholder"
156
+ :endPlaceholder="endPlaceholder"
157
+ :default-value="defaultValue"
158
+ :pleStatus="endMultipleStatus"
159
+ :showMonth="false"
160
+ :range="isRange"
161
+ :hasTime="hasTime"
162
+ :insert="false"
163
+ :hideSecond="hideSecond"
164
+ @confirm="mobileChange"
165
+ @maskClose="close"
166
+ />
167
+ </view>
110
168
  </template>
111
169
  <script>
112
- /**
113
- * DatetimePicker 时间选择器
114
- * @description 同时支持 PC 和移动端使用日历选择日期和日期范围
115
- * @tutorial https://ext.dcloud.net.cn/plugin?id=3962
116
- * @property {String} type 选择器类型
117
- * @property {String|Number|Array|Date} value 绑定值
118
- * @property {String} placeholder 单选择时的占位内容
119
- * @property {String} start 起始时间
120
- * @property {String} end 终止时间
121
- * @property {String} start-placeholder 范围选择时开始日期的占位内容
122
- * @property {String} end-placeholder 范围选择时结束日期的占位内容
123
- * @property {String} range-separator 选择范围时的分隔符
124
- * @property {Boolean} border = [true|false] 是否有边框
125
- * @property {Boolean} disabled = [true|false] 是否禁用
126
- * @property {Boolean} clearIcon = [true|false] 是否显示清除按钮(仅PC端适用)
127
- * @property {[String} defaultValue 选择器打开时默认显示的时间
128
- * @event {Function} change 确定日期时触发的事件
129
- * @event {Function} maskClick 点击遮罩层触发的事件
130
- * @event {Function} show 打开弹出层
131
- * @event {Function} close 关闭弹出层
132
- * @event {Function} clear 清除上次选中的状态和值
133
- **/
134
- import Calendar from './calendar.vue'
135
- import TimePicker from './time-picker.vue'
136
- import { initVueI18n } from '@dcloudio/uni-i18n'
137
- import i18nMessages from './i18n'
138
- import { getDateTime, getDate, getTime, getDefaultSecond, dateCompare, checkDate, fixIosDateFormat } from './util'
139
-
140
- export default {
141
- name: 'UniDatetimePicker',
142
- options: {
143
- virtualHost: true
144
- },
145
- components: {
146
- Calendar,
147
- TimePicker
148
- },
149
- data() {
150
- return {
151
- isRange: false,
152
- hasTime: false,
153
- displayValue: '',
154
- inputDate: '',
155
- calendarDate: '',
156
- pickerTime: '',
157
- calendarRange: {
158
- startDate: '',
159
- startTime: '',
160
- endDate: '',
161
- endTime: ''
162
- },
163
- displayRangeValue: {
164
- startDate: '',
165
- endDate: '',
166
- },
167
- tempRange: {
168
- startDate: '',
169
- startTime: '',
170
- endDate: '',
171
- endTime: ''
172
- },
173
- // 左右日历同步数据
174
- startMultipleStatus: {
175
- before: '',
176
- after: '',
177
- data: [],
178
- fulldate: ''
179
- },
180
- endMultipleStatus: {
181
- before: '',
182
- after: '',
183
- data: [],
184
- fulldate: ''
185
- },
186
- pickerVisible: false,
187
- pickerPositionStyle: null,
188
- isEmitValue: false,
189
- isPhone: false,
190
- isFirstShow: true,
191
- i18nT: () => {}
192
- }
193
- },
194
- props: {
195
- type: {
196
- type: String,
197
- default: 'datetime'
198
- },
199
- value: {
200
- type: [String, Number, Array, Date],
201
- default: ''
202
- },
203
- modelValue: {
204
- type: [String, Number, Array, Date],
205
- default: ''
206
- },
207
- start: {
208
- type: [Number, String],
209
- default: ''
210
- },
211
- end: {
212
- type: [Number, String],
213
- default: ''
214
- },
215
- returnType: {
216
- type: String,
217
- default: 'string'
218
- },
219
- placeholder: {
220
- type: String,
221
- default: ''
222
- },
223
- startPlaceholder: {
224
- type: String,
225
- default: ''
226
- },
227
- endPlaceholder: {
228
- type: String,
229
- default: ''
230
- },
231
- rangeSeparator: {
232
- type: String,
233
- default: '-'
234
- },
235
- border: {
236
- type: [Boolean],
237
- default: true
238
- },
239
- disabled: {
240
- type: [Boolean],
241
- default: false
242
- },
243
- clearIcon: {
244
- type: [Boolean],
245
- default: true
246
- },
247
- hideSecond: {
248
- type: [Boolean],
249
- default: false
250
- },
251
- defaultValue: {
252
- type: [String, Object, Array],
253
- default: ''
254
- }
255
- },
256
- watch: {
257
- type: {
258
- immediate: true,
259
- handler(newVal) {
260
- this.hasTime = newVal.indexOf('time') !== -1
261
- this.isRange = newVal.indexOf('range') !== -1
262
- }
263
- },
264
- // #ifndef VUE3
265
- value: {
266
- immediate: true,
267
- handler(newVal) {
268
- if (this.isEmitValue) {
269
- this.isEmitValue = false
270
- return
271
- }
272
- this.initPicker(newVal)
273
- }
274
- },
275
- // #endif
276
- // #ifdef VUE3
277
- modelValue: {
278
- immediate: true,
279
- handler(newVal) {
280
- if (this.isEmitValue) {
281
- this.isEmitValue = false
282
- return
283
- }
284
- this.initPicker(newVal)
285
- }
286
- },
287
- // #endif
288
- start: {
289
- immediate: true,
290
- handler(newVal) {
291
- if (!newVal) return
292
- this.calendarRange.startDate = getDate(newVal)
293
- if (this.hasTime) {
294
- this.calendarRange.startTime = getTime(newVal)
295
- }
296
- }
297
- },
298
- end: {
299
- immediate: true,
300
- handler(newVal) {
301
- if (!newVal) return
302
- this.calendarRange.endDate = getDate(newVal)
303
- if (this.hasTime) {
304
- this.calendarRange.endTime = getTime(newVal, this.hideSecond)
305
- }
306
- }
307
- },
308
- },
309
- computed: {
310
- timepickerStartTime() {
311
- const activeDate = this.isRange ? this.tempRange.startDate : this.inputDate
312
- return activeDate === this.calendarRange.startDate ? this.calendarRange.startTime : ''
313
- },
314
- timepickerEndTime() {
315
- const activeDate = this.isRange ? this.tempRange.endDate : this.inputDate
316
- return activeDate === this.calendarRange.endDate ? this.calendarRange.endTime : ''
317
- },
318
- mobileCalendarTime() {
319
- const timeRange = {
320
- start: this.tempRange.startTime,
321
- end: this.tempRange.endTime
322
- }
323
- return this.isRange ? timeRange : this.pickerTime
324
- },
325
- mobSelectableTime() {
326
- return {
327
- start: this.calendarRange.startTime,
328
- end: this.calendarRange.endTime
329
- }
330
- },
331
- datePopupWidth() {
332
- // todo
333
- return this.isRange ? 653 : 301
334
- },
335
-
336
- /**
337
- * for i18n
338
- */
339
- singlePlaceholderText() {
340
- return this.placeholder || (this.type === 'date' ? this.selectDateText : this.selectDateTimeText)
341
- },
342
- startPlaceholderText() {
343
- return this.startPlaceholder || this.startDateText
344
- },
345
- endPlaceholderText() {
346
- return this.endPlaceholder || this.endDateText
347
- },
348
- selectDateText() {
349
- return this.i18nT("uni-datetime-picker.selectDate")
350
- },
351
- selectDateTimeText() {
352
- return this.i18nT("uni-datetime-picker.selectDateTime")
353
- },
354
- selectTimeText() {
355
- return this.i18nT("uni-datetime-picker.selectTime")
356
- },
357
- startDateText() {
358
- return this.startPlaceholder || this.i18nT("uni-datetime-picker.startDate")
359
- },
360
- startTimeText() {
361
- return this.i18nT("uni-datetime-picker.startTime")
362
- },
363
- endDateText() {
364
- return this.endPlaceholder || this.i18nT("uni-datetime-picker.endDate")
365
- },
366
- endTimeText() {
367
- return this.i18nT("uni-datetime-picker.endTime")
368
- },
369
- okText() {
370
- return this.i18nT("uni-datetime-picker.ok")
371
- },
372
- clearText() {
373
- return this.i18nT("uni-datetime-picker.clear")
374
- },
375
- showClearIcon() {
376
- return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this.displayRangeValue.endDate))
377
- }
378
- },
379
- created() {
380
- this.initI18nT()
381
- this.platform()
382
- },
383
- methods: {
384
- initI18nT() {
385
- const vueI18n = initVueI18n(i18nMessages)
386
- this.i18nT = vueI18n.t
387
- },
388
- initPicker(newVal) {
389
- if ((!newVal && !this.defaultValue) || Array.isArray(newVal) && !newVal.length) {
390
- this.$nextTick(() => {
391
- this.clear(false)
392
- })
393
- return
394
- }
395
-
396
- if (!Array.isArray(newVal) && !this.isRange) {
397
- if(newVal){
398
- this.displayValue = this.inputDate = this.calendarDate = getDate(newVal)
399
- if (this.hasTime) {
400
- this.pickerTime = getTime(newVal, this.hideSecond)
401
- this.displayValue = `${this.displayValue} ${this.pickerTime}`
402
- }
403
- }else if(this.defaultValue){
404
- this.inputDate = this.calendarDate = getDate(this.defaultValue)
405
- if(this.hasTime){
406
- this.pickerTime = getTime(this.defaultValue, this.hideSecond)
407
- }
408
- }
409
- } else {
410
- const [before, after] = newVal
411
- if (!before && !after) return
412
- const beforeDate = getDate(before)
413
- const beforeTime = getTime(before, this.hideSecond)
414
-
415
- const afterDate = getDate(after)
416
- const afterTime = getTime(after, this.hideSecond)
417
- const startDate = beforeDate
418
- const endDate = afterDate
419
- this.displayRangeValue.startDate = this.tempRange.startDate = startDate
420
- this.displayRangeValue.endDate = this.tempRange.endDate = endDate
421
-
422
- if (this.hasTime) {
423
- this.displayRangeValue.startDate = `${beforeDate} ${beforeTime}`
424
- this.displayRangeValue.endDate = `${afterDate} ${afterTime}`
425
- this.tempRange.startTime = beforeTime
426
- this.tempRange.endTime = afterTime
427
- }
428
- const defaultRange = {
429
- before: beforeDate,
430
- after: afterDate
431
- }
432
- this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, {
433
- which: 'right'
434
- })
435
- this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, {
436
- which: 'left'
437
- })
438
- }
439
- },
440
- updateLeftCale(e) {
441
- const left = this.$refs.left
442
- // 设置范围选
443
- left.cale.setHoverMultiple(e.after)
444
- left.setDate(this.$refs.left.nowDate.fullDate)
445
- },
446
- updateRightCale(e) {
447
- const right = this.$refs.right
448
- // 设置范围选
449
- right.cale.setHoverMultiple(e.after)
450
- right.setDate(this.$refs.right.nowDate.fullDate)
451
- },
452
- platform() {
453
- const { windowWidth } = uni.getSystemInfoSync()
454
- this.isPhone = windowWidth <= 500
455
- this.windowWidth = windowWidth
456
- },
457
- show() {
458
- if (this.disabled) {
459
- return
460
- }
461
- this.platform()
462
- if (this.isPhone) {
463
- this.$refs.mobile.open()
464
- return
465
- }
466
- this.pickerPositionStyle = {
467
- top: '10px'
468
- }
469
- const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor")
470
- dateEditor.boundingClientRect(rect => {
471
- if (this.windowWidth - rect.left < this.datePopupWidth) {
472
- this.pickerPositionStyle.right = 0
473
- }
474
- }).exec()
475
- setTimeout(() => {
476
- this.pickerVisible = !this.pickerVisible
477
- if (!this.isPhone && this.isRange && this.isFirstShow) {
478
- this.isFirstShow = false
479
- const {
480
- startDate,
481
- endDate
482
- } = this.calendarRange
483
- if (startDate && endDate) {
484
- if (this.diffDate(startDate, endDate) < 30) {
485
- this.$refs.right.changeMonth('pre')
486
- }
487
- } else {
488
- this.$refs.right.changeMonth('next')
489
- this.$refs.right.cale.lastHover = false
490
- }
491
- }
492
-
493
- }, 50)
494
- },
495
- close() {
496
- setTimeout(() => {
497
- this.pickerVisible = false
498
- this.$emit('maskClick', this.value)
499
- this.$refs.mobile && this.$refs.mobile.close()
500
- }, 20)
501
- },
502
- setEmit(value) {
503
- if (this.returnType === "timestamp" || this.returnType === "date") {
504
- if (!Array.isArray(value)) {
505
- if (!this.hasTime) {
506
- value = value + ' ' + '00:00:00'
507
- }
508
- value = this.createTimestamp(value)
509
- if (this.returnType === "date") {
510
- value = new Date(value)
511
- }
512
- } else {
513
- if (!this.hasTime) {
514
- value[0] = value[0] + ' ' + '00:00:00'
515
- value[1] = value[1] + ' ' + '00:00:00'
516
- }
517
- value[0] = this.createTimestamp(value[0])
518
- value[1] = this.createTimestamp(value[1])
519
- if (this.returnType === "date") {
520
- value[0] = new Date(value[0])
521
- value[1] = new Date(value[1])
522
- }
523
- }
524
- }
525
-
526
- this.$emit('update:modelValue', value)
527
- this.$emit('input', value)
528
- this.$emit('change', value)
529
- this.isEmitValue = true
530
- },
531
- createTimestamp(date) {
532
- date = fixIosDateFormat(date)
533
- return Date.parse(new Date(date))
534
- },
535
- singleChange(e) {
536
- this.calendarDate = this.inputDate = e.fulldate
537
- if (this.hasTime) return
538
- this.confirmSingleChange()
539
- },
540
- confirmSingleChange() {
541
- if(!checkDate(this.inputDate)){
542
- const now = new Date()
543
- this.calendarDate = this.inputDate = getDate(now)
544
- this.pickerTime = getTime(now, this.hideSecond)
545
- }
170
+ /**
171
+ * DatetimePicker 时间选择器
172
+ * @description 同时支持 PC 和移动端使用日历选择日期和日期范围
173
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3962
174
+ * @property {String} type 选择器类型
175
+ * @property {String|Number|Array|Date} value 绑定值
176
+ * @property {String} placeholder 单选择时的占位内容
177
+ * @property {String} start 起始时间
178
+ * @property {String} end 终止时间
179
+ * @property {String} start-placeholder 范围选择时开始日期的占位内容
180
+ * @property {String} end-placeholder 范围选择时结束日期的占位内容
181
+ * @property {String} range-separator 选择范围时的分隔符
182
+ * @property {Boolean} border = [true|false] 是否有边框
183
+ * @property {Boolean} disabled = [true|false] 是否禁用
184
+ * @property {Boolean} clearIcon = [true|false] 是否显示清除按钮(仅PC端适用)
185
+ * @property {[String} defaultValue 选择器打开时默认显示的时间
186
+ * @event {Function} change 确定日期时触发的事件
187
+ * @event {Function} maskClick 点击遮罩层触发的事件
188
+ * @event {Function} show 打开弹出层
189
+ * @event {Function} close 关闭弹出层
190
+ * @event {Function} clear 清除上次选中的状态和值
191
+ **/
192
+ import Calendar from './calendar.vue';
193
+ import TimePicker from './time-picker.vue';
194
+ import { initVueI18n } from '@dcloudio/uni-i18n';
195
+ import i18nMessages from './i18n';
196
+ import { checkDate, dateCompare, fixIosDateFormat, getDate, getDateTime, getDefaultSecond, getTime } from './util';
197
+
198
+ export default {
199
+ name: 'UniDatetimePicker',
200
+ options: {
201
+ virtualHost: true,
202
+ },
203
+ components: {
204
+ Calendar,
205
+ TimePicker,
206
+ },
207
+ data() {
208
+ return {
209
+ isRange: false,
210
+ hasTime: false,
211
+ displayValue: '',
212
+ inputDate: '',
213
+ calendarDate: '',
214
+ pickerTime: '',
215
+ calendarRange: {
216
+ startDate: '',
217
+ startTime: '',
218
+ endDate: '',
219
+ endTime: '',
220
+ },
221
+ displayRangeValue: {
222
+ startDate: '',
223
+ endDate: '',
224
+ },
225
+ tempRange: {
226
+ startDate: '',
227
+ startTime: '',
228
+ endDate: '',
229
+ endTime: '',
230
+ },
231
+ // 左右日历同步数据
232
+ startMultipleStatus: {
233
+ before: '',
234
+ after: '',
235
+ data: [],
236
+ fulldate: '',
237
+ },
238
+ endMultipleStatus: {
239
+ before: '',
240
+ after: '',
241
+ data: [],
242
+ fulldate: '',
243
+ },
244
+ pickerVisible: false,
245
+ pickerPositionStyle: null,
246
+ isEmitValue: false,
247
+ isPhone: false,
248
+ isFirstShow: true,
249
+ i18nT: () => {},
250
+ };
251
+ },
252
+ props: {
253
+ type: {
254
+ type: String,
255
+ default: 'datetime',
256
+ },
257
+ value: {
258
+ type: [String, Number, Array, Date],
259
+ default: '',
260
+ },
261
+ modelValue: {
262
+ type: [String, Number, Array, Date],
263
+ default: '',
264
+ },
265
+ start: {
266
+ type: [Number, String],
267
+ default: '',
268
+ },
269
+ end: {
270
+ type: [Number, String],
271
+ default: '',
272
+ },
273
+ returnType: {
274
+ type: String,
275
+ default: 'string',
276
+ },
277
+ placeholder: {
278
+ type: String,
279
+ default: '',
280
+ },
281
+ startPlaceholder: {
282
+ type: String,
283
+ default: '',
284
+ },
285
+ endPlaceholder: {
286
+ type: String,
287
+ default: '',
288
+ },
289
+ rangeSeparator: {
290
+ type: String,
291
+ default: '-',
292
+ },
293
+ border: {
294
+ type: [Boolean],
295
+ default: true,
296
+ },
297
+ disabled: {
298
+ type: [Boolean],
299
+ default: false,
300
+ },
301
+ clearIcon: {
302
+ type: [Boolean],
303
+ default: true,
304
+ },
305
+ hideSecond: {
306
+ type: [Boolean],
307
+ default: false,
308
+ },
309
+ defaultValue: {
310
+ type: [String, Object, Array],
311
+ default: '',
312
+ },
313
+ },
314
+ watch: {
315
+ type: {
316
+ immediate: true,
317
+ handler(newVal) {
318
+ this.hasTime = newVal.indexOf('time') !== -1;
319
+ this.isRange = newVal.indexOf('range') !== -1;
320
+ },
321
+ },
322
+ // #ifndef VUE3
323
+ value: {
324
+ immediate: true,
325
+ handler(newVal) {
326
+ if (this.isEmitValue) {
327
+ this.isEmitValue = false;
328
+ return;
329
+ }
330
+ this.initPicker(newVal);
331
+ },
332
+ },
333
+ // #endif
334
+ // #ifdef VUE3
335
+ modelValue: {
336
+ immediate: true,
337
+ handler(newVal) {
338
+ if (this.isEmitValue) {
339
+ this.isEmitValue = false;
340
+ return;
341
+ }
342
+ this.initPicker(newVal);
343
+ },
344
+ },
345
+ // #endif
346
+ start: {
347
+ immediate: true,
348
+ handler(newVal) {
349
+ if (!newVal) return;
350
+ this.calendarRange.startDate = getDate(newVal);
351
+ if (this.hasTime) {
352
+ this.calendarRange.startTime = getTime(newVal);
353
+ }
354
+ },
355
+ },
356
+ end: {
357
+ immediate: true,
358
+ handler(newVal) {
359
+ if (!newVal) return;
360
+ this.calendarRange.endDate = getDate(newVal);
361
+ if (this.hasTime) {
362
+ this.calendarRange.endTime = getTime(newVal, this.hideSecond);
363
+ }
364
+ },
365
+ },
366
+ },
367
+ computed: {
368
+ timepickerStartTime() {
369
+ const activeDate = this.isRange ? this.tempRange.startDate : this.inputDate;
370
+ return activeDate === this.calendarRange.startDate ? this.calendarRange.startTime : '';
371
+ },
372
+ timepickerEndTime() {
373
+ const activeDate = this.isRange ? this.tempRange.endDate : this.inputDate;
374
+ return activeDate === this.calendarRange.endDate ? this.calendarRange.endTime : '';
375
+ },
376
+ mobileCalendarTime() {
377
+ const timeRange = {
378
+ start: this.tempRange.startTime,
379
+ end: this.tempRange.endTime,
380
+ };
381
+ return this.isRange ? timeRange : this.pickerTime;
382
+ },
383
+ mobSelectableTime() {
384
+ return {
385
+ start: this.calendarRange.startTime,
386
+ end: this.calendarRange.endTime,
387
+ };
388
+ },
389
+ datePopupWidth() {
390
+ // todo
391
+ return this.isRange ? 653 : 301;
392
+ },
393
+
394
+ /**
395
+ * for i18n
396
+ */
397
+ singlePlaceholderText() {
398
+ return this.placeholder || (this.type === 'date' ? this.selectDateText : this.selectDateTimeText);
399
+ },
400
+ startPlaceholderText() {
401
+ return this.startPlaceholder || this.startDateText;
402
+ },
403
+ endPlaceholderText() {
404
+ return this.endPlaceholder || this.endDateText;
405
+ },
406
+ selectDateText() {
407
+ return this.i18nT('uni-datetime-picker.selectDate');
408
+ },
409
+ selectDateTimeText() {
410
+ return this.i18nT('uni-datetime-picker.selectDateTime');
411
+ },
412
+ selectTimeText() {
413
+ return this.i18nT('uni-datetime-picker.selectTime');
414
+ },
415
+ startDateText() {
416
+ return this.startPlaceholder || this.i18nT('uni-datetime-picker.startDate');
417
+ },
418
+ startTimeText() {
419
+ return this.i18nT('uni-datetime-picker.startTime');
420
+ },
421
+ endDateText() {
422
+ return this.endPlaceholder || this.i18nT('uni-datetime-picker.endDate');
423
+ },
424
+ endTimeText() {
425
+ return this.i18nT('uni-datetime-picker.endTime');
426
+ },
427
+ okText() {
428
+ return this.i18nT('uni-datetime-picker.ok');
429
+ },
430
+ clearText() {
431
+ return this.i18nT('uni-datetime-picker.clear');
432
+ },
433
+ showClearIcon() {
434
+ return this.clearIcon && !this.disabled && (this.displayValue || (this.displayRangeValue.startDate && this.displayRangeValue.endDate));
435
+ },
436
+ },
437
+ created() {
438
+ this.initI18nT();
439
+ this.platform();
440
+ },
441
+ methods: {
442
+ initI18nT() {
443
+ const vueI18n = initVueI18n(i18nMessages);
444
+ this.i18nT = vueI18n.t;
445
+ },
446
+ initPicker(newVal) {
447
+ if ((!newVal && !this.defaultValue) || (Array.isArray(newVal) && !newVal.length)) {
448
+ this.$nextTick(() => {
449
+ this.clear(false);
450
+ });
451
+ return;
452
+ }
453
+
454
+ if (!Array.isArray(newVal) && !this.isRange) {
455
+ if (newVal) {
456
+ this.displayValue = this.inputDate = this.calendarDate = getDate(newVal);
457
+ if (this.hasTime) {
458
+ this.pickerTime = getTime(newVal, this.hideSecond);
459
+ this.displayValue = `${this.displayValue} ${this.pickerTime}`;
460
+ }
461
+ } else if (this.defaultValue) {
462
+ this.inputDate = this.calendarDate = getDate(this.defaultValue);
463
+ if (this.hasTime) {
464
+ this.pickerTime = getTime(this.defaultValue, this.hideSecond);
465
+ }
466
+ }
467
+ } else {
468
+ const [before, after] = newVal;
469
+ if (!before && !after) return;
470
+ const beforeDate = getDate(before);
471
+ const beforeTime = getTime(before, this.hideSecond);
472
+
473
+ const afterDate = getDate(after);
474
+ const afterTime = getTime(after, this.hideSecond);
475
+ const startDate = beforeDate;
476
+ const endDate = afterDate;
477
+ this.displayRangeValue.startDate = this.tempRange.startDate = startDate;
478
+ this.displayRangeValue.endDate = this.tempRange.endDate = endDate;
479
+
480
+ if (this.hasTime) {
481
+ this.displayRangeValue.startDate = `${beforeDate} ${beforeTime}`;
482
+ this.displayRangeValue.endDate = `${afterDate} ${afterTime}`;
483
+ this.tempRange.startTime = beforeTime;
484
+ this.tempRange.endTime = afterTime;
485
+ }
486
+ const defaultRange = {
487
+ before: beforeDate,
488
+ after: afterDate,
489
+ };
490
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, {
491
+ which: 'right',
492
+ });
493
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, {
494
+ which: 'left',
495
+ });
496
+ }
497
+ },
498
+ updateLeftCale(e) {
499
+ const left = this.$refs.left;
500
+ // 设置范围选
501
+ left.cale.setHoverMultiple(e.after);
502
+ left.setDate(this.$refs.left.nowDate.fullDate);
503
+ },
504
+ updateRightCale(e) {
505
+ const right = this.$refs.right;
506
+ // 设置范围选
507
+ right.cale.setHoverMultiple(e.after);
508
+ right.setDate(this.$refs.right.nowDate.fullDate);
509
+ },
510
+ platform() {
511
+ const { windowWidth } = uni.getSystemInfoSync();
512
+ this.isPhone = windowWidth <= 500;
513
+ this.windowWidth = windowWidth;
514
+ },
515
+ show() {
516
+ if (this.disabled) {
517
+ return;
518
+ }
519
+ this.platform();
520
+ if (this.isPhone) {
521
+ this.$refs.mobile.open();
522
+ return;
523
+ }
524
+ this.pickerPositionStyle = {
525
+ top: '10px',
526
+ };
527
+ const dateEditor = uni.createSelectorQuery().in(this).select('.uni-date-editor');
528
+ dateEditor
529
+ .boundingClientRect((rect) => {
530
+ if (this.windowWidth - rect.left < this.datePopupWidth) {
531
+ this.pickerPositionStyle.right = 0;
532
+ }
533
+ })
534
+ .exec();
535
+ setTimeout(() => {
536
+ this.pickerVisible = !this.pickerVisible;
537
+ if (!this.isPhone && this.isRange && this.isFirstShow) {
538
+ this.isFirstShow = false;
539
+ const { startDate, endDate } = this.calendarRange;
540
+ if (startDate && endDate) {
541
+ if (this.diffDate(startDate, endDate) < 30) {
542
+ this.$refs.right.changeMonth('pre');
543
+ }
544
+ } else {
545
+ this.$refs.right.changeMonth('next');
546
+ this.$refs.right.cale.lastHover = false;
547
+ }
548
+ }
549
+ }, 50);
550
+ },
551
+ close() {
552
+ setTimeout(() => {
553
+ this.pickerVisible = false;
554
+ this.$emit('maskClick', this.value);
555
+ this.$refs.mobile && this.$refs.mobile.close();
556
+ }, 20);
557
+ },
558
+ setEmit(value) {
559
+ if (this.returnType === 'timestamp' || this.returnType === 'date') {
560
+ if (!Array.isArray(value)) {
561
+ if (!this.hasTime) {
562
+ value = value + ' ' + '00:00:00';
563
+ }
564
+ value = this.createTimestamp(value);
565
+ if (this.returnType === 'date') {
566
+ value = new Date(value);
567
+ }
568
+ } else {
569
+ if (!this.hasTime) {
570
+ value[0] = value[0] + ' ' + '00:00:00';
571
+ value[1] = value[1] + ' ' + '00:00:00';
572
+ }
573
+ value[0] = this.createTimestamp(value[0]);
574
+ value[1] = this.createTimestamp(value[1]);
575
+ if (this.returnType === 'date') {
576
+ value[0] = new Date(value[0]);
577
+ value[1] = new Date(value[1]);
578
+ }
579
+ }
580
+ }
581
+
582
+ this.$emit('update:modelValue', value);
583
+ this.$emit('input', value);
584
+ this.$emit('change', value);
585
+ this.isEmitValue = true;
586
+ },
587
+ createTimestamp(date) {
588
+ date = fixIosDateFormat(date);
589
+ return Date.parse(new Date(date));
590
+ },
591
+ singleChange(e) {
592
+ this.calendarDate = this.inputDate = e.fulldate;
593
+ if (this.hasTime) return;
594
+ this.confirmSingleChange();
595
+ },
596
+ confirmSingleChange() {
597
+ if (!checkDate(this.inputDate)) {
598
+ const now = new Date();
599
+ this.calendarDate = this.inputDate = getDate(now);
600
+ this.pickerTime = getTime(now, this.hideSecond);
601
+ }
602
+
603
+ let startLaterInputDate = false;
604
+ let startDate, startTime;
605
+ if (this.start) {
606
+ let startString = this.start;
607
+ if (typeof this.start === 'number') {
608
+ startString = getDateTime(this.start, this.hideSecond);
609
+ }
610
+ [startDate, startTime] = startString.split(' ');
611
+ if (this.start && !dateCompare(startDate, this.inputDate)) {
612
+ startLaterInputDate = true;
613
+ this.inputDate = startDate;
614
+ }
615
+ }
616
+
617
+ let endEarlierInputDate = false;
618
+ let endDate, endTime;
619
+ if (this.end) {
620
+ let endString = this.end;
621
+ if (typeof this.end === 'number') {
622
+ endString = getDateTime(this.end, this.hideSecond);
623
+ }
624
+ [endDate, endTime] = endString.split(' ');
625
+ if (this.end && !dateCompare(this.inputDate, endDate)) {
626
+ endEarlierInputDate = true;
627
+ this.inputDate = endDate;
628
+ }
629
+ }
630
+ if (this.hasTime) {
631
+ if (startLaterInputDate) {
632
+ this.pickerTime = startTime || getDefaultSecond(this.hideSecond);
633
+ }
634
+ if (endEarlierInputDate) {
635
+ this.pickerTime = endTime || getDefaultSecond(this.hideSecond);
636
+ }
637
+ if (!this.pickerTime) {
638
+ this.pickerTime = getTime(Date.now(), this.hideSecond);
639
+ }
640
+ this.displayValue = `${this.inputDate} ${this.pickerTime}`;
641
+ } else {
642
+ this.displayValue = this.inputDate;
643
+ }
644
+ this.setEmit(this.displayValue);
645
+ this.pickerVisible = false;
646
+ },
647
+ leftChange(e) {
648
+ const { before, after } = e.range;
649
+ this.rangeChange(before, after);
650
+ const obj = {
651
+ before: e.range.before,
652
+ after: e.range.after,
653
+ data: e.range.data,
654
+ fulldate: e.fulldate,
655
+ };
656
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj);
657
+ },
658
+ rightChange(e) {
659
+ const { before, after } = e.range;
660
+ this.rangeChange(before, after);
661
+ const obj = {
662
+ before: e.range.before,
663
+ after: e.range.after,
664
+ data: e.range.data,
665
+ fulldate: e.fulldate,
666
+ };
667
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj);
668
+ },
669
+ mobileChange(e) {
670
+ if (this.isRange) {
671
+ const { before, after } = e.range;
672
+
673
+ if (!before || !after) {
674
+ return;
675
+ }
676
+
677
+ this.handleStartAndEnd(before, after, true);
678
+ if (this.hasTime) {
679
+ const { startTime, endTime } = e.timeRange;
680
+ this.tempRange.startTime = startTime;
681
+ this.tempRange.endTime = endTime;
682
+ }
683
+ this.confirmRangeChange();
684
+ } else {
685
+ if (this.hasTime) {
686
+ this.displayValue = e.fulldate + ' ' + e.time;
687
+ } else {
688
+ this.displayValue = e.fulldate;
689
+ }
690
+ this.setEmit(this.displayValue);
691
+ }
692
+ this.$refs.mobile.close();
693
+ },
694
+ rangeChange(before, after) {
695
+ if (!(before && after)) return;
696
+ this.handleStartAndEnd(before, after, true);
697
+ if (this.hasTime) return;
698
+ this.confirmRangeChange();
699
+ },
700
+ confirmRangeChange() {
701
+ if (!this.tempRange.startDate || !this.tempRange.endDate) {
702
+ this.pickerVisible = false;
703
+ return;
704
+ }
705
+ if (!checkDate(this.tempRange.startDate)) {
706
+ this.tempRange.startDate = getDate(Date.now());
707
+ }
708
+ if (!checkDate(this.tempRange.endDate)) {
709
+ this.tempRange.endDate = getDate(Date.now());
710
+ }
711
+
712
+ let start, end;
713
+
714
+ let startDateLaterRangeStartDate = false;
715
+ let startDateLaterRangeEndDate = false;
716
+ let startDate, startTime;
717
+ if (this.start) {
718
+ let startString = this.start;
719
+ if (typeof this.start === 'number') {
720
+ startString = getDateTime(this.start, this.hideSecond);
721
+ }
722
+ [startDate, startTime] = startString.split(' ');
723
+ if (this.start && !dateCompare(this.start, this.tempRange.startDate)) {
724
+ startDateLaterRangeStartDate = true;
725
+ this.tempRange.startDate = startDate;
726
+ }
727
+ if (this.start && !dateCompare(this.start, this.tempRange.endDate)) {
728
+ startDateLaterRangeEndDate = true;
729
+ this.tempRange.endDate = startDate;
730
+ }
731
+ }
732
+ let endDateEarlierRangeStartDate = false;
733
+ let endDateEarlierRangeEndDate = false;
734
+ let endDate, endTime;
735
+ if (this.end) {
736
+ let endString = this.end;
737
+ if (typeof this.end === 'number') {
738
+ endString = getDateTime(this.end, this.hideSecond);
739
+ }
740
+ [endDate, endTime] = endString.split(' ');
741
+
742
+ if (this.end && !dateCompare(this.tempRange.startDate, this.end)) {
743
+ endDateEarlierRangeStartDate = true;
744
+ this.tempRange.startDate = endDate;
745
+ }
746
+ if (this.end && !dateCompare(this.tempRange.endDate, this.end)) {
747
+ endDateEarlierRangeEndDate = true;
748
+ this.tempRange.endDate = endDate;
749
+ }
750
+ }
751
+ if (!this.hasTime) {
752
+ start = this.displayRangeValue.startDate = this.tempRange.startDate;
753
+ end = this.displayRangeValue.endDate = this.tempRange.endDate;
754
+ } else {
755
+ if (startDateLaterRangeStartDate) {
756
+ this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond);
757
+ } else if (endDateEarlierRangeStartDate) {
758
+ this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond);
759
+ }
760
+ if (!this.tempRange.startTime) {
761
+ this.tempRange.startTime = getTime(Date.now(), this.hideSecond);
762
+ }
763
+
764
+ if (startDateLaterRangeEndDate) {
765
+ this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond);
766
+ } else if (endDateEarlierRangeEndDate) {
767
+ this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond);
768
+ }
769
+ if (!this.tempRange.endTime) {
770
+ this.tempRange.endTime = getTime(Date.now(), this.hideSecond);
771
+ }
772
+ start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}`;
773
+ end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}`;
774
+ }
775
+ if (!dateCompare(start, end)) {
776
+ [start, end] = [end, start];
777
+ }
778
+ this.displayRangeValue.startDate = start;
779
+ this.displayRangeValue.endDate = end;
780
+ const displayRange = [start, end];
781
+ this.setEmit(displayRange);
782
+ this.pickerVisible = false;
783
+ },
784
+ handleStartAndEnd(before, after, temp = false) {
785
+ if (!(before && after)) return;
786
+
787
+ const type = temp ? 'tempRange' : 'range';
788
+ const isStartEarlierEnd = dateCompare(before, after);
789
+ this[type].startDate = isStartEarlierEnd ? before : after;
790
+ this[type].endDate = isStartEarlierEnd ? after : before;
791
+ },
792
+ /**
793
+ * 比较时间大小
794
+ */
795
+ dateCompare(startDate, endDate) {
796
+ // 计算截止时间
797
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'));
798
+ // 计算详细项的截止时间
799
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'));
800
+ return startDate <= endDate;
801
+ },
802
+
803
+ /**
804
+ * 比较时间差
805
+ */
806
+ diffDate(startDate, endDate) {
807
+ // 计算截止时间
808
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'));
809
+ // 计算详细项的截止时间
810
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'));
811
+ const diff = (endDate - startDate) / (24 * 60 * 60 * 1000);
812
+ return Math.abs(diff);
813
+ },
814
+
815
+ clear(needEmit = true) {
816
+ if (!this.isRange) {
817
+ this.displayValue = '';
818
+ this.inputDate = '';
819
+ this.pickerTime = '';
820
+ if (this.isPhone) {
821
+ this.$refs.mobile && this.$refs.mobile.clearCalender();
822
+ } else {
823
+ this.$refs.pcSingle && this.$refs.pcSingle.clearCalender();
824
+ }
825
+ if (needEmit) {
826
+ this.$emit('change', '');
827
+ this.$emit('input', '');
828
+ this.$emit('update:modelValue', '');
829
+ }
830
+ } else {
831
+ this.displayRangeValue.startDate = '';
832
+ this.displayRangeValue.endDate = '';
833
+ this.tempRange.startDate = '';
834
+ this.tempRange.startTime = '';
835
+ this.tempRange.endDate = '';
836
+ this.tempRange.endTime = '';
837
+ if (this.isPhone) {
838
+ this.$refs.mobile && this.$refs.mobile.clearCalender();
839
+ } else {
840
+ this.$refs.left && this.$refs.left.clearCalender();
841
+ this.$refs.right && this.$refs.right.clearCalender();
842
+ this.$refs.right && this.$refs.right.changeMonth('next');
843
+ }
844
+ if (needEmit) {
845
+ this.$emit('change', []);
846
+ this.$emit('input', []);
847
+ this.$emit('update:modelValue', []);
848
+ }
849
+ }
850
+ },
851
+ },
852
+ };
853
+ </script>
546
854
 
547
- let startLaterInputDate = false
548
- let startDate, startTime
549
- if(this.start) {
550
- let startString = this.start
551
- if(typeof this.start === 'number'){
552
- startString = getDateTime(this.start, this.hideSecond)
553
- }
554
- [startDate, startTime] = startString.split(' ')
555
- if(this.start && !dateCompare(startDate, this.inputDate)) {
556
- startLaterInputDate = true
557
- this.inputDate = startDate
558
- }
559
- }
855
+ <style lang="scss">
856
+ $uni-primary: #007aff !default;
560
857
 
561
- let endEarlierInputDate = false
562
- let endDate, endTime
563
- if(this.end) {
564
- let endString = this.end
565
- if(typeof this.end === 'number'){
566
- endString = getDateTime(this.end, this.hideSecond)
567
- }
568
- [endDate, endTime] = endString.split(' ')
569
- if(this.end && !dateCompare(this.inputDate, endDate)) {
570
- endEarlierInputDate = true
571
- this.inputDate = endDate
572
- }
573
- }
574
- if (this.hasTime) {
575
- if(startLaterInputDate){
576
- this.pickerTime = startTime || getDefaultSecond(this.hideSecond)
577
- }
578
- if(endEarlierInputDate){
579
- this.pickerTime = endTime || getDefaultSecond(this.hideSecond)
580
- }
581
- if(!this.pickerTime){
582
- this.pickerTime = getTime(Date.now(), this.hideSecond)
583
- }
584
- this.displayValue = `${this.inputDate} ${this.pickerTime}`
585
- } else {
586
- this.displayValue = this.inputDate
587
- }
588
- this.setEmit(this.displayValue)
589
- this.pickerVisible = false
590
- },
591
- leftChange(e) {
592
- const {
593
- before,
594
- after
595
- } = e.range
596
- this.rangeChange(before, after)
597
- const obj = {
598
- before: e.range.before,
599
- after: e.range.after,
600
- data: e.range.data,
601
- fulldate: e.fulldate
602
- }
603
- this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj)
604
- },
605
- rightChange(e) {
606
- const {
607
- before,
608
- after
609
- } = e.range
610
- this.rangeChange(before, after)
611
- const obj = {
612
- before: e.range.before,
613
- after: e.range.after,
614
- data: e.range.data,
615
- fulldate: e.fulldate
616
- }
617
- this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj)
618
- },
619
- mobileChange(e) {
620
- if (this.isRange) {
621
- const {before, after} = e.range
622
-
623
- if(!before || !after){
624
- return
625
- }
626
-
627
- this.handleStartAndEnd(before, after, true)
628
- if (this.hasTime) {
629
- const {
630
- startTime,
631
- endTime
632
- } = e.timeRange
633
- this.tempRange.startTime = startTime
634
- this.tempRange.endTime = endTime
635
- }
636
- this.confirmRangeChange()
637
- } else {
638
- if (this.hasTime) {
639
- this.displayValue = e.fulldate + ' ' + e.time
640
- } else {
641
- this.displayValue = e.fulldate
642
- }
643
- this.setEmit(this.displayValue)
644
- }
645
- this.$refs.mobile.close()
646
- },
647
- rangeChange(before, after) {
648
- if (!(before && after)) return
649
- this.handleStartAndEnd(before, after, true)
650
- if (this.hasTime) return
651
- this.confirmRangeChange()
652
- },
653
- confirmRangeChange() {
654
- if (!this.tempRange.startDate || !this.tempRange.endDate) {
655
- this.pickerVisible = false
656
- return
657
- }
658
- if(!checkDate(this.tempRange.startDate)){
659
- this.tempRange.startDate = getDate(Date.now())
858
+ .uni-date {
859
+ width: 100%;
860
+ flex: 1;
861
+ }
862
+ .uni-date-x {
863
+ display: flex;
864
+ flex-direction: row;
865
+ align-items: center;
866
+ justify-content: center;
867
+ border-radius: 4px;
868
+ background-color: #fff;
869
+ color: #666;
870
+ font-size: 14px;
871
+ flex: 1;
872
+
873
+ .icon-calendar {
874
+ padding-left: 3px;
660
875
  }
661
- if(!checkDate(this.tempRange.endDate)){
662
- this.tempRange.endDate = getDate(Date.now())
876
+ .range-separator {
877
+ height: 35px;
878
+ /* #ifndef MP */
879
+ padding: 0 2px;
880
+ /* #endif */
881
+ line-height: 35px;
663
882
  }
883
+ }
664
884
 
665
- let start, end
666
-
667
- let startDateLaterRangeStartDate = false
668
- let startDateLaterRangeEndDate = false
669
- let startDate, startTime
670
- if(this.start) {
671
- let startString = this.start
672
- if(typeof this.start === 'number'){
673
- startString = getDateTime(this.start, this.hideSecond)
674
- }
675
- [startDate,startTime] = startString.split(' ')
676
- if(this.start && !dateCompare(this.start, this.tempRange.startDate)) {
677
- startDateLaterRangeStartDate = true
678
- this.tempRange.startDate = startDate
679
- }
680
- if(this.start && !dateCompare(this.start, this.tempRange.endDate)) {
681
- startDateLaterRangeEndDate = true
682
- this.tempRange.endDate = startDate
683
- }
684
- }
685
- let endDateEarlierRangeStartDate = false
686
- let endDateEarlierRangeEndDate = false
687
- let endDate, endTime
688
- if(this.end) {
689
- let endString = this.end
690
- if(typeof this.end === 'number'){
691
- endString = getDateTime(this.end, this.hideSecond)
692
- }
693
- [endDate,endTime] = endString.split(' ')
694
-
695
- if(this.end && !dateCompare(this.tempRange.startDate, this.end)) {
696
- endDateEarlierRangeStartDate = true
697
- this.tempRange.startDate = endDate
698
- }
699
- if(this.end && !dateCompare(this.tempRange.endDate, this.end)) {
700
- endDateEarlierRangeEndDate = true
701
- this.tempRange.endDate = endDate
702
- }
703
- }
704
- if (!this.hasTime) {
705
- start = this.displayRangeValue.startDate = this.tempRange.startDate
706
- end = this.displayRangeValue.endDate = this.tempRange.endDate
707
- } else {
708
- if(startDateLaterRangeStartDate){
709
- this.tempRange.startTime = startTime || getDefaultSecond(this.hideSecond)
710
- }else if(endDateEarlierRangeStartDate){
711
- this.tempRange.startTime = endTime || getDefaultSecond(this.hideSecond)
712
- }
713
- if(!this.tempRange.startTime){
714
- this.tempRange.startTime = getTime(Date.now(), this.hideSecond)
715
- }
716
-
717
- if(startDateLaterRangeEndDate){
718
- this.tempRange.endTime = startTime || getDefaultSecond(this.hideSecond)
719
- }else if(endDateEarlierRangeEndDate){
720
- this.tempRange.endTime = endTime || getDefaultSecond(this.hideSecond)
721
- }
722
- if(!this.tempRange.endTime){
723
- this.tempRange.endTime = getTime(Date.now(), this.hideSecond)
724
- }
725
- start = this.displayRangeValue.startDate = `${this.tempRange.startDate} ${this.tempRange.startTime}`
726
- end = this.displayRangeValue.endDate = `${this.tempRange.endDate} ${this.tempRange.endTime}`
727
- }
728
- if(!dateCompare(start,end)){
729
- [start, end] = [end, start]
730
- }
731
- this.displayRangeValue.startDate = start
732
- this.displayRangeValue.endDate = end
733
- const displayRange = [start, end]
734
- this.setEmit(displayRange)
735
- this.pickerVisible = false
736
- },
737
- handleStartAndEnd(before, after, temp = false) {
738
- if (!(before && after)) return
739
-
740
- const type = temp ? 'tempRange' : 'range'
741
- const isStartEarlierEnd = dateCompare(before, after)
742
- this[type].startDate = isStartEarlierEnd ? before : after
743
- this[type].endDate = isStartEarlierEnd ? after : before
744
- },
745
- /**
746
- * 比较时间大小
747
- */
748
- dateCompare(startDate, endDate) {
749
- // 计算截止时间
750
- startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
751
- // 计算详细项的截止时间
752
- endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
753
- return startDate <= endDate
754
- },
755
-
756
- /**
757
- * 比较时间差
758
- */
759
- diffDate(startDate, endDate) {
760
- // 计算截止时间
761
- startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
762
- // 计算详细项的截止时间
763
- endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
764
- const diff = (endDate - startDate) / (24 * 60 * 60 * 1000)
765
- return Math.abs(diff)
766
- },
767
-
768
- clear(needEmit = true) {
769
- if (!this.isRange) {
770
- this.displayValue = ''
771
- this.inputDate = ''
772
- this.pickerTime = ''
773
- if (this.isPhone) {
774
- this.$refs.mobile && this.$refs.mobile.clearCalender()
775
- } else {
776
- this.$refs.pcSingle && this.$refs.pcSingle.clearCalender()
777
- }
778
- if (needEmit) {
779
- this.$emit('change', '')
780
- this.$emit('input', '')
781
- this.$emit('update:modelValue', '')
782
- }
783
- } else {
784
- this.displayRangeValue.startDate = ''
785
- this.displayRangeValue.endDate = ''
786
- this.tempRange.startDate = ''
787
- this.tempRange.startTime = ''
788
- this.tempRange.endDate = ''
789
- this.tempRange.endTime = ''
790
- if (this.isPhone) {
791
- this.$refs.mobile && this.$refs.mobile.clearCalender()
792
- } else {
793
- this.$refs.left && this.$refs.left.clearCalender()
794
- this.$refs.right && this.$refs.right.clearCalender()
795
- this.$refs.right && this.$refs.right.changeMonth('next')
796
- }
797
- if (needEmit) {
798
- this.$emit('change', [])
799
- this.$emit('input', [])
800
- this.$emit('update:modelValue', [])
801
- }
802
- }
803
- }
804
- }
805
- }
806
- </script>
885
+ .uni-date-x--border {
886
+ box-sizing: border-box;
887
+ border-radius: 4px;
888
+ border: 1px solid #e5e5e5;
889
+ }
807
890
 
808
- <style lang="scss">
809
- $uni-primary: #007aff !default;
810
-
811
- .uni-date {
812
- width: 100%;
813
- flex: 1;
814
- }
815
- .uni-date-x {
816
- display: flex;
817
- flex-direction: row;
818
- align-items: center;
819
- justify-content: center;
820
- border-radius: 4px;
821
- background-color: #fff;
822
- color: #666;
823
- font-size: 14px;
824
- flex: 1;
825
-
826
- .icon-calendar{
827
- padding-left: 3px;
891
+ .uni-date-editor--x {
892
+ display: flex;
893
+ align-items: center;
894
+ position: relative;
895
+ }
896
+
897
+ .uni-date-editor--x .uni-date__icon-clear {
898
+ padding-right: 3px;
899
+ display: flex;
900
+ align-items: center;
901
+ /* #ifdef H5 */
902
+ cursor: pointer;
903
+ /* #endif */
904
+ }
905
+
906
+ .uni-date__x-input {
907
+ width: auto;
908
+ height: 35px;
909
+ /* #ifndef MP */
910
+ padding-left: 5px;
911
+ /* #endif */
912
+ position: relative;
913
+ flex: 1;
914
+ line-height: 35px;
915
+ font-size: 14px;
916
+ overflow: hidden;
917
+ }
918
+
919
+ .text-center {
920
+ text-align: center;
921
+ }
922
+
923
+ .uni-date__input {
924
+ height: 40px;
925
+ width: 100%;
926
+ line-height: 40px;
927
+ font-size: 14px;
928
+ }
929
+
930
+ .uni-date-range__input {
931
+ text-align: center;
932
+ max-width: 142px;
933
+ }
934
+
935
+ .uni-date-picker__container {
936
+ position: relative;
937
+ }
938
+
939
+ .uni-date-mask--pc {
940
+ position: fixed;
941
+ bottom: 0px;
942
+ top: 0px;
943
+ left: 0px;
944
+ right: 0px;
945
+ background-color: rgba(0, 0, 0, 0);
946
+ transition-duration: 0.3s;
947
+ z-index: 996;
948
+ }
949
+
950
+ .uni-date-single--x {
951
+ background-color: #fff;
952
+ position: absolute;
953
+ top: 0;
954
+ z-index: 999;
955
+ border: 1px solid #ebeef5;
956
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
957
+ border-radius: 4px;
958
+ }
959
+
960
+ .uni-date-range--x {
961
+ background-color: #fff;
962
+ position: absolute;
963
+ top: 0;
964
+ z-index: 999;
965
+ border: 1px solid #ebeef5;
966
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
967
+ border-radius: 4px;
968
+ }
969
+
970
+ .uni-date-editor--x__disabled {
971
+ opacity: 0.4;
972
+ cursor: default;
973
+ }
974
+
975
+ .uni-date-editor--logo {
976
+ width: 16px;
977
+ height: 16px;
978
+ vertical-align: middle;
979
+ }
980
+
981
+ /* 添加时间 */
982
+ .popup-x-header {
983
+ /* #ifndef APP-NVUE */
984
+ display: flex;
985
+ /* #endif */
986
+ flex-direction: row;
987
+ }
988
+
989
+ .popup-x-header--datetime {
990
+ /* #ifndef APP-NVUE */
991
+ display: flex;
992
+ /* #endif */
993
+ flex-direction: row;
994
+ flex: 1;
995
+ }
996
+
997
+ .popup-x-body {
998
+ display: flex;
999
+ }
1000
+
1001
+ .popup-x-footer {
1002
+ padding: 0 15px;
1003
+ border-top-color: #f1f1f1;
1004
+ border-top-style: solid;
1005
+ border-top-width: 1px;
1006
+ line-height: 40px;
1007
+ text-align: right;
1008
+ color: #666;
1009
+ }
1010
+
1011
+ .popup-x-footer text:hover {
1012
+ color: $uni-primary;
1013
+ cursor: pointer;
1014
+ opacity: 0.8;
1015
+ }
1016
+
1017
+ .popup-x-footer .confirm-text {
1018
+ margin-left: 20px;
1019
+ color: $uni-primary;
1020
+ }
1021
+
1022
+ .uni-date-changed {
1023
+ text-align: center;
1024
+ color: #333;
1025
+ border-bottom-color: #f1f1f1;
1026
+ border-bottom-style: solid;
1027
+ border-bottom-width: 1px;
1028
+ }
1029
+
1030
+ .uni-date-changed--time text {
1031
+ height: 50px;
1032
+ line-height: 50px;
1033
+ }
1034
+
1035
+ .uni-date-changed .uni-date-changed--time {
1036
+ flex: 1;
1037
+ }
1038
+
1039
+ .uni-date-changed--time-date {
1040
+ color: #333;
1041
+ opacity: 0.6;
1042
+ }
1043
+
1044
+ .mr-50 {
1045
+ margin-right: 50px;
1046
+ }
1047
+
1048
+ /* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
1049
+ .uni-popper__arrow,
1050
+ .uni-popper__arrow::after {
1051
+ position: absolute;
1052
+ display: block;
1053
+ width: 0;
1054
+ height: 0;
1055
+ border: 6px solid transparent;
1056
+ border-top-width: 0;
1057
+ }
1058
+
1059
+ .uni-popper__arrow {
1060
+ filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
1061
+ top: -6px;
1062
+ left: 10%;
1063
+ margin-right: 3px;
1064
+ border-bottom-color: #ebeef5;
828
1065
  }
829
- .range-separator{
830
- height: 35px;
831
- /* #ifndef MP */
832
- padding: 0 2px;
833
- /* #endif */
834
- line-height: 35px;
1066
+
1067
+ .uni-popper__arrow::after {
1068
+ content: ' ';
1069
+ top: 1px;
1070
+ margin-left: -6px;
1071
+ border-bottom-color: #fff;
835
1072
  }
836
- }
837
-
838
- .uni-date-x--border {
839
- box-sizing: border-box;
840
- border-radius: 4px;
841
- border: 1px solid #e5e5e5;
842
- }
843
-
844
- .uni-date-editor--x {
845
- display: flex;
846
- align-items: center;
847
- position: relative;
848
- }
849
-
850
- .uni-date-editor--x .uni-date__icon-clear {
851
- padding-right: 3px;
852
- display: flex;
853
- align-items: center;
854
- /* #ifdef H5 */
855
- cursor: pointer;
856
- /* #endif */
857
- }
858
-
859
- .uni-date__x-input {
860
- width: auto;
861
- height: 35px;
862
- /* #ifndef MP */
863
- padding-left: 5px;
864
- /* #endif */
865
- position: relative;
866
- flex: 1;
867
- line-height: 35px;
868
- font-size: 14px;
869
- overflow: hidden;
870
- }
871
-
872
- .text-center {
873
- text-align: center;
874
- }
875
-
876
- .uni-date__input {
877
- height: 40px;
878
- width: 100%;
879
- line-height: 40px;
880
- font-size: 14px;
881
- }
882
-
883
- .uni-date-range__input {
884
- text-align: center;
885
- max-width: 142px;
886
- }
887
-
888
- .uni-date-picker__container {
889
- position: relative;
890
- }
891
-
892
- .uni-date-mask--pc {
893
- position: fixed;
894
- bottom: 0px;
895
- top: 0px;
896
- left: 0px;
897
- right: 0px;
898
- background-color: rgba(0, 0, 0, 0);
899
- transition-duration: 0.3s;
900
- z-index: 996;
901
- }
902
-
903
- .uni-date-single--x {
904
- background-color: #fff;
905
- position: absolute;
906
- top: 0;
907
- z-index: 999;
908
- border: 1px solid #EBEEF5;
909
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
910
- border-radius: 4px;
911
- }
912
-
913
- .uni-date-range--x {
914
- background-color: #fff;
915
- position: absolute;
916
- top: 0;
917
- z-index: 999;
918
- border: 1px solid #EBEEF5;
919
- box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
920
- border-radius: 4px;
921
- }
922
-
923
- .uni-date-editor--x__disabled {
924
- opacity: 0.4;
925
- cursor: default;
926
- }
927
-
928
- .uni-date-editor--logo {
929
- width: 16px;
930
- height: 16px;
931
- vertical-align: middle;
932
- }
933
-
934
- /* 添加时间 */
935
- .popup-x-header {
936
- /* #ifndef APP-NVUE */
937
- display: flex;
938
- /* #endif */
939
- flex-direction: row;
940
- }
941
-
942
- .popup-x-header--datetime {
943
- /* #ifndef APP-NVUE */
944
- display: flex;
945
- /* #endif */
946
- flex-direction: row;
947
- flex: 1;
948
- }
949
-
950
- .popup-x-body {
951
- display: flex;
952
- }
953
-
954
- .popup-x-footer {
955
- padding: 0 15px;
956
- border-top-color: #F1F1F1;
957
- border-top-style: solid;
958
- border-top-width: 1px;
959
- line-height: 40px;
960
- text-align: right;
961
- color: #666;
962
- }
963
-
964
- .popup-x-footer text:hover {
965
- color: $uni-primary;
966
- cursor: pointer;
967
- opacity: 0.8;
968
- }
969
-
970
- .popup-x-footer .confirm-text {
971
- margin-left: 20px;
972
- color: $uni-primary;
973
- }
974
-
975
- .uni-date-changed {
976
- text-align: center;
977
- color: #333;
978
- border-bottom-color: #F1F1F1;
979
- border-bottom-style: solid;
980
- border-bottom-width: 1px;
981
- }
982
-
983
- .uni-date-changed--time text {
984
- height: 50px;
985
- line-height: 50px;
986
- }
987
-
988
- .uni-date-changed .uni-date-changed--time {
989
- flex: 1;
990
- }
991
-
992
- .uni-date-changed--time-date {
993
- color: #333;
994
- opacity: 0.6;
995
- }
996
-
997
- .mr-50 {
998
- margin-right: 50px;
999
- }
1000
-
1001
- /* picker 弹出层通用的指示小三角, todo:扩展至上下左右方向定位 */
1002
- .uni-popper__arrow,
1003
- .uni-popper__arrow::after {
1004
- position: absolute;
1005
- display: block;
1006
- width: 0;
1007
- height: 0;
1008
- border: 6px solid transparent;
1009
- border-top-width: 0;
1010
- }
1011
-
1012
- .uni-popper__arrow {
1013
- filter: drop-shadow(0 2px 12px rgba(0, 0, 0, 0.03));
1014
- top: -6px;
1015
- left: 10%;
1016
- margin-right: 3px;
1017
- border-bottom-color: #EBEEF5;
1018
- }
1019
-
1020
- .uni-popper__arrow::after {
1021
- content: " ";
1022
- top: 1px;
1023
- margin-left: -6px;
1024
- border-bottom-color: #fff;
1025
- }
1026
1073
  </style>