bfg-common 1.4.260 → 1.4.261
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.
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { isBefore, startOfDay } from 'date-fns'
|
|
1
2
|
import type {
|
|
2
3
|
UI_I_Localization,
|
|
3
4
|
UI_I_ArbitraryObject,
|
|
@@ -83,3 +84,14 @@ export const validateField = (
|
|
|
83
84
|
|
|
84
85
|
return ''
|
|
85
86
|
}
|
|
87
|
+
export const validateDate = (
|
|
88
|
+
localization: UI_I_Localization,
|
|
89
|
+
date: string
|
|
90
|
+
): string => {
|
|
91
|
+
const currentDateTime = startOfDay(new Date())
|
|
92
|
+
const selectedDate = startOfDay(new Date(date)) // Начало дня выбранной даты
|
|
93
|
+
|
|
94
|
+
return isBefore(selectedDate, currentDateTime)
|
|
95
|
+
? localization.common.theValueLargeThanStartTime
|
|
96
|
+
: ''
|
|
97
|
+
}
|
|
@@ -95,14 +95,18 @@
|
|
|
95
95
|
</template>
|
|
96
96
|
|
|
97
97
|
<script lang="ts" setup>
|
|
98
|
+
import { format } from 'date-fns'
|
|
98
99
|
import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
|
|
99
100
|
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
100
101
|
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
101
102
|
import {
|
|
102
|
-
frequencyOnWeeksDaysFunc,
|
|
103
103
|
frequencyOnOrdinalNumberFunc,
|
|
104
|
+
frequencyOnWeeksDaysFunc,
|
|
104
105
|
} from '~/components/common/pages/scheduledTasks/modals/common/frequency/on/lib/config/options'
|
|
105
|
-
import {
|
|
106
|
+
import {
|
|
107
|
+
validateDate,
|
|
108
|
+
validateField,
|
|
109
|
+
} from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/utils'
|
|
106
110
|
|
|
107
111
|
const props = defineProps<{
|
|
108
112
|
type: string
|
|
@@ -110,7 +114,6 @@ const props = defineProps<{
|
|
|
110
114
|
const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
|
|
111
115
|
|
|
112
116
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
113
|
-
const { $store, $formattedDate, $isDate, $getUnixByDate }: any = useNuxtApp()
|
|
114
117
|
|
|
115
118
|
const selectedTimeMode = ref<'day' | 'week'>('day')
|
|
116
119
|
|
|
@@ -144,7 +147,9 @@ watch(
|
|
|
144
147
|
)
|
|
145
148
|
|
|
146
149
|
const schedulerAtOnceErrorText = computed<string>(() => {
|
|
147
|
-
return !model.value.frg_on_time
|
|
150
|
+
return !model.value.frg_on_time
|
|
151
|
+
? localization.value.common.fieldRequired
|
|
152
|
+
: validateDate(localization.value, model.value.frg_on_time)
|
|
148
153
|
})
|
|
149
154
|
watch(
|
|
150
155
|
schedulerAtOnceErrorText,
|
|
@@ -154,23 +159,13 @@ watch(
|
|
|
154
159
|
{ immediate: true }
|
|
155
160
|
)
|
|
156
161
|
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
// model.value.frg_on_time = val // milliseconds
|
|
165
|
-
//
|
|
166
|
-
// currentDateLocal.value = $formattedDate(new Date(val), 'MM.dd.yyyy, hh:mm')
|
|
167
|
-
// }
|
|
168
|
-
|
|
169
|
-
// watch(currentDateLocal, (newValue) => {
|
|
170
|
-
// $isDate(newValue) &&
|
|
171
|
-
// (calendarDefaultDate.value = model.value.frg_on_time =
|
|
172
|
-
// $getUnixByDate(newValue))
|
|
173
|
-
// })
|
|
162
|
+
onMounted(() => {
|
|
163
|
+
props.type === 'once' && setDefaultDateTime()
|
|
164
|
+
})
|
|
165
|
+
const setDefaultDateTime = () => {
|
|
166
|
+
const currentDateTime = new Date()
|
|
167
|
+
model.value.frg_on_time = format(currentDateTime, "yyyy-MM-dd'T'HH:mm")
|
|
168
|
+
}
|
|
174
169
|
</script>
|
|
175
170
|
|
|
176
171
|
<style lang="scss" scoped>
|