@kengic/uni 0.6.3-beta.6 → 0.6.3-beta.61

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