bfg-common 1.4.278 → 1.4.281
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/on/On.vue +1 -1
- package/components/common/pages/scheduledTasks/modals/common/frequency/on/selectWeek/SelectWeek.vue +21 -17
- package/components/common/pages/scheduledTasks/modals/common/newTaskForm/NewTaskForm.vue +39 -13
- package/package.json +1 -1
package/components/common/pages/scheduledTasks/modals/common/frequency/on/selectWeek/SelectWeek.vue
CHANGED
|
@@ -18,38 +18,42 @@
|
|
|
18
18
|
<script lang="ts" setup>
|
|
19
19
|
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
20
20
|
import type { UI_I_SelectWeekDayTab } from '~/components/common/pages/scheduledTasks/modals/common/frequency/on/selectWeek/lib/models/interfaces'
|
|
21
|
+
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
21
22
|
import { weekDaysFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/on/selectWeek/lib/config/weekOptions'
|
|
22
23
|
|
|
23
|
-
const
|
|
24
|
+
const modelFrequency = defineModel<UI_I_ScheduleNewTasksForm>({
|
|
25
|
+
required: true,
|
|
26
|
+
})
|
|
24
27
|
|
|
25
28
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
26
29
|
|
|
27
30
|
const onSelectDay = (value: number): void => {
|
|
28
|
-
const index =
|
|
31
|
+
const index = modelFrequency.value?.frg_on_week_days.indexOf(value)
|
|
29
32
|
|
|
30
33
|
if (index === -1) {
|
|
31
|
-
|
|
32
|
-
|
|
34
|
+
modelFrequency.value.frg_on_week_days.push(value)
|
|
35
|
+
modelFrequency.value.frg_on_week_days.sort((a: number, b: number) => a - b)
|
|
33
36
|
} else {
|
|
34
|
-
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
+
modelFrequency.value.frg_on_week_days =
|
|
38
|
+
modelFrequency.value?.frg_on_week_days.filter(
|
|
39
|
+
(_: number, key: number) => key !== index
|
|
40
|
+
)
|
|
37
41
|
}
|
|
38
42
|
}
|
|
39
43
|
|
|
40
44
|
const tabs = computed<UI_I_SelectWeekDayTab[]>(() =>
|
|
41
|
-
weekDaysFunc(localization.value,
|
|
45
|
+
weekDaysFunc(localization.value, modelFrequency.value.frg_on_week_days)
|
|
42
46
|
)
|
|
43
47
|
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
watch(
|
|
49
|
+
modelFrequency,
|
|
50
|
+
(newValue: UI_I_ScheduleNewTasksForm) => {
|
|
51
|
+
modelFrequency.value.isValid = !newValue.frg_on_week_days.length
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
immediate: true,
|
|
55
|
+
}
|
|
56
|
+
)
|
|
53
57
|
</script>
|
|
54
58
|
|
|
55
59
|
<style lang="scss" scoped>
|
|
@@ -155,7 +155,7 @@ const generateHourlyCronExpression = (delay: string, date: Date): any => {
|
|
|
155
155
|
// Генерируем cron-выражение
|
|
156
156
|
return `${minutes} ${hours}/${delay} * * *`
|
|
157
157
|
}
|
|
158
|
-
const generateDaylyCronExpression = (delay: string, date: Date):
|
|
158
|
+
const generateDaylyCronExpression = (delay: string, date: Date): string => {
|
|
159
159
|
if (!date) return
|
|
160
160
|
|
|
161
161
|
const minutes = date.getMinutes()
|
|
@@ -165,6 +165,25 @@ const generateDaylyCronExpression = (delay: string, date: Date): any => {
|
|
|
165
165
|
// Генерируем cron-выражение
|
|
166
166
|
return `${minutes} ${hours} ${day}/${delay} * *`
|
|
167
167
|
}
|
|
168
|
+
const generateWeeklyCronExpression = (
|
|
169
|
+
data: UI_I_ScheduleNewTasksForm
|
|
170
|
+
): string => {
|
|
171
|
+
const { frg_on_week_days } = data
|
|
172
|
+
|
|
173
|
+
// Генерируем cron-выражение
|
|
174
|
+
return `* * * * ${frg_on_week_days.join(',')}`
|
|
175
|
+
}
|
|
176
|
+
const generateMonthlyCronExpression = (delay: string, date: Date): string => {
|
|
177
|
+
if (!date) return
|
|
178
|
+
|
|
179
|
+
const minutes = date.getMinutes()
|
|
180
|
+
const hours = date.getHours()
|
|
181
|
+
const day = date.getDate()
|
|
182
|
+
const month = date.getMonth() + 1
|
|
183
|
+
|
|
184
|
+
// Генерируем cron-выражение
|
|
185
|
+
return `${minutes} ${hours} ${day} ${month}/${delay} *`
|
|
186
|
+
}
|
|
168
187
|
|
|
169
188
|
const generateCronExpression = (
|
|
170
189
|
runType: UI_T_FrequencyType,
|
|
@@ -175,8 +194,9 @@ const generateCronExpression = (
|
|
|
175
194
|
// Генерируем cron-выражение на основе runType
|
|
176
195
|
switch (runType) {
|
|
177
196
|
case 'once':
|
|
178
|
-
|
|
179
|
-
|
|
197
|
+
cronExpression = generateOnceCronExpression(
|
|
198
|
+
new Date(interval.frg_on_time)
|
|
199
|
+
)
|
|
180
200
|
break
|
|
181
201
|
case 'after-startup':
|
|
182
202
|
const delay =
|
|
@@ -186,22 +206,28 @@ const generateCronExpression = (
|
|
|
186
206
|
cronExpression = `${delay} * * * * after_procurator_startup` // Выполняется каждые N минут после запуска procurator_startup
|
|
187
207
|
break
|
|
188
208
|
case 'hour':
|
|
189
|
-
const hourlyDelay =
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
209
|
+
const hourlyDelay = interval.frg_interval
|
|
210
|
+
cronExpression = generateHourlyCronExpression(
|
|
211
|
+
hourlyDelay,
|
|
212
|
+
new Date(interval.frg_start_on_time)
|
|
213
|
+
)
|
|
193
214
|
break
|
|
194
215
|
case 'day':
|
|
195
|
-
const
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
216
|
+
const dayDelay = interval.frg_interval
|
|
217
|
+
cronExpression = generateDaylyCronExpression(
|
|
218
|
+
dayDelay,
|
|
219
|
+
new Date(interval.frg_start_on_time)
|
|
220
|
+
)
|
|
199
221
|
break
|
|
200
222
|
case 'week':
|
|
201
|
-
cronExpression =
|
|
223
|
+
cronExpression = generateWeeklyCronExpression(interval)
|
|
202
224
|
break
|
|
203
225
|
case 'month':
|
|
204
|
-
|
|
226
|
+
const monthDelay = interval.frg_interval
|
|
227
|
+
cronExpression = generateMonthlyCronExpression(
|
|
228
|
+
monthDelay,
|
|
229
|
+
new Date(interval.frg_start_on_time)
|
|
230
|
+
)
|
|
205
231
|
break
|
|
206
232
|
default:
|
|
207
233
|
cronExpression = '* * * * *'
|