@zscreate/zhxy-app-component 1.0.359 → 1.0.360
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.
- package/components/evan-form-item/evan-form-item.vue +2 -1
- package/components/uni-datetime-picker/components/uni-datetime-picker/calendar-item.vue +65 -6
- package/components/uni-datetime-picker/components/uni-datetime-picker/calendar.vue +65 -5
- package/components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue +26 -7
- package/package.json +1 -1
|
@@ -226,7 +226,8 @@
|
|
|
226
226
|
<view class="evan-form-item-container__main--body" v-else>
|
|
227
227
|
<uni-datetime-picker ref="datetime_picker" @change="dateChange" :hide-second="!(widget.options.format&&widget.options.format.includes(':ss'))" @click.native="isClickByUser = true" :type="widget.options.type"
|
|
228
228
|
:format="formatTime()" :clearIcon="!widget.options.disabled && widget.options.clearable"
|
|
229
|
-
:value="dataModel" @maskClick="maskClick" :border="false" :disabled="widget.options.disabled"
|
|
229
|
+
:value="dataModel" @maskClick="maskClick" :border="false" :disabled="widget.options.disabled" :disabledMinTime="widget.options.disabledMinTime"
|
|
230
|
+
:disabledMaxTime="widget.options.disabledMaxTime">
|
|
230
231
|
<view class="option-font-size">
|
|
231
232
|
{{ dataModel | filterDataModel(widget) }}
|
|
232
233
|
</view>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<view class="uni-calendar-item__weeks-box" :class="{
|
|
3
|
-
'uni-calendar-item--disable':weeks.disable,
|
|
3
|
+
'uni-calendar-item--disable':weeks.disable || isDateDisabled(weeks),
|
|
4
4
|
'uni-calendar-item--before-checked-x':weeks.beforeMultiple,
|
|
5
5
|
'uni-calendar-item--multiple': weeks.multiple,
|
|
6
6
|
'uni-calendar-item--after-checked-x':weeks.afterMultiple,
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
'uni-calendar-item--before-checked':weeks.beforeMultiple,
|
|
13
13
|
'uni-calendar-item--multiple': weeks.multiple,
|
|
14
14
|
'uni-calendar-item--after-checked':weeks.afterMultiple,
|
|
15
|
-
'uni-calendar-item--disable':weeks.disable,
|
|
15
|
+
'uni-calendar-item--disable':weeks.disable || isDateDisabled(weeks),
|
|
16
16
|
}">
|
|
17
17
|
<text v-if="selected&&weeks.extraInfo" class="uni-calendar-item__weeks-box-circle"></text>
|
|
18
18
|
<text class="uni-calendar-item__weeks-box-text">{{weeks.date}}</text>
|
|
@@ -23,7 +23,16 @@
|
|
|
23
23
|
<script>
|
|
24
24
|
export default {
|
|
25
25
|
props: {
|
|
26
|
-
|
|
26
|
+
// 添加禁用时间参数
|
|
27
|
+
disabledMinTime: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: ''
|
|
30
|
+
},
|
|
31
|
+
disabledMaxTime: {
|
|
32
|
+
type: String,
|
|
33
|
+
default: ''
|
|
34
|
+
},
|
|
35
|
+
type:{
|
|
27
36
|
type: String,
|
|
28
37
|
default: ''
|
|
29
38
|
},
|
|
@@ -55,12 +64,62 @@
|
|
|
55
64
|
}
|
|
56
65
|
},
|
|
57
66
|
methods: {
|
|
67
|
+
// 检查日期是否禁用
|
|
68
|
+
isDateDisabled(dateObj) {
|
|
69
|
+
const { disabledMinTime, disabledMaxTime } = this;
|
|
70
|
+
console.log('disabledMaxTime',this.disabledMaxTime)
|
|
71
|
+
if (!disabledMinTime && !disabledMaxTime) return false;
|
|
72
|
+
|
|
73
|
+
const currentDate = dateObj.fullDate; // 格式: YYYY-MM-DD
|
|
74
|
+
const currentDateTime = currentDate + ' 00:00:00';
|
|
75
|
+
|
|
76
|
+
// 比较日期
|
|
77
|
+
if (disabledMinTime) {
|
|
78
|
+
const minDate = this.formatDateToCompare(disabledMinTime);
|
|
79
|
+
if (this.compareDateTime(currentDateTime, minDate) < 0) {
|
|
80
|
+
return true;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (disabledMaxTime) {
|
|
85
|
+
const maxDate = this.formatDateToCompare(disabledMaxTime);
|
|
86
|
+
if (this.compareDateTime(currentDateTime, maxDate) > 0) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
return false;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
// 格式化日期为统一格式进行比较
|
|
95
|
+
formatDateToCompare(dateTimeStr) {
|
|
96
|
+
if (!dateTimeStr) return '';
|
|
97
|
+
|
|
98
|
+
let dateStr = dateTimeStr;
|
|
99
|
+
|
|
100
|
+
// 处理不同的日期时间格式
|
|
101
|
+
if (dateStr.length === 10) { // YYYY-MM-DD
|
|
102
|
+
dateStr += ' 00:00:00';
|
|
103
|
+
} else if (dateStr.length === 16) { // YYYY-MM-DD HH:mm
|
|
104
|
+
dateStr += ':00';
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return dateStr;
|
|
108
|
+
},
|
|
109
|
+
|
|
110
|
+
// 比较两个日期时间
|
|
111
|
+
compareDateTime(dateTimeA, dateTimeB) {
|
|
112
|
+
const timestampA = new Date(dateTimeA.replace(/-/g, '/')).getTime();
|
|
113
|
+
const timestampB = new Date(dateTimeB.replace(/-/g, '/')).getTime();
|
|
114
|
+
return timestampA - timestampB;
|
|
115
|
+
},
|
|
58
116
|
choiceDate(weeks) {
|
|
59
|
-
|
|
60
|
-
this.$emit('change', weeks)
|
|
117
|
+
if (weeks.disable || this.isDateDisabled(weeks)) return;
|
|
118
|
+
this.$emit('change', weeks);
|
|
61
119
|
},
|
|
62
120
|
handleMousemove(weeks) {
|
|
63
|
-
this
|
|
121
|
+
if (weeks.disable || this.isDateDisabled(weeks)) return;
|
|
122
|
+
this.$emit('handleMouse', weeks);
|
|
64
123
|
}
|
|
65
124
|
}
|
|
66
125
|
}
|
|
@@ -70,8 +70,8 @@
|
|
|
70
70
|
<view class="uni-calendar__weeks" v-for="(item,weekIndex) in weeks" :key="weekIndex">
|
|
71
71
|
<view class="uni-calendar__weeks-item" v-for="(weeks,weeksIndex) in item" :key="weeksIndex">
|
|
72
72
|
<calendar-item :type="type" class="uni-calendar-item--hook" :weeks="weeks" :calendar="calendar"
|
|
73
|
-
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate"
|
|
74
|
-
@handleMouse="handleMouse">
|
|
73
|
+
:selected="selected" :lunar="lunar" :checkHover="range" @change="choiceDate" :disabledMinTime="disabledMinTime"
|
|
74
|
+
:disabledMaxTime="disabledMaxTime" @handleMouse="handleMouse">
|
|
75
75
|
</calendar-item>
|
|
76
76
|
</view>
|
|
77
77
|
</view>
|
|
@@ -255,7 +255,16 @@
|
|
|
255
255
|
fulldate: ''
|
|
256
256
|
}
|
|
257
257
|
}
|
|
258
|
-
}
|
|
258
|
+
},
|
|
259
|
+
// 添加禁用时间参数
|
|
260
|
+
disabledMinTime: {
|
|
261
|
+
type: String,
|
|
262
|
+
default: ''
|
|
263
|
+
},
|
|
264
|
+
disabledMaxTime: {
|
|
265
|
+
type: String,
|
|
266
|
+
default: ''
|
|
267
|
+
},
|
|
259
268
|
},
|
|
260
269
|
data() {
|
|
261
270
|
return {
|
|
@@ -475,7 +484,7 @@
|
|
|
475
484
|
this.firstEnter = true
|
|
476
485
|
},
|
|
477
486
|
handleMouse(weeks) {
|
|
478
|
-
if (weeks.disable) return
|
|
487
|
+
if (weeks.disable || this.isDateDisabled(weeks)) return;
|
|
479
488
|
if (this.cale.lastHover) return
|
|
480
489
|
let {
|
|
481
490
|
before,
|
|
@@ -669,12 +678,63 @@
|
|
|
669
678
|
})
|
|
670
679
|
|
|
671
680
|
},
|
|
681
|
+
// 检查日期是否禁用
|
|
682
|
+
isDateDisabled(dateObj) {
|
|
683
|
+
const { disabledMinTime, disabledMaxTime } = this;
|
|
684
|
+
|
|
685
|
+
if (!disabledMinTime && !disabledMaxTime) return false;
|
|
686
|
+
|
|
687
|
+
const currentDate = dateObj.fullDate; // 格式: YYYY-MM-DD
|
|
688
|
+
const currentDateTime = dateObj.fullDate + ' 00:00:00'; // 转换为完整日期时间
|
|
689
|
+
|
|
690
|
+
// 比较日期
|
|
691
|
+
if (disabledMinTime) {
|
|
692
|
+
const minDate = this.formatDateToCompare(disabledMinTime);
|
|
693
|
+
if (this.compareDateTime(currentDateTime, minDate) < 0) {
|
|
694
|
+
return true;
|
|
695
|
+
}
|
|
696
|
+
}
|
|
697
|
+
|
|
698
|
+
if (disabledMaxTime) {
|
|
699
|
+
const maxDate = this.formatDateToCompare(disabledMaxTime);
|
|
700
|
+
if (this.compareDateTime(currentDateTime, maxDate) > 0) {
|
|
701
|
+
return true;
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
705
|
+
return false;
|
|
706
|
+
},
|
|
707
|
+
|
|
708
|
+
// 格式化日期为统一格式进行比较
|
|
709
|
+
formatDateToCompare(dateTimeStr) {
|
|
710
|
+
if (!dateTimeStr) return '';
|
|
711
|
+
|
|
712
|
+
// 处理不同的日期时间格式
|
|
713
|
+
let dateStr = dateTimeStr;
|
|
714
|
+
|
|
715
|
+
// 如果只有日期,添加默认时间
|
|
716
|
+
if (dateStr.length === 10) { // YYYY-MM-DD
|
|
717
|
+
dateStr += ' 00:00:00';
|
|
718
|
+
} else if (dateStr.length === 16) { // YYYY-MM-DD HH:mm
|
|
719
|
+
dateStr += ':00';
|
|
720
|
+
}
|
|
721
|
+
// YYYY-MM-DD HH:mm:ss 格式保持不变
|
|
722
|
+
|
|
723
|
+
return dateStr;
|
|
724
|
+
},
|
|
725
|
+
|
|
726
|
+
// 比较两个日期时间
|
|
727
|
+
compareDateTime(dateTimeA, dateTimeB) {
|
|
728
|
+
const timestampA = new Date(dateTimeA.replace(/-/g, '/')).getTime();
|
|
729
|
+
const timestampB = new Date(dateTimeB.replace(/-/g, '/')).getTime();
|
|
730
|
+
return timestampA - timestampB;
|
|
731
|
+
},
|
|
672
732
|
/**
|
|
673
733
|
* 选择天触发
|
|
674
734
|
* @param {Object} weeks
|
|
675
735
|
*/
|
|
676
736
|
choiceDate(weeks) {
|
|
677
|
-
if (weeks.disable) return
|
|
737
|
+
if (weeks.disable || this.isDateDisabled(weeks)) return;
|
|
678
738
|
this.calendar = weeks
|
|
679
739
|
this.calendar.userChecked = true
|
|
680
740
|
// 设置多选
|
package/components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue
CHANGED
|
@@ -16,14 +16,17 @@
|
|
|
16
16
|
<input class="uni-date__input t-c" type="text" v-model="tempSingleDate"
|
|
17
17
|
:placeholder="selectDateText" />
|
|
18
18
|
<time-picker type="time" v-model="time" :border="false" :disabled="!tempSingleDate"
|
|
19
|
-
:start="reactStartTime" :end="reactEndTime" :hideSecond="hideSecond" style="width: 100%;"
|
|
19
|
+
:start="reactStartTime" :end="reactEndTime" :hideSecond="hideSecond" style="width: 100%;" :disabledMinTime="disabledMinTime"
|
|
20
|
+
:disabledMaxTime="disabledMaxTime"
|
|
21
|
+
:currentDate="tempSingleDate">
|
|
20
22
|
<input class="uni-date__input t-c" type="text" v-model="time" :placeholder="selectTimeText"
|
|
21
23
|
:disabled="!tempSingleDate" />
|
|
22
24
|
</time-picker>
|
|
23
25
|
</view>
|
|
24
26
|
<calendar ref="pcSingle" class="uni-date_calendar-pc" :showMonth="false" :type="type"
|
|
25
27
|
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :date="defSingleDate"
|
|
26
|
-
@change="singleChange"
|
|
28
|
+
@change="singleChange" :disabledMinTime="disabledMinTime"
|
|
29
|
+
:disabledMaxTime="disabledMaxTime"/>
|
|
27
30
|
<view v-if="hasTime" class="popup-x-footer">
|
|
28
31
|
<!-- <text class="">此刻</text> -->
|
|
29
32
|
<text class="confirm" @click="confirmSingleChange">{{okText}}</text>
|
|
@@ -37,7 +40,9 @@
|
|
|
37
40
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.startDate"
|
|
38
41
|
:placeholder="startDateText" />
|
|
39
42
|
<time-picker type="time" v-model="tempRange.startTime" :start="reactStartTime" :border="false"
|
|
40
|
-
:disabled="!tempRange.startDate" :hideSecond="hideSecond"
|
|
43
|
+
:disabled="!tempRange.startDate" :hideSecond="hideSecond" :disabledMinTime="disabledMinTime"
|
|
44
|
+
:disabledMaxTime="disabledMaxTime"
|
|
45
|
+
:currentDate="tempSingleDate">
|
|
41
46
|
<input class="uni-date__input uni-date-range__input" type="text"
|
|
42
47
|
v-model="tempRange.startTime" :placeholder="startTimeText"
|
|
43
48
|
:disabled="!tempRange.startDate" />
|
|
@@ -48,7 +53,9 @@
|
|
|
48
53
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endDate"
|
|
49
54
|
:placeholder="endDateText" />
|
|
50
55
|
<time-picker type="time" v-model="tempRange.endTime" :end="reactEndTime" :border="false"
|
|
51
|
-
:disabled="!tempRange.endDate" :hideSecond="hideSecond"
|
|
56
|
+
:disabled="!tempRange.endDate" :hideSecond="hideSecond" :disabledMinTime="disabledMinTime"
|
|
57
|
+
:disabledMaxTime="disabledMaxTime"
|
|
58
|
+
:currentDate="tempSingleDate">
|
|
52
59
|
<input class="uni-date__input uni-date-range__input" type="text" v-model="tempRange.endTime"
|
|
53
60
|
:placeholder="endTimeText" :disabled="!tempRange.endDate" />
|
|
54
61
|
</time-picker>
|
|
@@ -58,11 +65,13 @@
|
|
|
58
65
|
<calendar ref="left" class="uni-date_calendar-pc" :showMonth="false"
|
|
59
66
|
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true"
|
|
60
67
|
@change="leftChange" :pleStatus="endMultipleStatus" @firstEnterCale="updateRightCale"
|
|
61
|
-
@monthSwitch="leftMonthSwitch"
|
|
68
|
+
@monthSwitch="leftMonthSwitch" :disabledMinTime="disabledMinTime"
|
|
69
|
+
:disabledMaxTime="disabledMaxTime"/>
|
|
62
70
|
<calendar ref="right" class="uni-date_calendar-pc" :showMonth="false"
|
|
63
71
|
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :range="true"
|
|
64
72
|
@change="rightChange" :pleStatus="startMultipleStatus" @firstEnterCale="updateLeftCale"
|
|
65
|
-
@monthSwitch="rightMonthSwitch" style="border-left: 1px solid #F1F1F1;"
|
|
73
|
+
@monthSwitch="rightMonthSwitch" style="border-left: 1px solid #F1F1F1;" :disabledMinTime="disabledMinTime"
|
|
74
|
+
:disabledMaxTime="disabledMaxTime"/>
|
|
66
75
|
</view>
|
|
67
76
|
<view v-if="hasTime" class="popup-x-footer">
|
|
68
77
|
<text class="" @click="clear">{{clearText}}</text>
|
|
@@ -73,7 +82,8 @@
|
|
|
73
82
|
<calendar v-if="isPhone" :type="type" ref="mobile" :clearDate="false" :date="defSingleDate" :defTime="reactMobDefTime"
|
|
74
83
|
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :selectableTimes="mobSelectableTime"
|
|
75
84
|
:pleStatus="endMultipleStatus" :showMonth="false" :range="isRange" :typeHasTime="hasTime" :insert="false"
|
|
76
|
-
:hideSecond="hideSecond" @confirm="mobileChange" @maskClick="close"
|
|
85
|
+
:hideSecond="hideSecond" @confirm="mobileChange" @maskClick="close" :disabledMinTime="disabledMinTime"
|
|
86
|
+
:disabledMaxTime="disabledMaxTime"/>
|
|
77
87
|
</view>
|
|
78
88
|
</template>
|
|
79
89
|
<script>
|
|
@@ -225,6 +235,15 @@
|
|
|
225
235
|
type: String,
|
|
226
236
|
default: 'YYYY-MM-DD HH:mm:ss'
|
|
227
237
|
},
|
|
238
|
+
// 添加禁用时间参数
|
|
239
|
+
disabledMinTime: {
|
|
240
|
+
type: String,
|
|
241
|
+
default: ''
|
|
242
|
+
},
|
|
243
|
+
disabledMaxTime: {
|
|
244
|
+
type: String,
|
|
245
|
+
default: ''
|
|
246
|
+
},
|
|
228
247
|
},
|
|
229
248
|
watch: {
|
|
230
249
|
format: {
|