@zscreate/zhxy-app-component 1.0.0

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 (70) hide show
  1. package/components/dying318-picker/Demo.vue +342 -0
  2. package/components/dying318-picker/Picker.nvue +441 -0
  3. package/components/dying318-picker/Picker.vue +442 -0
  4. package/components/dying318-picker/Pickers.vue +321 -0
  5. package/components/dying318-picker/README.md +479 -0
  6. package/components/easydrag-sort/easydrag-sort.vue +248 -0
  7. package/components/evan-form/evan-form.vue +102 -0
  8. package/components/evan-form/utils.js +125 -0
  9. package/components/evan-form-item/evan-form-item.vue +1457 -0
  10. package/components/evan-form-item/mixins/computedMixin.js +44 -0
  11. package/components/evan-form-item/mixins/pubSubMixin.js +104 -0
  12. package/components/evan-form-item/mixins/validateByApiMinxins.js +21 -0
  13. package/components/evan-form-item/mixins/validateFormMixin.js +71 -0
  14. package/components/evan-form-item/mixins/valueChangeMixin.js +64 -0
  15. package/components/evan-form-item/modules/edit.png +0 -0
  16. package/components/evan-form-item/utilForForm.js +35 -0
  17. package/components/evan-form-item/utils.js +51 -0
  18. package/components/form-container/data.js +709 -0
  19. package/components/form-container/form-container.vue +897 -0
  20. package/components/jin-edit/jin-edit.vue +327 -0
  21. package/components/jin-edit/jin-icons.vue +48 -0
  22. package/components/jin-edit/readme.md +65 -0
  23. package/components/l-file/l-file.vue +260 -0
  24. package/components/lb-picker/index.vue +286 -0
  25. package/components/signatrue-write/signatrue-write.vue +220 -0
  26. package/components/t-color-picker/t-color-picker.vue +784 -0
  27. package/components/uni-datetime-picker/changelog.md +76 -0
  28. package/components/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue +182 -0
  29. package/components/uni-datetime-picker/components/uni-datetime-picker/calendar.js +546 -0
  30. package/components/uni-datetime-picker/components/uni-datetime-picker/calendar.vue +1024 -0
  31. package/components/uni-datetime-picker/components/uni-datetime-picker/i18n/en.json +19 -0
  32. package/components/uni-datetime-picker/components/uni-datetime-picker/i18n/index.js +8 -0
  33. package/components/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hans.json +19 -0
  34. package/components/uni-datetime-picker/components/uni-datetime-picker/i18n/zh-Hant.json +19 -0
  35. package/components/uni-datetime-picker/components/uni-datetime-picker/keypress.js +45 -0
  36. package/components/uni-datetime-picker/components/uni-datetime-picker/time-picker.vue +927 -0
  37. package/components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue +966 -0
  38. package/components/uni-datetime-picker/components/uni-datetime-picker/util.js +437 -0
  39. package/components/uni-datetime-picker/components/uni-datetime-picker/year-mont-picker.vue +901 -0
  40. package/components/uni-datetime-picker/components/uni-datetime-picker/year-picker.vue +271 -0
  41. package/components/uni-datetime-picker/package.json +89 -0
  42. package/components/uni-datetime-picker/readme.md +159 -0
  43. package/components/uni-icons/icons.js +96 -0
  44. package/components/uni-icons/uni-icons.vue +57 -0
  45. package/components/uni-popup/message.js +29 -0
  46. package/components/uni-popup/popup.js +25 -0
  47. package/components/uni-popup/uni-popup-dialog.vue +243 -0
  48. package/components/uni-popup/uni-popup-message.vue +116 -0
  49. package/components/uni-popup/uni-popup-share.vue +165 -0
  50. package/components/uni-popup/uni-popup.vue +297 -0
  51. package/components/uni-rate/uni-rate.vue +140 -0
  52. package/components/uni-transition/uni-transition.vue +279 -0
  53. package/components/uploadFile/uploadFile.vue +124 -0
  54. package/components/viewcomponents/applicateGrid.vue +96 -0
  55. package/components/viewcomponents/card.vue +166 -0
  56. package/components/viewcomponents/formCard.vue +82 -0
  57. package/components/viewcomponents/infocell.vue +122 -0
  58. package/components/viewcomponents/navsearch.vue +59 -0
  59. package/components/viewcomponents/newscontent.vue +85 -0
  60. package/components/xp-picker/util.js +105 -0
  61. package/components/xp-picker/xp-picker.vue +330 -0
  62. package/index.js +9 -0
  63. package/package.json +29 -0
  64. package/static/iconfont.css +32 -0
  65. package/static/mttf.ttf +0 -0
  66. package/static/uni.ttf +0 -0
  67. package/utils/js-interp.js +6501 -0
  68. package/utils/js-interp.md +10 -0
  69. package/utils/moment.js +4601 -0
  70. package/utils/util.js +106 -0
