Skip to content

Commit d7a6de1

Browse files
fix: Fixed the issue where resource authorization modifications would automatically fold subfolders
1 parent 1d749a4 commit d7a6de1

File tree

2 files changed

+43
-27
lines changed

2 files changed

+43
-27
lines changed

ui/src/layout/layout-header/avatar/index.vue

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<el-avatar :size="30">
55
<img src="@/assets/user-icon.svg" style="width: 54%" alt=""/>
66
</el-avatar>
7-
<span class="ml-8 color-text-primary">{{ user.userInfo?.username }}</span>
7+
<span class="ml-8 color-text-primary ellipsis" :title="user.userInfo?.nick_name">{{ user.userInfo?.nick_name }}</span>
88
<el-icon class="el-icon--right">
99
<CaretBottom/>
1010
</el-icon>
@@ -19,7 +19,7 @@
1919
</el-avatar>
2020
</div>
2121
<div style="width: 90%">
22-
<p class="bold mb-4" style="font-size: 14px">{{ user.userInfo?.username }}</p>
22+
<p class="bold mb-4" style="font-size: 14px">{{ user.userInfo?.nick_name }}({{ user.userInfo?.username }})</p>
2323
<template v-if="user.userInfo?.role_name && user.userInfo.role_name.length > 0">
2424
<TagGroup
2525
size="small"
@@ -191,13 +191,13 @@ const m:any = {
191191
"工作空间管理员": 'layout.about.inner_wsm',
192192
"普通用户":'layout.about.inner_user'
193193
}
194-
const role_list = computed(() => {
195-
if (!user.userInfo) {
194+
const role_list = computed(() => {
195+
if (!user.userInfo) {
196196
return []
197197
}
198-
return user.userInfo?.role_name?.map(name => {
198+
return user.userInfo?.role_name?.map(name => {
199199
const inner = m[name]
200-
if (inner) {
200+
if (inner) {
201201
return t(inner)
202202
}
203203
return name

ui/src/views/system/resource-authorization/component/PermissionTable.vue

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,8 @@
6060
:maxTableHeight="260"
6161
:row-key="(row: any) => row.id"
6262
style="min-width: 600px"
63-
63+
:expand-row-keys="defaultExpandKeys"
64+
:default-expand-all="searchForm.name || searchForm.permission?.length > 0"
6465
show-overflow-tooltip
6566
>
6667
<el-table-column type="selection" width="55" :reserve-selection="true"> </el-table-column>
@@ -138,7 +139,7 @@
138139
</div>
139140
</template>
140141
<script setup lang="ts">
141-
import { ref, onMounted, computed, nextTick } from 'vue'
142+
import { ref, onMounted, computed, watch } from 'vue'
142143
import { useRoute } from 'vue-router'
143144
import type { Provider } from '@/api/type/model'
144145
import { SourceTypeEnum } from '@/enums/common'
@@ -159,25 +160,40 @@ const props = defineProps<{
159160
}>()
160161
const emit = defineEmits(['submitPermissions'])
161162
162-
const defaultExpandKeys = computed(() => {
163-
const searchName = searchForm.value.name || ''
164-
const searchPermissions = searchForm.value.permission ?? []
165-
if (!searchName && (!searchPermissions || searchPermissions.length === 0)) {
166-
return props.data?.length > 0 ? [props.data[0]?.id] : []
167-
}
168-
const expandIds: string[] = []
169-
// 传入过滤后的数据
170-
const collectExpandIds = (nodes: any[]) => {
171-
nodes.forEach((node) => {
172-
if (node.children && node.children.length > 0) {
173-
expandIds.push(node.id)
174-
collectExpandIds(node.children)
175-
}
176-
})
177-
}
178-
collectExpandIds(filteredData.value)
179-
return expandIds
180-
})
163+
const defaultExpandKeys = ref<Array<string>>([])
164+
const isComputedFirst = ref(true) // 仅第一次获得数据的时候需要计算一次展开属性
165+
166+
watch(
167+
() => props.data,
168+
(newData) => {
169+
if (newData && newData.length > 0 && isComputedFirst.value) {
170+
defaultExpandKeys.value = props.data?.length > 0 ? [props.data[0]?.id] : []
171+
isComputedFirst.value = false
172+
}
173+
},
174+
{ immediate: true },
175+
)
176+
177+
// const defaultExpandKeys = computed(() => {
178+
// const searchName = searchForm.value.name || ''
179+
// const searchPermissions = searchForm.value.permission ?? []
180+
// if (!searchName && (!searchPermissions || searchPermissions.length === 0)) {
181+
// return props.data?.length > 0 ? [props.data[0]?.id] : []
182+
183+
// }
184+
// const expandIds: string[] = []
185+
// // 传入过滤后的数据
186+
// const collectExpandIds = (nodes: any[]) => {
187+
// nodes.forEach((node) => {
188+
// if (node.children && node.children.length > 0) {
189+
// expandIds.push(node.id)
190+
// collectExpandIds(node.children)
191+
// }
192+
// })
193+
// }
194+
// collectExpandIds(filteredData.value)
195+
// return expandIds
196+
// })
181197
182198
const permissionOptionMap = computed(() => {
183199
return {

0 commit comments

Comments
 (0)