bfg-common 1.4.272 → 1.4.274
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/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types.ts +7 -0
- package/components/common/pages/scheduledTasks/modals/common/newTaskForm/NewTaskForm.vue +57 -0
- package/components/common/pages/scheduledTasks/modals/lib/config/createScheduledTask.ts +2 -3
- package/components/common/pages/scheduledTasks/modals/lib/models/interfaces.ts +1 -0
- package/package.json +1 -1
|
@@ -100,6 +100,7 @@ import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
|
100
100
|
import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
|
|
101
101
|
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
102
102
|
import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
|
|
103
|
+
import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
|
|
103
104
|
import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
|
|
104
105
|
|
|
105
106
|
const props = defineProps<{
|
|
@@ -124,6 +125,62 @@ const userNameErrorText = computed<string>(() => {
|
|
|
124
125
|
const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
|
|
125
126
|
frequencyMethodFunc(localization.value)
|
|
126
127
|
)
|
|
128
|
+
|
|
129
|
+
watch(
|
|
130
|
+
model,
|
|
131
|
+
(newValue: UI_I_ScheduleNewTasksForm) => {
|
|
132
|
+
console.log(newValue, '444444')
|
|
133
|
+
const date = newValue.frg_on_time && new Date(newValue.frg_on_time)
|
|
134
|
+
newValue.cron = generateCronExpression(newValue.frequency, newValue)
|
|
135
|
+
},
|
|
136
|
+
{ deep: true }
|
|
137
|
+
)
|
|
138
|
+
|
|
139
|
+
const generateOnceCronExpression = (date: Date): any => {
|
|
140
|
+
if (!date) return
|
|
141
|
+
|
|
142
|
+
const minutes = date.getMinutes()
|
|
143
|
+
const hours = date.getHours()
|
|
144
|
+
const day = date.getDate()
|
|
145
|
+
const month = date.getMonth() + 1 // В cron месяцы начинаются с 1 (январь = 1)
|
|
146
|
+
const dayOfWeek = '*' // Для одноразовой задачи день недели неважен
|
|
147
|
+
|
|
148
|
+
// Генерируем cron-выражение
|
|
149
|
+
return `${minutes} ${hours} ${day} ${month} ${dayOfWeek} once`
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
const generateCronExpression = (
|
|
153
|
+
runType: UI_T_FrequencyType,
|
|
154
|
+
interval: UI_I_ScheduleNewTasksForm
|
|
155
|
+
): string => {
|
|
156
|
+
let cronExpression
|
|
157
|
+
|
|
158
|
+
// Генерируем cron-выражение на основе runType
|
|
159
|
+
switch (runType) {
|
|
160
|
+
case 'once':
|
|
161
|
+
cronExpression = generateOnceCronExpression(interval.frg_on_time)
|
|
162
|
+
break
|
|
163
|
+
case 'after-startup':
|
|
164
|
+
cronExpression = `* * * * * after_procurator_startup` // Выполнение каждые N часов
|
|
165
|
+
break
|
|
166
|
+
case 'hour':
|
|
167
|
+
cronExpression = `* * * * *` // Выполнение каждые N дней в полночь
|
|
168
|
+
break
|
|
169
|
+
case 'day':
|
|
170
|
+
cronExpression = `* * * * *` // Выполнение каждые N дней в полночь
|
|
171
|
+
break
|
|
172
|
+
case 'week':
|
|
173
|
+
cronExpression = `* * * * *` // Выполнение раз в неделю
|
|
174
|
+
break
|
|
175
|
+
case 'month':
|
|
176
|
+
cronExpression = `* * * * *` // Выполнение раз в неделю
|
|
177
|
+
break
|
|
178
|
+
default:
|
|
179
|
+
cronExpression = '* * * * *'
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
return cronExpression
|
|
183
|
+
}
|
|
127
184
|
</script>
|
|
128
185
|
|
|
129
186
|
<style lang="scss" scoped>
|
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
UI_I_ScheduleNewTasksForm,
|
|
3
|
-
} from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
1
|
+
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
4
2
|
|
|
5
3
|
export const scheduledTaskDefaultFormFunc = (): UI_I_ScheduleNewTasksForm => {
|
|
6
4
|
return {
|
|
7
5
|
isValid: true,
|
|
6
|
+
cron: '* * * * *',
|
|
8
7
|
task_name: '',
|
|
9
8
|
description: '',
|
|
10
9
|
ntfn_target: '',
|