shared-ritm 1.3.129 → 1.3.131
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/dist/index.css +1 -1
- package/dist/shared-ritm.es.js +1625 -1649
- package/dist/shared-ritm.umd.js +135 -135
- package/dist/types/api/services/MetricsService.d.ts +2 -3
- package/dist/types/api/types/Api_Metrics.d.ts +0 -21
- package/package.json +70 -70
- package/src/App.vue +2461 -2461
- package/src/api/services/AuthService.ts +67 -67
- package/src/api/services/ControlsService.ts +100 -100
- package/src/api/services/EquipmentService.ts +68 -68
- package/src/api/services/GanttService.ts +58 -58
- package/src/api/services/InstrumentsService.ts +76 -76
- package/src/api/services/MetricsService.ts +3 -0
- package/src/api/services/RepairsService.ts +111 -111
- package/src/api/services/TasksService.ts +165 -165
- package/src/api/services/UserIssueService.ts +32 -32
- package/src/api/services/UserService.ts +129 -129
- package/src/api/services/VideoService.ts +118 -118
- package/src/api/settings/ApiService.ts +185 -185
- package/src/api/types/Api_Auth.ts +121 -121
- package/src/api/types/Api_Controls.ts +112 -112
- package/src/api/types/Api_Equipment.ts +54 -54
- package/src/api/types/Api_Instruments.ts +182 -182
- package/src/api/types/Api_Metrics.ts +112 -112
- package/src/api/types/Api_Repairs.ts +200 -200
- package/src/api/types/Api_Search.ts +81 -81
- package/src/api/types/Api_Tasks.ts +385 -378
- package/src/api/types/Api_User.ts +161 -161
- package/src/api/types/Api_User_Issue.ts +36 -36
- package/src/api/types/Api_Video.ts +244 -244
- package/src/common/app-button/Button.stories.ts +369 -369
- package/src/common/app-checkbox/AppCheckbox.vue +33 -33
- package/src/common/app-checkbox/Checkbox.stories.ts +252 -252
- package/src/common/app-date-picker/DatePicker.stories.ts +66 -66
- package/src/common/app-datepicker/AppDatepicker.vue +221 -221
- package/src/common/app-datepicker/Datepicker.stories.ts +145 -145
- package/src/common/app-dialogs/AppConfirmDialog.vue +109 -109
- package/src/common/app-dialogs/Confirm.stories.ts +93 -93
- package/src/common/app-dropdown/Dropdown.stories.ts +94 -94
- package/src/common/app-file/File.stories.ts +104 -104
- package/src/common/app-icon/AppIcon.vue +110 -110
- package/src/common/app-icon/Icon.stories.ts +91 -91
- package/src/common/app-input/AppInput.vue +150 -150
- package/src/common/app-input/Input.stories.ts +160 -160
- package/src/common/app-input-new/AppInputNew.vue +186 -186
- package/src/common/app-input-new/InputNew.stories.ts +240 -240
- package/src/common/app-input-search/InputSearch.stories.ts +149 -149
- package/src/common/app-layout/components/AppLayoutHeader.vue +289 -289
- package/src/common/app-loader/Loader.stories.ts +114 -114
- package/src/common/app-modal/index.vue +101 -101
- package/src/common/app-select/AppSelect.vue +167 -167
- package/src/common/app-select/Select.stories.ts +155 -155
- package/src/common/app-sheet-new/AppSheetNew.vue +254 -254
- package/src/common/app-sidebar/AppSidebar.vue +177 -177
- package/src/common/app-table/AppTable.vue +313 -313
- package/src/common/app-table/components/ModalSelect.stories.ts +323 -323
- package/src/common/app-table/components/ModalSelect.vue +311 -311
- package/src/common/app-table/components/TableModal.vue +369 -369
- package/src/common/app-table/controllers/useColumnSelector.ts +45 -45
- package/src/common/app-table/controllers/useTableModel.ts +98 -98
- package/src/common/app-toggle/AppToggle.vue +12 -12
- package/src/common/app-toggle/Toggle.stories.ts +245 -245
- package/src/common/app-wrapper/AppWrapper.vue +31 -31
- package/src/configs/storybook.ts +14 -14
- package/src/icons/sidebar/user-requests-icon.vue +23 -23
- package/src/index.ts +134 -134
- package/src/shared/styles/general.css +140 -140
- package/src/styles/variables.sass +12 -12
- package/src/utils/files.ts +38 -38
- package/src/utils/helpers.ts +59 -59
- package/dist/types/api/services/PhotoService.d.ts +0 -40
- package/dist/types/stories/Button.stories.d.ts +0 -13
- package/dist/types/stories/Checkbox.stories.d.ts +0 -7
- package/dist/types/stories/Confirm.stories.d.ts +0 -8
- package/dist/types/stories/DatePicker.stories.d.ts +0 -8
- package/dist/types/stories/Dropdown.stories.d.ts +0 -8
- package/dist/types/stories/File.stories.d.ts +0 -8
- package/dist/types/stories/Icon.stories.d.ts +0 -7
- package/dist/types/stories/Input.stories.d.ts +0 -11
- package/dist/types/stories/InputNew.stories.d.ts +0 -12
- package/dist/types/stories/InputSearch.stories.d.ts +0 -10
- package/dist/types/stories/Loader.stories.d.ts +0 -8
- package/dist/types/stories/Select.stories.d.ts +0 -7
- package/dist/types/stories/Toggle.stories.d.ts +0 -8
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
-
import DatePicker from '@/common/app-date-picker/AppDatePicker.vue'
|
|
3
|
-
|
|
4
|
-
const meta: Meta<typeof DatePicker> = {
|
|
5
|
-
title: 'Components/DatePicker',
|
|
6
|
-
component: DatePicker,
|
|
7
|
-
tags: ['autodocs'],
|
|
8
|
-
argTypes: {
|
|
9
|
-
label: {
|
|
10
|
-
control: 'text',
|
|
11
|
-
},
|
|
12
|
-
modelValue: {
|
|
13
|
-
control: 'text',
|
|
14
|
-
description: 'Выбранная дата в формате YYYY-MM-DD.',
|
|
15
|
-
},
|
|
16
|
-
disabled: {
|
|
17
|
-
control: 'boolean',
|
|
18
|
-
},
|
|
19
|
-
disableRuleDates: {
|
|
20
|
-
control: 'text',
|
|
21
|
-
description: 'Минимальная дата в формате YYYY-MM-DD. Если не указана — ограничение "не раньше сегодня".',
|
|
22
|
-
},
|
|
23
|
-
},
|
|
24
|
-
args: {
|
|
25
|
-
label: 'Дата начала',
|
|
26
|
-
modelValue: '',
|
|
27
|
-
disabled: false,
|
|
28
|
-
disableRuleDates: '',
|
|
29
|
-
},
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export default meta
|
|
33
|
-
|
|
34
|
-
type Story = StoryObj<typeof DatePicker>
|
|
35
|
-
|
|
36
|
-
export const Default: Story = {}
|
|
37
|
-
|
|
38
|
-
export const States: Story = {
|
|
39
|
-
render: () => ({
|
|
40
|
-
components: { DatePicker },
|
|
41
|
-
template: `
|
|
42
|
-
<div style="display: flex; flex-direction: column; gap: 20px;">
|
|
43
|
-
<div>
|
|
44
|
-
<DatePicker v-model="date1" label="Не ранее сегодня" />
|
|
45
|
-
</div>
|
|
46
|
-
<div>
|
|
47
|
-
<DatePicker v-model="date2" label="С 01.01.2026" disable-rule-dates="2026-01-01" />
|
|
48
|
-
</div>
|
|
49
|
-
<div>
|
|
50
|
-
<DatePicker v-model="disabledDate" label="Отключён" :disabled="true" />
|
|
51
|
-
</div>
|
|
52
|
-
<div>
|
|
53
|
-
<DatePicker v-model="selectedDate" label="С датой" />
|
|
54
|
-
</div>
|
|
55
|
-
</div>
|
|
56
|
-
`,
|
|
57
|
-
data() {
|
|
58
|
-
return {
|
|
59
|
-
date1: '',
|
|
60
|
-
date2: '',
|
|
61
|
-
disabledDate: '',
|
|
62
|
-
selectedDate: '2025-12-25',
|
|
63
|
-
}
|
|
64
|
-
},
|
|
65
|
-
}),
|
|
66
|
-
}
|
|
1
|
+
import type { Meta, StoryObj } from '@storybook/vue3'
|
|
2
|
+
import DatePicker from '@/common/app-date-picker/AppDatePicker.vue'
|
|
3
|
+
|
|
4
|
+
const meta: Meta<typeof DatePicker> = {
|
|
5
|
+
title: 'Components/DatePicker',
|
|
6
|
+
component: DatePicker,
|
|
7
|
+
tags: ['autodocs'],
|
|
8
|
+
argTypes: {
|
|
9
|
+
label: {
|
|
10
|
+
control: 'text',
|
|
11
|
+
},
|
|
12
|
+
modelValue: {
|
|
13
|
+
control: 'text',
|
|
14
|
+
description: 'Выбранная дата в формате YYYY-MM-DD.',
|
|
15
|
+
},
|
|
16
|
+
disabled: {
|
|
17
|
+
control: 'boolean',
|
|
18
|
+
},
|
|
19
|
+
disableRuleDates: {
|
|
20
|
+
control: 'text',
|
|
21
|
+
description: 'Минимальная дата в формате YYYY-MM-DD. Если не указана — ограничение "не раньше сегодня".',
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
args: {
|
|
25
|
+
label: 'Дата начала',
|
|
26
|
+
modelValue: '',
|
|
27
|
+
disabled: false,
|
|
28
|
+
disableRuleDates: '',
|
|
29
|
+
},
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export default meta
|
|
33
|
+
|
|
34
|
+
type Story = StoryObj<typeof DatePicker>
|
|
35
|
+
|
|
36
|
+
export const Default: Story = {}
|
|
37
|
+
|
|
38
|
+
export const States: Story = {
|
|
39
|
+
render: () => ({
|
|
40
|
+
components: { DatePicker },
|
|
41
|
+
template: `
|
|
42
|
+
<div style="display: flex; flex-direction: column; gap: 20px;">
|
|
43
|
+
<div>
|
|
44
|
+
<DatePicker v-model="date1" label="Не ранее сегодня" />
|
|
45
|
+
</div>
|
|
46
|
+
<div>
|
|
47
|
+
<DatePicker v-model="date2" label="С 01.01.2026" disable-rule-dates="2026-01-01" />
|
|
48
|
+
</div>
|
|
49
|
+
<div>
|
|
50
|
+
<DatePicker v-model="disabledDate" label="Отключён" :disabled="true" />
|
|
51
|
+
</div>
|
|
52
|
+
<div>
|
|
53
|
+
<DatePicker v-model="selectedDate" label="С датой" />
|
|
54
|
+
</div>
|
|
55
|
+
</div>
|
|
56
|
+
`,
|
|
57
|
+
data() {
|
|
58
|
+
return {
|
|
59
|
+
date1: '',
|
|
60
|
+
date2: '',
|
|
61
|
+
disabledDate: '',
|
|
62
|
+
selectedDate: '2025-12-25',
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
}),
|
|
66
|
+
}
|
|
@@ -1,221 +1,221 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="datepicker">
|
|
3
|
-
<app-input-new
|
|
4
|
-
v-model="model"
|
|
5
|
-
readonly
|
|
6
|
-
input-class="cursor-pointer"
|
|
7
|
-
:label="label"
|
|
8
|
-
:required="required"
|
|
9
|
-
:rules="rules"
|
|
10
|
-
:error="isError || error"
|
|
11
|
-
:disable="disabled"
|
|
12
|
-
:hide-bottom-space="hideBottomSpace"
|
|
13
|
-
placeholder="Выберите дату"
|
|
14
|
-
>
|
|
15
|
-
<q-popup-proxy v-if="!disabled" class="datepicker__wrapper" @update:model-value="updateError">
|
|
16
|
-
<q-date
|
|
17
|
-
:model-value="model"
|
|
18
|
-
:mask="time ? `DD.MM.YYYY ${timeFormat}` : 'DD.MM.YYYY'"
|
|
19
|
-
:options="disablePastDates"
|
|
20
|
-
@update:model-value="updateDate"
|
|
21
|
-
/>
|
|
22
|
-
<q-time
|
|
23
|
-
v-if="time"
|
|
24
|
-
v-model="model"
|
|
25
|
-
:mask="`DD.MM.YYYY ${timeFormat}`"
|
|
26
|
-
format24h
|
|
27
|
-
:hour-options="hourOptions()"
|
|
28
|
-
:minute-options="minuteOptions()"
|
|
29
|
-
/>
|
|
30
|
-
</q-popup-proxy>
|
|
31
|
-
<template #append>
|
|
32
|
-
<q-icon name="event" class="cursor-pointer"></q-icon>
|
|
33
|
-
</template>
|
|
34
|
-
</app-input-new>
|
|
35
|
-
</div>
|
|
36
|
-
</template>
|
|
37
|
-
|
|
38
|
-
<script setup lang="ts">
|
|
39
|
-
import AppInputNew from '@/common/app-input-new/AppInputNew.vue'
|
|
40
|
-
import { ref, withDefaults, defineEmits, defineProps, defineModel } from 'vue'
|
|
41
|
-
import { date } from 'quasar'
|
|
42
|
-
|
|
43
|
-
interface Props {
|
|
44
|
-
label?: string
|
|
45
|
-
modelValue?: string
|
|
46
|
-
rules?: ((val?: string | number | null) => boolean | string)[]
|
|
47
|
-
disableRuleDates?: string | string[]
|
|
48
|
-
time?: boolean
|
|
49
|
-
noPastDates?: boolean
|
|
50
|
-
disabled?: boolean
|
|
51
|
-
required?: boolean
|
|
52
|
-
timeFormat?: string
|
|
53
|
-
hideBottomSpace?: boolean
|
|
54
|
-
isError?: boolean
|
|
55
|
-
}
|
|
56
|
-
const props = withDefaults(defineProps<Props>(), {
|
|
57
|
-
label: '',
|
|
58
|
-
timeFormat: 'HH:mm',
|
|
59
|
-
rules: () => [],
|
|
60
|
-
disableRuleDates: undefined,
|
|
61
|
-
modelValue: undefined,
|
|
62
|
-
})
|
|
63
|
-
|
|
64
|
-
defineEmits(['update:modelValue'])
|
|
65
|
-
|
|
66
|
-
const model = defineModel<string | null | undefined>()
|
|
67
|
-
|
|
68
|
-
const error = ref(false)
|
|
69
|
-
|
|
70
|
-
const updateError = (state: boolean) => {
|
|
71
|
-
if (props.required && !error.value && !model.value && !state) {
|
|
72
|
-
error.value = true
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const updateDate = (value: string) => {
|
|
77
|
-
error.value = false
|
|
78
|
-
|
|
79
|
-
if (!props.noPastDates) {
|
|
80
|
-
model.value = value
|
|
81
|
-
return
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const today = new Date()
|
|
85
|
-
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
86
|
-
const selectedDate = getSelectedDate(value)
|
|
87
|
-
|
|
88
|
-
if (selectedDate !== todayStr) {
|
|
89
|
-
model.value = value
|
|
90
|
-
return
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
const selectedHour = getSelectedHour(value)
|
|
94
|
-
const selectedMinutes = getSelectedMinutes(value)
|
|
95
|
-
const currentHour = today.getHours()
|
|
96
|
-
const currentMinutes = today.getMinutes()
|
|
97
|
-
|
|
98
|
-
if (
|
|
99
|
-
(selectedHour || selectedHour === 0) &&
|
|
100
|
-
(selectedMinutes || selectedMinutes === 0) &&
|
|
101
|
-
(selectedHour < currentHour || (selectedHour === currentHour && selectedMinutes < currentMinutes))
|
|
102
|
-
) {
|
|
103
|
-
today.setHours(currentHour, currentMinutes, 0)
|
|
104
|
-
model.value = date.formatDate(today, `DD.MM.YYYY ${props.timeFormat}`)
|
|
105
|
-
} else {
|
|
106
|
-
model.value = value
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
const disablePastDates = (date: string) => {
|
|
111
|
-
if (!props.noPastDates && !props.disableRuleDates) return true
|
|
112
|
-
|
|
113
|
-
const [year, month, day] = date.split('/')
|
|
114
|
-
const currentDate = new Date(Number(year), Number(month) - 1, Number(day))
|
|
115
|
-
currentDate.setHours(0, 0, 0, 0)
|
|
116
|
-
|
|
117
|
-
if (props.disableRuleDates) {
|
|
118
|
-
if (Array.isArray(props.disableRuleDates)) {
|
|
119
|
-
const firstDate = props.disableRuleDates[0] ? new Date(props.disableRuleDates[0]) : null
|
|
120
|
-
firstDate?.setHours(0, 0, 0, 0)
|
|
121
|
-
const lastDate = props.disableRuleDates[1] ? new Date(props.disableRuleDates[1]) : null
|
|
122
|
-
lastDate?.setHours(0, 0, 0, 0)
|
|
123
|
-
|
|
124
|
-
return (!firstDate || currentDate >= firstDate) && (!lastDate || currentDate <= lastDate)
|
|
125
|
-
} else {
|
|
126
|
-
const firstDate = new Date(props.disableRuleDates)
|
|
127
|
-
return currentDate >= firstDate
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
const today = new Date()
|
|
132
|
-
const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate())
|
|
133
|
-
|
|
134
|
-
return currentDate >= todayDate
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
function getSelectedDate(value = model.value) {
|
|
138
|
-
if (!value) return null
|
|
139
|
-
|
|
140
|
-
return value.toString().substring(0, 10)
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
function getSelectedHour(value = model.value) {
|
|
144
|
-
if (!value) return null
|
|
145
|
-
|
|
146
|
-
const timePart = value.toString().split(' ')[1]
|
|
147
|
-
return timePart ? Number(timePart.split(':')[0]) : null
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
function getSelectedMinutes(value = model.value) {
|
|
151
|
-
if (!value) return null
|
|
152
|
-
|
|
153
|
-
const timePart = value.toString().split(' ')[1]
|
|
154
|
-
return timePart ? Number(timePart.split(':')[1]) : null
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function hourOptions(): number[] {
|
|
158
|
-
const today = new Date()
|
|
159
|
-
const selectedDate = getSelectedDate()
|
|
160
|
-
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
161
|
-
|
|
162
|
-
if (selectedDate !== todayStr) {
|
|
163
|
-
return Array.from({ length: 24 }, (_, i) => i)
|
|
164
|
-
}
|
|
165
|
-
|
|
166
|
-
const currentHour = today.getHours()
|
|
167
|
-
return Array.from({ length: 24 - currentHour }, (_, i) => currentHour + i)
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function minuteOptions(): number[] {
|
|
171
|
-
const today = new Date()
|
|
172
|
-
const selectedDate = getSelectedDate()
|
|
173
|
-
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
174
|
-
const selectedHour = getSelectedHour()
|
|
175
|
-
|
|
176
|
-
if (selectedDate !== todayStr) {
|
|
177
|
-
return Array.from({ length: 60 }, (_, i) => i)
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
if (selectedHour === today.getHours()) {
|
|
181
|
-
const currentMinutes = today.getMinutes()
|
|
182
|
-
return Array.from({ length: 60 - currentMinutes }, (_, i) => currentMinutes + i)
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
return Array.from({ length: 60 }, (_, i) => i)
|
|
186
|
-
}
|
|
187
|
-
</script>
|
|
188
|
-
|
|
189
|
-
<style scoped lang="scss">
|
|
190
|
-
.datepicker {
|
|
191
|
-
:deep(input),
|
|
192
|
-
:deep(.q-field--readonly.q-field--float .q-field__native) {
|
|
193
|
-
cursor: pointer;
|
|
194
|
-
}
|
|
195
|
-
|
|
196
|
-
&__label {
|
|
197
|
-
font-size: 14px;
|
|
198
|
-
font-weight: 700;
|
|
199
|
-
color: #7d8592;
|
|
200
|
-
|
|
201
|
-
.required {
|
|
202
|
-
color: #f65160;
|
|
203
|
-
font-weight: bold;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
}
|
|
207
|
-
</style>
|
|
208
|
-
|
|
209
|
-
<style lang="scss">
|
|
210
|
-
.datepicker {
|
|
211
|
-
&__wrapper {
|
|
212
|
-
display: flex;
|
|
213
|
-
|
|
214
|
-
.q-time,
|
|
215
|
-
.q-date {
|
|
216
|
-
box-shadow: none;
|
|
217
|
-
border-radius: 0;
|
|
218
|
-
}
|
|
219
|
-
}
|
|
220
|
-
}
|
|
221
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="datepicker">
|
|
3
|
+
<app-input-new
|
|
4
|
+
v-model="model"
|
|
5
|
+
readonly
|
|
6
|
+
input-class="cursor-pointer"
|
|
7
|
+
:label="label"
|
|
8
|
+
:required="required"
|
|
9
|
+
:rules="rules"
|
|
10
|
+
:error="isError || error"
|
|
11
|
+
:disable="disabled"
|
|
12
|
+
:hide-bottom-space="hideBottomSpace"
|
|
13
|
+
placeholder="Выберите дату"
|
|
14
|
+
>
|
|
15
|
+
<q-popup-proxy v-if="!disabled" class="datepicker__wrapper" @update:model-value="updateError">
|
|
16
|
+
<q-date
|
|
17
|
+
:model-value="model"
|
|
18
|
+
:mask="time ? `DD.MM.YYYY ${timeFormat}` : 'DD.MM.YYYY'"
|
|
19
|
+
:options="disablePastDates"
|
|
20
|
+
@update:model-value="updateDate"
|
|
21
|
+
/>
|
|
22
|
+
<q-time
|
|
23
|
+
v-if="time"
|
|
24
|
+
v-model="model"
|
|
25
|
+
:mask="`DD.MM.YYYY ${timeFormat}`"
|
|
26
|
+
format24h
|
|
27
|
+
:hour-options="hourOptions()"
|
|
28
|
+
:minute-options="minuteOptions()"
|
|
29
|
+
/>
|
|
30
|
+
</q-popup-proxy>
|
|
31
|
+
<template #append>
|
|
32
|
+
<q-icon name="event" class="cursor-pointer"></q-icon>
|
|
33
|
+
</template>
|
|
34
|
+
</app-input-new>
|
|
35
|
+
</div>
|
|
36
|
+
</template>
|
|
37
|
+
|
|
38
|
+
<script setup lang="ts">
|
|
39
|
+
import AppInputNew from '@/common/app-input-new/AppInputNew.vue'
|
|
40
|
+
import { ref, withDefaults, defineEmits, defineProps, defineModel } from 'vue'
|
|
41
|
+
import { date } from 'quasar'
|
|
42
|
+
|
|
43
|
+
interface Props {
|
|
44
|
+
label?: string
|
|
45
|
+
modelValue?: string
|
|
46
|
+
rules?: ((val?: string | number | null) => boolean | string)[]
|
|
47
|
+
disableRuleDates?: string | string[]
|
|
48
|
+
time?: boolean
|
|
49
|
+
noPastDates?: boolean
|
|
50
|
+
disabled?: boolean
|
|
51
|
+
required?: boolean
|
|
52
|
+
timeFormat?: string
|
|
53
|
+
hideBottomSpace?: boolean
|
|
54
|
+
isError?: boolean
|
|
55
|
+
}
|
|
56
|
+
const props = withDefaults(defineProps<Props>(), {
|
|
57
|
+
label: '',
|
|
58
|
+
timeFormat: 'HH:mm',
|
|
59
|
+
rules: () => [],
|
|
60
|
+
disableRuleDates: undefined,
|
|
61
|
+
modelValue: undefined,
|
|
62
|
+
})
|
|
63
|
+
|
|
64
|
+
defineEmits(['update:modelValue'])
|
|
65
|
+
|
|
66
|
+
const model = defineModel<string | null | undefined>()
|
|
67
|
+
|
|
68
|
+
const error = ref(false)
|
|
69
|
+
|
|
70
|
+
const updateError = (state: boolean) => {
|
|
71
|
+
if (props.required && !error.value && !model.value && !state) {
|
|
72
|
+
error.value = true
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
const updateDate = (value: string) => {
|
|
77
|
+
error.value = false
|
|
78
|
+
|
|
79
|
+
if (!props.noPastDates) {
|
|
80
|
+
model.value = value
|
|
81
|
+
return
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
const today = new Date()
|
|
85
|
+
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
86
|
+
const selectedDate = getSelectedDate(value)
|
|
87
|
+
|
|
88
|
+
if (selectedDate !== todayStr) {
|
|
89
|
+
model.value = value
|
|
90
|
+
return
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
const selectedHour = getSelectedHour(value)
|
|
94
|
+
const selectedMinutes = getSelectedMinutes(value)
|
|
95
|
+
const currentHour = today.getHours()
|
|
96
|
+
const currentMinutes = today.getMinutes()
|
|
97
|
+
|
|
98
|
+
if (
|
|
99
|
+
(selectedHour || selectedHour === 0) &&
|
|
100
|
+
(selectedMinutes || selectedMinutes === 0) &&
|
|
101
|
+
(selectedHour < currentHour || (selectedHour === currentHour && selectedMinutes < currentMinutes))
|
|
102
|
+
) {
|
|
103
|
+
today.setHours(currentHour, currentMinutes, 0)
|
|
104
|
+
model.value = date.formatDate(today, `DD.MM.YYYY ${props.timeFormat}`)
|
|
105
|
+
} else {
|
|
106
|
+
model.value = value
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
const disablePastDates = (date: string) => {
|
|
111
|
+
if (!props.noPastDates && !props.disableRuleDates) return true
|
|
112
|
+
|
|
113
|
+
const [year, month, day] = date.split('/')
|
|
114
|
+
const currentDate = new Date(Number(year), Number(month) - 1, Number(day))
|
|
115
|
+
currentDate.setHours(0, 0, 0, 0)
|
|
116
|
+
|
|
117
|
+
if (props.disableRuleDates) {
|
|
118
|
+
if (Array.isArray(props.disableRuleDates)) {
|
|
119
|
+
const firstDate = props.disableRuleDates[0] ? new Date(props.disableRuleDates[0]) : null
|
|
120
|
+
firstDate?.setHours(0, 0, 0, 0)
|
|
121
|
+
const lastDate = props.disableRuleDates[1] ? new Date(props.disableRuleDates[1]) : null
|
|
122
|
+
lastDate?.setHours(0, 0, 0, 0)
|
|
123
|
+
|
|
124
|
+
return (!firstDate || currentDate >= firstDate) && (!lastDate || currentDate <= lastDate)
|
|
125
|
+
} else {
|
|
126
|
+
const firstDate = new Date(props.disableRuleDates)
|
|
127
|
+
return currentDate >= firstDate
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
const today = new Date()
|
|
132
|
+
const todayDate = new Date(today.getFullYear(), today.getMonth(), today.getDate())
|
|
133
|
+
|
|
134
|
+
return currentDate >= todayDate
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
function getSelectedDate(value = model.value) {
|
|
138
|
+
if (!value) return null
|
|
139
|
+
|
|
140
|
+
return value.toString().substring(0, 10)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
function getSelectedHour(value = model.value) {
|
|
144
|
+
if (!value) return null
|
|
145
|
+
|
|
146
|
+
const timePart = value.toString().split(' ')[1]
|
|
147
|
+
return timePart ? Number(timePart.split(':')[0]) : null
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function getSelectedMinutes(value = model.value) {
|
|
151
|
+
if (!value) return null
|
|
152
|
+
|
|
153
|
+
const timePart = value.toString().split(' ')[1]
|
|
154
|
+
return timePart ? Number(timePart.split(':')[1]) : null
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function hourOptions(): number[] {
|
|
158
|
+
const today = new Date()
|
|
159
|
+
const selectedDate = getSelectedDate()
|
|
160
|
+
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
161
|
+
|
|
162
|
+
if (selectedDate !== todayStr) {
|
|
163
|
+
return Array.from({ length: 24 }, (_, i) => i)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
const currentHour = today.getHours()
|
|
167
|
+
return Array.from({ length: 24 - currentHour }, (_, i) => currentHour + i)
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
function minuteOptions(): number[] {
|
|
171
|
+
const today = new Date()
|
|
172
|
+
const selectedDate = getSelectedDate()
|
|
173
|
+
const todayStr = today.toLocaleDateString('ru-RU').slice(0, 10)
|
|
174
|
+
const selectedHour = getSelectedHour()
|
|
175
|
+
|
|
176
|
+
if (selectedDate !== todayStr) {
|
|
177
|
+
return Array.from({ length: 60 }, (_, i) => i)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
if (selectedHour === today.getHours()) {
|
|
181
|
+
const currentMinutes = today.getMinutes()
|
|
182
|
+
return Array.from({ length: 60 - currentMinutes }, (_, i) => currentMinutes + i)
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
return Array.from({ length: 60 }, (_, i) => i)
|
|
186
|
+
}
|
|
187
|
+
</script>
|
|
188
|
+
|
|
189
|
+
<style scoped lang="scss">
|
|
190
|
+
.datepicker {
|
|
191
|
+
:deep(input),
|
|
192
|
+
:deep(.q-field--readonly.q-field--float .q-field__native) {
|
|
193
|
+
cursor: pointer;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
&__label {
|
|
197
|
+
font-size: 14px;
|
|
198
|
+
font-weight: 700;
|
|
199
|
+
color: #7d8592;
|
|
200
|
+
|
|
201
|
+
.required {
|
|
202
|
+
color: #f65160;
|
|
203
|
+
font-weight: bold;
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
}
|
|
207
|
+
</style>
|
|
208
|
+
|
|
209
|
+
<style lang="scss">
|
|
210
|
+
.datepicker {
|
|
211
|
+
&__wrapper {
|
|
212
|
+
display: flex;
|
|
213
|
+
|
|
214
|
+
.q-time,
|
|
215
|
+
.q-date {
|
|
216
|
+
box-shadow: none;
|
|
217
|
+
border-radius: 0;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
</style>
|