bfg-common 1.5.895 → 1.5.896
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/newTaskForm/New.vue +126 -0
- package/components/common/pages/scheduledTasks/modals/common/newTaskForm/TaskForm.vue +101 -0
- package/components/common/pages/scheduledTasks/table/Table.vue +12 -4
- package/components/common/pages/scheduledTasks/table/new/New.vue +7 -8
- package/package.json +1 -1
- /package/components/common/pages/scheduledTasks/modals/common/newTaskForm/{NewTaskForm.vue → Old.vue} +0 -0
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<form class="form" @submit.prevent>
|
|
3
|
+
<section>
|
|
4
|
+
<div class="form__target">
|
|
5
|
+
{{ localization.common.target }}
|
|
6
|
+
</div>
|
|
7
|
+
</section>
|
|
8
|
+
</form>
|
|
9
|
+
</template>
|
|
10
|
+
|
|
11
|
+
<script lang="ts" setup>
|
|
12
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
13
|
+
import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
|
|
14
|
+
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
15
|
+
import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
|
|
16
|
+
import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
|
|
17
|
+
import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
|
|
18
|
+
import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
|
|
19
|
+
|
|
20
|
+
const props = defineProps<{
|
|
21
|
+
target: string
|
|
22
|
+
}>()
|
|
23
|
+
const model = defineModel<UI_I_ScheduleNewTasksForm>({ required: true })
|
|
24
|
+
|
|
25
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
26
|
+
|
|
27
|
+
const initValidationFields = ref<UI_I_InitialValidationFields>({
|
|
28
|
+
taskName: false,
|
|
29
|
+
})
|
|
30
|
+
const onInitValidation = (types: string[]): void => {
|
|
31
|
+
types.forEach((type) => (initValidationFields.value[type] = true))
|
|
32
|
+
}
|
|
33
|
+
const userNameErrorText = computed<string>(() => {
|
|
34
|
+
if (!initValidationFields.value.taskName) return ''
|
|
35
|
+
|
|
36
|
+
model.value.task_name = model.value.task_name.replace(/^\s+/, '')
|
|
37
|
+
|
|
38
|
+
return !model.value.task_name ? localization.value.common.fieldRequired : ''
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
|
|
42
|
+
frequencyMethodFunc(localization.value)
|
|
43
|
+
)
|
|
44
|
+
|
|
45
|
+
watch(
|
|
46
|
+
model,
|
|
47
|
+
(newValue: UI_I_ScheduleNewTasksForm) => {
|
|
48
|
+
newValue.cron = generateCronExpression(newValue.frequency, newValue)
|
|
49
|
+
},
|
|
50
|
+
{ deep: true }
|
|
51
|
+
)
|
|
52
|
+
|
|
53
|
+
const generateCronExpression = (
|
|
54
|
+
runType: UI_T_FrequencyType,
|
|
55
|
+
interval: UI_I_ScheduleNewTasksForm
|
|
56
|
+
): string => {
|
|
57
|
+
let cronExpression
|
|
58
|
+
|
|
59
|
+
// Генерируем cron-выражение на основе runType
|
|
60
|
+
switch (runType) {
|
|
61
|
+
case 'once':
|
|
62
|
+
const timestamp = Math.floor(
|
|
63
|
+
new Date(interval.frg_on_time).getTime() / 1000
|
|
64
|
+
)
|
|
65
|
+
cronExpression = `* * * * * ${timestamp}:0-0-0-0:once`
|
|
66
|
+
break
|
|
67
|
+
case 'after-startup':
|
|
68
|
+
const suffixDelay =
|
|
69
|
+
interval.frg_after_startup === 0 ? '' : `-${interval.frg_after_startup}`
|
|
70
|
+
cronExpression = `* * * * * after_procurator_startup${suffixDelay}` // Выполняется после запуска procurator_startup с задержой N минут
|
|
71
|
+
break
|
|
72
|
+
case 'hour':
|
|
73
|
+
cronExpression = cron.generateHourlyCronExpression(interval)
|
|
74
|
+
break
|
|
75
|
+
case 'day':
|
|
76
|
+
cronExpression = cron.generateDailyCronExpression(interval)
|
|
77
|
+
break
|
|
78
|
+
case 'week':
|
|
79
|
+
cronExpression = cron.generateWeeklyCronExpression(interval)
|
|
80
|
+
break
|
|
81
|
+
case 'month':
|
|
82
|
+
cronExpression = cron.generateMonthlyCronExpression(interval)
|
|
83
|
+
break
|
|
84
|
+
default:
|
|
85
|
+
cronExpression = '* * * * *'
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return cronExpression
|
|
89
|
+
}
|
|
90
|
+
</script>
|
|
91
|
+
|
|
92
|
+
<style lang="scss" scoped>
|
|
93
|
+
.form {
|
|
94
|
+
&__target {
|
|
95
|
+
background-color: var(--info-block-bg);
|
|
96
|
+
border-radius: 8px;
|
|
97
|
+
padding: 12px;
|
|
98
|
+
& > p {
|
|
99
|
+
font-family: 'Inter', sans-serif;
|
|
100
|
+
color: #9da6ad; // for light and dark theme
|
|
101
|
+
font-weight: 400;
|
|
102
|
+
font-size: 13px;
|
|
103
|
+
line-height: 18px;
|
|
104
|
+
margin-bottom: 8px;
|
|
105
|
+
}
|
|
106
|
+
.icon {
|
|
107
|
+
min-width: 20px;
|
|
108
|
+
width: 20px;
|
|
109
|
+
height: 20px;
|
|
110
|
+
margin-right: 6px;
|
|
111
|
+
}
|
|
112
|
+
.text {
|
|
113
|
+
font-family: 'Inter', sans-serif;
|
|
114
|
+
color: var(--title-form-first-color);
|
|
115
|
+
font-weight: 400;
|
|
116
|
+
font-size: 13px;
|
|
117
|
+
line-height: 18px;
|
|
118
|
+
word-break: break-word;
|
|
119
|
+
|
|
120
|
+
.highlight {
|
|
121
|
+
color: var(--text-red);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
</style>
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<component
|
|
3
|
+
:is="currentComponent"
|
|
4
|
+
v-model="scheduledTaskFormModel"
|
|
5
|
+
:target="props.target"
|
|
6
|
+
/>
|
|
7
|
+
</template>
|
|
8
|
+
|
|
9
|
+
<script lang="ts" setup>
|
|
10
|
+
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
11
|
+
import type { UI_I_SelectInputItem } from '~/components/common/select/input/lib/models/interfaces'
|
|
12
|
+
import type { UI_I_ScheduleNewTasksForm } from '~/components/common/pages/scheduledTasks/modals/lib/models/interfaces'
|
|
13
|
+
import type { UI_I_InitialValidationFields } from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/models/interfaces'
|
|
14
|
+
import type { UI_T_FrequencyType } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/models/types'
|
|
15
|
+
import * as cron from '~/components/common/pages/scheduledTasks/modals/common/newTaskForm/lib/utils'
|
|
16
|
+
import { frequencyMethodFunc } from '~/components/common/pages/scheduledTasks/modals/common/frequency/lib/config/frequencyOptions'
|
|
17
|
+
|
|
18
|
+
const scheduledTaskFormModel = defineModel<UI_I_ScheduleNewTasksForm>({
|
|
19
|
+
required: true,
|
|
20
|
+
})
|
|
21
|
+
const props = defineProps<{
|
|
22
|
+
target: string
|
|
23
|
+
}>()
|
|
24
|
+
|
|
25
|
+
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
26
|
+
const { $store }: any = useNuxtApp()
|
|
27
|
+
|
|
28
|
+
const isNewView = computed<boolean>(() => $store.getters['main/getIsNewView'])
|
|
29
|
+
const currentComponent = computed(() =>
|
|
30
|
+
isNewView.value
|
|
31
|
+
? defineAsyncComponent(() => import('./New.vue'))
|
|
32
|
+
: defineAsyncComponent(() => import('./Old.vue'))
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
const initValidationFields = ref<UI_I_InitialValidationFields>({
|
|
36
|
+
taskName: false,
|
|
37
|
+
})
|
|
38
|
+
const onInitValidation = (types: string[]): void => {
|
|
39
|
+
types.forEach((type) => (initValidationFields.value[type] = true))
|
|
40
|
+
}
|
|
41
|
+
const userNameErrorText = computed<string>(() => {
|
|
42
|
+
if (!initValidationFields.value.taskName) return ''
|
|
43
|
+
|
|
44
|
+
scheduledTaskFormModel.value.task_name =
|
|
45
|
+
scheduledTaskFormModel.value.task_name.replace(/^\s+/, '')
|
|
46
|
+
|
|
47
|
+
return !scheduledTaskFormModel.value.task_name
|
|
48
|
+
? localization.value.common.fieldRequired
|
|
49
|
+
: ''
|
|
50
|
+
})
|
|
51
|
+
|
|
52
|
+
const frequencyMethodOptions = computed<UI_I_SelectInputItem[]>(() =>
|
|
53
|
+
frequencyMethodFunc(localization.value)
|
|
54
|
+
)
|
|
55
|
+
|
|
56
|
+
watch(
|
|
57
|
+
scheduledTaskFormModel,
|
|
58
|
+
(newValue: UI_I_ScheduleNewTasksForm) => {
|
|
59
|
+
newValue.cron = generateCronExpression(newValue.frequency, newValue)
|
|
60
|
+
},
|
|
61
|
+
{ deep: true }
|
|
62
|
+
)
|
|
63
|
+
|
|
64
|
+
const generateCronExpression = (
|
|
65
|
+
runType: UI_T_FrequencyType,
|
|
66
|
+
interval: UI_I_ScheduleNewTasksForm
|
|
67
|
+
): string => {
|
|
68
|
+
let cronExpression
|
|
69
|
+
|
|
70
|
+
// Генерируем cron-выражение на основе runType
|
|
71
|
+
switch (runType) {
|
|
72
|
+
case 'once':
|
|
73
|
+
const timestamp = Math.floor(
|
|
74
|
+
new Date(interval.frg_on_time).getTime() / 1000
|
|
75
|
+
)
|
|
76
|
+
cronExpression = `* * * * * ${timestamp}:0-0-0-0:once`
|
|
77
|
+
break
|
|
78
|
+
case 'after-startup':
|
|
79
|
+
const suffixDelay =
|
|
80
|
+
interval.frg_after_startup === 0 ? '' : `-${interval.frg_after_startup}`
|
|
81
|
+
cronExpression = `* * * * * after_procurator_startup${suffixDelay}` // Выполняется после запуска procurator_startup с задержой N минут
|
|
82
|
+
break
|
|
83
|
+
case 'hour':
|
|
84
|
+
cronExpression = cron.generateHourlyCronExpression(interval)
|
|
85
|
+
break
|
|
86
|
+
case 'day':
|
|
87
|
+
cronExpression = cron.generateDailyCronExpression(interval)
|
|
88
|
+
break
|
|
89
|
+
case 'week':
|
|
90
|
+
cronExpression = cron.generateWeeklyCronExpression(interval)
|
|
91
|
+
break
|
|
92
|
+
case 'month':
|
|
93
|
+
cronExpression = cron.generateMonthlyCronExpression(interval)
|
|
94
|
+
break
|
|
95
|
+
default:
|
|
96
|
+
cronExpression = '* * * * *'
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return cronExpression
|
|
100
|
+
}
|
|
101
|
+
</script>
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
<template>
|
|
2
|
+
<!-- Аргументы (:selected-scheduler) используется только для нового интерфейса -->
|
|
2
3
|
<component
|
|
3
4
|
:is="currentComponent"
|
|
4
5
|
v-model="selectedScheduledTaskLocal"
|
|
5
6
|
:table-items="props.schedulerData?.items || []"
|
|
6
7
|
:total-items="props.schedulerData?.total_items || 0"
|
|
7
8
|
:total-pages="props.schedulerData?.total_pages || 1"
|
|
9
|
+
:selected-scheduler="props.selectedScheduler"
|
|
8
10
|
:is-loading="props.isLoading"
|
|
9
11
|
/>
|
|
10
12
|
</template>
|
|
@@ -14,10 +16,16 @@ import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
|
14
16
|
import type { UI_I_ScheduledTasks } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
|
|
15
17
|
|
|
16
18
|
const selectedScheduledTaskLocal = defineModel<string | null>()
|
|
17
|
-
const props =
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
19
|
+
const props = withDefaults(
|
|
20
|
+
defineProps<{
|
|
21
|
+
schedulerData: UI_I_ScheduledTasks
|
|
22
|
+
selectedScheduler?: UI_I_ScheduledTasks['items'][number] // используется только в новом виде
|
|
23
|
+
isLoading: boolean
|
|
24
|
+
}>(),
|
|
25
|
+
{
|
|
26
|
+
selectedScheduler: undefined,
|
|
27
|
+
}
|
|
28
|
+
)
|
|
21
29
|
|
|
22
30
|
const localization = computed<UI_I_Localization>(() => useLocal())
|
|
23
31
|
const { $store }: any = useNuxtApp()
|
|
@@ -14,11 +14,10 @@
|
|
|
14
14
|
@select-row="onSelectRow"
|
|
15
15
|
>
|
|
16
16
|
<template #insteadOfTitleActions>
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
<!-- />-->
|
|
17
|
+
<templates-inventory-vm-configure-scheduled-tasks-tools-panel
|
|
18
|
+
:selected-task="selectedScheduledTaskLocal"
|
|
19
|
+
:selected-task-from-table="props.selectedScheduler"
|
|
20
|
+
/>
|
|
22
21
|
</template>
|
|
23
22
|
|
|
24
23
|
<template #icon="{ item }">
|
|
@@ -133,7 +132,7 @@ import type {
|
|
|
133
132
|
import type { UI_T_ArbitraryObject } from '~/node_modules/bfg-uikit/models/types'
|
|
134
133
|
import type { UI_I_TableTarget } from '~/lib/models/table/interfaces'
|
|
135
134
|
import type { UI_I_Localization } from '~/lib/models/interfaces'
|
|
136
|
-
import type {
|
|
135
|
+
import type { UI_I_ScheduledTasks } from '~/components/common/pages/scheduledTasks/lib/models/interfaces'
|
|
137
136
|
import {
|
|
138
137
|
options,
|
|
139
138
|
getTargetActionsFunc,
|
|
@@ -145,10 +144,10 @@ const selectedScheduledTaskLocal = defineModel<string | null>({
|
|
|
145
144
|
required: true,
|
|
146
145
|
})
|
|
147
146
|
const props = defineProps<{
|
|
148
|
-
tableItems:
|
|
147
|
+
tableItems: UI_I_ScheduledTasks['items']
|
|
149
148
|
totalItems: number
|
|
150
149
|
totalPages: number
|
|
151
|
-
|
|
150
|
+
selectedScheduler: UI_I_ScheduledTasks['items'][number]
|
|
152
151
|
isLoading: boolean
|
|
153
152
|
}>()
|
|
154
153
|
const emits = defineEmits<{
|
package/package.json
CHANGED
|
File without changes
|