Updated flows tree
Deploy Frontend / build-and-deploy (push) Successful in 1m9s
Details
Deploy Frontend / build-and-deploy (push) Successful in 1m9s
Details
This commit is contained in:
parent
9d61e80d92
commit
aa50168138
|
|
@ -29,6 +29,7 @@ import { useUsers } from '@/features/users/hooks/useUsers'
|
||||||
import { useDepartments } from '@/features/departments/hooks/useDepartments'
|
import { useDepartments } from '@/features/departments/hooks/useDepartments'
|
||||||
import { useCategories } from '@/features/categories/hooks/useCategories'
|
import { useCategories } from '@/features/categories/hooks/useCategories'
|
||||||
import { useTopics } from '@/features/topics/hooks/useTopics'
|
import { useTopics } from '@/features/topics/hooks/useTopics'
|
||||||
|
import { useAllSystemOptions } from '@/features/hierarchies/hooks/useSystemOptions' // 👈 ИМПОРТИРОВАЛИ ХУК
|
||||||
import type { ChainGroup } from '@/features/hierarchies/utils'
|
import type { ChainGroup } from '@/features/hierarchies/utils'
|
||||||
|
|
||||||
interface ChainDuplicateModalProps {
|
interface ChainDuplicateModalProps {
|
||||||
|
|
@ -42,6 +43,7 @@ type ScopeType = 'global' | 'category' | 'topic'
|
||||||
interface StepForm {
|
interface StepForm {
|
||||||
approver_id: number | null
|
approver_id: number | null
|
||||||
priority: number
|
priority: number
|
||||||
|
target_system: string | null // 👈 ДОБАВИЛИ ПОЛЕ В ИНТЕРФЕЙС
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function ChainDuplicateModal({
|
export default function ChainDuplicateModal({
|
||||||
|
|
@ -54,9 +56,9 @@ export default function ChainDuplicateModal({
|
||||||
const { data: departments } = useDepartments()
|
const { data: departments } = useDepartments()
|
||||||
const { data: categories } = useCategories({ limit: 1000 })
|
const { data: categories } = useCategories({ limit: 1000 })
|
||||||
|
|
||||||
// Полный список тем без фильтра — нужен, чтобы восстановить
|
// Подтягиваем доступные системы
|
||||||
// topic_category_id по topic_id, когда scopeType === 'topic'
|
const { options: systemOptions } = useAllSystemOptions()
|
||||||
// (см. useEffect ниже — та же логика, что в HierarchyEditModal).
|
|
||||||
const { data: allTopics } = useTopics({ limit: 1000 })
|
const { data: allTopics } = useTopics({ limit: 1000 })
|
||||||
|
|
||||||
const form = useForm({
|
const form = useForm({
|
||||||
|
|
@ -97,11 +99,6 @@ export default function ChainDuplicateModal({
|
||||||
...(form.values.topic_category_id && { category_id: form.values.topic_category_id }),
|
...(form.values.topic_category_id && { category_id: form.values.topic_category_id }),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Заполняем форму данными из цепочки
|
|
||||||
// 🩹 ФИКС: раньше при scopeType === 'topic' в topic_category_id
|
|
||||||
// подставлялся group.scopeObjectId — а это ID ТЕМЫ, не категории (мусор
|
|
||||||
// в поле категории). Теперь категория корректно достаётся через
|
|
||||||
// allTopics по topic_id — та же логика, что уже чинили в HierarchyEditModal.
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (group && opened) {
|
if (group && opened) {
|
||||||
let resolvedCategoryId: number | null = null
|
let resolvedCategoryId: number | null = null
|
||||||
|
|
@ -121,6 +118,7 @@ export default function ChainDuplicateModal({
|
||||||
steps: group.steps.map((s, idx) => ({
|
steps: group.steps.map((s, idx) => ({
|
||||||
approver_id: s.approver_id || null,
|
approver_id: s.approver_id || null,
|
||||||
priority: idx,
|
priority: idx,
|
||||||
|
target_system: s.target_system || null, // 👈 ИНИЦИАЛИЗИРУЕМ ИЗ БД
|
||||||
})),
|
})),
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -141,12 +139,12 @@ export default function ChainDuplicateModal({
|
||||||
form.insertListItem('steps', {
|
form.insertListItem('steps', {
|
||||||
approver_id: null,
|
approver_id: null,
|
||||||
priority: form.values.steps.length,
|
priority: form.values.steps.length,
|
||||||
|
target_system: null, // 👈 ИНИЦИАЛИЗИРУЕМ ДЛЯ НОВОГО ШАГА
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeStep = (index: number) => {
|
const removeStep = (index: number) => {
|
||||||
form.removeListItem('steps', index)
|
form.removeListItem('steps', index)
|
||||||
// Пересчитываем priority
|
|
||||||
form.values.steps.forEach((_, idx) => {
|
form.values.steps.forEach((_, idx) => {
|
||||||
form.setFieldValue(`steps.${idx}.priority`, idx)
|
form.setFieldValue(`steps.${idx}.priority`, idx)
|
||||||
})
|
})
|
||||||
|
|
@ -187,13 +185,13 @@ export default function ChainDuplicateModal({
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Создаём все записи последовательно
|
|
||||||
for (const step of values.steps) {
|
for (const step of values.steps) {
|
||||||
await createHierarchy.mutateAsync({
|
await createHierarchy.mutateAsync({
|
||||||
subordinate_id: values.subordinate_id!,
|
subordinate_id: values.subordinate_id!,
|
||||||
approver_id: step.approver_id!,
|
approver_id: step.approver_id!,
|
||||||
department_id: values.department_id!,
|
department_id: values.department_id!,
|
||||||
priority: step.priority,
|
priority: step.priority,
|
||||||
|
target_system: step.target_system || null, // 👈 ОТПРАВЛЯЕМ СИСТЕМУ
|
||||||
topic_category_id:
|
topic_category_id:
|
||||||
values.scope_type === 'global'
|
values.scope_type === 'global'
|
||||||
? null
|
? null
|
||||||
|
|
@ -431,20 +429,39 @@ export default function ChainDuplicateModal({
|
||||||
</Badge>
|
</Badge>
|
||||||
</Group>
|
</Group>
|
||||||
|
|
||||||
<Select
|
<Group grow gap="xs">
|
||||||
placeholder="Выберите согласующего"
|
<Select
|
||||||
data={userOptions}
|
placeholder="Выберите согласующего"
|
||||||
value={step.approver_id ? String(step.approver_id) : null}
|
data={userOptions}
|
||||||
onChange={(v) =>
|
value={step.approver_id ? String(step.approver_id) : null}
|
||||||
form.setFieldValue(`steps.${index}.approver_id`, v ? Number(v) : null)
|
onChange={(v) =>
|
||||||
}
|
form.setFieldValue(`steps.${index}.approver_id`, v ? Number(v) : null)
|
||||||
searchable
|
}
|
||||||
error={
|
searchable
|
||||||
Array.isArray(form.errors.steps) && form.errors.steps[index]
|
error={
|
||||||
? (form.errors.steps[index] as any)?.approver_id
|
Array.isArray(form.errors.steps) && form.errors.steps[index]
|
||||||
: undefined
|
? (form.errors.steps[index] as any)?.approver_id
|
||||||
}
|
: undefined
|
||||||
/>
|
}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{/* 👈 ДОБАВЛЕННЫЙ ВЫБОР СИСТЕМЫ */}
|
||||||
|
<Select
|
||||||
|
placeholder="Система: Все (по умолчанию)"
|
||||||
|
data={[
|
||||||
|
{ value: 'all', label: 'Система: Все' },
|
||||||
|
...systemOptions.map((s) => ({ value: s.value, label: `Система: ${s.label}` })),
|
||||||
|
]}
|
||||||
|
value={step.target_system || 'all'}
|
||||||
|
onChange={(v) =>
|
||||||
|
form.setFieldValue(
|
||||||
|
`steps.${index}.target_system`,
|
||||||
|
(v === 'all' || !v) ? null : v
|
||||||
|
)
|
||||||
|
}
|
||||||
|
clearable
|
||||||
|
/>
|
||||||
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<ActionIcon
|
<ActionIcon
|
||||||
|
|
@ -485,6 +502,7 @@ export default function ChainDuplicateModal({
|
||||||
{users?.data?.find(
|
{users?.data?.find(
|
||||||
(u) => u.id === step.approver_id
|
(u) => u.id === step.approver_id
|
||||||
)?.full_name || `Шаг ${index + 1}`}
|
)?.full_name || `Шаг ${index + 1}`}
|
||||||
|
{step.target_system && ` (${step.target_system})`}
|
||||||
</Badge>
|
</Badge>
|
||||||
</Group>
|
</Group>
|
||||||
))}
|
))}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue