-
Notifications
You must be signed in to change notification settings - Fork 261
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(user): add organization preview to user page
- Loading branch information
Showing
7 changed files
with
86 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
44 changes: 44 additions & 0 deletions
44
apps/vue/src/views/identity/user/hooks/useOrganizationUnit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import type { Ref } from 'vue'; | ||
import { computed, ref, onMounted, watchEffect } from 'vue'; | ||
import { getAll as getAllOrganizationUnits } from '/@/api/identity/organization-units'; | ||
import { OrganizationUnit } from '/@/api/identity/organization-units/model'; | ||
import { getOrganizationUnits } from '/@/api/identity/users'; | ||
import { listToTree } from '/@/utils/helper/treeHelper'; | ||
|
||
interface UseOrganizationUnit { | ||
userRef: Ref<Recordable | undefined>; | ||
} | ||
|
||
export function useOrganizationUnit({ userRef }: UseOrganizationUnit) { | ||
const organizationUnits = ref<OrganizationUnit[]>([]); | ||
const hasInOrganizationUnitKeys = ref<string[]>([]); | ||
|
||
const getOrganizationUnitsTree = computed(() => { | ||
const ouTree = listToTree(organizationUnits.value, { | ||
id: 'id', | ||
pid: 'parentId', | ||
children: 'children', | ||
}); | ||
return ouTree; | ||
}); | ||
|
||
async function fetchOrganizationUnits() { | ||
const { items } = await getAllOrganizationUnits(); | ||
organizationUnits.value = items; | ||
} | ||
|
||
async function fetchUserOrganizationUnits(userId: string) { | ||
const { items } = await getOrganizationUnits(userId); | ||
hasInOrganizationUnitKeys.value = items.map((item) => item.code); | ||
} | ||
|
||
onMounted(fetchOrganizationUnits); | ||
watchEffect(() => { | ||
userRef.value?.id && fetchUserOrganizationUnits(userRef.value.id); | ||
}); | ||
|
||
return { | ||
getOrganizationUnitsTree, | ||
hasInOrganizationUnitKeys, | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
<TargetFramework>net8.0</TargetFramework> <!-- 或其他适合的框架 --> | ||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild> | ||
<PackageId>LINGYUN.Abp.MicroService.Templates</PackageId> | ||
<Version>8.1.1.1</Version> | ||
<Version>8.1.3</Version> | ||
<Authors>[email protected]</Authors> | ||
<Description>Abp framework micro-service template</Description> | ||
<PackageLicenseExpression>MIT</PackageLicenseExpression> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters