bfg-common 1.4.273 → 1.4.275

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.
@@ -0,0 +1,7 @@
1
+ export type UI_T_FrequencyType =
2
+ | 'once'
3
+ | 'after-startup'
4
+ | 'hour'
5
+ | 'day'
6
+ | 'week'
7
+ | 'month'
@@ -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<{
@@ -128,15 +129,14 @@ const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
128
129
  watch(
129
130
  model,
130
131
  (newValue: UI_I_ScheduleNewTasksForm) => {
131
- console.log(newValue, '444444')
132
- const date = newValue.frg_on_time && new Date(newValue.frg_on_time)
133
- newValue.cron = generateOnceCronExpression(date)
132
+ newValue.cron = generateCronExpression(newValue.frequency, newValue)
134
133
  },
135
134
  { deep: true }
136
135
  )
137
136
 
138
- const generateOnceCronExpression = (date: Date | null): any => {
139
- if(!date) return
137
+ const generateOnceCronExpression = (date: Date): any => {
138
+ if (!date) return
139
+
140
140
  const minutes = date.getMinutes()
141
141
  const hours = date.getHours()
142
142
  const day = date.getDate()
@@ -144,7 +144,41 @@ const generateOnceCronExpression = (date: Date | null): any => {
144
144
  const dayOfWeek = '*' // Для одноразовой задачи день недели неважен
145
145
 
146
146
  // Генерируем cron-выражение
147
- const cronExpression = `${minutes} ${hours} ${day} ${month} ${dayOfWeek} once`
147
+ return `${minutes} ${hours} ${day} ${month} ${dayOfWeek} once`
148
+ }
149
+
150
+ const generateCronExpression = (
151
+ runType: UI_T_FrequencyType,
152
+ interval: UI_I_ScheduleNewTasksForm
153
+ ): string => {
154
+ let cronExpression
155
+
156
+ // Генерируем cron-выражение на основе runType
157
+ switch (runType) {
158
+ case 'once':
159
+ const date = interval.frg_on_time && new Date(interval.frg_on_time)
160
+ cronExpression = generateOnceCronExpression(date)
161
+ break
162
+ case 'after-startup':
163
+ const delay = `*/${interval.frg_after_startup}`
164
+ cronExpression = `${delay} * * * * after_procurator_startup` // Выполняется каждые N минут после запуска procurator_startup
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
+
148
182
  return cronExpression
149
183
  }
150
184
  </script>
@@ -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: '',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "bfg-common",
3
3
  "private": false,
4
- "version": "1.4.273",
4
+ "version": "1.4.275",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",