@10yun/cv-mobile-ui 0.4.2 → 0.4.4

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 (168) hide show
  1. package/package.json +1 -1
  2. package/ui-cv/cv-form-item/cv-form-item.vue +1 -1
  3. package/ui-cv/cv-input-password/cv-input-password.vue +2 -2
  4. package/ui-uni/amap-wx/js/util.js +166 -158
  5. package/ui-uni/page-foot/page-foot.vue +38 -0
  6. package/ui-uni/page-head/page-head.vue +16 -0
  7. package/ui-uni/product.vue +52 -52
  8. package/ui-uni/u-charts/u-charts.js +743 -1092
  9. package/ui-uni/u-link/u-link.vue +59 -0
  10. package/ui-uni/uni-badge/uni-badge.vue +250 -0
  11. package/ui-uni/uni-calendar/calendar.js +546 -0
  12. package/ui-uni/uni-calendar/uni-calendar-item.vue +171 -0
  13. package/ui-uni/uni-calendar/uni-calendar.vue +504 -0
  14. package/{ui-cv/cv-calendar → ui-uni/uni-calendar}/util.js +0 -0
  15. package/ui-uni/uni-card/uni-card.vue +420 -0
  16. package/ui-uni/uni-col/uni-col.vue +2968 -0
  17. package/ui-uni/uni-collapse/uni-collapse.vue +146 -0
  18. package/ui-uni/uni-collapse-item/uni-collapse-item.vue +378 -0
  19. package/ui-uni/uni-combox/uni-combox.vue +237 -0
  20. package/ui-uni/uni-countdown/uni-countdown.vue +234 -0
  21. package/ui-uni/uni-data-checkbox/uni-data-checkbox.vue +792 -0
  22. package/{ui-cv/cv-data-indexed-list → ui-uni/uni-data-indexed-list}/clientdb.js +0 -0
  23. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list-item.vue +142 -0
  24. package/ui-uni/uni-data-indexed-list/uni-data-indexed-list.vue +364 -0
  25. package/{ui-cv/cv-data-picker → ui-uni/uni-data-picker}/keypress.js +0 -0
  26. package/ui-uni/uni-data-picker/uni-data-picker.vue +468 -0
  27. package/{ui-cv/cv-data-pickerview/cv-data-picker.js → ui-uni/uni-data-pickerview/uni-data-picker.js} +0 -0
  28. package/ui-uni/uni-data-pickerview/uni-data-pickerview.vue +298 -0
  29. package/{ui-cv/cv-dateformat → ui-uni/uni-dateformat}/date-format.js +0 -0
  30. package/ui-uni/uni-dateformat/uni-dateformat.vue +88 -0
  31. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar-item.vue +0 -0
  32. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/calendar.js +0 -0
  33. package/ui-uni/uni-datetime-picker/calendar.vue +747 -0
  34. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/keypress.js +0 -0
  35. package/ui-uni/uni-datetime-picker/time-picker.vue +899 -0
  36. package/ui-uni/uni-datetime-picker/uni-datetime-picker.vue +874 -0
  37. package/{ui-cv/cv-datetime-picker → ui-uni/uni-datetime-picker}/util.js +0 -0
  38. package/ui-uni/uni-drawer/keypress.js +45 -0
  39. package/ui-uni/uni-drawer/uni-drawer.vue +178 -0
  40. package/{ui-cv/cv-easyinput → ui-uni/uni-easyinput}/common.js +0 -0
  41. package/ui-uni/uni-easyinput/uni-easyinput.vue +438 -0
  42. package/ui-uni/uni-fab/uni-fab.vue +443 -0
  43. package/{ui-cv/cv-fab/cv-fab.vue.bak → ui-uni/uni-fab/uni-fab.vue.bak} +2 -2
  44. package/ui-uni/uni-fav/uni-fav.vue +136 -0
  45. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/choose-and-upload-file.js +0 -0
  46. package/ui-uni/uni-file-picker/uni-file-picker.vue +614 -0
  47. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-file.vue +0 -0
  48. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/upload-image.vue +0 -0
  49. package/{ui-cv/cv-file-picker → ui-uni/uni-file-picker}/utils.js +0 -0
  50. package/ui-uni/uni-forms/uni-forms.vue +467 -0
  51. package/ui-uni/uni-forms/validate.js +486 -0
  52. package/ui-uni/uni-forms-item/uni-forms-item.vue +500 -0
  53. package/{ui-cv/cv-goods-nav/cv-goods-nav.vue → ui-uni/uni-goods-nav/uni-goods-nav.vue} +1 -1
  54. package/ui-uni/uni-grid/uni-grid.vue +141 -0
  55. package/ui-uni/uni-grid-item/uni-grid-item.vue +123 -0
  56. package/ui-uni/uni-group/uni-group.vue +123 -0
  57. package/ui-uni/uni-icons/icons.js +132 -0
  58. package/ui-uni/uni-icons/uni-icons.vue +72 -0
  59. package/{ui-cv/cv-icon2 → ui-uni/uni-icons}/uni.ttf +0 -0
  60. package/ui-uni/uni-indexed-list/uni-indexed-list-item.vue +142 -0
  61. package/ui-uni/uni-indexed-list/uni-indexed-list.vue +357 -0
  62. package/ui-uni/uni-link/uni-link.vue +117 -0
  63. package/ui-uni/uni-list/uni-list.vue +107 -0
  64. package/ui-uni/uni-list/uni-refresh.vue +65 -0
  65. package/{ui-cv/cv-list → ui-uni/uni-list}/uni-refresh.wxs +0 -0
  66. package/ui-uni/uni-list-ad/uni-list-ad.vue +106 -0
  67. package/{ui-cv/cv-list-chat/cv-list-chat.scss → ui-uni/uni-list-chat/uni-list-chat.scss} +0 -0
  68. package/{ui-cv/cv-list-chat/cv-list-chat.vue → ui-uni/uni-list-chat/uni-list-chat.vue} +0 -0
  69. package/ui-uni/uni-list-item/uni-list-item.vue +428 -0
  70. package/ui-uni/uni-load-more/uni-load-more.vue +366 -0
  71. package/ui-uni/uni-nav-bar/uni-nav-bar.vue +244 -0
  72. package/{ui-cv/cv-nav-bar/cv-status-bar.vue → ui-uni/uni-nav-bar/uni-status-bar.vue} +0 -0
  73. package/ui-uni/uni-notice-bar/uni-notice-bar.vue +394 -0
  74. package/ui-uni/uni-number-box/uni-number-box.vue +224 -0
  75. package/ui-uni/uni-pagination/uni-pagination.vue +376 -0
  76. package/{ui-cv/cv-popup → ui-uni/uni-popup}/keypress.js +0 -0
  77. package/{ui-cv/cv-popup → ui-uni/uni-popup}/popup.js +0 -0
  78. package/ui-uni/uni-popup/uni-popup.vue +412 -0
  79. package/{ui-cv/cv-popup-dialog → ui-uni/uni-popup-dialog}/keypress.js +0 -0
  80. package/{ui-cv/cv-popup-dialog/cv-popup-dialog.vue → ui-uni/uni-popup-dialog/uni-popup-dialog.vue} +0 -0
  81. package/ui-uni/uni-popup-message/uni-popup-message.vue +143 -0
  82. package/{ui-cv/cv-popup-share/cv-popup-share.vue → ui-uni/uni-popup-share/uni-popup-share.vue} +0 -0
  83. package/ui-uni/uni-rate/uni-rate.vue +357 -0
  84. package/ui-uni/uni-row/uni-row.vue +155 -0
  85. package/ui-uni/uni-search-bar/uni-search-bar.vue +262 -0
  86. package/{ui-cv/cv-section/cv-section.vue → ui-uni/uni-section/uni-section.vue} +0 -0
  87. package/{ui-cv/cv-segmented-control/cv-segmented-control.vue → ui-uni/uni-segmented-control/uni-segmented-control.vue} +0 -0
  88. package/{ui-cv/cv-status-bar/cv-status-bar.vue → ui-uni/uni-status-bar/uni-status-bar.vue} +0 -0
  89. package/ui-uni/uni-steps/uni-steps.vue +250 -0
  90. package/{ui-cv/cv-swipe-action/cv-swipe-action.vue → ui-uni/uni-swipe-action/uni-swipe-action.vue} +0 -0
  91. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/bindingx.js +0 -0
  92. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/index.wxs +0 -0
  93. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/isPC.js +0 -0
  94. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpalipay.js +0 -0
  95. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpother.js +0 -0
  96. package/{ui-cv/cv-swipe-action-item → ui-uni/uni-swipe-action-item}/mpwxs.js +0 -0
  97. package/{ui-cv/cv-swipe-action-item/cv-swipe-action-item.vue → ui-uni/uni-swipe-action-item/uni-swipe-action-item.vue} +0 -0
  98. package/ui-uni/uni-swiper-dot/uni-swiper-dot.vue +205 -0
  99. package/ui-uni/uni-table/uni-table.vue +455 -0
  100. package/ui-uni/uni-tag/uni-tag.vue +283 -0
  101. package/ui-uni/uni-tbody/uni-tbody.vue +30 -0
  102. package/ui-uni/uni-td/uni-td.vue +88 -0
  103. package/{ui-cv/cv-test/cv-test.vue → ui-uni/uni-test/uni-test.vue} +0 -0
  104. package/{ui-cv/cv-th → ui-uni/uni-th}/filter-dropdown.vue +0 -0
  105. package/ui-uni/uni-th/uni-th.vue +259 -0
  106. package/ui-uni/uni-thead/uni-thead.vue +114 -0
  107. package/ui-uni/uni-title/uni-title.vue +171 -0
  108. package/{ui-cv/cv-tr → ui-uni/uni-tr}/table-checkbox.vue +0 -0
  109. package/ui-uni/uni-tr/uni-tr.vue +156 -0
  110. package/{ui-cv/cv-transition → ui-uni/uni-transition}/createAnimation.js +0 -0
  111. package/ui-uni/uni-transition/uni-transition.vue +287 -0
  112. package/ui-cv/cv-badge/cv-badge.vue +0 -249
  113. package/ui-cv/cv-calendar/calendar.js +0 -963
  114. package/ui-cv/cv-calendar/cv-calendar-item.vue +0 -198
  115. package/ui-cv/cv-calendar/cv-calendar.vue +0 -508
  116. package/ui-cv/cv-card/cv-card.vue +0 -427
  117. package/ui-cv/cv-col/cv-col.vue +0 -2965
  118. package/ui-cv/cv-collapse/cv-collapse.vue +0 -146
  119. package/ui-cv/cv-collapse-item/cv-collapse-item.vue +0 -395
  120. package/ui-cv/cv-combox/cv-combox.vue +0 -250
  121. package/ui-cv/cv-countdown/cv-countdown.vue +0 -245
  122. package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +0 -841
  123. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +0 -154
  124. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +0 -376
  125. package/ui-cv/cv-data-picker/cv-data-picker.vue +0 -486
  126. package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +0 -304
  127. package/ui-cv/cv-dateformat/cv-dateformat.vue +0 -86
  128. package/ui-cv/cv-datetime-picker/calendar.vue +0 -761
  129. package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +0 -958
  130. package/ui-cv/cv-datetime-picker/time-picker.vue +0 -907
  131. package/ui-cv/cv-drawer/cv-drawer.vue +0 -185
  132. package/ui-cv/cv-drawer/keypress.js +0 -45
  133. package/ui-cv/cv-easyinput/cv-easyinput.vue +0 -514
  134. package/ui-cv/cv-fab/cv-fab.vue +0 -465
  135. package/ui-cv/cv-fav/cv-fav.vue +0 -150
  136. package/ui-cv/cv-file-picker/cv-file-picker.vue +0 -619
  137. package/ui-cv/cv-form-base/cv-form-base.vue +0 -470
  138. package/ui-cv/cv-form-base/validate.js +0 -477
  139. package/ui-cv/cv-grid-group/cv-grid-group.vue +0 -148
  140. package/ui-cv/cv-grid-item/cv-grid-item.vue +0 -132
  141. package/ui-cv/cv-icon2/cv-icon2.vue +0 -78
  142. package/ui-cv/cv-icon2/icons.js +0 -132
  143. package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +0 -154
  144. package/ui-cv/cv-indexed-list/cv-indexed-list.vue +0 -371
  145. package/ui-cv/cv-link2/cv-link2.vue +0 -130
  146. package/ui-cv/cv-list/cv-list.vue +0 -107
  147. package/ui-cv/cv-list/cv-refresh.vue +0 -65
  148. package/ui-cv/cv-list-ad/cv-list-ad.vue +0 -113
  149. package/ui-cv/cv-list-item/cv-list-item.vue +0 -449
  150. package/ui-cv/cv-nav-bar/cv-nav-bar.vue +0 -256
  151. package/ui-cv/cv-notice-bar/cv-notice-bar.vue +0 -453
  152. package/ui-cv/cv-number-box/cv-number-box.vue +0 -223
  153. package/ui-cv/cv-pagination/cv-pagination.vue +0 -397
  154. package/ui-cv/cv-popup/cv-popup.vue +0 -429
  155. package/ui-cv/cv-popup-message/cv-popup-message.vue +0 -143
  156. package/ui-cv/cv-row/cv-row.vue +0 -157
  157. package/ui-cv/cv-search-bar/cv-search-bar.vue +0 -280
  158. package/ui-cv/cv-steps/cv-steps.vue +0 -293
  159. package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +0 -255
  160. package/ui-cv/cv-table/cv-table.vue +0 -460
  161. package/ui-cv/cv-tag/cv-tag.vue +0 -276
  162. package/ui-cv/cv-tbody/cv-tbody.vue +0 -28
  163. package/ui-cv/cv-td/cv-td.vue +0 -93
  164. package/ui-cv/cv-th/cv-th.vue +0 -270
  165. package/ui-cv/cv-thead/cv-thead.vue +0 -114
  166. package/ui-cv/cv-title/cv-title.vue +0 -168
  167. package/ui-cv/cv-tr/cv-tr.vue +0 -166
  168. package/ui-cv/cv-transition/cv-transition.vue +0 -279
