diff --git a/src/pages/07_agencies-management/AgenciesDialog.vue b/src/pages/07_agencies-management/AgenciesDialog.vue index 8e0826a6..3e2d4c77 100644 --- a/src/pages/07_agencies-management/AgenciesDialog.vue +++ b/src/pages/07_agencies-management/AgenciesDialog.vue @@ -199,16 +199,23 @@ watch( @@ -317,9 +324,10 @@ watch( > @@ -354,7 +364,10 @@ watch( }" style="position: absolute; z-index: 999; top: 0; right: 0" > -
+
{ + dialog({ + color: targetStatus !== 'INACTIVE' ? 'warning' : 'info', + icon: + targetStatus !== 'INACTIVE' + ? 'mdi-alert' + : 'mdi-message-processing-outline', + title: t('dialog.title.confirmChangeStatus'), + actionText: + targetStatus !== 'INACTIVE' ? t('general.close') : t('general.open'), + message: + targetStatus !== 'INACTIVE' + ? t('dialog.message.confirmChangeStatusOff') + : t('dialog.message.confirmChangeStatusOn'), + action: async () => { + await changeStatus(targetId).then(resolve).catch(reject); + }, + cancel: () => {}, + }); + }); +} + +async function changeStatus(id?: string) { + const targetId = id || currAgenciesData.value?.id; + if (targetId === undefined) return; + + formData.value.status = + formData.value.status !== 'INACTIVE' ? 'INACTIVE' : 'ACTIVE'; + + const res = await institutionStore.editInstitution({ + id: targetId, + ...formData.value, + }); + if (res) { + formData.value.status = res.status; + if (currAgenciesData.value) { + currAgenciesData.value.status = res.status; + } + await fetchData(); + } +} + onMounted(async () => { navigatorStore.current.title = 'agencies.title'; navigatorStore.current.path = [{ text: 'agencies.caption', i18n: true }]; @@ -540,6 +591,18 @@ watch(
+ +
@@ -606,7 +669,6 @@ watch( " /> @@ -649,6 +712,18 @@ watch(
+ + {{ @@ -677,7 +752,6 @@ watch( " /> @@ -814,6 +889,7 @@ watch( if (v) await submit({ selectedImage: v }); } " + @change-status="triggerChangeStatus" :readonly="!pageState.isDrawerEdit" :isEdit="pageState.isDrawerEdit" v-model="pageState.addModal" diff --git a/src/stores/institution/index.ts b/src/stores/institution/index.ts index 930ebda2..c639f708 100644 --- a/src/stores/institution/index.ts +++ b/src/stores/institution/index.ts @@ -40,7 +40,7 @@ export const useInstitution = defineStore('institution-store', () => { params, }, ) - : await api.get>(`/institution`, { + : await api.get>('/institution', { params, }); @@ -80,6 +80,7 @@ export const useInstitution = defineStore('institution-store', () => { const res = await api.put(`/institution/${data.id}`, { ...data, id: undefined, + group: undefined, }); if (res.status < 400) { return res.data;