@@ -0,0 +1,966 @@
1
+ <template>
2
+ <view class="uni-date">
3
+ <view class="uni-date-editor" @click="show">
4
+ <slot></slot>
5
+ </view>
6
+ <view
7
+ v-show="clearIcon && (singleVal.trim()!=='' || range.startDate !== '')"
8
+ class="uni-date__icon-clear clear-btn"
9
+ @click.stop="clear">
10
+ <uni-icons type="clear" color="#e1e1e1" size="14"></uni-icons>
11
+ </view>
12
+ <view v-show="popup" class="uni-date-mask" @click="close"></view>
13
+ <view v-if="!isPhone" ref="datePicker" v-show="popup" class="uni-date-picker__container">
14
+ <view v-if="!isRange" class="uni-date-single--x" :style="popover">
15
+ <view v-show="hasTime" class="uni-date-changed popup-x-header">
16
+ <input class="uni-date__input t-c" type="text" v-model="tempSingleDate"
17
+ :placeholder="selectDateText" />
18
+ <time-picker type="time" v-model="time" :border="false" :disabled="!tempSingleDate"
19
+ :start="reactStartTime" :end="reactEndTime" :hideSecond="hideSecond" style="width: 100%;">
20
+ <input class="uni-date__input t-c" type="text" v-model="time" :placeholder="selectTimeText"
21
+ :disabled="!tempSingleDate" />
22
+ </time-picker>
23
+ </view>
24
+ <calendar ref="pcSingle" class="uni-date_calendar-pc" :showMonth="false"
25
+ :start-date="caleRange.startDate" :end-date="caleRange.endDate" :date="defSingleDate"
26
+ @change="singleChange" />
27
+ <view v-if="hasTime" class="popup-x-footer">
28
+ <!-- <text class="">此刻</text> -->
29
+ <text class="confirm" @click="confirmSingleChange">{{okText}}</text>
30
+ </view>
31
+ <view class="uni-date-popper__arrow"></view>
32
+ </view>
33
+
34
+ <view v-else class="uni-date-range--x" :style="popover">
35
+ <view v-show="hasTime" class="popup-x-header uni-date-changed">
36
+ <view class="popup-x-header--datetime">
37
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
38
+ :placeholder="startDateText" />
39
+ <time-picker type="time" v-model="tempRange.startTime" :start="reactStartTime" :border="false"
40
+ :disabled="!tempRange.startDate" :hideSecond="hideSecond">
41
+ <input class="uni-date__input uni-date-range__input" type="text"
42
+ v-model="tempRange.startTime" :placeholder="startTimeText"
43
+ :disabled="!tempRange.startDate" />
44
+ </time-picker>
45
+ </view>
46
+ <uni-icons type="arrowthinright" color="#999" style="line-height: 40px;"></uni-icons>
47
+ <view class="popup-x-header--datetime">
48
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
49
+ :placeholder="endDateText" />
50
+ <time-picker type="time" v-model="tempRange.endTime" :end="reactEndTime" :border="false"
51
+ :disabled="!tempRange.endDate" :hideSecond="hideSecond">
52
+ <input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime"
53
+ :placeholder="endTimeText" :disabled="!tempRange.endDate" />
54
+ </time-picker>
55
+ </view>
56
+ </view>
57
+ <view class="popup-x-body">
58
+ <calendar ref="left" class="uni-date_calendar-pc" :showMonth="false"
59
+ :start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true"
60
+ @change="leftChange" :pleStatus="endMultipleStatus" @firstEnterCale="updateRightCale"
61
+ @monthSwitch="leftMonthSwitch" />
62
+ <calendar ref="right" class="uni-date_calendar-pc" :showMonth="false"
63
+ :start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true"
64
+ @change="rightChange" :pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
65
+ @monthSwitch="rightMonthSwitch" style="border-left: 1px solid #F1F1F1;" />
66
+ </view>
67
+ <view v-if="hasTime" class="popup-x-footer">
68
+ <text class="" @click="clear">{{clearText}}</text>
69
+ <text class="confirm" @click="confirmRangeChange">{{okText}}</text>
70
+ </view>
71
+ </view>
72
+ </view>
73
+ <calendar v-if="isPhone" :type="type" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime"
74
+ :start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime"
75
+ :pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false"
76
+ :hideSecond="hideSecond" @confirm="mobileChange" @maskClick="close" />
77
+ </view>
78
+ </template>
79
+ <script>
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
+ import calendar from './calendar.vue'
98
+ import timePicker from './time-picker.vue'
99
+ import {
100
+ initVueI18n
101
+ } from '@dcloudio/uni-i18n'
102
+ import messages from './i18n/index.js'
103
+ const {
104
+ t
105
+ } = initVueI18n(messages)
106
+
107
+ export default {
108
+ name: 'UniDatetimePicker',
109
+ components: {
110
+ calendar,
111
+ timePicker
112
+ },
113
+ data() {
114
+ return {
115
+ yearValue: '',
116
+ monthValue: '',
117
+ isRange: false,
118
+ hasTime: false,
119
+ mobileRange: false,
120
+ // 单选
121
+ singleVal: '',
122
+ tempSingleDate: '',
123
+ defSingleDate: '',
124
+ time: '',
125
+ // 范围选
126
+ caleRange: {
127
+ startDate: '',
128
+ startTime: '',
129
+ endDate: '',
130
+ endTime: ''
131
+ },
132
+ range: {
133
+ startDate: '',
134
+ // startTime: '',
135
+ endDate: '',
136
+ // endTime: ''
137
+ },
138
+ tempRange: {
139
+ startDate: '',
140
+ startTime: '',
141
+ endDate: '',
142
+ endTime: ''
143
+ },
144
+ // 左右日历同步数据
145
+ startMultipleStatus: {
146
+ before: '',
147
+ after: '',
148
+ data: [],
149
+ fulldate: ''
150
+ },
151
+ endMultipleStatus: {
152
+ before: '',
153
+ after: '',
154
+ data: [],
155
+ fulldate: ''
156
+ },
157
+ visible: false,
158
+ popup: false,
159
+ popover: null,
160
+ isEmitValue: false,
161
+ isPhone: false,
162
+ isFirstShow: true,
163
+ 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=='
164
+ }
165
+ },
166
+ props: {
167
+ type: {
168
+ type: String,
169
+ default: 'date'
170
+ },
171
+ value: {
172
+ type: [String, Number, Array, Date],
173
+ default: ''
174
+ },
175
+ modelValue: {
176
+ type: [String, Number, Array, Date],
177
+ default: ''
178
+ },
179
+ start: {
180
+ type: [Number, String],
181
+ default: ''
182
+ },
183
+ end: {
184
+ type: [Number, String],
185
+ default: ''
186
+ },
187
+ returnType: {
188
+ type: String,
189
+ default: 'string'
190
+ },
191
+ placeholder: {
192
+ type: String,
193
+ default: ''
194
+ },
195
+ startPlaceholder: {
196
+ type: String,
197
+ default: ''
198
+ },
199
+ endPlaceholder: {
200
+ type: String,
201
+ default: ''
202
+ },
203
+ rangeSeparator: {
204
+ type: String,
205
+ default: '-'
206
+ },
207
+ border: {
208
+ type: [Boolean],
209
+ default: true
210
+ },
211
+ disabled: {
212
+ type: [Boolean],
213
+ default: false
214
+ },
215
+ clearIcon: {
216
+ type: [Boolean],
217
+ default: true
218
+ },
219
+ hideSecond: {
220
+ type: [Boolean],
221
+ default: false
222
+ },
223
+ format: {
224
+ type: String,
225
+ default: 'YYYY-MM-DD HH:mm:ss'
226
+ },
227
+ },
228
+ watch: {
229
+ format: {
230
+ immediate: true,
231
+ handler(newVal, oldVal) {
232
+ if (newVal.indexOf('HH:mm:ss') !== -1 && this.type !== 'month' && this.type !== 'week') {
233
+ this.hasTime = true
234
+ } else {
235
+ this.hasTime = false
236
+ }
237
+ }
238
+ },
239
+ type: {
240
+ immediate: true,
241
+ handler(newVal, oldVal) {
242
+ // if (newVal.indexOf('time') !== -1) {
243
+ // this.hasTime = true
244
+ // } else {
245
+ // this.hasTime = false
246
+ // }
247
+ if (newVal.indexOf('range') !== -1) {
248
+ this.isRange = true
249
+ } else {
250
+ this.isRange = false
251
+ }
252
+ }
253
+ },
254
+ value: {
255
+ immediate: true,
256
+ handler(newVal, oldVal) {
257
+ if (this.isEmitValue) {
258
+ this.isEmitValue = false
259
+ return
260
+ }
261
+ this.initPicker(newVal)
262
+ }
263
+ },
264
+
265
+ start: {
266
+ immediate: true,
267
+ handler(newVal, oldVal) {
268
+ if (!newVal) return
269
+ const {
270
+ defDate,
271
+ defTime
272
+ } = this.parseDate(newVal)
273
+ this.caleRange.startDate = defDate
274
+ if (this.hasTime) {
275
+ this.caleRange.startTime = defTime
276
+ }
277
+ }
278
+ },
279
+
280
+ end: {
281
+ immediate: true,
282
+ handler(newVal, oldVal) {
283
+ if (!newVal) return
284
+ const {
285
+ defDate,
286
+ defTime
287
+ } = this.parseDate(newVal)
288
+ this.caleRange.endDate = defDate
289
+ if (this.hasTime) {
290
+ this.caleRange.endTime = defTime
291
+ }
292
+ }
293
+ },
294
+ },
295
+ computed: {
296
+ reactStartTime() {
297
+ const activeDate = this.isRange ? this.tempRange.startDate : this.tempSingleDate
298
+ const res = activeDate === this.caleRange.startDate ? this.caleRange.startTime : ''
299
+ return res
300
+ },
301
+ reactEndTime() {
302
+ const activeDate = this.isRange ? this.tempRange.endDate : this.tempSingleDate
303
+ const res = activeDate === this.caleRange.endDate ? this.caleRange.endTime : ''
304
+ return res
305
+ },
306
+ reactMobDefTime() {
307
+ const times = {
308
+ start: this.tempRange.startTime,
309
+ end: this.tempRange.endTime
310
+ }
311
+ return this.isRange ? times : this.time
312
+ },
313
+ mobSelectableTime() {
314
+ return {
315
+ start: this.caleRange.startTime,
316
+ end: this.caleRange.endTime
317
+ }
318
+ },
319
+ datePopupWidth() {
320
+ // todo
321
+ return this.isRange ? 653 : 301
322
+ },
323
+
324
+ /**
325
+ * for i18n
326
+ */
327
+ singlePlaceholderText() {
328
+ return this.placeholder || (this.type === 'date' ? this.selectDateText : t(
329
+ "uni-datetime-picker.selectDateTime"))
330
+ },
331
+ startPlaceholderText() {
332
+ return this.startPlaceholder || this.startDateText
333
+ },
334
+ endPlaceholderText() {
335
+ return this.endPlaceholder || this.endDateText
336
+ },
337
+ selectDateText() {
338
+ return t("uni-datetime-picker.selectDate")
339
+ },
340
+ selectTimeText() {
341
+ return t("uni-datetime-picker.selectTime")
342
+ },
343
+ startDateText() {
344
+ return this.startPlaceholder || t("uni-datetime-picker.startDate")
345
+ },
346
+ startTimeText() {
347
+ return t("uni-datetime-picker.startTime")
348
+ },
349
+ endDateText() {
350
+ return this.endPlaceholder || t("uni-datetime-picker.endDate")
351
+ },
352
+ endTimeText() {
353
+ return t("uni-datetime-picker.endTime")
354
+ },
355
+ okText() {
356
+ return t("uni-datetime-picker.ok")
357
+ },
358
+ clearText() {
359
+ return t("uni-datetime-picker.clear")
360
+ }
361
+ },
362
+ created() {
363
+ this.form = this.getForm('uniForms')
364
+ this.formItem = this.getForm('uniFormsItem')
365
+
366
+ // if (this.formItem) {
367
+ // if (this.formItem.name) {
368
+ // this.rename = this.formItem.name
369
+ // this.form.inputChildrens.push(this)
370
+ // }
371
+ // }
372
+ },
373
+ mounted() {
374
+ this.platform()
375
+ },
376
+ methods: {
377
+ bindDateChange(e) {
378
+ this.singleVal = e.detail.value
379
+ this.setEmit(this.singleVal)
380
+ },
381
+ /**
382
+ * 获取父元素实例
383
+ */
384
+ getForm(name = 'uniForms') {
385
+ let parent = this.$parent;
386
+ let parentName = parent.$options.name;
387
+ while (parentName !== name) {
388
+ parent = parent.$parent;
389
+ if (!parent) return false
390
+ parentName = parent.$options.name;
391
+ }
392
+ return parent;
393
+ },
394
+ initPicker(newVal) {
395
+ if (!newVal || Array.isArray(newVal) && !newVal.length) {
396
+ this.$nextTick(() => {
397
+ this.clear(false)
398
+ })
399
+ return
400
+ }
401
+ if (!Array.isArray(newVal) && !this.isRange) {
402
+ const {
403
+ defDate,
404
+ defTime
405
+ } = this.parseDate(newVal)
406
+ this.singleVal = defDate
407
+ this.tempSingleDate = defDate
408
+ this.defSingleDate = defDate
409
+ if (this.hasTime) {
410
+ this.singleVal = defDate + ' ' + defTime
411
+ this.time = defTime
412
+ }
413
+ } else {
414
+ const [before, after] = newVal
415
+ if (!before && !after) return
416
+ const defBefore = this.parseDate(before)
417
+ const defAfter = this.parseDate(after)
418
+ const startDate = defBefore.defDate
419
+ const endDate = defAfter.defDate
420
+ this.range.startDate = this.tempRange.startDate = startDate
421
+ this.range.endDate = this.tempRange.endDate = endDate
422
+
423
+ if (this.hasTime) {
424
+ this.range.startDate = defBefore.defDate + ' ' + defBefore.defTime
425
+ this.range.endDate = defAfter.defDate + ' ' + defAfter.defTime
426
+ this.tempRange.startTime = defBefore.defTime
427
+ this.tempRange.endTime = defAfter.defTime
428
+ }
429
+ const defaultRange = {
430
+ before: defBefore.defDate,
431
+ after: defAfter.defDate
432
+ }
433
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, defaultRange, {
434
+ which: 'right'
435
+ })
436
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, defaultRange, {
437
+ which: 'left'
438
+ })
439
+ }
440
+ },
441
+ updateLeftCale(e) {
442
+ const left = this.$refs.left
443
+ // 设置范围选
444
+ left.cale.setHoverMultiple(e.after)
445
+ left.setDate(this.$refs.left.nowDate.fullDate)
446
+ },
447
+ updateRightCale(e) {
448
+ const right = this.$refs.right
449
+ // 设置范围选
450
+ right.cale.setHoverMultiple(e.after)
451
+ right.setDate(this.$refs.right.nowDate.fullDate)
452
+ },
453
+ platform() {
454
+ const systemInfo = uni.getSystemInfoSync()
455
+ this.isPhone = systemInfo.windowWidth <= 500
456
+ this.windowWidth = systemInfo.windowWidth
457
+ },
458
+ show(event) {
459
+ if (this.disabled) {
460
+ return
461
+ }
462
+ this.platform()
463
+ if (this.isPhone) {
464
+ this.$refs.mobile.open()
465
+ return
466
+ }
467
+ this.popover = {
468
+ top: '10px'
469
+ }
470
+ const dateEditor = uni.createSelectorQuery().in(this).select(".uni-date-editor")
471
+ dateEditor.boundingClientRect(rect => {
472
+ if (this.windowWidth - rect.left < this.datePopupWidth) {
473
+ this.popover.right = 0
474
+ }
475
+ }).exec()
476
+ setTimeout(() => {
477
+ this.popup = !this.popup
478
+ if (!this.isPhone && this.isRange && this.isFirstShow) {
479
+ this.isFirstShow = false
480
+ const {
481
+ startDate,
482
+ endDate
483
+ } = this.range
484
+ if (startDate && endDate) {
485
+ if (this.diffDate(startDate, endDate) < 30) {
486
+ this.$refs.right.next()
487
+ }
488
+ } else {
489
+ this.$refs.right.next()
490
+ this.$refs.right.cale.lastHover = false
491
+ }
492
+ }
493
+
494
+ }, 20)
495
+ },
496
+
497
+ close() {
498
+ console.log('close')
499
+ setTimeout(() => {
500
+ this.popup = false
501
+ }, 20)
502
+ },
503
+ setEmit(value) {
504
+ // if (this.returnType === "timestamp" || this.returnType === "date") {
505
+ // if (!Array.isArray(value)) {
506
+ // if (!this.hasTime) {
507
+ // value = value + ' ' + '00:00:00'
508
+ // }
509
+ // value = this.createTimestamp(value)
510
+ // if (this.returnType === "date") {
511
+ // value = new Date(value)
512
+ // }
513
+ // } else {
514
+ // if (!this.hasTime) {
515
+ // value[0] = value[0] + ' ' + '00:00:00'
516
+ // value[1] = value[1] + ' ' + '00:00:00'
517
+ // }
518
+ // value[0] = this.createTimestamp(value[0])
519
+ // value[1] = this.createTimestamp(value[1])
520
+ // if (this.returnType === "date") {
521
+ // value[0] = new Date(value[0])
522
+ // value[1] = new Date(value[1])
523
+ // }
524
+ // }
525
+ // }
526
+ // this.formItem && this.formItem.setValue(value)
527
+
528
+ this.$emit('change', value)
529
+ this.$emit('input', value)
530
+ this.$emit('update:modelValue', value)
531
+ this.isEmitValue = true
532
+
533
+ },
534
+ createTimestamp(date) {
535
+ date = this.fixIosDateFormat(date)
536
+ return Date.parse(new Date(date))
537
+ },
538
+ singleChange(e) {
539
+ this.tempSingleDate = e.fulldate
540
+ if (this.hasTime) return
541
+ this.confirmSingleChange()
542
+ },
543
+
544
+ confirmSingleChange() {
545
+ if (!this.tempSingleDate) {
546
+ this.popup = false
547
+ return
548
+ }
549
+ if (this.hasTime) {
550
+ this.singleVal = this.tempSingleDate + ' ' + (this.time ? this.time : '00:00:00')
551
+ } else {
552
+ this.singleVal = this.tempSingleDate
553
+ }
554
+ this.setEmit(this.singleVal)
555
+ this.popup = false
556
+ },
557
+
558
+ leftChange(e) {
559
+ const {
560
+ before,
561
+ after
562
+ } = e.range
563
+ this.rangeChange(before, after)
564
+ const obj = {
565
+ before: e.range.before,
566
+ after: e.range.after,
567
+ data: e.range.data,
568
+ fulldate: e.fulldate
569
+ }
570
+ this.startMultipleStatus = Object.assign({}, this.startMultipleStatus, obj)
571
+ },
572
+
573
+ rightChange(e) {
574
+ const {
575
+ before,
576
+ after
577
+ } = e.range
578
+ this.rangeChange(before, after)
579
+ const obj = {
580
+ before: e.range.before,
581
+ after: e.range.after,
582
+ data: e.range.data,
583
+ fulldate: e.fulldate
584
+ }
585
+ this.endMultipleStatus = Object.assign({}, this.endMultipleStatus, obj)
586
+ },
587
+
588
+ mobileChange(e) {
589
+ if (this.isRange) {
590
+ const {
591
+ before,
592
+ after
593
+ } = e.range
594
+ this.handleStartAndEnd(before, after, true)
595
+ if (this.hasTime) {
596
+ const {
597
+ startTime,
598
+ endTime
599
+ } = e.timeRange
600
+ this.tempRange.startTime = startTime
601
+ this.tempRange.endTime = endTime
602
+ }
603
+ this.confirmRangeChange()
604
+
605
+ } else {
606
+ if (this.hasTime) {
607
+ if (e.fulldate === '') {
608
+ this.singleVal = ''
609
+ } else {
610
+ this.singleVal = e.fulldate + ' ' + (e.time ? e.time : '00:00:00')
611
+ }
612
+ } else {
613
+ this.singleVal = e.fulldate
614
+ }
615
+ this.setEmit(this.singleVal)
616
+ }
617
+ this.$refs.mobile.close()
618
+ },
619
+
620
+ rangeChange(before, after) {
621
+ if (!(before && after)) return
622
+ this.handleStartAndEnd(before, after, true)
623
+ if (this.hasTime) return
624
+ this.confirmRangeChange()
625
+ },
626
+
627
+ confirmRangeChange() {
628
+ if (!this.tempRange.startDate && !this.tempRange.endDate) {
629
+ this.popup = false
630
+ return
631
+ }
632
+ let start, end
633
+ if (!this.hasTime) {
634
+ start = this.range.startDate = this.tempRange.startDate
635
+ end = this.range.endDate = this.tempRange.endDate
636
+ } else {
637
+ start = this.range.startDate = this.tempRange.startDate + ' ' +
638
+ (this.tempRange.startTime ? this.tempRange.startTime : '00:00:00')
639
+ end = this.range.endDate = this.tempRange.endDate + ' ' +
640
+ (this.tempRange.endTime ? this.tempRange.endTime : '00:00:00')
641
+ }
642
+ const displayRange = [start, end]
643
+ this.setEmit(displayRange)
644
+ this.popup = false
645
+ },
646
+
647
+ handleStartAndEnd(before, after, temp = false) {
648
+ if (!(before && after)) return
649
+ const type = temp ? 'tempRange' : 'range'
650
+ if (this.dateCompare(before, after)) {
651
+ this[type].startDate = before
652
+ this[type].endDate = after
653
+ } else {
654
+ this[type].startDate = after
655
+ this[type].endDate = before
656
+ }
657
+ },
658
+
659
+ /**
660
+ * 比较时间大小
661
+ */
662
+ dateCompare(startDate, endDate) {
663
+ // 计算截止时间
664
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
665
+ // 计算详细项的截止时间
666
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
667
+ if (startDate <= endDate) {
668
+ return true
669
+ } else {
670
+ return false
671
+ }
672
+ },
673
+
674
+ /**
675
+ * 比较时间差
676
+ */
677
+ diffDate(startDate, endDate) {
678
+ // 计算截止时间
679
+ startDate = new Date(startDate.replace('-', '/').replace('-', '/'))
680
+ // 计算详细项的截止时间
681
+ endDate = new Date(endDate.replace('-', '/').replace('-', '/'))
682
+ const diff = (endDate - startDate) / (24 * 60 * 60 * 1000)
683
+ return Math.abs(diff)
684
+ },
685
+
686
+ clear(needEmit = true) {
687
+ if (!this.isRange) {
688
+ this.singleVal = ''
689
+ this.tempSingleDate = ''
690
+ this.time = ''
691
+ if (this.isPhone) {
692
+ this.$refs.mobile.clearCalender()
693
+ } else {
694
+ this.$refs.pcSingle.clearCalender()
695
+ }
696
+ if (needEmit) {
697
+ this.formItem && this.formItem.setValue('')
698
+ this.$emit('change', '')
699
+ this.$emit('input', '')
700
+ this.$emit('update:modelValue', '')
701
+ }
702
+ } else {
703
+ this.range.startDate = ''
704
+ this.range.endDate = ''
705
+ this.tempRange.startDate= ''
706
+ this.tempRange.startTime= ''
707
+ this.tempRange.endDate= ''
708
+ this.tempRange.endTime= ''
709
+ if (this.isPhone) {
710
+ this.$refs.mobile.clearCalender()
711
+ } else {
712
+ this.$refs.left.clearCalender()
713
+ this.$refs.right.clearCalender()
714
+ this.$refs.right.next()
715
+ }
716
+ if (needEmit) {
717
+ this.formItem && this.formItem.setValue([])
718
+ this.$emit('change', [])
719
+ this.$emit('input', [])
720
+ this.$emit('update:modelValue', [])
721
+ }
722
+ }
723
+ },
724
+
725
+ parseDate(date) {
726
+ date = this.fixIosDateFormat(date)
727
+ const defVal = new Date(date)
728
+ const year = defVal.getFullYear()
729
+ const month = defVal.getMonth() + 1
730
+ const day = defVal.getDate()
731
+ const hour = defVal.getHours()
732
+ const minute = defVal.getMinutes()
733
+ const second = defVal.getSeconds()
734
+ const defDate = year + '-' + this.lessTen(month) + '-' + this.lessTen(day)
735
+ const defTime = this.lessTen(hour) + ':' + this.lessTen(minute) + (this.hideSecond ? '' : (':' + this.lessTen(second)))
736
+ return {
737
+ defDate,
738
+ defTime
739
+ }
740
+ },
741
+
742
+ lessTen(item) {
743
+ return item < 10 ? '0' + item : item
744
+ },
745
+
746
+ //兼容 iOS、safari 日期格式
747
+ fixIosDateFormat(value) {
748
+ if (typeof value === 'string') {
749
+ value = value.replace(/-/g, '/')
750
+ }
751
+ return value
752
+ },
753
+
754
+ leftMonthSwitch(e) {
755
+ // console.log('leftMonthSwitch 返回:', e)
756
+ },
757
+ rightMonthSwitch(e) {
758
+ // console.log('rightMonthSwitch 返回:', e)
759
+ }
760
+ }
761
+ }
762
+ </script>
763
+
764
+ <style>
765
+ .uni-date-x {
766
+ display: flex;
767
+ flex-direction: row;
768
+ align-items: center;
769
+ justify-content: center;
770
+ padding: 0 10px;
771
+ border-radius: 4px;
772
+ background-color: #fff;
773
+ color: #666;
774
+ font-size: 14px;
775
+ }
776
+
777
+ .uni-date-x--border {
778
+ box-sizing: border-box;
779
+ border-radius: 4px;
780
+ border: 1px solid #dcdfe6;
781
+ }
782
+
783
+ .uni-date-editor--x {
784
+ position: relative;
785
+ }
786
+
787
+ .uni-date-editor--x .uni-date__icon-clear {
788
+ position: absolute;
789
+ top: 5px;
790
+ right: 0;
791
+ display: inline-block;
792
+ box-sizing: border-box;
793
+ border: 6px solid transparent;
794
+ margin-right: 6px;
795
+ background-color: red;
796
+ /* #ifdef H5 */
797
+ cursor: pointer;
798
+ /* #endif */
799
+ }
800
+
801
+ .uni-date__x-input {
802
+ padding: 0 8px;
803
+ height: 40px;
804
+ width: 100%;
805
+ line-height: 40px;
806
+ font-size: 14px;
807
+ }
808
+
809
+ .t-c {
810
+ text-align: center;
811
+ }
812
+
813
+ .uni-date__input {
814
+ height: 40px;
815
+ width: 100%;
816
+ line-height: 40px;
817
+ font-size: 14px;
818
+ }
819
+
820
+ .uni-date-range__input {
821
+ text-align: center;
822
+ max-width: 142px;
823
+ }
824
+
825
+ .uni-date-picker__container {
826
+ position: relative;
827
+ /* position: fixed;
828
+ left: 0;
829
+ right: 0;
830
+ top: 0;
831
+ bottom: 0;
832
+ box-sizing: border-box;
833
+ z-index: 996;
834
+ font-size: 14px; */
835
+ }
836
+
837
+ .uni-date-mask {
838
+ position: fixed;
839
+ bottom: 0px;
840
+ top: 0px;
841
+ left: 0px;
842
+ right: 0px;
843
+ background-color: rgba(0, 0, 0, 0);
844
+ transition-duration: 0.3s;
845
+ z-index: 996;
846
+ }
847
+
848
+ .uni-date-single--x {
849
+ /* padding: 0 8px; */
850
+ background-color: #fff;
851
+ position: absolute;
852
+ top: 0;
853
+ z-index: 999;
854
+ border: 1px solid #e4e7ed;
855
+ box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
856
+ border-radius: 4px;
857
+ }
858
+
859
+ .uni-date-range--x {
860
+ /* padding: 0 8px; */
861
+ background-color: #fff;
862
+ position: absolute;
863
+ top: 0;
864
+ z-index: 999;
865
+ border: 1px solid #e4e7ed;
866
+ box-shadow: 0 2px 12px 0 rgb(0 0 0 / 10%);
867
+ border-radius: 4px;
868
+ }
869
+
870
+ .uni-date-editor--x__disabled {
871
+ opacity: 0.4;
872
+ cursor: default;
873
+ }
874
+
875
+ .uni-date-editor--logo {
876
+ width: 16px;
877
+ height: 16px;
878
+ vertical-align: middle;
879
+ }
880
+
881
+ /* 添加时间 */
882
+ .popup-x-header {
883
+ /* #ifndef APP-NVUE */
884
+ display: flex;
885
+ /* #endif */
886
+ flex-direction: row;
887
+ /* justify-content: space-between; */
888
+ }
889
+
890
+ .popup-x-header--datetime {
891
+ /* #ifndef APP-NVUE */
892
+ display: flex;
893
+ /* #endif */
894
+ flex-direction: row;
895
+ flex: 1;
896
+ }
897
+
898
+ .popup-x-body {
899
+ display: flex;
900
+ }
901
+
902
+ .popup-x-footer {
903
+ padding: 0 15px;
904
+ border-top-color: #F1F1F1;
905
+ border-top-style: solid;
906
+ border-top-width: 1px;
907
+ background-color: #fff;
908
+ line-height: 40px;
909
+ text-align: right;
910
+ color: #666;
911
+ }
912
+
913
+ .popup-x-footer text:hover {
914
+ color: #007aff;
915
+ cursor: pointer;
916
+ opacity: 0.8;
917
+ }
918
+
919
+ .popup-x-footer .confirm {
920
+ margin-left: 20px;
921
+ color: #007aff;
922
+ }
923
+
924
+ .uni-date-changed {
925
+ background-color: #fff;
926
+ text-align: center;
927
+ color: #333;
928
+ border-bottom-color: #F1F1F1;
929
+ border-bottom-style: solid;
930
+ border-bottom-width: 1px;
931
+ /* padding: 0 50px; */
932
+ }
933
+
934
+ .uni-date-changed--time text {
935
+ /* padding: 0 20px; */
936
+ height: 50px;
937
+ line-height: 50px;
938
+ }
939
+
940
+ .uni-date-changed .uni-date-changed--time {
941
+ /* display: flex; */
942
+ flex: 1;
943
+ }
944
+
945
+ .uni-date-changed--time-date {
946
+ color: #333;
947
+ opacity: 0.6;
948
+ }
949
+
950
+ .mr-50 {
951
+ margin-right: 50px;
952
+ }
953
+
954
+ .uni-date_calendar-pc {
955
+ padding: 0 6px;
956
+ }
957
+ .clear-btn {
958
+ position: absolute;
959
+ width: 55rpx;
960
+ height: 55rpx;
961
+ line-height: 55rpx;
962
+ z-index: 80;
963
+ top: 0;
964
+ right: 0px;
965
+ }
966
+ </style>