@studio-west/component-sw 0.12.23 → 0.12.25
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/README.md +0 -2
- package/dist/{SwAlert-DdNME1KV.js → SwAlert-CU7nEnO-.js} +1 -1
- package/dist/{SwDropdownItem-BQ0sWjy3.js → SwDropdownItem-CKOTwhTf.js} +1 -1
- package/dist/{SwGide-T8VMbn6F.js → SwGide-Ie6XCPUn.js} +1 -1
- package/dist/{SwIcon-jPY932qp.js → SwIcon-D6FCTrgR.js} +2 -2
- package/dist/{SwInput-BvqWmT5t.js → SwInput-u7kS3lQn.js} +1 -1
- package/dist/{SwMessage-T2PdfXm1.js → SwMessage-DRjFGSK3.js} +1 -1
- package/dist/component-sw.css +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +7 -7
- package/package.json +2 -5
- package/src/Alert.ts +0 -70
- package/src/components/SwAlert.vue +0 -70
- package/src/components/SwButton.vue +0 -57
- package/src/components/SwButtonGroup.vue +0 -68
- package/src/components/SwCollapse.vue +0 -13
- package/src/components/SwDatePicker.vue +0 -375
- package/src/components/SwDropdown.vue +0 -195
- package/src/components/SwDropdownItem.vue +0 -26
- package/src/components/SwDropdownNew.vue +0 -175
- package/src/components/SwFormItem.vue +0 -21
- package/src/components/SwGide.vue +0 -128
- package/src/components/SwIcon.vue +0 -35
- package/src/components/SwInput.vue +0 -106
- package/src/components/SwMenu.vue +0 -217
- package/src/components/SwMessage.vue +0 -53
- package/src/components/SwSection.vue +0 -17
- package/src/components/SwSelect.vue +0 -153
- package/src/components/SwSkeleton.vue +0 -13
- package/src/components/SwSkeletonItem.vue +0 -27
- package/src/components/SwSlider.vue +0 -281
- package/src/components/SwSwitch.vue +0 -53
- package/src/components/SwTable.vue +0 -481
- package/src/components/SwTableColumn.vue +0 -88
- package/src/components/SwTabs.vue +0 -42
- package/src/components/SwTabsPane.vue +0 -44
- package/src/index.ts +0 -38
- package/src/utils/index.ts +0 -149
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<transition name="fade">
|
|
3
|
-
<div v-if="visible" :class="style" @mouseenter="pauseTimer" @mouseleave="resumeTimer">
|
|
4
|
-
<sw-icon v-if="props.before.length > 0" :icon-class="props.before" />
|
|
5
|
-
<slot v-else name="prefix"></slot>
|
|
6
|
-
<slot>{{ props.message }}</slot>
|
|
7
|
-
<sw-icon v-if="props.after.length > 0" :icon-class="props.after" @click="close"/>
|
|
8
|
-
<slot v-else name="suffix"></slot>
|
|
9
|
-
<footer><slot name="footer"></slot></footer>
|
|
10
|
-
</div>
|
|
11
|
-
</transition>
|
|
12
|
-
</template>
|
|
13
|
-
|
|
14
|
-
<script setup>
|
|
15
|
-
import { ref, computed, onMounted, onUnmounted } from "vue"
|
|
16
|
-
import SwIcon from "./SwIcon.vue"
|
|
17
|
-
const props = defineProps({
|
|
18
|
-
message: {type: String, default: "Default message"},
|
|
19
|
-
before: {type: String, default: ''},
|
|
20
|
-
class: { type: String, default: ''},
|
|
21
|
-
after: {type: String, default: ''},
|
|
22
|
-
size: {type:String, default: ''},
|
|
23
|
-
duration: {type: Number, default: 6000},
|
|
24
|
-
type: {type:String, default: 'info', validator: (value) => ['success', 'warning', 'error', 'info'].includes(value)}
|
|
25
|
-
})
|
|
26
|
-
const emit = defineEmits(['closed'])
|
|
27
|
-
const visible = ref(false)
|
|
28
|
-
let timer = null
|
|
29
|
-
const show = () => {
|
|
30
|
-
document.querySelector('.sw-alert-wrapper').togglePopover()
|
|
31
|
-
visible.value = true
|
|
32
|
-
document.querySelector('.sw-alert-wrapper').showPopover()
|
|
33
|
-
startTimer()
|
|
34
|
-
|
|
35
|
-
}
|
|
36
|
-
const close = () => {
|
|
37
|
-
visible.value = false
|
|
38
|
-
emit("closed")
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
const pauseTimer = () => {
|
|
42
|
-
if (timer) {
|
|
43
|
-
clearTimeout(timer)
|
|
44
|
-
timer = null
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
|
|
48
|
-
const resumeTimer = () => {
|
|
49
|
-
startTimer()
|
|
50
|
-
};
|
|
51
|
-
|
|
52
|
-
const startTimer = () => {
|
|
53
|
-
timer = setTimeout(close, props.duration)
|
|
54
|
-
};
|
|
55
|
-
onMounted(() => {
|
|
56
|
-
show()
|
|
57
|
-
})
|
|
58
|
-
onUnmounted(() => {
|
|
59
|
-
if (timer) {
|
|
60
|
-
clearTimeout(timer)
|
|
61
|
-
}
|
|
62
|
-
})
|
|
63
|
-
const style = computed(() =>{
|
|
64
|
-
const s = ['sw-alert']
|
|
65
|
-
if(props.size.length > 0) s.push(`sw-${props.size}`)
|
|
66
|
-
if(props.type.length > 0) s.push(`sw-${props.type}`)
|
|
67
|
-
if(props.class.length > 0) s.push(props.class)
|
|
68
|
-
return s
|
|
69
|
-
})
|
|
70
|
-
</script>
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
<template>
|
|
3
|
-
<button :class="style" @click="isClick">
|
|
4
|
-
<slot><sw-icon v-if="prefix" :iconClass="prefix" />{{ label }}<sw-icon v-if="postfix" :iconClass="postfix" /></slot>
|
|
5
|
-
</button>
|
|
6
|
-
</template>
|
|
7
|
-
|
|
8
|
-
<script setup lang="ts">
|
|
9
|
-
import { computed } from "vue"
|
|
10
|
-
|
|
11
|
-
// Define prop types
|
|
12
|
-
interface Props {
|
|
13
|
-
class?: string
|
|
14
|
-
size?: 'large' | 'small' | ''
|
|
15
|
-
type?: 'primary' | 'success' | 'info' | 'warning' | 'danger' | ''
|
|
16
|
-
round?: boolean
|
|
17
|
-
text?: boolean
|
|
18
|
-
link?: boolean
|
|
19
|
-
href?: string
|
|
20
|
-
disabled?: boolean
|
|
21
|
-
label?: string
|
|
22
|
-
prefix?: string
|
|
23
|
-
postfix?: string
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
27
|
-
class: '',
|
|
28
|
-
size: '',
|
|
29
|
-
type: '',
|
|
30
|
-
round: false,
|
|
31
|
-
text: false,
|
|
32
|
-
link: false,
|
|
33
|
-
href: '',
|
|
34
|
-
disabled: false,
|
|
35
|
-
label: '',
|
|
36
|
-
prefix: '',
|
|
37
|
-
postfix: ''
|
|
38
|
-
})
|
|
39
|
-
const isClick = () =>{
|
|
40
|
-
if(props.href.length > 0){
|
|
41
|
-
const element = document.createElement('a')
|
|
42
|
-
element.setAttribute('href', props.href)
|
|
43
|
-
element.setAttribute('target', '_blank')
|
|
44
|
-
if(!props.disabled) element.click()
|
|
45
|
-
}}
|
|
46
|
-
const style = computed(() =>{
|
|
47
|
-
let s = ['sw-button']
|
|
48
|
-
if(props.size.length > 0) s.push('sw-' + props.size)
|
|
49
|
-
if(props.type.length > 0) s.push('sw-' + props.type)
|
|
50
|
-
if(props.round) s.push('sw-round')
|
|
51
|
-
if(props.text) s.push('sw-text')
|
|
52
|
-
if(props.link) s.push('sw-link')
|
|
53
|
-
if(props.disabled) s.push('sw-disabled')
|
|
54
|
-
if(props.class.length > 0) s.push(props.class)
|
|
55
|
-
return s
|
|
56
|
-
})
|
|
57
|
-
</script>
|
|
@@ -1,68 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import {computed, onMounted, onUnmounted, ref, watch} from "vue"
|
|
3
|
-
|
|
4
|
-
const model = defineModel()
|
|
5
|
-
const buttons = ref([])
|
|
6
|
-
const buttonGroup = ref(null)
|
|
7
|
-
const observer = ref(null)
|
|
8
|
-
const props = defineProps({
|
|
9
|
-
class: {type:String, default: ''},
|
|
10
|
-
vertical: {type:Boolean, default: false},
|
|
11
|
-
radio: {type:Boolean, default: false},
|
|
12
|
-
round: {type:Boolean, default: false},
|
|
13
|
-
})
|
|
14
|
-
const style = computed(() =>{
|
|
15
|
-
let s = ['sw-button-group']
|
|
16
|
-
if(props.vertical) s.push('sw-vertical')
|
|
17
|
-
if(props.round) s.push('sw-round')
|
|
18
|
-
if(props.class.length > 0) s.push(props.class)
|
|
19
|
-
return s
|
|
20
|
-
})
|
|
21
|
-
|
|
22
|
-
onMounted(async () => {
|
|
23
|
-
await new Promise(resolve => setTimeout(resolve, 0))
|
|
24
|
-
if (props.radio) findSlotRootElements()
|
|
25
|
-
if (buttonGroup.value) {
|
|
26
|
-
observer.value = new MutationObserver(() => {
|
|
27
|
-
if (props.radio) findSlotRootElements()
|
|
28
|
-
})
|
|
29
|
-
observer.value.observe(buttonGroup.value, {
|
|
30
|
-
childList: true,
|
|
31
|
-
subtree: true
|
|
32
|
-
})
|
|
33
|
-
}
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
onUnmounted(() => {
|
|
37
|
-
if (observer.value) {
|
|
38
|
-
observer.value.disconnect()
|
|
39
|
-
}
|
|
40
|
-
})
|
|
41
|
-
|
|
42
|
-
watch(model,() => {
|
|
43
|
-
if (props.radio) {
|
|
44
|
-
[].forEach.call(buttons.value, (button, id) => {
|
|
45
|
-
if (id === model.value) button.classList.remove('sw-text')
|
|
46
|
-
else button.classList.add('sw-text')
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
|
|
51
|
-
const findSlotRootElements = () => {
|
|
52
|
-
buttons.value = []
|
|
53
|
-
if (buttonGroup.value) buttons.value = buttonGroup.value.querySelectorAll('button, .sw-button')
|
|
54
|
-
if (props.radio) {
|
|
55
|
-
[].forEach.call(buttons.value, (button, id) => {
|
|
56
|
-
if (model.value !== id) button.classList.add('sw-text');
|
|
57
|
-
else button.classList.remove('sw-text');
|
|
58
|
-
button.addEventListener('click', () => model.value = id)
|
|
59
|
-
})
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
</script>
|
|
63
|
-
|
|
64
|
-
<template>
|
|
65
|
-
<div :class="style" ref="buttonGroup">
|
|
66
|
-
<slot />
|
|
67
|
-
</div>
|
|
68
|
-
</template>
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="sw-collapse" :class="{ 'is-open': props.visual }" >
|
|
3
|
-
<div class="sw-collapse__inner">
|
|
4
|
-
<slot></slot>
|
|
5
|
-
</div>
|
|
6
|
-
</div>
|
|
7
|
-
</template>
|
|
8
|
-
<script setup>
|
|
9
|
-
const props = defineProps({
|
|
10
|
-
visual: { type: Boolean, default: true }
|
|
11
|
-
})
|
|
12
|
-
</script>
|
|
13
|
-
|
|
@@ -1,375 +0,0 @@
|
|
|
1
|
-
<script setup>
|
|
2
|
-
import {computed, ref} from 'vue'
|
|
3
|
-
import { parseTime, parseDateString } from "../utils/index.js"
|
|
4
|
-
|
|
5
|
-
const props = defineProps({
|
|
6
|
-
data: Object,
|
|
7
|
-
limitation: {
|
|
8
|
-
type: [Boolean, Array],
|
|
9
|
-
default: () => false
|
|
10
|
-
},
|
|
11
|
-
range: {
|
|
12
|
-
type: String,
|
|
13
|
-
default: 'solid'
|
|
14
|
-
}
|
|
15
|
-
})
|
|
16
|
-
|
|
17
|
-
const emit = defineEmits(['input'])
|
|
18
|
-
const year = ref(5)
|
|
19
|
-
// Текущие даты
|
|
20
|
-
const start = ref(new Date())
|
|
21
|
-
const end = ref(new Date())
|
|
22
|
-
|
|
23
|
-
// Год и месяц для отображения
|
|
24
|
-
const startYear = ref(new Date().getFullYear())
|
|
25
|
-
const startMonth = ref(new Date().getMonth())
|
|
26
|
-
const endYear = ref(new Date().getFullYear())
|
|
27
|
-
const endMonth = ref(new Date().getMonth())
|
|
28
|
-
const nextMonth = ref(new Date(startYear.value, startMonth.value +1, 1).getMonth())
|
|
29
|
-
|
|
30
|
-
// Дни и индексатор
|
|
31
|
-
const days = ref([])
|
|
32
|
-
const ind = ref(0)
|
|
33
|
-
const startId = ref(-1)
|
|
34
|
-
const endId = ref(-1)
|
|
35
|
-
const locale = ref((typeof navigator !== 'undefined' && navigator.language) || 'ru')
|
|
36
|
-
const iso = (/en|zh|ja|he/.test(locale.value)) ? 0 : 1
|
|
37
|
-
const months = computed(() => {
|
|
38
|
-
return Array.from({ length: 12 }, (_, i) => {
|
|
39
|
-
const date = new Date(2024, i)
|
|
40
|
-
return new Intl.DateTimeFormat(locale.value, { month: 'long' }).format(date)
|
|
41
|
-
})
|
|
42
|
-
})
|
|
43
|
-
const decade = ref(Math.floor(startYear.value / 10) * 10)
|
|
44
|
-
const decades = computed(() => {
|
|
45
|
-
return Array.from({length:12}, (_,i) => {
|
|
46
|
-
return decade.value + i - 1
|
|
47
|
-
})
|
|
48
|
-
})
|
|
49
|
-
|
|
50
|
-
// Инициализация стартовой и конечной даты
|
|
51
|
-
if (props.data?.startDate) {
|
|
52
|
-
start.value = new Date(parseDateString(props.data.startDate))
|
|
53
|
-
startYear.value = start.value.getFullYear()
|
|
54
|
-
startMonth.value = start.value.getMonth()
|
|
55
|
-
} else if(props.data?.firstDate){
|
|
56
|
-
startYear.value = new Date(parseDateString(props.data.firstDate)).getFullYear()
|
|
57
|
-
startMonth.value = new Date(parseDateString(props.data.firstDate)).getMonth()
|
|
58
|
-
nextMonth.value = new Date(startYear.value, startMonth.value +1, 1).getMonth()
|
|
59
|
-
}
|
|
60
|
-
if (props.data?.endDate && props.range === 'range') {
|
|
61
|
-
end.value = new Date(parseDateString(props.data.endDate))
|
|
62
|
-
endYear.value = end.value.getFullYear()
|
|
63
|
-
endMonth.value = end.value.getMonth()
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
// Построение календаря
|
|
67
|
-
const view = () => {
|
|
68
|
-
days.value = []
|
|
69
|
-
ind.value = 0
|
|
70
|
-
// console.log('view', year.value)
|
|
71
|
-
// Предыдущий месяц
|
|
72
|
-
const preMonth = new Date(startYear.value, startMonth.value, 0)
|
|
73
|
-
for (let i = preMonth.getDate() - preMonth.getDay() + iso; i <= preMonth.getDate(); i++) {
|
|
74
|
-
if (preMonth.getDay() !== 6 + iso) {
|
|
75
|
-
days.value.push({ day: i, month: preMonth.getMonth(), year: preMonth.getFullYear(), class: [] })
|
|
76
|
-
ind.value++
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// Текущий месяц
|
|
81
|
-
const currentMonthDays = new Date(startYear.value, startMonth.value + 1, 0).getDate()
|
|
82
|
-
for (let i = 1; i <= currentMonthDays; i++) {
|
|
83
|
-
days.value.push({ day: i, month: startMonth.value, year: startYear.value, class: [] })
|
|
84
|
-
ind.value++
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
// Следующий месяц (если диапазон)
|
|
88
|
-
if (props.range === 'range') {
|
|
89
|
-
const nextMonthDate = new Date(startYear.value, startMonth.value + 1, 1)
|
|
90
|
-
const nextMonthLastDay = new Date(startYear.value, startMonth.value + 2, 0).getDate()
|
|
91
|
-
for (let i = 1; i <= nextMonthLastDay; i++) {
|
|
92
|
-
days.value.push({ day: i, month: nextMonthDate.getMonth(), year: nextMonthDate.getFullYear(), class: [] })
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
// Подсветка праздников
|
|
97
|
-
highlightSpecialDays()
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
// Подсветка праздников и выходных
|
|
101
|
-
const highlightSpecialDays = () => {
|
|
102
|
-
if (!props.data?.holiday) return
|
|
103
|
-
|
|
104
|
-
const markClass = (dates, className) => {
|
|
105
|
-
dates.forEach(d => {
|
|
106
|
-
const [year, month, day] = d.split('-').map(Number)
|
|
107
|
-
const index = days.value.findIndex(el => el.year === year && el.month + 1 === month && el.day === day)
|
|
108
|
-
if (index !== -1) days.value[index].class[0] = className
|
|
109
|
-
})
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
markClass(props.data.holiday.preholidays, 'preholiday')
|
|
113
|
-
markClass(props.data.holiday.holidays, 'weekend')
|
|
114
|
-
markClass(props.data.holiday.holiday, 'holiday')
|
|
115
|
-
markClass(props.data.holiday.nowork, 'nowork')
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
// Проверка пересечения диапазонов
|
|
119
|
-
const checkOverlap = () => {
|
|
120
|
-
if (!props.limitation || props.limitation.length < 2) return false
|
|
121
|
-
|
|
122
|
-
const sorted = [...props.limitation].sort((a, b) =>
|
|
123
|
-
new Date(parseDateString(a.startDate)).getTime() - new Date(parseDateString(b.startDate)).getTime()
|
|
124
|
-
)
|
|
125
|
-
|
|
126
|
-
for (let i = 1; i < sorted.length; i++) {
|
|
127
|
-
const prevEnd = new Date(parseDateString(sorted[i - 1].endDate))
|
|
128
|
-
const currStart = new Date(parseDateString(sorted[i].startDate))
|
|
129
|
-
if (currStart <= prevEnd) {
|
|
130
|
-
console.warn("Warning: Диапазоны пересекаются:", sorted[i - 1], sorted[i])
|
|
131
|
-
return true
|
|
132
|
-
}
|
|
133
|
-
}
|
|
134
|
-
return false
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Фильтр дат по ограничениям
|
|
138
|
-
const filterData = (year, month, day) => {
|
|
139
|
-
if (!props.limitation || props.limitation.length === 0) return true
|
|
140
|
-
|
|
141
|
-
const targetDate = new Date(year, month, day).getTime()
|
|
142
|
-
|
|
143
|
-
for (let range of props.limitation) {
|
|
144
|
-
const { startDate, endDate } = range
|
|
145
|
-
|
|
146
|
-
// Если только endDate
|
|
147
|
-
if (!startDate && endDate) {
|
|
148
|
-
const end = new Date(parseDateString(endDate)).getTime()
|
|
149
|
-
if (targetDate <= end) return false
|
|
150
|
-
}
|
|
151
|
-
|
|
152
|
-
// Если только startDate
|
|
153
|
-
if (startDate && !endDate) {
|
|
154
|
-
const start = new Date(parseDateString(startDate)).getTime()
|
|
155
|
-
if (targetDate >= start) return false
|
|
156
|
-
}
|
|
157
|
-
|
|
158
|
-
// Если обе даты
|
|
159
|
-
if (startDate && endDate) {
|
|
160
|
-
const start = new Date(parseDateString(startDate)).getTime()
|
|
161
|
-
const end = new Date(parseDateString(endDate)).getTime()
|
|
162
|
-
|
|
163
|
-
if (start <= end) {
|
|
164
|
-
// обычный диапазон и одиночный
|
|
165
|
-
if (targetDate >= start && targetDate <= end) return false
|
|
166
|
-
} else {
|
|
167
|
-
// инвертированный диапазон (end < start)
|
|
168
|
-
if (targetDate >= start || targetDate <= end) return false
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
return true
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
// Выбор дня
|
|
176
|
-
const selectDays = (day, key) => {
|
|
177
|
-
const d = parseTime(new Date(day.year, day.month, day.day), '{dd}.{m}.{Y}')
|
|
178
|
-
|
|
179
|
-
if (props.range === 'range') {
|
|
180
|
-
if (endId.value !== -1) {
|
|
181
|
-
resetSelection()
|
|
182
|
-
startId.value = key
|
|
183
|
-
days.value[key].class[1] = 'active'
|
|
184
|
-
} else {
|
|
185
|
-
if (startId.value !== -1) {
|
|
186
|
-
endId.value = key
|
|
187
|
-
highlightRange(startId.value, endId.value, d)
|
|
188
|
-
} else {
|
|
189
|
-
startId.value = key
|
|
190
|
-
days.value[key].class[1] = 'active'
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
} else {
|
|
194
|
-
if (startId.value !== -1) {
|
|
195
|
-
days.value[startId.value].class[1] = ''
|
|
196
|
-
}
|
|
197
|
-
startId.value = key
|
|
198
|
-
days.value[key].class[1] = 'active'
|
|
199
|
-
emit('input', { dateStart: d, count: 1 })
|
|
200
|
-
}
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
// Очистка выделения
|
|
204
|
-
const resetSelection = () => {
|
|
205
|
-
days.value.forEach(day => day.class[1] = '')
|
|
206
|
-
startId.value = -1
|
|
207
|
-
endId.value = -1
|
|
208
|
-
}
|
|
209
|
-
|
|
210
|
-
// Подсветка диапазона
|
|
211
|
-
const highlightRange = (startKey, endKey, endDate) => {
|
|
212
|
-
let m = parseTime(new Date(days.value[startKey].year, days.value[startKey].month, days.value[startKey].day), '{dd}.{m}.{Y}')
|
|
213
|
-
if (endKey >= startKey) {
|
|
214
|
-
for (let i = startKey + 1; i < endKey; i++) {
|
|
215
|
-
days.value[i].class[1] = 'select'
|
|
216
|
-
}
|
|
217
|
-
emit('input', {dateStart: m, dateEnd: endDate, count: countDays(startKey, endKey)})
|
|
218
|
-
} else {
|
|
219
|
-
for (let i = endKey + 1; i < startKey; i++) {
|
|
220
|
-
days.value[i].class[1] = 'select'
|
|
221
|
-
}
|
|
222
|
-
emit('input', {dateStart: endDate, dateEnd: m, count: countDays(endKey, startKey)})
|
|
223
|
-
}
|
|
224
|
-
days.value[endKey].class[1] = 'active'
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
// Подсчет рабочих дней
|
|
228
|
-
const countDays = (a, b) => {
|
|
229
|
-
let count = Math.abs(a - b) + 1
|
|
230
|
-
let [min, max] = [Math.min(a, b), Math.max(a, b)]
|
|
231
|
-
for (let i = min; i <= max; i++) {
|
|
232
|
-
if (days.value[i]?.class[0] === 'holiday') count--
|
|
233
|
-
}
|
|
234
|
-
return count
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
// Изменение месяца
|
|
238
|
-
const change = (years, month) => {
|
|
239
|
-
if (filterData(years, month)) {
|
|
240
|
-
start.value = new Date(years, month, 1)
|
|
241
|
-
startYear.value = start.value.getFullYear()
|
|
242
|
-
startMonth.value = start.value.getMonth()
|
|
243
|
-
nextMonth.value = new Date(years, month + 1, 1).getMonth()
|
|
244
|
-
// console.log("change", year.value)
|
|
245
|
-
if((props.range === 'year' || props.range === 'decades') && year.value === 0) selectDays({year:years, month, day:1},8)
|
|
246
|
-
else view()
|
|
247
|
-
}
|
|
248
|
-
}
|
|
249
|
-
|
|
250
|
-
// Инициализация
|
|
251
|
-
view()
|
|
252
|
-
|
|
253
|
-
// Проверка на пересечение диапазонов
|
|
254
|
-
checkOverlap()
|
|
255
|
-
|
|
256
|
-
// Установка активных дат
|
|
257
|
-
if (props.data?.startDate) {
|
|
258
|
-
startId.value = days.value.findIndex(el => (
|
|
259
|
-
el.day === start.value.getDate() &&
|
|
260
|
-
el.month === startMonth.value &&
|
|
261
|
-
el.year === startYear.value
|
|
262
|
-
))
|
|
263
|
-
if (startId.value !== -1) days.value[startId.value].class[1] = 'active'
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
if (props.data?.endDate && props.range === 'range') {
|
|
267
|
-
endId.value = days.value.findIndex(el => (
|
|
268
|
-
el.day === end.value.getDate() &&
|
|
269
|
-
el.month === endMonth.value &&
|
|
270
|
-
el.year === endYear.value
|
|
271
|
-
))
|
|
272
|
-
if (endId.value !== -1) {
|
|
273
|
-
days.value[endId.value].class[1] = 'active'
|
|
274
|
-
for (let i = startId.value + 1; i < endId.value; i++) {
|
|
275
|
-
days.value[i].class[1] = 'select'
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
}
|
|
279
|
-
</script>
|
|
280
|
-
|
|
281
|
-
<template>
|
|
282
|
-
<div class="sw-data-picker">
|
|
283
|
-
<div>
|
|
284
|
-
<p class="month_year" v-if="props.range ==='decades' || year === 3">
|
|
285
|
-
<span>
|
|
286
|
-
<button @click.prevent="decade -= 10;change(startYear,startMonth )"><slot name="double-arrow">«</slot></button>
|
|
287
|
-
</span>
|
|
288
|
-
<span class="text">{{decades[0]}} - {{decades[11]}}</span>
|
|
289
|
-
<span>
|
|
290
|
-
<button class="sw-revers" @click.prevent="decade += 10;change(startYear,startMonth )"><slot name="double-arrow">«</slot></button>
|
|
291
|
-
</span>
|
|
292
|
-
</p>
|
|
293
|
-
<p class="month_year" v-else>
|
|
294
|
-
<span>
|
|
295
|
-
<button @click.prevent="change(startYear - 1,startMonth)"><slot name="double-arrow">«</slot></button>
|
|
296
|
-
<button @click.prevent="year = 0;change(startYear,startMonth - 1)"><slot name="arrow">‹</slot></button>
|
|
297
|
-
</span>
|
|
298
|
-
<span class="text">
|
|
299
|
-
<button @click.prevent="year = 3">{{ startYear }}</button>
|
|
300
|
-
<button @click.prevent="year = 1">{{ parseTime(start.setMonth(startMonth), '{F}') }}</button>
|
|
301
|
-
</span>
|
|
302
|
-
<span>
|
|
303
|
-
<button class="sw-revers" @click.prevent="year = 0;change(startYear,startMonth + 1)"><slot name="arrow">‹</slot></button>
|
|
304
|
-
<button class="sw-revers" @click.prevent="change(startYear + 1,startMonth)"><slot name="double-arrow">«</slot></button>
|
|
305
|
-
</span>
|
|
306
|
-
</p>
|
|
307
|
-
<div class="week" v-if="!(props.range ==='year' || props.range ==='decades' || year === 1 || year === 3)">
|
|
308
|
-
<button v-for="(i, key) in 7" :key="key" class="disabled">{{ parseTime(new Date(1970,1,i + iso), '{D}') }}</button>
|
|
309
|
-
</div>
|
|
310
|
-
<div class="year" v-if="year !== 3 && props.range ==='year' || year === 1">
|
|
311
|
-
<template v-for="(month, index) in months" :key="index">
|
|
312
|
-
<button @click.prevent="year = 0;change(startYear,index)" :class="(index === startMonth)?'active' :''">{{ month }}</button>
|
|
313
|
-
</template>
|
|
314
|
-
</div>
|
|
315
|
-
<div class="year" v-else-if="props.range ==='decades' || year === 3">
|
|
316
|
-
<template v-for="(y, ind) in decades" :key="ind">
|
|
317
|
-
<button @click.prevent="year = (props.range ==='year')?1:0;change(y,startMonth)" :class="(decade + ind - 1 === startYear)?'active' :''">{{ y }}</button>
|
|
318
|
-
</template>
|
|
319
|
-
</div>
|
|
320
|
-
<div class="month" v-else>
|
|
321
|
-
<template v-for="(day, key) in days" :key="key">
|
|
322
|
-
<button v-if="key < ind + (7 - new Date(startYear,startMonth +1, 1).getDay() + iso) % 7"
|
|
323
|
-
:class="(day.month === startMonth && filterData(day.year, day.month, day.day))? day.class : 'disabled'"
|
|
324
|
-
@click.prevent="() => {if(day.month === startMonth) selectDays(day,key)}">{{ day.day }}</button>
|
|
325
|
-
</template>
|
|
326
|
-
</div>
|
|
327
|
-
</div>
|
|
328
|
-
<div v-if="props.range === 'range'">
|
|
329
|
-
<p class="month_year" v-if="props.range ==='decades' || year === 4">
|
|
330
|
-
<span>
|
|
331
|
-
<button @click.prevent="decade -= 10;change(startYear,startMonth )"><slot name="double-arrow">«</slot></button>
|
|
332
|
-
</span>
|
|
333
|
-
<span class="text">{{decades[0]}} - {{decades[11]}}</span>
|
|
334
|
-
<span>
|
|
335
|
-
<button class="sw-revers" @click.prevent="decade += 10;change(startYear,startMonth )"><slot name="double-arrow">«</slot></button>
|
|
336
|
-
</span>
|
|
337
|
-
</p>
|
|
338
|
-
<p class="month_year" v-else>
|
|
339
|
-
<span>
|
|
340
|
-
<button @click.prevent="change(startYear - 1,startMonth)"><slot name="double-arrow">«</slot></button>
|
|
341
|
-
<button @click.prevent="year = 0;change(startYear,startMonth - 1)"><slot name="arrow">‹</slot></button>
|
|
342
|
-
</span>
|
|
343
|
-
<span class="text">
|
|
344
|
-
<button @click.prevent="year = 4">{{ new Date(startYear, (startMonth + 1)).getFullYear()}}</button>
|
|
345
|
-
<button @click.prevent="year = 2">{{ parseTime(start.setMonth(startMonth +1), '{F}') }}</button>
|
|
346
|
-
</span>
|
|
347
|
-
<span>
|
|
348
|
-
<button class="sw-revers" @click.prevent="year = 0;change(startYear,startMonth + 1)"><slot name="arrow">‹</slot></button>
|
|
349
|
-
<button class="sw-revers" @click.prevent="change(startYear + 1,startMonth)"><slot name="double-arrow">«</slot></button>
|
|
350
|
-
</span>
|
|
351
|
-
</p>
|
|
352
|
-
<div class="week" v-if="!(year === 2 || year === 4)">
|
|
353
|
-
<button v-for="(i, key) in 7" :key="key" class="disabled">{{ parseTime(new Date(1970,1,i + iso), '{D}') }}</button>
|
|
354
|
-
</div>
|
|
355
|
-
<div class="year" v-if="year === 2">
|
|
356
|
-
<template v-for="(month, index) in months" :key="index">
|
|
357
|
-
<button @click.prevent="year = 0;change(startYear,index-1)" :class="(index === (startMonth + 1) % 12 )?'active' :''">{{ month }}</button>
|
|
358
|
-
</template>
|
|
359
|
-
</div>
|
|
360
|
-
<!-- decades -->
|
|
361
|
-
<div class="year" v-else-if="year === 4">
|
|
362
|
-
<template v-for="(y, ind) in decades" :key="ind">
|
|
363
|
-
<button @click.prevent="year = 0;change(y,startMonth)" :class="(decade + ind - 1 === startYear)?'active' :''">{{ y }}</button>
|
|
364
|
-
</template>
|
|
365
|
-
</div>
|
|
366
|
-
<div class="month" v-else>
|
|
367
|
-
<template v-for="(day, key) in days" :key="key">
|
|
368
|
-
<button v-if="key >= ind - (7 + new Date(startYear,startMonth +1, 1).getDay() - iso) % 7"
|
|
369
|
-
:class="(day.month === nextMonth && filterData(day.year, day.month, day.day))? day.class :'disabled'"
|
|
370
|
-
@click.prevent="() => {if(day.month === nextMonth) selectDays(day,key)}">{{ day.day }}</button>
|
|
371
|
-
</template>
|
|
372
|
-
</div>
|
|
373
|
-
</div>
|
|
374
|
-
</div>
|
|
375
|
-
</template>
|