oxy-uni-ui 1.2.0 → 1.2.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/attributes.json +1 -1
- package/components/common/abstracts/variable.scss +51 -1
- package/components/common/path.ts +9 -0
- package/components/common/util.ts +42 -0
- package/components/composables/useGlobalLoading.ts +42 -0
- package/components/composables/useGlobalMessage.ts +48 -0
- package/components/composables/useGlobalToast.ts +84 -0
- package/components/composables/useVirtualScroll.ts +3 -2
- package/components/oxy-cell/oxy-cell.vue +15 -2
- package/components/oxy-cell/types.ts +4 -0
- package/components/oxy-checkbox/index.scss +1 -1
- package/components/oxy-checkbox/oxy-checkbox.vue +2 -2
- package/components/oxy-col-picker/oxy-col-picker.vue +3 -0
- package/components/oxy-col-picker/types.ts +5 -1
- package/components/oxy-corner/oxy-corner.vue +15 -3
- package/components/oxy-corner/types.ts +15 -1
- package/components/oxy-date-strip/index.scss +10 -0
- package/components/oxy-date-strip/oxy-date-strip.vue +198 -0
- package/components/oxy-date-strip/types.ts +98 -0
- package/components/oxy-date-strip/utils.ts +67 -0
- package/components/oxy-date-strip-item/index.scss +94 -0
- package/components/oxy-date-strip-item/oxy-date-strip-item.vue +102 -0
- package/components/oxy-date-strip-item/types.ts +53 -0
- package/components/oxy-datetime-picker/oxy-datetime-picker.vue +3 -1
- package/components/oxy-datetime-picker/types.ts +5 -1
- package/components/oxy-echarts/index.scss +17 -0
- package/components/oxy-echarts/index.ts +1 -0
- package/components/oxy-echarts/oxy-echarts.vue +32 -0
- package/components/oxy-echarts/types.ts +12 -0
- package/components/oxy-file-list/index.scss +26 -0
- package/components/oxy-file-list/oxy-file-list.vue +208 -34
- package/components/oxy-file-list/types.ts +58 -2
- package/components/oxy-global-loading/oxy-global-loading.vue +53 -0
- package/components/oxy-global-message/oxy-global-message.vue +64 -0
- package/components/oxy-global-toast/oxy-global-toast.vue +53 -0
- package/components/oxy-img-lazy/index.scss +17 -0
- package/components/oxy-img-lazy/oxy-img-lazy.vue +332 -0
- package/components/oxy-img-lazy/types.ts +69 -0
- package/components/oxy-link/index.scss +57 -0
- package/components/oxy-link/oxy-link.vue +130 -0
- package/components/oxy-link/types.ts +81 -0
- package/components/oxy-list/index.scss +7 -1
- package/components/oxy-list/types.ts +1 -1
- package/components/oxy-picker/oxy-picker.vue +3 -0
- package/components/oxy-picker/types.ts +5 -1
- package/components/oxy-radio/index.scss +3 -3
- package/components/oxy-radio/oxy-radio.vue +1 -1
- package/components/oxy-rich-text/icon/emjio.svg +1 -0
- package/components/oxy-rich-text/icon/quote.svg +1 -0
- package/components/oxy-rich-text/icon/text.svg +1 -0
- package/components/oxy-rich-text/icon/title.svg +1 -0
- package/components/oxy-rich-text/index.scss +159 -0
- package/components/oxy-rich-text/mp-html/card/card.vue +122 -0
- package/components/oxy-rich-text/mp-html/card/index.js +7 -0
- package/components/oxy-rich-text/mp-html/editable/config.js +15 -0
- package/components/oxy-rich-text/mp-html/editable/index.js +553 -0
- package/components/oxy-rich-text/mp-html/emoji/index.js +203 -0
- package/components/oxy-rich-text/mp-html/highlight/config.js +5 -0
- package/components/oxy-rich-text/mp-html/highlight/index.js +96 -0
- package/components/oxy-rich-text/mp-html/highlight/prism.css +1 -0
- package/components/oxy-rich-text/mp-html/highlight/prism.min.js +7 -0
- package/components/oxy-rich-text/mp-html/img-cache/index.js +138 -0
- package/components/oxy-rich-text/mp-html/latex/index.js +80 -0
- package/components/oxy-rich-text/mp-html/latex/katex.css +1 -0
- package/components/oxy-rich-text/mp-html/latex/katex.min.js +1 -0
- package/components/oxy-rich-text/mp-html/markdown/index.js +50 -0
- package/components/oxy-rich-text/mp-html/markdown/marked.min.js +71 -0
- package/components/oxy-rich-text/mp-html/mp-html.d.ts +184 -0
- package/components/oxy-rich-text/mp-html/mp-html.vue +675 -0
- package/components/oxy-rich-text/mp-html/node/node.vue +1161 -0
- package/components/oxy-rich-text/mp-html/parser.js +1428 -0
- package/components/oxy-rich-text/mp-html/search/index.js +132 -0
- package/components/oxy-rich-text/mp-html/style/index.js +129 -0
- package/components/oxy-rich-text/mp-html/style/parser.js +175 -0
- package/components/oxy-rich-text/mp-html/template/index.js +67 -0
- package/components/oxy-rich-text/mp-html/txv-video/index.js +46 -0
- package/components/oxy-rich-text/oxy-rich-text.vue +642 -0
- package/components/oxy-rich-text/types.ts +71 -0
- package/components/oxy-select/index.scss +255 -0
- package/components/oxy-select/oxy-select.vue +421 -0
- package/components/oxy-select/types.ts +71 -0
- package/components/oxy-select-picker/oxy-select-picker.vue +3 -0
- package/components/oxy-select-picker/types.ts +5 -1
- package/components/oxy-stream-render/index.scss +6 -0
- package/components/oxy-stream-render/oxy-stream-render.vue +204 -0
- package/components/oxy-stream-render/types.ts +5 -0
- package/components/oxy-tree/index.scss +17 -1
- package/components/oxy-tree/oxy-tree.vue +89 -8
- package/components/oxy-tree/types.ts +11 -1
- package/components/oxy-waterfall/index.scss +18 -0
- package/components/oxy-waterfall/oxy-waterfall.vue +218 -0
- package/components/oxy-waterfall/types.ts +90 -0
- package/components/oxy-waterfall-item/index.scss +8 -0
- package/components/oxy-waterfall-item/oxy-waterfall-item.vue +89 -0
- package/components/oxy-waterfall-item/types.ts +16 -0
- package/global.d.ts +7 -0
- package/index.ts +3 -0
- package/locale/lang/en-US.ts +26 -0
- package/locale/lang/zh-CN.ts +26 -0
- package/oxy-uni-ui.zip +0 -0
- package/package.json +1 -1
- package/tags.json +1 -1
- package/uni-echarts/changelog.md +2 -0
- package/uni-echarts/components/index.js +1 -0
- package/uni-echarts/components/uni-echarts/events.js +95 -0
- package/uni-echarts/components/uni-echarts/types.d.ts +183 -0
- package/uni-echarts/components/uni-echarts/types.js +1 -0
- package/uni-echarts/components/uni-echarts/uni-echarts.vue +530 -0
- package/uni-echarts/components/uni-echarts/uni-echarts.vue.d.ts +19 -0
- package/uni-echarts/global.d.ts +7 -0
- package/uni-echarts/index.d.ts +440 -0
- package/uni-echarts/index.js +2 -0
- package/uni-echarts/package.json +105 -0
- package/uni-echarts/shared-core.d.ts +269 -0
- package/uni-echarts/shared-core.js +900 -0
- package/web-types.json +1 -1
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<scroll-view
|
|
3
|
+
:class="`oxy-date-strip oxy-date-strip__scroll ${customClass}`"
|
|
4
|
+
:scroll-x="true"
|
|
5
|
+
:scroll-left="scrollLeft"
|
|
6
|
+
:show-scrollbar="false"
|
|
7
|
+
direction="horizontal"
|
|
8
|
+
:style="rootStyle"
|
|
9
|
+
v-if="switchMode === 'none'"
|
|
10
|
+
>
|
|
11
|
+
<oxy-date-strip-item
|
|
12
|
+
:dates="displayWeeks[0].dates"
|
|
13
|
+
:color="color"
|
|
14
|
+
:activeBgColor="activeBgColor"
|
|
15
|
+
:activeColor="activeColor"
|
|
16
|
+
:bgColor="bgColor"
|
|
17
|
+
:radius="radius"
|
|
18
|
+
:switchMode="switchMode"
|
|
19
|
+
:shape="shape"
|
|
20
|
+
@click="onClick"
|
|
21
|
+
></oxy-date-strip-item>
|
|
22
|
+
</scroll-view>
|
|
23
|
+
<swiper
|
|
24
|
+
v-else
|
|
25
|
+
:class="`oxy-date-strip ${customClass}`"
|
|
26
|
+
:style="rootStyle"
|
|
27
|
+
:current="currentWeekIndex"
|
|
28
|
+
:circular="swiperCircular"
|
|
29
|
+
@change="swiperChange"
|
|
30
|
+
>
|
|
31
|
+
<swiper-item v-for="(week, g) in displayWeeks" :key="g">
|
|
32
|
+
<oxy-date-strip-item
|
|
33
|
+
:dates="week.dates"
|
|
34
|
+
:color="color"
|
|
35
|
+
:activeBgColor="activeBgColor"
|
|
36
|
+
:activeColor="activeColor"
|
|
37
|
+
:bgColor="bgColor"
|
|
38
|
+
:radius="radius"
|
|
39
|
+
:switchMode="switchMode"
|
|
40
|
+
:shape="shape"
|
|
41
|
+
@click="onClick"
|
|
42
|
+
></oxy-date-strip-item>
|
|
43
|
+
</swiper-item>
|
|
44
|
+
</swiper>
|
|
45
|
+
</template>
|
|
46
|
+
|
|
47
|
+
<script lang="ts">
|
|
48
|
+
export default {
|
|
49
|
+
name: 'oxy-date-strip',
|
|
50
|
+
options: {
|
|
51
|
+
addGlobalClass: true,
|
|
52
|
+
virtualHost: true,
|
|
53
|
+
styleIsolation: 'shared'
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<script lang="ts" setup>
|
|
59
|
+
import OxyDateStripItem from '../oxy-date-strip-item/oxy-date-strip-item.vue'
|
|
60
|
+
import { ref, computed, watch, onMounted, nextTick, reactive } from 'vue'
|
|
61
|
+
import { objToStyle, unitConvert } from '../common/util'
|
|
62
|
+
import { getWeekRange, addDays, addWeeks, calcType, daysBetween } from './utils'
|
|
63
|
+
import { dateStripProps, type WeekDateCollection, type DateStriPDay } from './types'
|
|
64
|
+
|
|
65
|
+
const props = defineProps(dateStripProps)
|
|
66
|
+
const emit = defineEmits(['change', 'select', 'update:modelValue', 'input'])
|
|
67
|
+
|
|
68
|
+
// 当前选中的周索引
|
|
69
|
+
const currentWeekIndex = ref(0)
|
|
70
|
+
const scrollLeft = ref(0)
|
|
71
|
+
// 是否循环滚动
|
|
72
|
+
const swiperCircular = ref(true)
|
|
73
|
+
const selectedDate = ref<Date | null>(null)
|
|
74
|
+
// 计算一周的星期顺序
|
|
75
|
+
const firstDayOfWeek = computed((): number => Math.min(Math.max(props.firstDayOfWeek, 0), 6))
|
|
76
|
+
|
|
77
|
+
// 计算最小和最大日期
|
|
78
|
+
const today = new Date()
|
|
79
|
+
const minDate = computed((): Date => (props.minDate !== null ? new Date(props.minDate!) : today))
|
|
80
|
+
const maxDate = computed((): Date => (props.maxDate !== null ? new Date(props.maxDate!) : addDays(today, 31)))
|
|
81
|
+
|
|
82
|
+
const days = computed((): number => {
|
|
83
|
+
return daysBetween(maxDate.value, minDate.value)
|
|
84
|
+
})
|
|
85
|
+
|
|
86
|
+
const rootStyle = computed(() => {
|
|
87
|
+
const style: Record<string, any> = {}
|
|
88
|
+
if (props.height) {
|
|
89
|
+
style['height'] = props.height
|
|
90
|
+
}
|
|
91
|
+
if (props.bgColor) {
|
|
92
|
+
style['background'] = props.bgColor
|
|
93
|
+
}
|
|
94
|
+
return `${objToStyle(style)}${props.customStyle}`
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
const cache = new Map<number, WeekDateCollection>()
|
|
98
|
+
const createWeek = (currentStartDate: Date, length: number): WeekDateCollection => {
|
|
99
|
+
const dates: DateStriPDay[] = []
|
|
100
|
+
const time = currentStartDate.getTime()
|
|
101
|
+
if (cache.has(time)) {
|
|
102
|
+
return cache.get(time)!
|
|
103
|
+
}
|
|
104
|
+
for (let i = 0; i < length; i++) {
|
|
105
|
+
const date = new Date(time)
|
|
106
|
+
date.setDate(currentStartDate.getDate() + i)
|
|
107
|
+
const week = date.getDay()
|
|
108
|
+
const year = date.getFullYear()
|
|
109
|
+
const month = date.getMonth() + 1
|
|
110
|
+
const day = date.getDate()
|
|
111
|
+
const dateObj = reactive<DateStriPDay>({
|
|
112
|
+
key: `${year}-${month}-${day}`,
|
|
113
|
+
date,
|
|
114
|
+
year,
|
|
115
|
+
month,
|
|
116
|
+
day,
|
|
117
|
+
text: `${day}`.padStart(2, '0'),
|
|
118
|
+
type: calcType(date, minDate.value, maxDate.value, selectedDate.value, props.disableDate),
|
|
119
|
+
prefix: props.weekdays[week]
|
|
120
|
+
})
|
|
121
|
+
dates.push(props.format !== null ? props.format!(dateObj) : dateObj)
|
|
122
|
+
}
|
|
123
|
+
const obj: WeekDateCollection = {
|
|
124
|
+
start: new Date(dates[0].year, dates[0].month - 1, dates[0].day).getTime(),
|
|
125
|
+
end: new Date(dates[length - 1].year, dates[length - 1].month - 1, dates[length - 1].day).getTime(),
|
|
126
|
+
dates
|
|
127
|
+
} as WeekDateCollection
|
|
128
|
+
return obj
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const currentDate = ref<Date>(today)
|
|
132
|
+
|
|
133
|
+
// 计算要显示的三周数据
|
|
134
|
+
const displayWeeks = computed((): WeekDateCollection[] => {
|
|
135
|
+
const weeks: WeekDateCollection[] = []
|
|
136
|
+
if (props.switchMode === 'week') {
|
|
137
|
+
const currentRange = getWeekRange(currentDate.value, firstDayOfWeek.value)
|
|
138
|
+
const offsetMap = new Map<number, number[]>([
|
|
139
|
+
[0, [0, 1, -1]],
|
|
140
|
+
[1, [-1, 0, 1]],
|
|
141
|
+
[2, [1, -1, 0]]
|
|
142
|
+
])
|
|
143
|
+
let indices = offsetMap.get(currentWeekIndex.value)!
|
|
144
|
+
indices.forEach((i) => {
|
|
145
|
+
const weekDate = addWeeks(currentRange.start, i)
|
|
146
|
+
weeks.push(createWeek(weekDate, 7))
|
|
147
|
+
})
|
|
148
|
+
} else {
|
|
149
|
+
weeks.push(createWeek(minDate.value, days.value))
|
|
150
|
+
}
|
|
151
|
+
return weeks
|
|
152
|
+
})
|
|
153
|
+
|
|
154
|
+
const swiperChange = (event: any) => {
|
|
155
|
+
const delta = event.detail.current - currentWeekIndex.value
|
|
156
|
+
const newDate = addWeeks(currentDate.value, delta == 1 || delta == -2 ? 1 : -1)
|
|
157
|
+
currentDate.value = newDate
|
|
158
|
+
currentWeekIndex.value = event.detail.current
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const onClick = (day: DateStriPDay) => {
|
|
162
|
+
if (day.type == 'disabled') return
|
|
163
|
+
selectedDate.value = day.date
|
|
164
|
+
const v = day.date.getTime()
|
|
165
|
+
emit('change', v)
|
|
166
|
+
emit('select', v)
|
|
167
|
+
emit('update:modelValue', v)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
const scrollToDate = (date: Date) => {
|
|
171
|
+
currentDate.value = date
|
|
172
|
+
if (props.switchMode !== 'none') return
|
|
173
|
+
scrollLeft.value = unitConvert(props.gridWidth || 50) * daysBetween(date, minDate.value)
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
watch(
|
|
177
|
+
() => props.modelValue,
|
|
178
|
+
(value) => {
|
|
179
|
+
if (!value) return
|
|
180
|
+
selectedDate.value = new Date(value)
|
|
181
|
+
},
|
|
182
|
+
{ deep: true, immediate: true }
|
|
183
|
+
)
|
|
184
|
+
|
|
185
|
+
onMounted(() => {
|
|
186
|
+
nextTick(() => {
|
|
187
|
+
scrollToDate(currentDate.value)
|
|
188
|
+
})
|
|
189
|
+
})
|
|
190
|
+
|
|
191
|
+
defineExpose({
|
|
192
|
+
scrollToDate
|
|
193
|
+
})
|
|
194
|
+
</script>
|
|
195
|
+
|
|
196
|
+
<style lang="scss" scoped>
|
|
197
|
+
@import './index.scss';
|
|
198
|
+
</style>
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import type { ComponentPublicInstance, ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
|
|
3
|
+
import { baseProps, makeArrayProp, makeNumberProp, makeStringProp } from '../common/props'
|
|
4
|
+
|
|
5
|
+
export type DateType = 'selected' | 'disabled' | ''
|
|
6
|
+
export type DisableDate = (date: Date) => boolean
|
|
7
|
+
export type FormatDate = (day: DateStriPDay) => DateStriPDay
|
|
8
|
+
|
|
9
|
+
export type DateStripSwitchMode = 'week' | 'none'
|
|
10
|
+
export type DateStripShape = 'square' | 'circle' | 'none'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 定义一个表示周范围的类
|
|
14
|
+
*/
|
|
15
|
+
export type WeekRange = {
|
|
16
|
+
start: Date
|
|
17
|
+
end: Date
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export type DateStriPDay = {
|
|
21
|
+
date: Date
|
|
22
|
+
key: string
|
|
23
|
+
day: number
|
|
24
|
+
year: number
|
|
25
|
+
month: number
|
|
26
|
+
text: string
|
|
27
|
+
type: DateType
|
|
28
|
+
prefix: string
|
|
29
|
+
suffix?: string
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export type WeekDateCollection = {
|
|
33
|
+
start: number
|
|
34
|
+
end: number
|
|
35
|
+
dates: DateStriPDay[]
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const dateStripProps = {
|
|
39
|
+
...baseProps,
|
|
40
|
+
// 当前选择的日期
|
|
41
|
+
modelValue: {
|
|
42
|
+
type: [Number, null] as PropType<number | null>,
|
|
43
|
+
default: null
|
|
44
|
+
},
|
|
45
|
+
// 日期行高
|
|
46
|
+
height: makeStringProp(''),
|
|
47
|
+
// 第一天从星期几开始,默认 1 = 周一
|
|
48
|
+
firstDayOfWeek: makeNumberProp(0),
|
|
49
|
+
// 日期格式,可选
|
|
50
|
+
format: {
|
|
51
|
+
type: Function as PropType<FormatDate>,
|
|
52
|
+
default: null
|
|
53
|
+
},
|
|
54
|
+
// 最大可选日期,不传则默认半年后
|
|
55
|
+
maxDate: {
|
|
56
|
+
type: [Number, null] as PropType<number | null>,
|
|
57
|
+
default: null
|
|
58
|
+
},
|
|
59
|
+
// 最小可选日期,不传则默认今天
|
|
60
|
+
minDate: {
|
|
61
|
+
type: [Number, null] as PropType<number | null>,
|
|
62
|
+
default: null
|
|
63
|
+
},
|
|
64
|
+
// 网格宽度
|
|
65
|
+
gridWidth: makeStringProp(''),
|
|
66
|
+
// 主题色,对底部按钮和选中日期生效
|
|
67
|
+
color: makeStringProp(''),
|
|
68
|
+
// 选中日期的背景色
|
|
69
|
+
activeBgColor: makeStringProp(''),
|
|
70
|
+
// 选中日期的文字颜色
|
|
71
|
+
activeColor: makeStringProp(''),
|
|
72
|
+
// 背景色
|
|
73
|
+
bgColor: makeStringProp(''),
|
|
74
|
+
// 圆角半径
|
|
75
|
+
radius: makeStringProp(''),
|
|
76
|
+
// 切换模式,'week' 或 'none'
|
|
77
|
+
switchMode: makeStringProp<DateStripSwitchMode>('week'),
|
|
78
|
+
// 形状,'square'、'circle' 或 'none'
|
|
79
|
+
shape: makeStringProp<DateStripShape>('square'),
|
|
80
|
+
// 星期几的名称数组
|
|
81
|
+
weekdays: {
|
|
82
|
+
...makeArrayProp<string>(),
|
|
83
|
+
default: () => ['日', '一', '二', '三', '四', '五', '六']
|
|
84
|
+
},
|
|
85
|
+
// 禁用日期函数
|
|
86
|
+
disableDate: {
|
|
87
|
+
type: Function as PropType<DisableDate>,
|
|
88
|
+
default: null
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export type DateStripProps = ExtractPropTypes<typeof dateStripProps>
|
|
93
|
+
|
|
94
|
+
export type DateStripExpose = {
|
|
95
|
+
scrollToDate: (date: Date) => void
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
export type DateStripInstance = ComponentPublicInstance<DateStripProps, DateStripExpose>
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import type { WeekRange, DateType, DisableDate } from './types'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* 获取指定日期所在周的日期范围。
|
|
5
|
+
* @param {Date} date - 指定日期。
|
|
6
|
+
* @param {number} firstDayOfWeek - 一周的第一天,0 表示周日,1 表示周一,以此类推。
|
|
7
|
+
* @returns {WeekRange} 返回一个包含周起始和结束日期的对象。
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
export function getWeekRange(date: Date, firstDayOfWeek: number): WeekRange {
|
|
11
|
+
const start = new Date(date.getTime())
|
|
12
|
+
const dayOffset = (date.getDay() - firstDayOfWeek + 7) % 7
|
|
13
|
+
start.setDate(start.getDate() - dayOffset)
|
|
14
|
+
|
|
15
|
+
const end = new Date(start.getTime())
|
|
16
|
+
end.setDate(end.getDate() + 6)
|
|
17
|
+
return { start, end } as WeekRange
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* 向指定日期添加天数。
|
|
22
|
+
* @param {Date} date - 基础日期。
|
|
23
|
+
* @param {number} days - 要添加的天数,可以是正数或负数。
|
|
24
|
+
* @returns {Date} 返回一个新的日期对象,该对象是基础日期加上指定天数后的结果。
|
|
25
|
+
*/
|
|
26
|
+
export function addDays(date: Date, days: number): Date {
|
|
27
|
+
const result = new Date(date.getTime())
|
|
28
|
+
result.setDate(result.getDate() + days)
|
|
29
|
+
return result
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function addWeeks(date: Date, weeks: number): Date {
|
|
33
|
+
const result = new Date(date.getTime())
|
|
34
|
+
result.setDate(result.getDate() + weeks * 7)
|
|
35
|
+
return result
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 判断两个日期是否表示同一天(忽略时间部分)。
|
|
40
|
+
*
|
|
41
|
+
* @param date1 - 第一个日期。
|
|
42
|
+
* @param date2 - 第二个日期。
|
|
43
|
+
* @returns 如果两个日期是同一天,返回 true;否则返回 false。
|
|
44
|
+
*/
|
|
45
|
+
function isSameDay(date1: Date, date2: Date): boolean {
|
|
46
|
+
return date1.getFullYear() == date2.getFullYear() && date1.getMonth() == date2.getMonth() && date1.getDate() == date2.getDate()
|
|
47
|
+
}
|
|
48
|
+
export function calcType(date: Date, minDate: Date, maxDate: Date, selectedDate: Date | null, disableDate?: DisableDate): DateType {
|
|
49
|
+
// 检查日期是否早于 minDate 或晚于 maxDate
|
|
50
|
+
if (date.getTime() < minDate.getTime() || date.getTime() > maxDate.getTime()) {
|
|
51
|
+
return 'disabled'
|
|
52
|
+
}
|
|
53
|
+
if (disableDate && disableDate(date)) {
|
|
54
|
+
return 'disabled'
|
|
55
|
+
}
|
|
56
|
+
// 如果 selectedDate 不为 null,检查日期是否等于 selectedDate
|
|
57
|
+
if (selectedDate != null && isSameDay(date, selectedDate)) {
|
|
58
|
+
return 'selected'
|
|
59
|
+
}
|
|
60
|
+
return ''
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function daysBetween(date1: Date, date2: Date): number {
|
|
64
|
+
// 将两个日期转换为毫秒
|
|
65
|
+
const diffInMilliseconds = Math.abs(date2.getTime() - date1.getTime())
|
|
66
|
+
return Math.floor(diffInMilliseconds / (1000 * 3600 * 24))
|
|
67
|
+
}
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
@import '../common/abstracts/variable';
|
|
2
|
+
@import '../common/abstracts/mixin';
|
|
3
|
+
|
|
4
|
+
@include b(date-strip-item) {
|
|
5
|
+
display: flex;
|
|
6
|
+
flex-direction: row;
|
|
7
|
+
padding: $-date-strip-padding-y $-date-strip-padding-x;
|
|
8
|
+
box-sizing: border-box;
|
|
9
|
+
/* #ifndef UNI-APP-X && APP */
|
|
10
|
+
height: 100%;
|
|
11
|
+
/* #endif */
|
|
12
|
+
&--week {
|
|
13
|
+
flex: 1;
|
|
14
|
+
.oxy-date-strip-item__grid {
|
|
15
|
+
flex: 1;
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
&--none {
|
|
19
|
+
.oxy-date-strip-item__grid {
|
|
20
|
+
width: $-date-strip-grid-width;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
&__grid {
|
|
24
|
+
/* #ifndef UNI-APP-X && APP */
|
|
25
|
+
flex-shrink: 0;
|
|
26
|
+
/* #endif */
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
margin: 0 4rpx;
|
|
30
|
+
transition-duration: 300ms;
|
|
31
|
+
transition-property: background-color, color;
|
|
32
|
+
transition-timing-function: linear;
|
|
33
|
+
|
|
34
|
+
&-prefix,&-day,&-suffix {
|
|
35
|
+
text-align: center;
|
|
36
|
+
transition-duration: 200ms;
|
|
37
|
+
transition-property: color;
|
|
38
|
+
transition-timing-function: linear;
|
|
39
|
+
}
|
|
40
|
+
&-prefix {
|
|
41
|
+
font-size: $-date-strip-prefix-font-size;
|
|
42
|
+
color: $-date-strip-prefix-color;
|
|
43
|
+
}
|
|
44
|
+
&--none {
|
|
45
|
+
.oxy-date-strip-item__grid-prefix {
|
|
46
|
+
padding-bottom: 4px;
|
|
47
|
+
padding-top: 4px;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
&--circle {
|
|
51
|
+
.oxy-date-strip-item__grid-prefix {
|
|
52
|
+
padding-bottom: 4px;
|
|
53
|
+
}
|
|
54
|
+
.oxy-date-strip-item__grid-info {
|
|
55
|
+
border-radius: $-date-strip-grid-circle-radius;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
&--square {
|
|
59
|
+
border-radius: $-date-strip-square-radius;
|
|
60
|
+
padding: $-date-strip-grid-square-padding-y $-date-strip-grid-square-padding-x;
|
|
61
|
+
}
|
|
62
|
+
&-suffix {
|
|
63
|
+
position: absolute;
|
|
64
|
+
top: 50%;
|
|
65
|
+
transform: translateY(60%);
|
|
66
|
+
font-size: $-date-strip-suffix-font-size;
|
|
67
|
+
color: $-date-strip-suffix-color;
|
|
68
|
+
}
|
|
69
|
+
&-day {
|
|
70
|
+
font-size: $-date-strip-font-size;
|
|
71
|
+
color: $-date-strip-color;
|
|
72
|
+
font-weight: bold;
|
|
73
|
+
}
|
|
74
|
+
&-info {
|
|
75
|
+
display: flex;
|
|
76
|
+
flex: 1;
|
|
77
|
+
justify-content: center;
|
|
78
|
+
align-items: center;
|
|
79
|
+
position: relative;
|
|
80
|
+
}
|
|
81
|
+
&--active-bg {
|
|
82
|
+
background-color: $-date-strip-active-color;
|
|
83
|
+
}
|
|
84
|
+
&--active-text {
|
|
85
|
+
color: white;
|
|
86
|
+
&-none {
|
|
87
|
+
color: $-date-strip-active-color;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
&--disabled {
|
|
91
|
+
opacity: 0.4;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<view :class="`oxy-date-strip-item oxy-date-strip-item--${switchMode} ${customClass}`" :style="customStyle">
|
|
3
|
+
<view
|
|
4
|
+
class="oxy-date-strip-item__grid"
|
|
5
|
+
v-for="item in dates"
|
|
6
|
+
:style="[
|
|
7
|
+
styles,
|
|
8
|
+
item.type == 'selected' && shape == 'square' && activeBgColor != null ? { background: activeBgColor } : {},
|
|
9
|
+
shape == 'square' && radius != null ? { 'border-radius': radius } : {}
|
|
10
|
+
]"
|
|
11
|
+
:class="[
|
|
12
|
+
'oxy-date-strip-item__grid--' + shape,
|
|
13
|
+
{
|
|
14
|
+
'oxy-date-strip-item__grid--active-bg': shape == 'square' && item.type == 'selected',
|
|
15
|
+
'oxy-date-strip-item__grid--disabled': item.type == 'disabled',
|
|
16
|
+
'oxy-date-strip-item__grid--selected': item.type == 'selected'
|
|
17
|
+
}
|
|
18
|
+
]"
|
|
19
|
+
@click="onClick(item)"
|
|
20
|
+
:key="item.key"
|
|
21
|
+
>
|
|
22
|
+
<text
|
|
23
|
+
class="oxy-date-strip-item__grid-prefix"
|
|
24
|
+
:class="{
|
|
25
|
+
'oxy-date-strip-item__grid--active-text': item.type == 'selected' && shape == 'square',
|
|
26
|
+
'oxy-date-strip-item__grid--active-text-none': item.type == 'selected' && shape == 'none'
|
|
27
|
+
}"
|
|
28
|
+
:style="[item.type == 'selected' && activeColor ? { color: activeColor } : {}]"
|
|
29
|
+
>
|
|
30
|
+
{{ item.prefix }}
|
|
31
|
+
</text>
|
|
32
|
+
<view
|
|
33
|
+
class="oxy-date-strip-item__grid-info"
|
|
34
|
+
:class="{
|
|
35
|
+
'oxy-date-strip-item__grid--active-bg': shape == 'circle' && item.type == 'selected'
|
|
36
|
+
}"
|
|
37
|
+
:style="[
|
|
38
|
+
item.type == 'selected' && shape == 'circle' && activeBgColor ? { background: activeBgColor } : {},
|
|
39
|
+
shape == 'square' && radius ? { 'border-radius': radius } : {}
|
|
40
|
+
]"
|
|
41
|
+
>
|
|
42
|
+
<text
|
|
43
|
+
class="oxy-date-strip-item__grid-day"
|
|
44
|
+
:class="{
|
|
45
|
+
'oxy-date-strip-item__grid--active-text': item.type == 'selected' && shape != 'none',
|
|
46
|
+
'oxy-date-strip-item__grid--active-text-none': item.type == 'selected' && shape == 'none'
|
|
47
|
+
}"
|
|
48
|
+
:style="[item.type == 'selected' && activeColor ? { color: activeColor } : {}]"
|
|
49
|
+
>
|
|
50
|
+
{{ item.text }}
|
|
51
|
+
</text>
|
|
52
|
+
<text
|
|
53
|
+
class="oxy-date-strip-item__grid-suffix"
|
|
54
|
+
:class="{
|
|
55
|
+
'oxy-date-strip-item__grid--active-text': item.type == 'selected' && shape != 'none',
|
|
56
|
+
'oxy-date-strip-item__grid--active-text-none': item.type == 'selected' && shape == 'none'
|
|
57
|
+
}"
|
|
58
|
+
:style="[item.type == 'selected' && activeColor ? { color: activeColor } : {}]"
|
|
59
|
+
v-if="item.suffix"
|
|
60
|
+
>
|
|
61
|
+
{{ item.suffix }}
|
|
62
|
+
</text>
|
|
63
|
+
</view>
|
|
64
|
+
</view>
|
|
65
|
+
</view>
|
|
66
|
+
</template>
|
|
67
|
+
|
|
68
|
+
<script lang="ts">
|
|
69
|
+
export default {
|
|
70
|
+
name: 'oxy-date-strip-item',
|
|
71
|
+
options: {
|
|
72
|
+
addGlobalClass: true,
|
|
73
|
+
virtualHost: true,
|
|
74
|
+
styleIsolation: 'shared'
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
</script>
|
|
78
|
+
|
|
79
|
+
<script lang="ts" setup>
|
|
80
|
+
import { ref, computed } from 'vue'
|
|
81
|
+
import { dateStripItemProps } from './types'
|
|
82
|
+
import type { DateStriPDay } from '../oxy-date-strip/types'
|
|
83
|
+
|
|
84
|
+
const props = defineProps(dateStripItemProps)
|
|
85
|
+
const emit = defineEmits(['click'])
|
|
86
|
+
|
|
87
|
+
const styles = computed(() => {
|
|
88
|
+
const style: Record<string, any> = {}
|
|
89
|
+
if (props.gridWidth && props.switchMode == 'none') {
|
|
90
|
+
style['width'] = props.gridWidth
|
|
91
|
+
}
|
|
92
|
+
return style
|
|
93
|
+
})
|
|
94
|
+
|
|
95
|
+
const onClick = (day: DateStriPDay) => {
|
|
96
|
+
emit('click', day)
|
|
97
|
+
}
|
|
98
|
+
</script>
|
|
99
|
+
|
|
100
|
+
<style lang="scss" scoped>
|
|
101
|
+
@import './index.scss';
|
|
102
|
+
</style>
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import type { ExtractPropTypes, PropType } from 'vue'
|
|
2
|
+
import { baseProps } from '../common/props'
|
|
3
|
+
import type { DateStriPDay, DateStripShape, DateStripSwitchMode } from '../oxy-date-strip/types'
|
|
4
|
+
|
|
5
|
+
export const dateStripItemProps = {
|
|
6
|
+
...baseProps,
|
|
7
|
+
dates: {
|
|
8
|
+
type: Array as PropType<DateStriPDay[]>,
|
|
9
|
+
default: () => []
|
|
10
|
+
},
|
|
11
|
+
// 网格宽度
|
|
12
|
+
gridWidth: {
|
|
13
|
+
type: String,
|
|
14
|
+
default: null
|
|
15
|
+
},
|
|
16
|
+
// 主题色,对底部按钮和选中日期生效
|
|
17
|
+
color: {
|
|
18
|
+
type: String,
|
|
19
|
+
default: null
|
|
20
|
+
},
|
|
21
|
+
// 选中日期的背景色
|
|
22
|
+
activeBgColor: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: null
|
|
25
|
+
},
|
|
26
|
+
// 选中日期的文字颜色
|
|
27
|
+
activeColor: {
|
|
28
|
+
type: String,
|
|
29
|
+
default: null
|
|
30
|
+
},
|
|
31
|
+
// 背景色
|
|
32
|
+
bgColor: {
|
|
33
|
+
type: String,
|
|
34
|
+
default: null
|
|
35
|
+
},
|
|
36
|
+
// 圆角半径
|
|
37
|
+
radius: {
|
|
38
|
+
type: String,
|
|
39
|
+
default: null
|
|
40
|
+
},
|
|
41
|
+
// 切换模式,'week' 或 'none'
|
|
42
|
+
switchMode: {
|
|
43
|
+
type: String as PropType<DateStripSwitchMode>,
|
|
44
|
+
default: 'week'
|
|
45
|
+
},
|
|
46
|
+
// 形状,'square'、'circle' 或 'none'
|
|
47
|
+
shape: {
|
|
48
|
+
type: String as PropType<DateStripShape>,
|
|
49
|
+
default: 'square'
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type DateStripItemProps = ExtractPropTypes<typeof dateStripItemProps>
|
|
@@ -512,7 +512,9 @@ function close() {
|
|
|
512
512
|
|
|
513
513
|
function showPopup() {
|
|
514
514
|
if (props.disabled || props.readonly) return
|
|
515
|
-
|
|
515
|
+
if (isFunction(props.beforeOpen) && !props.beforeOpen()) {
|
|
516
|
+
return
|
|
517
|
+
}
|
|
516
518
|
emit('open')
|
|
517
519
|
if (region.value) {
|
|
518
520
|
popupShow.value = true
|
|
@@ -196,7 +196,11 @@ export const datetimePickerProps = {
|
|
|
196
196
|
/**
|
|
197
197
|
* 必填标记位置,可选值:before、after
|
|
198
198
|
*/
|
|
199
|
-
markerSide: makeStringProp<'before' | 'after'>('before')
|
|
199
|
+
markerSide: makeStringProp<'before' | 'after'>('before'),
|
|
200
|
+
/**
|
|
201
|
+
* 打开pop之前的校验
|
|
202
|
+
*/
|
|
203
|
+
beforeOpen: Function as PropType<() => boolean>
|
|
200
204
|
}
|
|
201
205
|
|
|
202
206
|
export type DatetimePickerDisplayFormat = (items: Record<string, any>[]) => string
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '../../uni-echarts'
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<uni-echarts ref="echartsRef" v-bind="$attrs">
|
|
3
|
+
<slot></slot>
|
|
4
|
+
</uni-echarts>
|
|
5
|
+
</template>
|
|
6
|
+
<script lang="ts">
|
|
7
|
+
import { ref } from 'vue'
|
|
8
|
+
import { echartsProps } from './types'
|
|
9
|
+
import UniEcharts from '../../../../uni_modules/oxy-uni-ui/uni-echarts/components/uni-echarts/uni-echarts.vue'
|
|
10
|
+
import type { UniEchartsInst } from '../../../../uni_modules/oxy-uni-ui/uni-echarts'
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
name: 'oxy-echarts',
|
|
14
|
+
options: {
|
|
15
|
+
virtualHost: true,
|
|
16
|
+
addGlobalClass: true,
|
|
17
|
+
styleIsolation: 'shared'
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<script lang="ts" setup>
|
|
23
|
+
const props = defineProps(echartsProps)
|
|
24
|
+
const echartsRef = ref<UniEchartsInst | null>(null)
|
|
25
|
+
defineExpose({
|
|
26
|
+
echartsInstance: echartsRef
|
|
27
|
+
})
|
|
28
|
+
</script>
|
|
29
|
+
|
|
30
|
+
<style lang="scss" scoped>
|
|
31
|
+
@import './index.scss';
|
|
32
|
+
</style>
|