diff --git a/components/desktop/src/features/Branch/SelectBranch/ui/SelectBranchOverlay.vue b/components/desktop/src/features/Branch/SelectBranch/ui/SelectBranchOverlay.vue index 7277cc7b48e..d5000699f0b 100644 --- a/components/desktop/src/features/Branch/SelectBranch/ui/SelectBranchOverlay.vue +++ b/components/desktop/src/features/Branch/SelectBranch/ui/SelectBranchOverlay.vue @@ -13,11 +13,14 @@ BaseDialog( div(v-if="step === 1") p.q-mt-lg | Кооператив перешёл на двухэтапную систему управления на основании общего собрания уполномоченных председателей кооперативных участков... + Loader(v-if="branchesLoading" text="Загружаем список кооперативных участков...") Form( + v-else :handler-submit="next" :is-submitting="isSubmitting" :showSubmit="!isLoading" :showCancel="false" + :disabled="!selectedBranch" :button-submit-txt="'Продолжить'" ) BranchSelector( @@ -53,6 +56,7 @@ BaseDialog( document, isSubmitting, isLoading, + branchesLoading, next, back, sign diff --git a/components/desktop/src/processes/select-branch/index.ts b/components/desktop/src/processes/select-branch/index.ts index 56dd4a02430..e90a79133c9 100644 --- a/components/desktop/src/processes/select-branch/index.ts +++ b/components/desktop/src/processes/select-branch/index.ts @@ -20,21 +20,45 @@ export function useSelectBranchProcess() { const system = useSystemStore() const session = useSessionStore() const branchStore = useBranchStore() - const { selectBranch } = useSelectBranch() + const { isVisible, selectBranch } = useSelectBranch() const branches = computed(() => branchStore.publicBranches) + const branchesLoading = ref(false) - // Вотчер на авторизацию + const loadBranches = async () => { + if (!session.isAuth || !system.info.coopname) return + + try { + branchesLoading.value = true + await branchStore.loadPublicBranches({ coopname: system.info.coopname }) + } catch (e: unknown) { + FailAlert(e) + } finally { + branchesLoading.value = false + } + } + + // Загрузка при входе watch( () => session.isAuth, (isAuth, wasAuth) => { if (isAuth && !wasAuth) { - branchStore.loadPublicBranches({ coopname: system.info.coopname }) + void loadBranches() } }, { immediate: true } ) + // Перезагрузка при переходе в мажоритарный режим или показе оверлея + watch( + [() => isVisible.value, () => system.info?.cooperator_account?.is_branched], + ([visible, branched]) => { + if (visible && branched && session.isAuth) { + void loadBranches() + } + } + ) + const next = async () => { isLoading.value = true document.value = await digitalDocument.generate({ @@ -80,6 +104,7 @@ export function useSelectBranchProcess() { document, isSubmitting, isLoading, + branchesLoading, next, back, sign,