stellar-ui-v2 1.35.3
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/common/css/common.scss +61 -0
- package/components/ste-animate/README.md +117 -0
- package/components/ste-animate/animate.scss +247 -0
- package/components/ste-animate/ste-animate.vue +200 -0
- package/components/ste-badge/README.md +171 -0
- package/components/ste-badge/ste-badge.vue +238 -0
- package/components/ste-barcode/README.md +36 -0
- package/components/ste-barcode/encode2.js +317 -0
- package/components/ste-barcode/ste-barcode.vue +213 -0
- package/components/ste-button/README.md +129 -0
- package/components/ste-button/ste-button.vue +345 -0
- package/components/ste-calendar/README.md +304 -0
- package/components/ste-calendar/self-date.js +119 -0
- package/components/ste-calendar/ste-calendar.vue +578 -0
- package/components/ste-checkbox/README.md +297 -0
- package/components/ste-checkbox/ste-checkbox.vue +305 -0
- package/components/ste-checkbox-group/ste-checkbox-group.vue +133 -0
- package/components/ste-code-input/README.md +67 -0
- package/components/ste-code-input/ste-code-input.vue +302 -0
- package/components/ste-date-picker/README.md +135 -0
- package/components/ste-date-picker/ste-date-picker.vue +407 -0
- package/components/ste-drag/README.md +103 -0
- package/components/ste-drag/ste-drag.vue +203 -0
- package/components/ste-dropdown-menu/README.md +358 -0
- package/components/ste-dropdown-menu/ste-dropdown-menu.vue +405 -0
- package/components/ste-dropdown-menu-item/ste-dropdown-menu-item.vue +176 -0
- package/components/ste-icon/README.md +90 -0
- package/components/ste-icon/iconfont.css +8 -0
- package/components/ste-icon/ste-icon.vue +147 -0
- package/components/ste-image/README.md +154 -0
- package/components/ste-image/ste-image.vue +218 -0
- package/components/ste-index-item/ste-index-item.vue +96 -0
- package/components/ste-index-list/README.md +153 -0
- package/components/ste-index-list/ste-index-list.vue +128 -0
- package/components/ste-input/README.md +146 -0
- package/components/ste-input/ste-input.vue +480 -0
- package/components/ste-loading/README.md +81 -0
- package/components/ste-loading/ste-loading.vue +166 -0
- package/components/ste-media-preview/README.md +243 -0
- package/components/ste-media-preview/TouchScaleing.js +102 -0
- package/components/ste-media-preview/ste-media-preview.vue +267 -0
- package/components/ste-message-box/README.md +217 -0
- package/components/ste-message-box/ste-message-box.js +72 -0
- package/components/ste-message-box/ste-message-box.vue +380 -0
- package/components/ste-notice-bar/README.md +129 -0
- package/components/ste-notice-bar/ste-notice-bar.vue +331 -0
- package/components/ste-number-keyboard/README.md +246 -0
- package/components/ste-number-keyboard/keyboard.vue +140 -0
- package/components/ste-number-keyboard/ste-number-keyboard.vue +240 -0
- package/components/ste-picker/ste-picker.vue +258 -0
- package/components/ste-popup/README.md +148 -0
- package/components/ste-popup/ste-popup.vue +337 -0
- package/components/ste-price/README.md +129 -0
- package/components/ste-price/ste-price.vue +258 -0
- package/components/ste-progress/README.md +87 -0
- package/components/ste-progress/ste-progress.vue +200 -0
- package/components/ste-qrcode/README.md +50 -0
- package/components/ste-qrcode/ste-qrcode.vue +164 -0
- package/components/ste-qrcode/uqrcode.js +34 -0
- package/components/ste-radio/README.md +286 -0
- package/components/ste-radio/ste-radio.vue +293 -0
- package/components/ste-radio-group/ste-radio-group.vue +128 -0
- package/components/ste-rate/README.md +115 -0
- package/components/ste-rate/ste-rate.vue +202 -0
- package/components/ste-read-more/README.md +111 -0
- package/components/ste-read-more/ste-read-more.vue +133 -0
- package/components/ste-rich-text/README.md +31 -0
- package/components/ste-rich-text/ste-rich-text.vue +70 -0
- package/components/ste-scroll-to/README.md +68 -0
- package/components/ste-scroll-to/mixin.js +173 -0
- package/components/ste-scroll-to/ste-scroll-to.vue +45 -0
- package/components/ste-scroll-to-item/ste-scroll-to-item.vue +25 -0
- package/components/ste-search/README.md +262 -0
- package/components/ste-search/ste-search.vue +547 -0
- package/components/ste-select/README.md +434 -0
- package/components/ste-select/datapager.vue +62 -0
- package/components/ste-select/datetime.vue +106 -0
- package/components/ste-select/defaultDate.js +142 -0
- package/components/ste-select/ste-select.vue +843 -0
- package/components/ste-signature/README.md +105 -0
- package/components/ste-signature/ste-signature.vue +220 -0
- package/components/ste-slider/README.md +165 -0
- package/components/ste-slider/ste-slider.vue +544 -0
- package/components/ste-step/ste-step.vue +264 -0
- package/components/ste-stepper/README.md +170 -0
- package/components/ste-stepper/ste-stepper.vue +373 -0
- package/components/ste-steps/README.md +132 -0
- package/components/ste-steps/ste-steps.vue +65 -0
- package/components/ste-sticky/README.md +52 -0
- package/components/ste-sticky/ste-sticky.vue +127 -0
- package/components/ste-swipe-action/README.md +197 -0
- package/components/ste-swipe-action/ste-swipe-action.vue +303 -0
- package/components/ste-swipe-action-group/ste-swipe-action-group.vue +104 -0
- package/components/ste-swiper/README.md +173 -0
- package/components/ste-swiper/ste-swiper.vue +462 -0
- package/components/ste-swiper-item/ste-swiper-item.vue +41 -0
- package/components/ste-switch/README.md +110 -0
- package/components/ste-switch/ste-switch.vue +144 -0
- package/components/ste-tab/ste-tab.vue +87 -0
- package/components/ste-table/README.md +785 -0
- package/components/ste-table/common.js +8 -0
- package/components/ste-table/ste-table.vue +666 -0
- package/components/ste-table/utils.js +20 -0
- package/components/ste-table-column/checkbox-icon.vue +65 -0
- package/components/ste-table-column/common.scss +65 -0
- package/components/ste-table-column/radio-icon.vue +110 -0
- package/components/ste-table-column/ste-table-column.vue +255 -0
- package/components/ste-table-column/sub-table.vue +116 -0
- package/components/ste-table-column/table-popover.vue +204 -0
- package/components/ste-table-column/var.scss +1 -0
- package/components/ste-tabs/README.md +475 -0
- package/components/ste-tabs/props.js +212 -0
- package/components/ste-tabs/ste-tabs.vue +758 -0
- package/components/ste-text/README.md +66 -0
- package/components/ste-text/ste-text.vue +72 -0
- package/components/ste-toast/README.md +243 -0
- package/components/ste-toast/ste-toast.js +69 -0
- package/components/ste-toast/ste-toast.vue +231 -0
- package/components/ste-touch-swipe/README.md +104 -0
- package/components/ste-touch-swipe/TouchEvent.js +72 -0
- package/components/ste-touch-swipe/ste-touch-swipe.vue +327 -0
- package/components/ste-touch-swipe-item/ste-touch-swipe-item.vue +33 -0
- package/components/ste-tour/README.md +194 -0
- package/components/ste-tour/ste-tour.vue +355 -0
- package/components/ste-tree/README.md +240 -0
- package/components/ste-tree/ste-tree.vue +350 -0
- package/components/ste-upload/README.md +276 -0
- package/components/ste-upload/ReadFile.js +229 -0
- package/components/ste-upload/ste-upload.vue +526 -0
- package/components/ste-video/README.md +60 -0
- package/components/ste-video/props.js +149 -0
- package/components/ste-video/ste-video.vue +647 -0
- package/config/color.js +22 -0
- package/index.js +2 -0
- package/package.json +19 -0
- package/utils/Color.js +66 -0
- package/utils/System.js +110 -0
- package/utils/dayjs.min.js +1 -0
- package/utils/mixin.js +67 -0
- package/utils/store.js +7 -0
- package/utils/utils.js +604 -0
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import utils from '../../utils/utils.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取从当前月份开始的12个月
|
|
5
|
+
*/
|
|
6
|
+
function getMonthList(minDate, maxDate, defaultDate, monthCount) {
|
|
7
|
+
if (maxDate) monthCount = 12;
|
|
8
|
+
const start = minDate ? utils.dayjs(minDate) : utils.dayjs(defaultDate);
|
|
9
|
+
const sY = Number(start.format('YYYY'));
|
|
10
|
+
const sM = Number(start.format('MM'));
|
|
11
|
+
const end = maxDate ? utils.dayjs(maxDate) : null;
|
|
12
|
+
let eY, eM;
|
|
13
|
+
if (end) {
|
|
14
|
+
eY = Number(end.format('YYYY'));
|
|
15
|
+
eM = Number(end.format('MM'));
|
|
16
|
+
} else {
|
|
17
|
+
eY = sM + monthCount - 1 > 12 ? sY + 1 : sY;
|
|
18
|
+
eM = sM + monthCount - 1 > 12 ? sM + monthCount - 1 - 12 : sM + monthCount - 1;
|
|
19
|
+
}
|
|
20
|
+
const months = [];
|
|
21
|
+
for (let y = sY; y <= eY; y++) {
|
|
22
|
+
for (let m = y === sY ? sM : 1; m <= (y === eY ? eM : 12); m++) {
|
|
23
|
+
months.push(utils.dayjs(`${y}-${m < 10 ? '0' + m : m}-01`));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
return months;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 获取每个月的天数
|
|
31
|
+
*/
|
|
32
|
+
export function getMonthDays(year, month) {
|
|
33
|
+
// 是否是闰年
|
|
34
|
+
const isLeapYear = (year % 4 === 0 && year % 100 !== 0) || year % 400 === 0;
|
|
35
|
+
// 每个月的天数
|
|
36
|
+
const daysCount = [31, isLeapYear ? 29 : 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
|
|
37
|
+
return daysCount[month];
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* 获取日历数据
|
|
42
|
+
* @param {Date} minDate 最小日期
|
|
43
|
+
* @param {Date} maxDate 最大日期
|
|
44
|
+
* @param {Date} defaultDate 默认日期
|
|
45
|
+
* @param {number} monthCount 渲染月数
|
|
46
|
+
* @param {String} formatter 格式化
|
|
47
|
+
* @param {{"2024-11-13":[{content:"XXXXXXXX",style:{},className:string}]} signs 日期标记
|
|
48
|
+
*/
|
|
49
|
+
export function getCalendarData(minDate, maxDate, defaultDate, monthCount = 12, formatter = 'YYYY-MM-DD',
|
|
50
|
+
signs = {}, ) {
|
|
51
|
+
const monthDatas = [];
|
|
52
|
+
const months = getMonthList(minDate, maxDate, defaultDate, monthCount);
|
|
53
|
+
const defaultY = utils.dayjs(defaultDate).year();
|
|
54
|
+
const defaultM = utils.dayjs(defaultDate).month();
|
|
55
|
+
const defaultD = utils.dayjs(defaultDate).date();
|
|
56
|
+
const today = utils.dayjs().format('YYYY-MM-DD');
|
|
57
|
+
months.forEach((date) => {
|
|
58
|
+
|
|
59
|
+
const daysCount = getMonthDays(date.year(), date.month());
|
|
60
|
+
// 一号的星期
|
|
61
|
+
const firstDay = date.startOf('month').day();
|
|
62
|
+
const monthData = {
|
|
63
|
+
date,
|
|
64
|
+
monthText: date.format('YYYY年MM月'),
|
|
65
|
+
key: date.format('YYYY-MM'),
|
|
66
|
+
month: date.month() + 1,
|
|
67
|
+
weeks: [],
|
|
68
|
+
};
|
|
69
|
+
// 计算本月周数
|
|
70
|
+
const weekNum = Math.ceil((daysCount + firstDay) / 7);
|
|
71
|
+
let day = 1;
|
|
72
|
+
for (let w = 0; w < weekNum; w++) {
|
|
73
|
+
const week = [];
|
|
74
|
+
for (let d = 0; d < 7; d++) {
|
|
75
|
+
let _day;
|
|
76
|
+
if ((w === 0 && d < firstDay) || day > daysCount) {
|
|
77
|
+
_day = '';
|
|
78
|
+
} else {
|
|
79
|
+
_day = day++;
|
|
80
|
+
}
|
|
81
|
+
const key = _day ? utils.dayjs(`${monthData.key}-${_day}`).format(formatter) : Math.random();
|
|
82
|
+
let disabled = !_day;
|
|
83
|
+
if (_day) {
|
|
84
|
+
disabled = (minDate && key < minDate) || (maxDate && key > maxDate);
|
|
85
|
+
}
|
|
86
|
+
const daySigns = _day && signs && signs[key] ? signs[key].slice(0, 3).map(item => ({
|
|
87
|
+
...item,
|
|
88
|
+
key: Math.random()
|
|
89
|
+
})) : null;
|
|
90
|
+
week.push({
|
|
91
|
+
dayText: _day,
|
|
92
|
+
key,
|
|
93
|
+
disabled,
|
|
94
|
+
weekend: d === 0 || d === 6,
|
|
95
|
+
// 是否是今天
|
|
96
|
+
today: _day && today === key,
|
|
97
|
+
date: _day ? key : null,
|
|
98
|
+
signs: daySigns,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
monthData.weeks.push(week);
|
|
102
|
+
}
|
|
103
|
+
monthDatas.push(monthData);
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
monthDatas,
|
|
107
|
+
weekTexts: '日一二三四五六'.split('')
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* 格式化时间
|
|
113
|
+
* @param {Object} date
|
|
114
|
+
* @param {Object} formatter
|
|
115
|
+
* @returns {String}
|
|
116
|
+
*/
|
|
117
|
+
export function formatDate(date, formatter = 'YYYY-MM-DD') {
|
|
118
|
+
return utils.dayjs(date).format(formatter);
|
|
119
|
+
}
|
|
@@ -0,0 +1,578 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view class="ste-calendar-root" :style="[cmpRootStyle, { opacity: initing ? 0 : 1 }]">
|
|
3
|
+
<view v-if="showTitle" class="calendar-title">{{ title }}</view>
|
|
4
|
+
<view class="week-head">
|
|
5
|
+
<view class="week-row">
|
|
6
|
+
<view
|
|
7
|
+
class="week-item"
|
|
8
|
+
:class="{ weekend: index === 0 || index === 6 }"
|
|
9
|
+
v-for="(w, index) in cmpDates.weekTexts"
|
|
10
|
+
:key="index"
|
|
11
|
+
>
|
|
12
|
+
{{ w }}
|
|
13
|
+
</view>
|
|
14
|
+
</view>
|
|
15
|
+
</view>
|
|
16
|
+
<scroll-view
|
|
17
|
+
class="date-content"
|
|
18
|
+
:class="{ 'show-confirm': cmpShowConfirm, 'show-title': showTitle }"
|
|
19
|
+
scroll-y
|
|
20
|
+
:scroll-top="contentScrollTop"
|
|
21
|
+
@scroll="onScroll"
|
|
22
|
+
>
|
|
23
|
+
<view class="month-item" v-for="m in cmpDates.monthDatas" :key="m.key" :id="`month-${m.key}`">
|
|
24
|
+
<view class="month-bg" v-if="showMark">
|
|
25
|
+
{{ m.month }}
|
|
26
|
+
</view>
|
|
27
|
+
<view class="month-text">{{ m.monthText }}</view>
|
|
28
|
+
<view class="week-row" v-for="(w, index) in m.weeks" :key="index">
|
|
29
|
+
<view
|
|
30
|
+
class="week-item day-item"
|
|
31
|
+
v-for="d in w"
|
|
32
|
+
:key="d.key"
|
|
33
|
+
@click="onSelect(d)"
|
|
34
|
+
:class="{
|
|
35
|
+
weekend: d.weekend,
|
|
36
|
+
range: mode === 'range',
|
|
37
|
+
signs: cmpShowSigns,
|
|
38
|
+
active: dataList.indexOf(d.key) >= 0,
|
|
39
|
+
start: startDate === d.key,
|
|
40
|
+
end: endDate === d.key,
|
|
41
|
+
disabled: d.disabled,
|
|
42
|
+
not: !d.dayText,
|
|
43
|
+
today: d.today,
|
|
44
|
+
}"
|
|
45
|
+
>
|
|
46
|
+
<block v-if="d.dayText">
|
|
47
|
+
<view class="day-range-head" v-if="mode === 'range'"></view>
|
|
48
|
+
<view class="day-content">{{ d.dayText }}</view>
|
|
49
|
+
<view class="day-range-foot" v-if="mode === 'range'"></view>
|
|
50
|
+
<view class="day-signs" v-if="cmpShowSigns">
|
|
51
|
+
<block v-if="d.signs">
|
|
52
|
+
<view
|
|
53
|
+
class="day-sign"
|
|
54
|
+
v-for="sign in d.signs"
|
|
55
|
+
:key="sign.key"
|
|
56
|
+
:style="[sign.style]"
|
|
57
|
+
:class="sign.className"
|
|
58
|
+
>
|
|
59
|
+
{{ sign.content }}
|
|
60
|
+
</view>
|
|
61
|
+
</block>
|
|
62
|
+
</view>
|
|
63
|
+
</block>
|
|
64
|
+
</view>
|
|
65
|
+
</view>
|
|
66
|
+
</view>
|
|
67
|
+
</scroll-view>
|
|
68
|
+
<view v-if="cmpShowConfirm" class="confirm-button" @click="confirm">确定</view>
|
|
69
|
+
</view>
|
|
70
|
+
</template>
|
|
71
|
+
|
|
72
|
+
<script>
|
|
73
|
+
import { formatDate, getCalendarData } from './self-date.js';
|
|
74
|
+
import utils from '../../utils/utils.js';
|
|
75
|
+
import useColor from '../../config/color.js';
|
|
76
|
+
let color = useColor();
|
|
77
|
+
/**
|
|
78
|
+
* ste-calendar 日历
|
|
79
|
+
* @description 日历组件
|
|
80
|
+
* @tutorial https://stellar-ui.intecloud.com.cn/pc/index/index?name=ste-calendar
|
|
81
|
+
* @property {String} title 标题
|
|
82
|
+
* @property {Boolean} showTitle 是否显示标题
|
|
83
|
+
* @property {Array} list 默认选中的日期
|
|
84
|
+
* @property {String} mode 选项的值
|
|
85
|
+
* @value single 选择单个日期(默认)
|
|
86
|
+
* @value multiple 可以选择多个日期
|
|
87
|
+
* @value range 可以选择日期范围
|
|
88
|
+
* @property {String} startText 开始日期的提示文字
|
|
89
|
+
* @property {String} endText 结束日期的提示文字
|
|
90
|
+
* @property {String} color 主题颜色(选中日期背景、当天日期颜色和确定按钮)
|
|
91
|
+
* @property {String} weekendColor 周末日期颜色
|
|
92
|
+
* @property {String | Number | Date} minDate 最小可选日期
|
|
93
|
+
* @property {String | Number | Date} maxDate 最大可选日期
|
|
94
|
+
* @property {String | Number | Date} defaultDate 默认展示的月份
|
|
95
|
+
* @property {Number} monthCount 渲染的月份数量
|
|
96
|
+
* @property {String | Number} maxCount mode=multiple时,最多可选多少个日期
|
|
97
|
+
* @property {String} formatter 日期格式化(默认'YYYY-MM-DD')
|
|
98
|
+
* @property {Boolean} showMark 是否显示月份背景色
|
|
99
|
+
* @property {Boolean} readonly 是否为只读状态,只读状态下禁止选择日期
|
|
100
|
+
* @property {Boolean} maxRange 日期区间最多可选天数,默认无限制,mode = range时有效
|
|
101
|
+
* @property {Boolean} rangePrompt 范围选择超过最多可选天数时的提示文案,mode = range时有效
|
|
102
|
+
* @property {Boolean} showRangePrompt 范围选择超过最多可选天数时,是否展示提示文案,mode = range时有效
|
|
103
|
+
* @property {Boolean} allowSameDay 是否允许日期范围的起止时间为同一天,mode = range时有效
|
|
104
|
+
* @property {Boolean} showConfirm 是否显示确定按钮
|
|
105
|
+
* @property {Object} signs 标签数据
|
|
106
|
+
* @event {Function} confirm 日期选择完成后触发,若showConfirm为true,则点击确认按钮后触发
|
|
107
|
+
* @event {Function} select 点击/选择后触发
|
|
108
|
+
* @event {Function} viewMonth 在视图区域的月份发生改变时触发
|
|
109
|
+
*/
|
|
110
|
+
export default {
|
|
111
|
+
group: '表单组件',
|
|
112
|
+
title: 'Calendar 日历',
|
|
113
|
+
name: 'ste-calendar',
|
|
114
|
+
props: {
|
|
115
|
+
title: { type: [String, null], default: () => '日期选择' },
|
|
116
|
+
showTitle: { type: [Boolean, null], default: () => true },
|
|
117
|
+
list: { type: [Array, null], default: () => [] },
|
|
118
|
+
// 选择模式:single-选择单个日期,multiple-可以选择多个日期,range-选择日期范围
|
|
119
|
+
mode: { type: [String, null], default: () => 'single' },
|
|
120
|
+
startText: { type: [String, null], default: () => '开始' },
|
|
121
|
+
endText: { type: [String, null], default: () => '结束' },
|
|
122
|
+
color: { type: [String, null], default: () => '' },
|
|
123
|
+
weekendColor: { type: [String, null], default: () => '' },
|
|
124
|
+
minDate: { type: [String, Number, Date, null], default: () => 0 },
|
|
125
|
+
maxDate: { type: [String, Number, Date, null], default: () => 0 },
|
|
126
|
+
defaultDate: { type: [Number, String, Date, null], default: () => 0 },
|
|
127
|
+
monthCount: { type: [Number, null], default: () => 12 },
|
|
128
|
+
maxCount: { type: [Number, String, null], default: () => 0 },
|
|
129
|
+
formatter: { type: [String, null], default: () => 'YYYY-MM-DD' },
|
|
130
|
+
showMark: { type: [Boolean, null], default: () => true },
|
|
131
|
+
readonly: { type: [Boolean, null], default: () => false },
|
|
132
|
+
maxRange: { type: [Number, null], default: () => null },
|
|
133
|
+
rangePrompt: { type: [String, null], default: () => null },
|
|
134
|
+
showRangePrompt: { type: [Boolean, null], default: () => true },
|
|
135
|
+
allowSameDay: { type: [Boolean, null], default: () => false },
|
|
136
|
+
showConfirm: { type: [Boolean, null], default: () => true },
|
|
137
|
+
width: { type: [Number, String, null], default: () => '100%' },
|
|
138
|
+
height: { type: [Number, String, null], default: () => '100%' },
|
|
139
|
+
signs: { type: Object, default: () => ({}) },
|
|
140
|
+
},
|
|
141
|
+
data() {
|
|
142
|
+
return {
|
|
143
|
+
initing: true, // 初始化中
|
|
144
|
+
startDate: null, // 选中开始时间
|
|
145
|
+
endDate: null, // 选中结束时间
|
|
146
|
+
dataList: [], // 选中的日期列表
|
|
147
|
+
contentScrollTop: 0, // 设置滚动距离
|
|
148
|
+
scrollTop: 0, // 用户滚动距离
|
|
149
|
+
viewDate: utils.dayjs(), // 默认日期
|
|
150
|
+
viewTimer: null, // 渲染定时器
|
|
151
|
+
viewMonth: null, // 当前展示的月份
|
|
152
|
+
};
|
|
153
|
+
},
|
|
154
|
+
computed: {
|
|
155
|
+
cmpRootStyle() {
|
|
156
|
+
const rowHeight = this.cmpShowSigns ? utils.formatPx(180, 'num') : utils.formatPx(126, 'num');
|
|
157
|
+
const style = {
|
|
158
|
+
'--calendar-width': utils.formatPx(this.width),
|
|
159
|
+
'--calendar-height': utils.formatPx(this.height),
|
|
160
|
+
'--calendar-color': this.color ? this.color : color.getColor().steThemeColor,
|
|
161
|
+
'--calendar-weekend-color': this.weekendColor ? this.weekendColor : color.getColor().steThemeColor,
|
|
162
|
+
'--calendar-bg-color': utils.Color.formatColor(
|
|
163
|
+
this.color ? this.color : color.getColor().steThemeColor,
|
|
164
|
+
0.1
|
|
165
|
+
),
|
|
166
|
+
'--calendar-range-color': utils.Color.formatColor(
|
|
167
|
+
this.color ? this.color : color.getColor().steThemeColor,
|
|
168
|
+
0.2
|
|
169
|
+
),
|
|
170
|
+
'--calendar-disabled-color': utils.Color.formatColor(
|
|
171
|
+
this.color ? this.color : color.getColor().steThemeColor,
|
|
172
|
+
0.3
|
|
173
|
+
),
|
|
174
|
+
'--calendar-sign-color': utils.Color.formatColor(
|
|
175
|
+
this.color ? this.color : color.getColor().steThemeColor,
|
|
176
|
+
0.7
|
|
177
|
+
),
|
|
178
|
+
'--calendar-start-text': `"${this.startText}"`,
|
|
179
|
+
'--calendar-end-text': `"${this.endText}"`,
|
|
180
|
+
'--calendar-line-height': `${rowHeight}px`,
|
|
181
|
+
rowHeight,
|
|
182
|
+
};
|
|
183
|
+
return style;
|
|
184
|
+
},
|
|
185
|
+
cmpDates() {
|
|
186
|
+
const datas = getCalendarData(
|
|
187
|
+
this.minDate,
|
|
188
|
+
this.maxDate,
|
|
189
|
+
this.viewDate,
|
|
190
|
+
this.monthCount,
|
|
191
|
+
this.formatter,
|
|
192
|
+
this.signs
|
|
193
|
+
);
|
|
194
|
+
return datas;
|
|
195
|
+
},
|
|
196
|
+
cmpMonthTops() {
|
|
197
|
+
const datas = this.cmpDates.monthDatas;
|
|
198
|
+
const rowHeight = this.cmpRootStyle.rowHeight;
|
|
199
|
+
const tops = {};
|
|
200
|
+
let end = 0;
|
|
201
|
+
for (let i = 0; i < datas.length; i++) {
|
|
202
|
+
const month = datas[i];
|
|
203
|
+
tops[month.key] = { top: end };
|
|
204
|
+
end += utils.formatPx(80, 'num');
|
|
205
|
+
end += rowHeight * month.weeks.length;
|
|
206
|
+
tops[month.key].end = end;
|
|
207
|
+
}
|
|
208
|
+
return tops;
|
|
209
|
+
},
|
|
210
|
+
cmpShowConfirm() {
|
|
211
|
+
return this.showConfirm && !this.readonly;
|
|
212
|
+
},
|
|
213
|
+
cmpShowSigns() {
|
|
214
|
+
return Object.keys(this.signs).length > 0;
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
watch: {
|
|
218
|
+
list: {
|
|
219
|
+
handler(v) {
|
|
220
|
+
this.dataList = (v || []).map((d) => formatDate(d, this.formatter));
|
|
221
|
+
if (this.mode === 'range' && this.dataList.length >= 2) {
|
|
222
|
+
this.startDate = this.dataList[0];
|
|
223
|
+
this.endDate = this.dataList[this.dataList.length - 1];
|
|
224
|
+
this.rangeDates();
|
|
225
|
+
}
|
|
226
|
+
},
|
|
227
|
+
immediate: true,
|
|
228
|
+
},
|
|
229
|
+
defaultDate: {
|
|
230
|
+
handler(v) {
|
|
231
|
+
this.viewDate = v ? utils.dayjs(v) : utils.dayjs();
|
|
232
|
+
this.showMonth();
|
|
233
|
+
},
|
|
234
|
+
immediate: true,
|
|
235
|
+
},
|
|
236
|
+
},
|
|
237
|
+
mounted() {
|
|
238
|
+
this.showMonth();
|
|
239
|
+
},
|
|
240
|
+
methods: {
|
|
241
|
+
showMonth(date) {
|
|
242
|
+
const newDate = date ? utils.dayjs(date) : this.viewDate;
|
|
243
|
+
if (newDate.format('YYYY-MM-DD') !== this.viewDate.format('YYYY-MM-DD')) {
|
|
244
|
+
this.viewDate = newDate;
|
|
245
|
+
}
|
|
246
|
+
clearTimeout(this.viewTimer);
|
|
247
|
+
this.viewTimer = setTimeout(() => {
|
|
248
|
+
const viewMonth = this.viewDate.format('YYYY-MM');
|
|
249
|
+
const tops = this.cmpMonthTops;
|
|
250
|
+
const top = tops[viewMonth]?.top || 0;
|
|
251
|
+
if (top === undefined || this.scrollTop === top) {
|
|
252
|
+
this.initing = false;
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
this.contentScrollTop = this.scrollTop;
|
|
256
|
+
this.$nextTick(() => {
|
|
257
|
+
this.contentScrollTop = top;
|
|
258
|
+
this.scrollTop = top;
|
|
259
|
+
this.viewMonth = viewMonth;
|
|
260
|
+
this.initing = false;
|
|
261
|
+
});
|
|
262
|
+
}, 10);
|
|
263
|
+
},
|
|
264
|
+
onShowMonth(scrollTop) {
|
|
265
|
+
clearTimeout(this.viewTimer);
|
|
266
|
+
this.viewTimer = setTimeout(() => {
|
|
267
|
+
for (let month in this.cmpMonthTops) {
|
|
268
|
+
const { top, end } = this.cmpMonthTops[month];
|
|
269
|
+
if (scrollTop >= top && scrollTop < end) {
|
|
270
|
+
if (this.viewMonth === month) return;
|
|
271
|
+
this.viewMonth = month;
|
|
272
|
+
this.$emit('view-month', month);
|
|
273
|
+
return;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
}, 100);
|
|
277
|
+
},
|
|
278
|
+
onScroll(e) {
|
|
279
|
+
this.scrollTop = e.detail.scrollTop;
|
|
280
|
+
this.onShowMonth(e.detail.scrollTop);
|
|
281
|
+
},
|
|
282
|
+
onSelect(day) {
|
|
283
|
+
if (this.readonly || !day.dayText || day.disabled) return;
|
|
284
|
+
if (this.mode === 'single') {
|
|
285
|
+
this.dataList = [day.key];
|
|
286
|
+
} else if (this.mode === 'multiple') {
|
|
287
|
+
this.onMultiple(day);
|
|
288
|
+
} else if (this.mode === 'range') {
|
|
289
|
+
this.onRange(day);
|
|
290
|
+
}
|
|
291
|
+
this.$emit('select', this.dataList, day.key);
|
|
292
|
+
},
|
|
293
|
+
onMultiple(day) {
|
|
294
|
+
const index = this.dataList.indexOf(day.key);
|
|
295
|
+
if (index === -1) {
|
|
296
|
+
if (this.maxCount && this.dataList.length >= this.maxCount) return;
|
|
297
|
+
this.dataList.push(day.key);
|
|
298
|
+
} else {
|
|
299
|
+
this.dataList.splice(index, 1);
|
|
300
|
+
}
|
|
301
|
+
},
|
|
302
|
+
onRange(day) {
|
|
303
|
+
this.dataList = [];
|
|
304
|
+
if (!this.startDate) {
|
|
305
|
+
this.startDate = day.key;
|
|
306
|
+
} else if (!this.endDate) {
|
|
307
|
+
if ((this.allowSameDay && day.key === this.startDate) || day.key > this.startDate) {
|
|
308
|
+
this.endDate = day.key;
|
|
309
|
+
} else if (day.key < this.startDate) {
|
|
310
|
+
this.endDate = this.startDate;
|
|
311
|
+
this.startDate = day.key;
|
|
312
|
+
}
|
|
313
|
+
} else {
|
|
314
|
+
this.startDate = day.key;
|
|
315
|
+
this.endDate = null;
|
|
316
|
+
}
|
|
317
|
+
this.rangeDates();
|
|
318
|
+
},
|
|
319
|
+
rangeDates() {
|
|
320
|
+
if (!this.startDate || !this.endDate) return;
|
|
321
|
+
const start = formatDate(this.startDate);
|
|
322
|
+
const end = formatDate(this.endDate);
|
|
323
|
+
let list = [];
|
|
324
|
+
for (let i = new Date(start); i <= new Date(end); i.setDate(i.getDate() + 1)) {
|
|
325
|
+
list.push(formatDate(i, this.formatter));
|
|
326
|
+
}
|
|
327
|
+
if (list.length < 2) {
|
|
328
|
+
list = [this.startDate, this.endDate];
|
|
329
|
+
}
|
|
330
|
+
if (this.maxRange !== null && list.length > this.maxRange) {
|
|
331
|
+
this.endDate = null;
|
|
332
|
+
if (this.showRangePrompt) {
|
|
333
|
+
uni.showModal({
|
|
334
|
+
title: '提示',
|
|
335
|
+
content: this.rangePrompt ? this.rangePrompt : `选择天数不能超过${this.maxRange}天`,
|
|
336
|
+
showCancel: false,
|
|
337
|
+
});
|
|
338
|
+
}
|
|
339
|
+
return;
|
|
340
|
+
}
|
|
341
|
+
this.dataList = list;
|
|
342
|
+
},
|
|
343
|
+
confirm() {
|
|
344
|
+
this.$emit('confirm', this.dataList);
|
|
345
|
+
},
|
|
346
|
+
},
|
|
347
|
+
};
|
|
348
|
+
</script>
|
|
349
|
+
|
|
350
|
+
<style lang="scss" scoped>
|
|
351
|
+
.ste-calendar-root {
|
|
352
|
+
width: var(--calendar-width);
|
|
353
|
+
height: var(--calendar-height);
|
|
354
|
+
color: #252525;
|
|
355
|
+
.week-row {
|
|
356
|
+
width: 100%;
|
|
357
|
+
display: grid;
|
|
358
|
+
grid-template-columns: repeat(7, 1fr);
|
|
359
|
+
grid-gap: 0;
|
|
360
|
+
.week-item {
|
|
361
|
+
text-align: center;
|
|
362
|
+
&.weekend {
|
|
363
|
+
color: var(--calendar-weekend-color);
|
|
364
|
+
}
|
|
365
|
+
}
|
|
366
|
+
& + .week-row {
|
|
367
|
+
margin-top: 0;
|
|
368
|
+
}
|
|
369
|
+
}
|
|
370
|
+
.calendar-title {
|
|
371
|
+
height: 90rpx;
|
|
372
|
+
font-size: 32rpx;
|
|
373
|
+
line-height: 44rpx;
|
|
374
|
+
padding-top: 30rpx;
|
|
375
|
+
|
|
376
|
+
text-align: center;
|
|
377
|
+
}
|
|
378
|
+
.week-head {
|
|
379
|
+
width: 100%;
|
|
380
|
+
height: 80rpx;
|
|
381
|
+
line-height: 80rpx;
|
|
382
|
+
font-size: 32rpx;
|
|
383
|
+
border-bottom: 1px solid #ddd;
|
|
384
|
+
box-shadow: 0px 3px 10px 1px rgba(0, 0, 0, 0.1);
|
|
385
|
+
border-radius: 8px;
|
|
386
|
+
}
|
|
387
|
+
.date-content {
|
|
388
|
+
width: 100%;
|
|
389
|
+
overflow-y: auto;
|
|
390
|
+
height: calc(100% - 80rpx);
|
|
391
|
+
padding-bottom: 12rpx;
|
|
392
|
+
&.show-title {
|
|
393
|
+
height: calc(100% - 142rpx);
|
|
394
|
+
}
|
|
395
|
+
&.show-confirm {
|
|
396
|
+
height: calc(100% - 132rpx);
|
|
397
|
+
&.show-title {
|
|
398
|
+
height: calc(100% - 242rpx);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
.month-item {
|
|
403
|
+
padding: 20rpx 0;
|
|
404
|
+
position: relative;
|
|
405
|
+
.month-bg {
|
|
406
|
+
position: absolute;
|
|
407
|
+
z-index: 1;
|
|
408
|
+
top: 0;
|
|
409
|
+
left: 0;
|
|
410
|
+
bottom: 0;
|
|
411
|
+
right: 0;
|
|
412
|
+
display: flex;
|
|
413
|
+
justify-content: center;
|
|
414
|
+
align-items: center;
|
|
415
|
+
font-size: 360rpx;
|
|
416
|
+
color: var(--calendar-bg-color);
|
|
417
|
+
font-weight: bold;
|
|
418
|
+
}
|
|
419
|
+
.month-text {
|
|
420
|
+
position: relative;
|
|
421
|
+
z-index: 2;
|
|
422
|
+
width: 100%;
|
|
423
|
+
text-align: center;
|
|
424
|
+
height: 44rpx;
|
|
425
|
+
line-height: 44rpx;
|
|
426
|
+
font-size: 32rpx;
|
|
427
|
+
}
|
|
428
|
+
.week-row {
|
|
429
|
+
height: var(--calendar-line-height);
|
|
430
|
+
.day-item {
|
|
431
|
+
position: relative;
|
|
432
|
+
height: 100%;
|
|
433
|
+
z-index: 2;
|
|
434
|
+
display: flex;
|
|
435
|
+
flex-direction: column;
|
|
436
|
+
justify-content: center;
|
|
437
|
+
align-items: center;
|
|
438
|
+
// #ifdef H5
|
|
439
|
+
cursor: pointer;
|
|
440
|
+
&.not {
|
|
441
|
+
cursor: default !important;
|
|
442
|
+
}
|
|
443
|
+
// #endif
|
|
444
|
+
&.active,
|
|
445
|
+
&.start,
|
|
446
|
+
&.end {
|
|
447
|
+
&.range {
|
|
448
|
+
background-color: var(--calendar-color);
|
|
449
|
+
color: #fff;
|
|
450
|
+
}
|
|
451
|
+
&:not(.signs):not(.range) {
|
|
452
|
+
background-color: var(--calendar-color);
|
|
453
|
+
color: #fff;
|
|
454
|
+
}
|
|
455
|
+
&.signs {
|
|
456
|
+
.day-content {
|
|
457
|
+
background-color: var(--calendar-color);
|
|
458
|
+
color: #fff;
|
|
459
|
+
border-radius: 6rpx;
|
|
460
|
+
}
|
|
461
|
+
}
|
|
462
|
+
}
|
|
463
|
+
&.start,
|
|
464
|
+
&.end {
|
|
465
|
+
.day-range-head,
|
|
466
|
+
.day-range-foot {
|
|
467
|
+
display: block;
|
|
468
|
+
}
|
|
469
|
+
.day-signs {
|
|
470
|
+
display: none;
|
|
471
|
+
}
|
|
472
|
+
}
|
|
473
|
+
&.today {
|
|
474
|
+
font-weight: bold;
|
|
475
|
+
&:not(.active):not(.start):not(.end) {
|
|
476
|
+
color: var(--calendar-color);
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
&.active.range:not(.start):not(.end) {
|
|
480
|
+
background-color: var(--calendar-range-color);
|
|
481
|
+
color: var(--calendar-color);
|
|
482
|
+
.day-content {
|
|
483
|
+
background-color: transparent;
|
|
484
|
+
color: inherit;
|
|
485
|
+
border-radius: 0;
|
|
486
|
+
}
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
&.start {
|
|
490
|
+
.day-range-head::before {
|
|
491
|
+
content: '';
|
|
492
|
+
}
|
|
493
|
+
|
|
494
|
+
.day-range-foot::before {
|
|
495
|
+
content: var(--calendar-start-text);
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
|
|
499
|
+
&.end {
|
|
500
|
+
.day-range-head::before {
|
|
501
|
+
content: '';
|
|
502
|
+
}
|
|
503
|
+
.day-range-foot::before {
|
|
504
|
+
content: var(--calendar-end-text);
|
|
505
|
+
}
|
|
506
|
+
}
|
|
507
|
+
&.start.end {
|
|
508
|
+
.day-range-head::before {
|
|
509
|
+
content: var(--calendar-start-text);
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
&.disabled {
|
|
514
|
+
background-color: initial !important;
|
|
515
|
+
color: #bbb !important;
|
|
516
|
+
}
|
|
517
|
+
&.signs {
|
|
518
|
+
.day-content {
|
|
519
|
+
height: 72rpx;
|
|
520
|
+
line-height: 72rpx;
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
.day-content {
|
|
524
|
+
width: 100%;
|
|
525
|
+
height: 48rpx;
|
|
526
|
+
line-height: 48rpx;
|
|
527
|
+
font-size: 32rpx;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
.day-range-head,
|
|
531
|
+
.day-range-foot {
|
|
532
|
+
width: 100%;
|
|
533
|
+
height: 24rpx;
|
|
534
|
+
line-height: 24rpx;
|
|
535
|
+
font-size: 24rpx;
|
|
536
|
+
}
|
|
537
|
+
.day-range-head,
|
|
538
|
+
.day-range-foot {
|
|
539
|
+
display: none;
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
.day-signs {
|
|
543
|
+
width: 100%;
|
|
544
|
+
height: 102rpx;
|
|
545
|
+
padding: 0 4rpx;
|
|
546
|
+
display: flex;
|
|
547
|
+
flex-direction: column;
|
|
548
|
+
.day-sign {
|
|
549
|
+
width: 100%;
|
|
550
|
+
height: 24rpx;
|
|
551
|
+
line-height: 24rpx;
|
|
552
|
+
font-size: 24rpx;
|
|
553
|
+
overflow: hidden;
|
|
554
|
+
margin-top: 6rpx;
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
}
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
.confirm-button {
|
|
563
|
+
width: 100%;
|
|
564
|
+
height: 72rpx;
|
|
565
|
+
line-height: 72rpx;
|
|
566
|
+
border-radius: 36rpx;
|
|
567
|
+
background-color: var(--calendar-color);
|
|
568
|
+
color: #fff;
|
|
569
|
+
text-align: center;
|
|
570
|
+
// #ifdef H5
|
|
571
|
+
cursor: pointer;
|
|
572
|
+
// #endif
|
|
573
|
+
&.disabled {
|
|
574
|
+
background-color: var(--calendar-disabled-color);
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
</style>
|