@@ -0,0 +1,874 @@
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,
6
+ 'uni-date-x--border': border}">
7
+ <view v-if="!isRange" class="uni-date-x uni-date-single">
8
+ <view class="uni-date__icon-logo">
9
+ <image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
10
+ </view>
11
+ <input class="uni-date__input" type="text" v-model="singleVal" :placeholder="placeholder" :disabled="true" />
12
+ </view>
13
+ <view v-else class="uni-date-x uni-date-range">
14
+ <view class="uni-date__icon-logo">
15
+ <image class="uni-date-editor--logo" :src="iconBase64" mode=""></image>
16
+ </view>
17
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="range.startDate" :placeholder="startPlaceholder" :disabled="true" />
18
+ <slot>
19
+ <view class="">{{rangeSeparator}}</view>
20
+ </slot>
21
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="range.endDate" :placeholder="endPlaceholder" :disabled="true" />
22
+ </view>
23
+ <view v-show="clearIcon && !disabled && !isPhone && (singleVal || (range.startDate && range.endDate))" class="uni-date__icon-clear" @click.stop="clear">
24
+ <uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons>
25
+ </view>
26
+ </view>
27
+ </slot>
28
+ </view>
29
+
30
+ <view v-show="popup" class="uni-date-mask" @click="close"></view>
31
+ <view v-if="!isPhone" ref="datePicker" v-show="popup" class="uni-date-picker__container">
32
+ <view v-if="!isRange" class="uni-date-single--x" :style="popover">
33
+ <view v-show="hasTime" class="uni-date-changed popup-x-header">
34
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempSingleDate" placeholder="选择日期" />
35
+ <time-picker type="time" v-model="time" :border="false" :disabled="!tempSingleDate" :start="reactStartTime" :end="reactEndTime">
36
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="time" placeholder="选择时间" :disabled="!tempSingleDate" />
37
+ </time-picker>
38
+ </view>
39
+ <calendar ref="pcSingle" :showMonth="false" :start-date="caleRange.startDate" :end-date="caleRange.endDate" :date="defSingleDate" @change="singleChange" />
40
+ <view v-if="hasTime" class="popup-x-footer">
41
+ <!-- <text class="">此刻</text> -->
42
+ <text class="confirm" @click="confirmSingleChange">确定</text>
43
+ </view>
44
+ <view class="uni-date-popper__arrow"></view>
45
+ </view>
46
+
47
+ <view v-else class="uni-date-range--x" :style="popover">
48
+ <view v-show="hasTime" class="popup-x-header uni-date-changed">
49
+ <view class="popup-x-header--datetime">
50
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate" placeholder="开始日期" />
51
+ <time-picker type="time" v-model="tempRange.startTime" :start="reactStartTime" :border="false" :disabled="!tempRange.startDate">
52
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startTime" placeholder="开始时间" :disabled="!tempRange.startDate" />
53
+ </time-picker>
54
+ </view>
55
+ <uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons>
56
+ <view class="popup-x-header--datetime">
57
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate" placeholder="结束日期" />
58
+ <time-picker type="time" v-model="tempRange.endTime" :end="reactEndTime" :border="false" :disabled="!tempRange.endDate">
59
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime" placeholder="结束时间" :disabled="!tempRange.endDate" />
60
+ </time-picker>
61
+ </view>
62
+ </view>
63
+ <view class="popup-x-body">
64
+ <calendar ref="left" :showMonth="false" :start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true" @change="leftChange" :pleStatus="endMultipleStatus" @firstEnterCale="updateRightCale" @monthSwitch="leftMonthSwitch" style="padding-right: 16px;" />
65
+ <calendar ref="right" :showMonth="false" :start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true" @change="rightChange" :pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale" @monthSwitch="rightMonthSwitch" style="padding-left: 16px;border-left: 1px solid #F1F1F1;" />
66
+ </view>
67
+ <view v-if="hasTime" class="popup-x-footer">
68
+ <text class="" @click="clear">清空</text>
69
+ <text class="confirm" @click="confirmRangeChange">确定</text>
70
+ </view>
71
+ </view>
72
+ </view>
73
+ <calendar v-if="isPhone" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime" :start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime" :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false" @confirm="mobileChange" />
74
+ </view>
75
+ </template>
76
+ <script>
77
+ import calendar from './calendar.vue'
78
+ import timePicker from './time-picker.vue'
79
+
80
+ /**
81
+ * DatetimePicker 时间选择器
82
+ * @description 同时支持 PC 和移动端使用日历选择日期和日期范围
83
+ * @tutorial https://ext.dcloud.net.cn/plugin?id=3962
84
+ * @property {String} type 选择器类型
85
+ * @property {String|Array} value 绑定值
86
+ * @property {String} placeholder 单选择时的占位内容
87
+ * @property {String} start 起始时间
88
+ * @property {String} start 终止时间
89
+ * @property {String} start-placeholder 范围选择时开始日期的占位内容
90
+ * @property {String} end-placeholder 范围选择时结束日期的占位内容
91
+ * @property {String} range-separator 选择范围时的分隔符
92
+ * @property {Boolean} border = [true|false] 是否有边框
93
+ * @property {Boolean} disabled = [true|false] 是否禁用
94
+ * @property {Boolean} clearIcon = [true|false] 是否显示清除按钮(仅PC端适用)
95
+ * @event {Function} change 确定日期时触发的事件
96
+ **/
97
+
98
+ export default {
99
+ name: 'UniDatetimePicker',
100
+ components: {
101
+ calendar,
102
+ timePicker
103
+ },
104
+ data() {
105
+ return {
106
+ isRange: false,
107
+ hasTime: false,
108
+ mobileRange: false,
109
+ // 单选
110
+ singleVal: '',
111
+ tempSingleDate: '',
112
+ defSingleDate: '',
113
+ time: '',
114
+ // 范围选
115
+ caleRange: {
116
+ startDate: '',
117
+ startTime: '',
118
+ endDate: '',
119
+ endTime: ''
120
+ },
121
+ range: {
122
+ startDate: '',
123
+ // startTime: '',
124
+ endDate: '',
125
+ // endTime: ''
126
+ },
127
+ tempRange: {
128
+ startDate: '',
129
+ startTime: '',
130
+ endDate: '',
131
+ endTime: ''
132
+ },
133
+ // 左右日历同步数据
134
+ startMultipleStatus: {
135
+ before: '',
136
+ after: '',
137
+ data: [],
138
+ fulldate: ''
139
+ },
140
+ endMultipleStatus: {
141
+ before: '',
142
+ after: '',
143
+ data: [],
144
+ fulldate: ''
145
+ },
146
+ visible: false,
147
+ popup: false,
148
+ popover: null,
149
+ isEmitValue: false,
150
+ isPhone: false,
151
+ isFirstShow: true,
152
+ iconBase64: 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAADIAAAAyCAYAAAAeP4ixAAAABmJLR0QA/wD/AP+gvaeTAAACVklEQVRoge2Zv2vTQRTAP4oWJQQskmolBAnSQVMcSxbp4ubmIEWETu0oIjg5iIOgpLNunfQfMHToUgpOVgfRqRAL4q8WRLQVq4sOdyHPL9/7evfNJReS+8DB433v7r37fl/eu9xBJBKUB0BLt+uDaOOQZb8SUNXyuKuRftg46NeXcBww6M8AC0ANOAycAyb1s7e6+SbNxi/gBfAQ2HadcA7YB/4MUPsKzLos4jzwewAcNy3mhMnx5I/9BiqUAD4DDWAXmAfqWt8Enlq+GBfSbEwAt4AicAxYBO7aTPaGzhu4KvTLQn/Hh9cpmGzcFvqmaXAyaxWE/MGTg93yXsgFUyfbOrJCJ2s8y+tRP21s0fmMTlmih8zT8WnN1GloCmJWaF0CpvrlSAb1/3fJXshNT470hZEIrZeoahqaU8BZ10Exa4XGtiCaKKL+EIHaMX8U81ZEP7ntrwi7n4CfWi7p+UCFdFdh7Rpaps9+mn93rjY2THut0QqtoVlIkpi1QjNyCzEdnl0W+idCXxb6VmKudaGfsbBhRbcHdEWhf5eYt0o6FVR6BjhqYcOKoQkt2y/SAB5rWVbpVeCilmUl3hb6JNeAI1p+ZWEjFzH9hsY2tEwHdHX9DGATWNLyceCeGL/YhY+58LWhy9o0uhJDKw3T4dlr4L6WZab5JvRBGJqs9UPI5R44lQfpx56pUzK0NlA3R6AK1Engu1+/nGhfK7R5bjtwGnXdFfpSJ6190Quz5grqQCC048lFXMhy2nQZWkUVsRowZv8OvLOPCvdHwE5APyKRSMQzfwE22DtT3T5PPwAAAABJRU5ErkJggg=='
153
+ }
154
+ },
155
+ props: {
156
+ type: {
157
+ type: String,
158
+ default: 'datetime'
159
+ },
160
+ value: {
161
+ type: [String, Number, Array, Date],
162
+ default: ''
163
+ },
164
+ modelValue: {
165
+ type: [String, Number, Array, Date],
166
+ default: ''
167
+ },
168
+ start: {
169
+ type: [Number, String],
170
+ default: ''
171
+ },
172
+ end: {
173
+ type: [Number, String],
174
+ default: ''
175
+ },
176
+ returnType: {
177
+ type: String,
178
+ default: 'string'
179
+ },
180
+ placeholder: {
181
+ type: String,
182
+ default: '选择日期'
183
+ },
184
+ startPlaceholder: {
185
+ type: String,
186
+ default: '起始日期'
187
+ },
188
+ endPlaceholder: {
189
+ type: String,
190
+ default: '结束日期'
191
+ },
192
+ rangeSeparator: {
193
+ type: String,
194
+ default: '-'
195
+ },
196
+ border: {
197
+ type: [Boolean],
198
+ default: true
199
+ },
200
+ disabled: {
201
+ type: [Boolean],
202
+ default: false
203
+ },
204
+ clearIcon: {
205
+ type: [Boolean],
206
+ default: true
207
+ }
208
+ },
209
+ watch: {
210
+ type: {
211
+ immediate: true,
212
+ handler(newVal, oldVal) {
213
+ if (newVal.indexOf('time') !== -1) {
214
+ this.hasTime = true
215
+ } else {
216
+ this.hasTime = false
217
+ }
218
+ if (newVal.indexOf('range') !== -1) {
219
+ this.isRange = true
220
+ } else {
221
+ this.isRange = false
222
+ }
223
+ }
224
+ },
225
+ value: {
226
+ immediate: true,
227
+ handler(newVal, oldVal) {
228
+ if (this.isEmitValue) {
229
+ this.isEmitValue = false
230
+ return
231
+ }
232
+ this.initPicker(newVal)
233
+ }
234
+ },
235
+
236
+ start: {
237
+ immediate: true,
238
+ handler(newVal, oldVal) {
239
+ if (!newVal) return
240
+ const {
241
+ defDate,
242
+ defTime
243
+ } = this.parseDate(newVal)
244
+ this.caleRange.startDate = defDate
245
+ if (this.hasTime) {
246
+ this.caleRange.startTime = defTime
247
+ }
248
+ }
249
+ },
250
+
251
+ end: {
252
+ immediate: true,
253
+ handler(newVal, oldVal) {
254
+ if (!newVal) return
255
+ const {
256
+ defDate,
257
+ defTime
258
+ } = this.parseDate(newVal)
259
+ this.caleRange.endDate = defDate
260
+ if (this.hasTime) {
261
+ this.caleRange.endTime = defTime
262
+ }
263
+ }
264
+ },
265
+ },
266
+ computed: {
267
+ reactStartTime() {
268
+ const activeDate = this.isRange ? this.tempRange.startDate : this.tempSingleDate
269
+ const res = activeDate === this.caleRange.startDate ? this.caleRange.startTime : ''
270
+ return res
271
+ },
272
+ reactEndTime() {
273
+ const activeDate = this.isRange ? this.tempRange.endDate : this.tempSingleDate
274
+ const res = activeDate === this.caleRange.endDate ? this.caleRange.endTime : ''
275
+ return res
276
+ },
277
+ reactMobDefTime() {
278
+ return this.isRange ? {
279
+ start: this.tempRange.startTime,
280
+ end: this.tempRange.endTime
281
+ } : this.time
282
+ },
283
+ mobSelectableTime() {
284
+ return {
285
+ start: this.caleRange.startTime,
286
+ end: this.caleRange.endTime
287
+ }
288
+ },
289
+ datePopupWidth() {
290
+ // todo
291
+ return this.isRange ? 653 : 301
292
+ }
293
+ },
294
+ created() {
295
+ this.form = this.getForm('uniForms')
296
+ this.formItem = this.getForm('uniFormsItem')
297
+
298
+ // if (this.formItem) {
299
+ // if (this.formItem.name) {
300
+ // this.rename = this.formItem.name
301
+ // this.form.inputChildrens.push(this)
302
+ // }
303
+ // }
304
+ },
305
+ mounted() {
306
+ this.platform()
307
+ },
308
+ methods: {
309
+ /**
310
+ * 获取父元素实例
311
+ */
312
+ getForm(name = 'uniForms') {
313
+ let parent = this.$parent;
314
+ let parentName = parent.$options.name;
315
+ while (parentName !== name) {
316
+ parent = parent.$parent;
317
+ if (!parent) return false
318
+ parentName = parent.$options.name;
319
+ }
320
+ return parent;
321
+ },
322
+ initPicker(newVal) {
323
+ if (!newVal || Array.isArray(newVal) && !newVal.length) {
324
+ this.$nextTick(() => {
325
+ this.clear(false)
326
+ })
327
+ return
328
+ }
329
+ if (!Array.isArray(newVal) && !this.isRange) {
330
+ const {
331
+ defDate,
332
+ defTime
333
+ } = this.parseDate(newVal)
334
+ this.singleVal = defDate
335
+ this.tempSingleDate = defDate
336
+ this.defSingleDate = defDate
337
+ if (this.hasTime) {
338
+ this.singleVal = defDate + ' ' + defTime
339
+ this.time = defTime
340
+ }
341
+ } else {
342
+ const [before, after] = newVal
343
+ if (!before && !after) return
344
+ const defBefore = this.parseDate(before)
345
+ const defAfter = this.parseDate(after)
346
+ const startDate = defBefore.defDate
347
+ const endDate = defAfter.defDate
348
+ this.range.startDate = this.tempRange.startDate = startDate
349
+ this.range.endDate = this.tempRange.endDate = endDate
350
+
351
+ if (this.hasTime) {
352
+ this.range.startDate = defBefore.defDate + ' ' + defBefore.defTime
353
+ this.range.endDate = defAfter.defDate + ' ' + defAfter.defTime
354
+ this.tempRange.startTime = defBefore.defTime
355
+ this.tempRange.endTime = defAfter.defTime
356
+ }
357
+ const defaultRange = {
358
+ before: defBefore.defDate,
359
+ after: defAfter.defDate
360
+ }
361
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, {
362
+ which: 'right'
363
+ })
364
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, {
365
+ which: 'left'
366
+ })
367
+ }
368
+ },
369
+ updateLeftCale(e) {
370
+ const left = this.$refs.left
371
+ // 设置范围选
372
+ left.cale.setHoverMultiple(e.after)
373
+ left.setDate(this.$refs.left.nowDate.fullDate)
374
+ },
375
+ updateRightCale(e) {
376
+ const right = this.$refs.right
377
+ // 设置范围选
378
+ right.cale.setHoverMultiple(e.after)
379
+ right.setDate(this.$refs.right.nowDate.fullDate)
380
+ },
381
+ platform() {
382
+ const systemInfo = uni.getSystemInfoSync()
383
+ this.isPhone = systemInfo.windowWidth <= 500
384
+ this.windowWidth = systemInfo.windowWidth
385
+ },
386
+ show(event) {
387
+ if (this.disabled) {
388
+ return
389
+ }
390
+ this.platform()
391
+ if (this.isPhone) {
392
+ this.$refs.mobile.open()
393
+ return
394
+ }
395
+ this.popover = {
396
+ top: '10px'
397
+ }
398
+ const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor")
399
+ dateEditor.boundingClientRect(rect => {
400
+ if (this.windowWidth - rect.left < this.datePopupWidth) {
401
+ this.popover.right = 0
402
+ }
403
+ }).exec()
404
+ setTimeout(() => {
405
+ this.popup = !this.popup
406
+ if (!this.isPhone && this.isRange && this.isFirstShow) {
407
+ this.isFirstShow = false
408
+ const {
409
+ startDate,
410
+ endDate
411
+ } = this.range
412
+ if (startDate && endDate) {
413
+ if (this.diffDate(startDate, endDate) < 30) {
414
+ this.$refs.right.next()
415
+ }
416
+ } else {
417
+ this.$refs.right.next()
418
+ this.$refs.right.cale.lastHover = false
419
+ }
420
+ }
421
+
422
+ }, 20)
423
+ },
424
+
425
+ close() {
426
+ setTimeout(() => {
427
+ this.popup = false
428
+ this.$emit('maskClick', this.value)
429
+ }, 20)
430
+ },
431
+ setEmit(value) {
432
+ if (this.returnType === "timestamp" || this.returnType === "date") {
433
+ if (!Array.isArray(value)) {
434
+ if (!this.hasTime) {
435
+ value = value + ' ' + '00:00:00'
436
+ }
437
+ value = this.createTimestamp(value)
438
+ if (this.returnType === "date") {
439
+ value = new Date(value)
440
+ }
441
+ } else {
442
+ if (!this.hasTime) {
443
+ value[0] = value[0] + ' ' + '00:00:00'
444
+ value[1] = value[1] + ' ' + '00:00:00'
445
+ }
446
+ value[0] = this.createTimestamp(value[0])
447
+ value[1] = this.createTimestamp(value[1])
448
+ if (this.returnType === "date") {
449
+ value[0] = new Date(value[0])
450
+ value[1] = new Date(value[1])
451
+ }
452
+ }
453
+ }
454
+ this.formItem && this.formItem.setValue(value)
455
+ this.$emit('change', value)
456
+ this.$emit('input', value)
457
+ this.$emit('update:modelValue', value)
458
+ this.isEmitValue = true
459
+ },
460
+ createTimestamp(date) {
461
+ date = this.fixIosDateFormat(date)
462
+ return Date.parse(new Date(date))
463
+ },
464
+ singleChange(e) {
465
+ this.tempSingleDate = e.fulldate
466
+ if (this.hasTime) return
467
+ this.confirmSingleChange()
468
+ },
469
+
470
+ confirmSingleChange() {
471
+ if (!this.tempSingleDate) {
472
+ this.popup = false
473
+ return
474
+ }
475
+ if (this.hasTime) {
476
+ this.singleVal = this.tempSingleDate + ' ' + (this.time ? this.time : '00:00:00')
477
+ } else {
478
+ this.singleVal = this.tempSingleDate
479
+ }
480
+ this.setEmit(this.singleVal)
481
+ this.popup = false
482
+ },
483
+
484
+ leftChange(e) {
485
+ const {
486
+ before,
487
+ after
488
+ } = e.range
489
+ this.rangeChange(before, after)
490
+ const obj = {
491
+ before: e.range.before,
492
+ after: e.range.after,
493
+ data: e.range.data,
494
+ fulldate: e.fulldate
495
+ }
496
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj)
497
+ },
498
+
499
+ rightChange(e) {
500
+ const {
501
+ before,
502
+ after
503
+ } = e.range
504
+ this.rangeChange(before, after)
505
+ const obj = {
506
+ before: e.range.before,
507
+ after: e.range.after,
508
+ data: e.range.data,
509
+ fulldate: e.fulldate
510
+ }
511
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj)
512
+ },
513
+
514
+ mobileChange(e) {
515
+ if (this.isRange) {
516
+ const {
517
+ before,
518
+ after
519
+ } = e.range
520
+ this.handleStartAndEnd(before, after, true)
521
+ if (this.hasTime) {
522
+ const {
523
+ startTime,
524
+ endTime
525
+ } = e.timeRange
526
+ this.tempRange.startTime = startTime
527
+ this.tempRange.endTime = endTime
528
+ }
529
+ this.confirmRangeChange()
530
+
531
+ } else {
532
+ if (this.hasTime) {
533
+ this.singleVal = e.fulldate + ' ' + e.time
534
+ } else {
535
+ this.singleVal = e.fulldate
536
+ }
537
+ this.setEmit(this.singleVal)
538
+ }
539
+ this.$refs.mobile.close()
540
+ },
541
+
542
+ rangeChange(before, after) {
543
+ if (!(before && after)) return
544
+ this.handleStartAndEnd(before, after, true)
545
+ if (this.hasTime) return
546
+ this.confirmRangeChange()
547
+ },
548
+
549
+ confirmRangeChange() {
550
+ if (!this.tempRange.startDate && !this.tempRange.endDate) {
551
+ this.popup = false
552
+ return
553
+ }
554
+ let start, end
555
+ if (!this.hasTime) {
556
+ start = this.range.startDate = this.tempRange.startDate
557
+ end = this.range.endDate = this.tempRange.endDate
558
+ } else {
559
+ start = this.range.startDate = this.tempRange.startDate + ' ' +
560
+ (this.tempRange.startTime ? this.tempRange.startTime : '00:00:00')
561
+ end = this.range.endDate = this.tempRange.endDate + ' ' +
562
+ (this.tempRange.endTime ? this.tempRange.endTime : '00:00:00')
563
+ }
564
+ const displayRange = [start, end]
565
+ this.setEmit(displayRange)
566
+ this.popup = false
567
+ },
568
+
569
+ handleStartAndEnd(before, after, temp = false) {
570
+ if (!(before && after)) return
571
+ const type = temp ? 'tempRange' : 'range'
572
+ if (this.dateCompare(before, after)) {
573
+ this[type].startDate = before
574
+ this[type].endDate = after
575
+ } else {
576
+ this[type].startDate = after
577
+ this[type].endDate = before
578
+ }
579
+ },
580
+
581
+ /**
582
+ * 比较时间大小
583
+ */
584
+ dateCompare(startDate, endDate) {
585
+ // 计算截止时间
586
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
587
+ // 计算详细项的截止时间
588
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
589
+ if (startDate <= endDate) {
590
+ return true
591
+ } else {
592
+ return false
593
+ }
594
+ },
595
+
596
+ /**
597
+ * 比较时间差
598
+ */
599
+ diffDate(startDate, endDate) {
600
+ // 计算截止时间
601
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
602
+ // 计算详细项的截止时间
603
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
604
+ const diff = (endDate - startDate) / (24 * 60 * 60 * 1000)
605
+ return Math.abs(diff)
606
+ },
607
+
608
+ clear(needEmit = true) {
609
+ if (!this.isRange) {
610
+ this.singleVal = ''
611
+ if (this.isPhone) {
612
+ this.defSingleDate = ''
613
+ } else {
614
+ this.$refs.pcSingle.calendar.fullDate = ''
615
+ this.$refs.pcSingle.setDate()
616
+ }
617
+ if (needEmit) {
618
+ this.formItem && this.formItem.setValue('')
619
+ this.$emit('change', '')
620
+ this.$emit('input', '')
621
+ this.$emit('update:modelValue', '')
622
+ }
623
+ } else {
624
+ this.range.startDate = ''
625
+ this.range.endDate = ''
626
+ this.tempRange = {}
627
+ if (this.isPhone) {
628
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, {
629
+ before: '',
630
+ after: '',
631
+ data: [],
632
+ fulldate: ''
633
+ }, {
634
+ which: 'left'
635
+ })
636
+ } else {
637
+ this.$refs.left.cale.multipleStatus.before = ''
638
+ this.$refs.left.cale.multipleStatus.after = ''
639
+ this.$refs.left.cale.multipleStatus.data = []
640
+ this.$refs.left.cale.lastHover = false
641
+ this.$refs.left.setDate()
642
+ this.$refs.right.cale.multipleStatus.before = ''
643
+ this.$refs.right.cale.multipleStatus.after = ''
644
+ this.$refs.right.cale.multipleStatus.data = []
645
+ this.$refs.right.cale.lastHover = false
646
+ this.$refs.right.setDate()
647
+ this.$refs.right.next()
648
+ }
649
+ if (needEmit) {
650
+ this.formItem && this.formItem.setValue([])
651
+ this.$emit('change', [])
652
+ this.$emit('input', [])
653
+ this.$emit('update:modelValue', [])
654
+ }
655
+ }
656
+ },
657
+
658
+ parseDate(date) {
659
+ date = this.fixIosDateFormat(date)
660
+ const defVal = new Date(date)
661
+ const year = defVal.getFullYear()
662
+ const month = defVal.getMonth() + 1
663
+ const day = defVal.getDate()
664
+ const hour = defVal.getHours()
665
+ const minute = defVal.getMinutes()
666
+ const second = defVal.getSeconds()
667
+ const defDate = year + '-' + this.lessTen(month) + '-' + this.lessTen(day)
668
+ const defTime = this.lessTen(hour) + ':' + this.lessTen(minute) + ':' + this.lessTen(second)
669
+ return {
670
+ defDate,
671
+ defTime
672
+ }
673
+ },
674
+
675
+ lessTen(item) {
676
+ return item < 10 ? '0' + item : item
677
+ },
678
+
679
+ //兼容 iOS、safari 日期格式
680
+ fixIosDateFormat(value) {
681
+ if (typeof value === 'string') {
682
+ value = value.replace(/-/g, '/')
683
+ }
684
+ return value
685
+ },
686
+
687
+ leftMonthSwitch(e) {
688
+ // console.log('leftMonthSwitch 返回:', e)
689
+ },
690
+ rightMonthSwitch(e) {
691
+ // console.log('rightMonthSwitch 返回:', e)
692
+ }
693
+ }
694
+ }
695
+ </script>
696
+
697
+ <style scoped>
698
+ @charset "UTF-8";
699
+
700
+ .uni-date-x {
701
+ display: flex;
702
+ flex-direction: row;
703
+ align-items: center;
704
+ justify-content: center;
705
+ padding: 0 10px;
706
+ border-radius: 4px;
707
+ background-color: #fff;
708
+ color: #666;
709
+ font-size: 14px;
710
+ }
711
+
712
+ .uni-date-x--border {
713
+ box-sizing: border-box;
714
+ border-radius: 4px;
715
+ border: 1px solid #dcdfe6;
716
+ }
717
+
718
+ .uni-date-editor--x {
719
+ position: relative;
720
+ }
721
+
722
+ .uni-date-editor--x .uni-date__icon-clear {
723
+ position: absolute;
724
+ top: 5px;
725
+ right: 0;
726
+ display: inline-block;
727
+ box-sizing: border-box;
728
+ border: 6px solid transparent;
729
+ margin-right: 6px;
730
+ /* #ifdef H5 */
731
+ cursor: pointer;
732
+ /* #endif */
733
+ }
734
+
735
+ .uni-date__input {
736
+ height: 40px;
737
+ width: 100%;
738
+ padding: 0 8px;
739
+ line-height: 40px;
740
+ font-size: 14px;
741
+ }
742
+
743
+ .uni-date-range__input {
744
+ text-align: center;
745
+ }
746
+
747
+ .uni-date-picker__container {
748
+ position: relative;
749
+ /* position: fixed;
750
+ left: 0;
751
+ right: 0;
752
+ top: 0;
753
+ bottom: 0;
754
+ box-sizing: border-box;
755
+ z-index: 996;
756
+ font-size: 14px; */
757
+ }
758
+
759
+ .uni-date-mask {
760
+ position: fixed;
761
+ bottom: 0px;
762
+ top: 0px;
763
+ left: 0px;
764
+ right: 0px;
765
+ background-color: rgba(0, 0, 0, 0);
766
+ transition-duration: 0.3s;
767
+ z-index: 996;
768
+ }
769
+
770
+ .uni-date-single--x {
771
+ /* padding: 0 8px; */
772
+ position: absolute;
773
+ top: 0;
774
+ z-index: 999;
775
+ border: 1px solid #e4e7ed;
776
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
777
+ border-radius: 4px;
778
+ }
779
+
780
+ .uni-date-range--x {
781
+ padding: 0 8px;
782
+ background-color: #fff;
783
+ position: absolute;
784
+ top: 0;
785
+ z-index: 999;
786
+ border: 1px solid #e4e7ed;
787
+ box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.1);
788
+ border-radius: 4px;
789
+ }
790
+
791
+ .uni-date-editor--x__disabled {
792
+ opacity: 0.4;
793
+ cursor: default;
794
+ }
795
+
796
+ .uni-date-editor--logo {
797
+ width: 16px;
798
+ height: 16px;
799
+ vertical-align: middle;
800
+ }
801
+
802
+ /* 添加时间 */
803
+ .popup-x-header {
804
+ /* #ifndef APP-NVUE */
805
+ display: flex;
806
+ /* #endif */
807
+ flex-direction: row;
808
+ /* justify-content: space-between; */
809
+ }
810
+
811
+ .popup-x-header--datetime {
812
+ /* #ifndef APP-NVUE */
813
+ display: flex;
814
+ /* #endif */
815
+ flex-direction: row;
816
+ flex: 1;
817
+ }
818
+
819
+ .popup-x-body {
820
+ display: flex;
821
+ }
822
+
823
+ .popup-x-footer {
824
+ padding: 0 15px;
825
+ border-top-color: #F1F1F1;
826
+ border-top-style: solid;
827
+ border-top-width: 1px;
828
+ background-color: #fff;
829
+ line-height: 40px;
830
+ text-align: right;
831
+ color: #666;
832
+ }
833
+
834
+ .popup-x-footer text:hover {
835
+ color: #007aff;
836
+ cursor: pointer;
837
+ opacity: 0.8;
838
+ }
839
+
840
+ .popup-x-footer .confirm {
841
+ margin-left: 20px;
842
+ color: #007aff;
843
+ }
844
+
845
+ .uni-date-changed {
846
+ background-color: #fff;
847
+ text-align: center;
848
+ color: #333;
849
+ border-bottom-color: #F1F1F1;
850
+ border-bottom-style: solid;
851
+ border-bottom-width: 1px;
852
+ /* padding: 0 50px; */
853
+ }
854
+
855
+ .uni-date-changed--time text {
856
+ /* padding: 0 20px; */
857
+ height: 50px;
858
+ line-height: 50px;
859
+ }
860
+
861
+ .uni-date-changed .uni-date-changed--time {
862
+ /* display: flex; */
863
+ flex: 1;
864
+ }
865
+
866
+ .uni-date-changed--time-date {
867
+ color: #333;
868
+ opacity: 0.6;
869
+ }
870
+
871
+ .mr-50 {
872
+ margin-right: 50px;
873
+ }
874
+ </style>