@zscreate/zhxy-app-component 1.0.333 → 1.0.334-test.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.
- package/components/evan-form-item/evan-form-item.vue +1 -1
- package/components/uni-datetime-picker/components/uni-datetime-picker/calendar.vue +5 -0
- package/components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue +40 -2
- package/components/uni-datetime-picker/components/uni-datetime-picker/util.js +15 -5
- package/package.json +1 -1
|
@@ -2464,7 +2464,7 @@ export default {
|
|
|
2464
2464
|
this.widget.key = v
|
|
2465
2465
|
this.$emit('upDateWidget', this.widget)
|
|
2466
2466
|
} else if (this.widget.type === 'date') {
|
|
2467
|
-
if (this.widget.options.type !== 'range' && v) {
|
|
2467
|
+
if (this.widget.options.type !== 'range' && this.widget.options.type !== 'week' && v) {
|
|
2468
2468
|
try {
|
|
2469
2469
|
this.dataModel = v = moment(v).format(this.widget.options.format)
|
|
2470
2470
|
} catch (e) {
|
|
@@ -169,6 +169,10 @@
|
|
|
169
169
|
timePicker,
|
|
170
170
|
},
|
|
171
171
|
props: {
|
|
172
|
+
type:{
|
|
173
|
+
type: String,
|
|
174
|
+
default: ''
|
|
175
|
+
},
|
|
172
176
|
date: {
|
|
173
177
|
type: String,
|
|
174
178
|
default: ''
|
|
@@ -429,6 +433,7 @@
|
|
|
429
433
|
startDate: this.startDate,
|
|
430
434
|
endDate: this.endDate,
|
|
431
435
|
range: this.range,
|
|
436
|
+
type: this.type
|
|
432
437
|
// multipleStatus: this.pleStatus
|
|
433
438
|
})
|
|
434
439
|
|
package/components/uni-datetime-picker/components/uni-datetime-picker/uni-datetime-picker.vue
CHANGED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
:disabled="!tempSingleDate" />
|
|
22
22
|
</time-picker>
|
|
23
23
|
</view>
|
|
24
|
-
<calendar ref="pcSingle" class="uni-date_calendar-pc" :showMonth="false"
|
|
24
|
+
<calendar ref="pcSingle" class="uni-date_calendar-pc" :showMonth="false" :type="type"
|
|
25
25
|
:start-date="caleRange.startDate" :end-date="caleRange.endDate" :date="defSingleDate"
|
|
26
26
|
@change="singleChange" />
|
|
27
27
|
<view v-if="hasTime" class="popup-x-footer">
|
|
@@ -77,6 +77,7 @@
|
|
|
77
77
|
</view>
|
|
78
78
|
</template>
|
|
79
79
|
<script>
|
|
80
|
+
import moment from '../../../../utils/moment'
|
|
80
81
|
/**
|
|
81
82
|
* DatetimePicker 时间选择器
|
|
82
83
|
* @description 同时支持 PC 和移动端使用日历选择日期和日期范围
|
|
@@ -399,10 +400,15 @@
|
|
|
399
400
|
return
|
|
400
401
|
}
|
|
401
402
|
if (!Array.isArray(newVal) && !this.isRange) {
|
|
402
|
-
|
|
403
|
+
let {
|
|
403
404
|
defDate,
|
|
404
405
|
defTime
|
|
405
406
|
} = this.parseDate(newVal)
|
|
407
|
+
if(this.type == 'week'){
|
|
408
|
+
defDate = this.getFirstDayOfWeekByWeekStr(newVal).fullDate
|
|
409
|
+
this.caleRange.startDate = defDate
|
|
410
|
+
this.caleRange.endDate = moment(defDate).add(6,'d').format('YYYY-MM-DD')
|
|
411
|
+
}
|
|
406
412
|
this.singleVal = defDate
|
|
407
413
|
this.tempSingleDate = defDate
|
|
408
414
|
this.defSingleDate = defDate
|
|
@@ -721,7 +727,39 @@
|
|
|
721
727
|
}
|
|
722
728
|
}
|
|
723
729
|
},
|
|
730
|
+
getDate(date) {
|
|
731
|
+
const y = date.getFullYear();
|
|
732
|
+
const m = date.getMonth() + 1 < 10 ? '0' + (date.getMonth() + 1) : date.getMonth() + 1;
|
|
733
|
+
const d = date.getDate() < 10 ? '0' + date.getDate() : date.getDate();
|
|
734
|
+
return {
|
|
735
|
+
fullDate: `${y}-${m}-${d}`,
|
|
736
|
+
year: y,
|
|
737
|
+
month: m,
|
|
738
|
+
day: d,
|
|
739
|
+
date
|
|
740
|
+
};
|
|
741
|
+
},
|
|
724
742
|
|
|
743
|
+
/**
|
|
744
|
+
* 获取指定年份和第几周的第一天
|
|
745
|
+
* @param {String} weekStr 格式为 'YYYY-MM周',其中 MM 表示第几周
|
|
746
|
+
* @returns {String} 返回该周的第一天,格式为 'YYYY-MM-DD'
|
|
747
|
+
*/
|
|
748
|
+
getFirstDayOfWeekByWeekStr(weekStr) {
|
|
749
|
+
if (!weekStr) return '';
|
|
750
|
+
// 解析输入的年份和周数
|
|
751
|
+
const [year, week] = weekStr.split('-');
|
|
752
|
+
const parsedYear = parseInt(year, 10);
|
|
753
|
+
const parsedWeek = parseInt(week.replace('周', ''), 10);
|
|
754
|
+
// 计算该年的第一天是周几(0 表示周日,1 表示周一,以此类推)
|
|
755
|
+
const firstDayOfYear = new Date(parsedYear, 0, 1).getDay();
|
|
756
|
+
// 计算第 1 周的第一天(周日为第一天)
|
|
757
|
+
const firstDayOfFirstWeek = new Date(parsedYear, 0, 1 - firstDayOfYear);
|
|
758
|
+
// 计算目标周的第一天
|
|
759
|
+
const daysToAdd = (parsedWeek - 1) * 7;
|
|
760
|
+
const firstDayOfTargetWeek = new Date(firstDayOfFirstWeek.getTime() + daysToAdd * 24 * 60 * 60 * 1000);
|
|
761
|
+
return this.getDate(firstDayOfTargetWeek);
|
|
762
|
+
},
|
|
725
763
|
parseDate(date) {
|
|
726
764
|
date = this.fixIosDateFormat(date)
|
|
727
765
|
const defVal = new Date(date)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import CALENDAR from './calendar.js'
|
|
2
|
-
|
|
2
|
+
import moment from '../../../../utils/moment'
|
|
3
3
|
class Calendar {
|
|
4
4
|
constructor({
|
|
5
5
|
date,
|
|
@@ -7,7 +7,8 @@ class Calendar {
|
|
|
7
7
|
startDate,
|
|
8
8
|
endDate,
|
|
9
9
|
range,
|
|
10
|
-
months
|
|
10
|
+
months,
|
|
11
|
+
type//值:month.year,week,range
|
|
11
12
|
// multipleStatus
|
|
12
13
|
} = {}) {
|
|
13
14
|
// 当前日期
|
|
@@ -19,6 +20,7 @@ class Calendar {
|
|
|
19
20
|
// 范围结束
|
|
20
21
|
this.endDate = endDate
|
|
21
22
|
this.range = range
|
|
23
|
+
this.type = type
|
|
22
24
|
// 多选状态
|
|
23
25
|
this.cleanMultipleStatus()
|
|
24
26
|
// 每周日期
|
|
@@ -169,7 +171,12 @@ class Calendar {
|
|
|
169
171
|
let multiples = this.multipleStatus.data
|
|
170
172
|
let checked = false
|
|
171
173
|
let multiplesStatus = -1
|
|
172
|
-
if (this.range) {
|
|
174
|
+
if (this.range||this.type == 'week') {
|
|
175
|
+
if(this.type == 'week') multiples = [
|
|
176
|
+
this.startDate,moment(this.startDate).add(1,'d').format('YYYY-MM-DD'),
|
|
177
|
+
moment(this.startDate).add(2,'d').format('YYYY-MM-DD'),moment(this.startDate).add(3,'d').format('YYYY-MM-DD'),moment(this.startDate).add(4,'d').format('YYYY-MM-DD'),
|
|
178
|
+
moment(this.startDate).add(5,'d').format('YYYY-MM-DD'),moment(this.startDate).add(6,'d').format('YYYY-MM-DD')
|
|
179
|
+
]
|
|
173
180
|
if (multiples) {
|
|
174
181
|
multiplesStatus = multiples.findIndex((item) => {
|
|
175
182
|
return this.dateEqual(item, nowDate)
|
|
@@ -179,16 +186,19 @@ class Calendar {
|
|
|
179
186
|
checked = true
|
|
180
187
|
}
|
|
181
188
|
}
|
|
189
|
+
console.log('this.type',this.type)
|
|
190
|
+
// 更改multiple为true,则颜色是选中
|
|
191
|
+
// 更改beforeMultiple
|
|
182
192
|
let data = {
|
|
183
193
|
fullDate: nowDate,
|
|
184
194
|
year: full.year,
|
|
185
195
|
date: i,
|
|
186
|
-
multiple: this.range ? checked : false,
|
|
196
|
+
multiple: this.range ? checked : (this.type == 'week'?checked:false),
|
|
187
197
|
beforeMultiple: this.dateEqual(this.multipleStatus.before, nowDate),
|
|
188
198
|
afterMultiple: this.dateEqual(this.multipleStatus.after, nowDate),
|
|
189
199
|
month: full.month,
|
|
190
200
|
lunar: this.getlunar(full.year, full.month, i),
|
|
191
|
-
disable:
|
|
201
|
+
disable: this.type != 'week'&&!(disableBefore && disableAfter),
|
|
192
202
|
isDay,
|
|
193
203
|
userChecked: false
|
|
194
204
|
}
|