sadais-piui 1.2.7-beta130 → 1.2.7-beta132
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.
|
@@ -48,7 +48,7 @@ import { getConfig } from '../../config'
|
|
|
48
48
|
|
|
49
49
|
const TAG = 'PiDatePicker'
|
|
50
50
|
const { datePicker } = getConfig()
|
|
51
|
-
const FIELDS = ['year', 'month', 'day','halfday', 'hour', 'minute', 'second'
|
|
51
|
+
const FIELDS = ['year', 'month', 'day', 'halfday', 'hour', 'minute', 'second']
|
|
52
52
|
|
|
53
53
|
export default {
|
|
54
54
|
name: 'PiDatePicker',
|
|
@@ -228,9 +228,9 @@ export default {
|
|
|
228
228
|
},
|
|
229
229
|
data() {
|
|
230
230
|
let date = this.$pi.date.parseDate(this.defaultValue)
|
|
231
|
-
if(this.field === 'halfday') {
|
|
231
|
+
if (this.field === 'halfday') {
|
|
232
232
|
const time = date.time
|
|
233
|
-
if(date.hour < 12){
|
|
233
|
+
if (date.hour < 12) {
|
|
234
234
|
time.setHours(0)
|
|
235
235
|
} else {
|
|
236
236
|
time.setHours(12)
|
|
@@ -251,7 +251,10 @@ export default {
|
|
|
251
251
|
datePicker.confirmBtn,
|
|
252
252
|
this.popupSelect.confirmBtn
|
|
253
253
|
)
|
|
254
|
-
const mergeConfirmBtn = this.$pi.lang.mergeDeep(
|
|
254
|
+
const mergeConfirmBtn = this.$pi.lang.mergeDeep(
|
|
255
|
+
datePickerConfirmBtn,
|
|
256
|
+
this.confirmBtn
|
|
257
|
+
)
|
|
255
258
|
if (!mergeConfirmBtn.disabled) {
|
|
256
259
|
mergeConfirmBtn.disabled = this.scrolling
|
|
257
260
|
}
|
|
@@ -265,7 +268,10 @@ export default {
|
|
|
265
268
|
return this.$pi.lang.mergeDeep(datePickerCancelBtn, this.cancelBtn)
|
|
266
269
|
},
|
|
267
270
|
getPopup() {
|
|
268
|
-
const datePickerPopup = this.$pi.lang.mergeDeep(
|
|
271
|
+
const datePickerPopup = this.$pi.lang.mergeDeep(
|
|
272
|
+
datePicker.popup,
|
|
273
|
+
this.popupSelect.popup
|
|
274
|
+
)
|
|
269
275
|
return this.$pi.lang.mergeDeep(datePickerPopup, this.popup)
|
|
270
276
|
},
|
|
271
277
|
options() {
|
|
@@ -352,7 +358,7 @@ export default {
|
|
|
352
358
|
unit: '',
|
|
353
359
|
key: 'hour',
|
|
354
360
|
setMethod: 'setHours',
|
|
355
|
-
items: ['上午','下午']
|
|
361
|
+
items: ['上午', '下午']
|
|
356
362
|
},
|
|
357
363
|
{
|
|
358
364
|
field: 'hour',
|
|
@@ -378,12 +384,12 @@ export default {
|
|
|
378
384
|
type: 'time',
|
|
379
385
|
items: this.$pi.common.generateArray(0, 59)
|
|
380
386
|
}
|
|
381
|
-
]
|
|
387
|
+
]
|
|
382
388
|
|
|
383
389
|
columns = columns.filter((col, index) => {
|
|
384
390
|
return FIELDS.slice(index).includes(this.field)
|
|
385
391
|
})
|
|
386
|
-
if(this.field !== 'halfday'){
|
|
392
|
+
if (this.field !== 'halfday') {
|
|
387
393
|
columns = columns.filter(col => col.field !== 'halfday')
|
|
388
394
|
}
|
|
389
395
|
if (this.dateType === 'time') {
|
|
@@ -399,7 +405,7 @@ export default {
|
|
|
399
405
|
const value = this.date[col.key]
|
|
400
406
|
if (value !== null) {
|
|
401
407
|
// 查找当前picker中索引对应的真实值
|
|
402
|
-
if(col.field === 'halfday'){
|
|
408
|
+
if (col.field === 'halfday') {
|
|
403
409
|
const val = value < 12 ? 0 : 1
|
|
404
410
|
pickerValue.push(val)
|
|
405
411
|
} else {
|
|
@@ -424,15 +430,15 @@ export default {
|
|
|
424
430
|
methods: {
|
|
425
431
|
init() {
|
|
426
432
|
this.date = this.$pi.date.parseDate(this.defaultValue)
|
|
427
|
-
if(this.field === 'halfday') {
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
+
if (this.field === 'halfday') {
|
|
434
|
+
const time = this.date.time
|
|
435
|
+
if (this.date.hour < 12) {
|
|
436
|
+
time.setHours(0)
|
|
437
|
+
} else {
|
|
438
|
+
time.setHours(12)
|
|
439
|
+
}
|
|
440
|
+
this.date = this.$pi.date.parseDate(time)
|
|
433
441
|
}
|
|
434
|
-
this.date = this.$pi.date.parseDate(time)
|
|
435
|
-
}
|
|
436
442
|
},
|
|
437
443
|
handlePickstart() {
|
|
438
444
|
this.scrolling = true
|
|
@@ -456,12 +462,14 @@ export default {
|
|
|
456
462
|
const col = this.columns[index]
|
|
457
463
|
let val = col.items[value] // 取出对应picker值
|
|
458
464
|
if (col.field === 'month') val--
|
|
459
|
-
if(col.field === 'halfday') val = value === 0 ? 0 : 12
|
|
465
|
+
if (col.field === 'halfday') val = value === 0 ? 0 : 12
|
|
460
466
|
time[col.setMethod](val) // 调用原生date方法赋值
|
|
461
467
|
}
|
|
462
468
|
})
|
|
463
469
|
// 重新解析
|
|
464
470
|
this.date = this.$pi.date.parseDate(time)
|
|
471
|
+
|
|
472
|
+
this.$emit('scrollend', this.date)
|
|
465
473
|
},
|
|
466
474
|
/**
|
|
467
475
|
* @vuese
|
|
@@ -482,7 +490,7 @@ export default {
|
|
|
482
490
|
*/
|
|
483
491
|
handleConfirm() {
|
|
484
492
|
// 提交
|
|
485
|
-
if(this.field === 'halfday'){
|
|
493
|
+
if (this.field === 'halfday') {
|
|
486
494
|
const time = this.date.time
|
|
487
495
|
time.setMinutes(0)
|
|
488
496
|
time.setSeconds(0)
|
|
@@ -39,9 +39,11 @@
|
|
|
39
39
|
>
|
|
40
40
|
<slot v-if="$slots.toolbar" name="toolbar" />
|
|
41
41
|
<template v-else>
|
|
42
|
-
<view class="item-btn" @tap.stop="handlePopupClose"
|
|
42
|
+
<view class="item-btn" @tap.stop="handlePopupClose">
|
|
43
|
+
{{ getCancelBtn.text }}
|
|
44
|
+
</view>
|
|
43
45
|
<view class="item-btn pi-primary" @tap.stop="handleConfirm">
|
|
44
|
-
|
|
46
|
+
{{ getConfirmBtn.text }}
|
|
45
47
|
</view>
|
|
46
48
|
</template>
|
|
47
49
|
</view>
|