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

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 (112) hide show
  1. package/package.json +1 -1
  2. package/ui-cv/cv-badge/{uni-badge.vue → cv-badge.vue} +2 -2
  3. package/ui-cv/cv-calendar/calendar.js +762 -345
  4. package/ui-cv/cv-calendar/cv-calendar-item.vue +198 -0
  5. package/ui-cv/cv-calendar/cv-calendar.vue +508 -0
  6. package/ui-cv/cv-card/cv-card.vue +427 -0
  7. package/ui-cv/cv-col/cv-col.vue +2965 -0
  8. package/ui-cv/cv-collapse/cv-collapse.vue +146 -0
  9. package/ui-cv/cv-collapse-item/cv-collapse-item.vue +395 -0
  10. package/ui-cv/cv-combox/cv-combox.vue +250 -0
  11. package/ui-cv/cv-countdown/cv-countdown.vue +245 -0
  12. package/ui-cv/cv-data-checkbox/cv-data-checkbox.vue +841 -0
  13. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list-item.vue +154 -0
  14. package/ui-cv/cv-data-indexed-list/cv-data-indexed-list.vue +376 -0
  15. package/ui-cv/cv-data-picker/cv-data-picker.vue +486 -0
  16. package/ui-cv/cv-data-pickerview/{uni-data-picker.js → cv-data-picker.js} +0 -0
  17. package/ui-cv/cv-data-pickerview/cv-data-pickerview.vue +304 -0
  18. package/ui-cv/cv-dateformat/cv-dateformat.vue +86 -0
  19. package/ui-cv/cv-datetime-picker/calendar.vue +752 -738
  20. package/ui-cv/cv-datetime-picker/cv-datetime-picker.vue +958 -0
  21. package/ui-cv/cv-datetime-picker/time-picker.vue +900 -892
  22. package/ui-cv/cv-easyinput/cv-easyinput.vue +514 -0
  23. package/ui-cv/cv-fab/cv-fab.vue +465 -0
  24. package/ui-cv/cv-fab/{uni-fab.vue.bak → cv-fab.vue.bak} +2 -2
  25. package/ui-cv/cv-fav/cv-fav.vue +150 -0
  26. package/ui-cv/cv-file-picker/cv-file-picker.vue +619 -0
  27. package/ui-cv/cv-form-item/cv-form-item.vue +1 -1
  28. package/ui-cv/cv-goods-nav/{uni-goods-nav.vue → cv-goods-nav.vue} +1 -1
  29. package/ui-cv/{cv-icons2/cv-icons2.vue → cv-icon2/cv-icon2.vue} +3 -3
  30. package/ui-cv/{cv-icons2 → cv-icon2}/icons.js +0 -0
  31. package/ui-cv/{cv-icons2 → cv-icon2}/uni.ttf +0 -0
  32. package/ui-cv/cv-indexed-list/cv-indexed-list-item.vue +154 -0
  33. package/ui-cv/cv-indexed-list/cv-indexed-list.vue +371 -0
  34. package/ui-cv/cv-input-password/cv-input-password.vue +2 -2
  35. package/ui-cv/{cv-link/uni-link.vue → cv-link2/cv-link2.vue} +1 -1
  36. package/ui-cv/cv-list/cv-list.vue +107 -0
  37. package/ui-cv/cv-list/cv-refresh.vue +65 -0
  38. package/ui-cv/cv-list-ad/cv-list-ad.vue +113 -0
  39. package/ui-cv/cv-list-chat/{uni-list-chat.scss → cv-list-chat.scss} +0 -0
  40. package/ui-cv/cv-list-chat/{uni-list-chat.vue → cv-list-chat.vue} +0 -0
  41. package/ui-cv/cv-list-item/cv-list-item.vue +449 -0
  42. package/ui-cv/cv-nav-bar/cv-nav-bar.vue +256 -0
  43. package/ui-cv/cv-nav-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
  44. package/ui-cv/cv-notice-bar/cv-notice-bar.vue +453 -0
  45. package/ui-cv/cv-number-box/cv-number-box.vue +223 -0
  46. package/ui-cv/cv-pagination/cv-pagination.vue +397 -0
  47. package/ui-cv/cv-popup/cv-popup.vue +429 -0
  48. package/ui-cv/cv-popup-dialog/{uni-popup-dialog.vue → cv-popup-dialog.vue} +0 -0
  49. package/ui-cv/cv-popup-message/cv-popup-message.vue +143 -0
  50. package/ui-cv/cv-popup-share/{uni-popup-share.vue → cv-popup-share.vue} +0 -0
  51. package/ui-cv/cv-row/{uni-row.vue → cv-row.vue} +1 -1
  52. package/ui-cv/cv-search-bar/cv-search-bar.vue +280 -0
  53. package/ui-cv/cv-section/{uni-section.vue → cv-section.vue} +0 -0
  54. package/ui-cv/cv-segmented-control/{uni-segmented-control.vue → cv-segmented-control.vue} +0 -0
  55. package/ui-cv/cv-status-bar/{uni-status-bar.vue → cv-status-bar.vue} +0 -0
  56. package/ui-cv/cv-steps/cv-steps.vue +293 -0
  57. package/ui-cv/cv-swipe-action/{uni-swipe-action.vue → cv-swipe-action.vue} +0 -0
  58. package/ui-cv/cv-swipe-action-item/{uni-swipe-action-item.vue → cv-swipe-action-item.vue} +0 -0
  59. package/ui-cv/cv-swiper-dot/cv-swiper-dot.vue +255 -0
  60. package/ui-cv/cv-table/cv-table.vue +460 -0
  61. package/ui-cv/cv-tag/cv-tag.vue +276 -0
  62. package/ui-cv/cv-tbody/cv-tbody.vue +28 -0
  63. package/ui-cv/cv-td/cv-td.vue +93 -0
  64. package/ui-cv/cv-test/{uni-test.vue → cv-test.vue} +0 -0
  65. package/ui-cv/cv-th/cv-th.vue +270 -0
  66. package/ui-cv/cv-thead/cv-thead.vue +114 -0
  67. package/ui-cv/cv-title/cv-title.vue +168 -0
  68. package/ui-cv/cv-tr/cv-tr.vue +166 -0
  69. package/ui-cv/cv-transition/cv-transition.vue +279 -0
  70. package/ui-cv/cv-calendar/uni-calendar-item.vue +0 -171
  71. package/ui-cv/cv-calendar/uni-calendar.vue +0 -504
  72. package/ui-cv/cv-card/uni-card.vue +0 -420
  73. package/ui-cv/cv-col/uni-col.vue +0 -2968
  74. package/ui-cv/cv-collapse/uni-collapse.vue +0 -146
  75. package/ui-cv/cv-collapse-item/uni-collapse-item.vue +0 -378
  76. package/ui-cv/cv-combox/uni-combox.vue +0 -237
  77. package/ui-cv/cv-countdown/uni-countdown.vue +0 -234
  78. package/ui-cv/cv-data-checkbox/uni-data-checkbox.vue +0 -792
  79. package/ui-cv/cv-data-indexed-list/uni-data-indexed-list-item.vue +0 -142
  80. package/ui-cv/cv-data-indexed-list/uni-data-indexed-list.vue +0 -364
  81. package/ui-cv/cv-data-picker/uni-data-picker.vue +0 -468
  82. package/ui-cv/cv-data-pickerview/uni-data-pickerview.vue +0 -298
  83. package/ui-cv/cv-dateformat/uni-dateformat.vue +0 -88
  84. package/ui-cv/cv-datetime-picker/uni-datetime-picker.vue +0 -874
  85. package/ui-cv/cv-easyinput/uni-easyinput.vue +0 -438
  86. package/ui-cv/cv-fab/uni-fab.vue +0 -443
  87. package/ui-cv/cv-fav/uni-fav.vue +0 -136
  88. package/ui-cv/cv-file-picker/uni-file-picker.vue +0 -614
  89. package/ui-cv/cv-indexed-list/uni-indexed-list-item.vue +0 -142
  90. package/ui-cv/cv-indexed-list/uni-indexed-list.vue +0 -357
  91. package/ui-cv/cv-list/uni-list.vue +0 -107
  92. package/ui-cv/cv-list/uni-refresh.vue +0 -65
  93. package/ui-cv/cv-list-ad/uni-list-ad.vue +0 -106
  94. package/ui-cv/cv-list-item/uni-list-item.vue +0 -428
  95. package/ui-cv/cv-nav-bar/uni-nav-bar.vue +0 -244
  96. package/ui-cv/cv-notice-bar/uni-notice-bar.vue +0 -394
  97. package/ui-cv/cv-number-box/uni-number-box.vue +0 -224
  98. package/ui-cv/cv-pagination/uni-pagination.vue +0 -376
  99. package/ui-cv/cv-popup/uni-popup.vue +0 -412
  100. package/ui-cv/cv-popup-message/uni-popup-message.vue +0 -143
  101. package/ui-cv/cv-search-bar/uni-search-bar.vue +0 -262
  102. package/ui-cv/cv-steps/uni-steps.vue +0 -250
  103. package/ui-cv/cv-swiper-dot/uni-swiper-dot.vue +0 -205
  104. package/ui-cv/cv-table/uni-table.vue +0 -455
  105. package/ui-cv/cv-tag/uni-tag.vue +0 -283
  106. package/ui-cv/cv-tbody/uni-tbody.vue +0 -30
  107. package/ui-cv/cv-td/uni-td.vue +0 -88
  108. package/ui-cv/cv-th/uni-th.vue +0 -259
  109. package/ui-cv/cv-thead/uni-thead.vue +0 -114
  110. package/ui-cv/cv-title/uni-title.vue +0 -171
  111. package/ui-cv/cv-tr/uni-tr.vue +0 -156
  112. package/ui-cv/cv-transition/uni-transition.vue +0 -287
@@ -1,874 +0,0 @@
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>