bfg-common 1.4.273 → 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.
@@ -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<{
@@ -130,13 +131,14 @@ watch(
130
131
  (newValue: UI_I_ScheduleNewTasksForm) => {
131
132
  console.log(newValue, '444444')
132
133
  const date = newValue.frg_on_time && new Date(newValue.frg_on_time)
133
- newValue.cron = generateOnceCronExpression(date)
134
+ newValue.cron = generateCronExpression(newValue.frequency, newValue)
134
135
  },
135
136
  { deep: true }
136
137
  )
137
138
 
138
- const generateOnceCronExpression = (date: Date | null): any => {
139
- if(!date) return
139
+ const generateOnceCronExpression = (date: Date): any => {
140
+ if (!date) return
141
+
140
142
  const minutes = date.getMinutes()
141
143
  const hours = date.getHours()
142
144
  const day = date.getDate()
@@ -144,7 +146,39 @@ const generateOnceCronExpression = (date: Date | null): any => {
144
146
  const dayOfWeek = '*' // Для одноразовой задачи день недели неважен
145
147
 
146
148
  // Генерируем cron-выражение
147
- const cronExpression = `${minutes} ${hours} ${day} ${month} ${dayOfWeek} once`
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
+
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.274",
5
5
  "scripts": {
6
6
  "build": "nuxt build",
7
7
  "dev": "nuxt dev --port=3002",