119119 </template >
120120 </el-table-column >
121121 </app-table >
122+ <!-- 单个资源授权提示框 -->
123+ <el-dialog
124+ v-model =" singleSelectDialogVisible"
125+ :title =" $t('views.system.resourceAuthorization.setting.configure')"
126+ destroy-on-close
127+ @close =" closeSingleSelectDialog"
128+ >
129+ <el-radio-group v-model =" authAllChildren" class =" radio-block" >
130+ <el-radio :value =" false" >
131+ <p class =" color-text-primary lighter" >{{ $t('views.system.resourceAuthorization.setting.currentOnly') }}</p >
132+ </el-radio >
133+ <el-radio :value =" true" >
134+ <p class =" color-text-primary lighter" >{{ $t('views.system.resourceAuthorization.setting.includeAll') }}</p >
135+ </el-radio >
136+ </el-radio-group >
137+ <template #footer >
138+ <div class =" dialog-footer mt-24" >
139+ <el-button @click =" closeSingleSelectDialog" >{{ $t('common.cancel') }}</el-button >
140+ <el-button type =" primary" @click =" confirmSinglePermission" >{{ $t('common.confirm') }}</el-button >
141+ </div >
142+ </template >
143+ </el-dialog >
122144
123145 <!-- 批量配置 弹出层 -->
124146 <el-dialog
128150 @close =" closeDialog"
129151 >
130152 <el-radio-group v-model =" radioPermission" class =" radio-block" >
131- <template v-for =" (item , index ) in permissionOptions " :key =" index " >
153+ <template v-for =" (item , index ) in getFolderPermissionOptions () " :key =" index " >
132154 <el-radio :value =" item.value" class =" mr-16" >
133155 <p class =" color-text-primary lighter" >{{ item.label }}</p >
134156 <el-text class =" color-secondary lighter" >{{ item.desc }}</el-text >
135157 </el-radio >
136158 </template >
137159 </el-radio-group >
160+ <!-- 如果是文件夹,显示子资源选项 -->
161+ <div v-if =" isFolder" class =" mt-16" >
162+ <el-divider />
163+ <div class =" color-text-primary mb-8" >{{ $t('views.system.resourceAuthorization.setting.effectiveResource') }}</div >
164+ <el-radio-group v-model =" batchAuthAllChildren" class =" radio-block" >
165+ <el-radio :value =" false" >
166+ <p class =" color-text-primary lighter" >{{ $t('views.system.resourceAuthorization.setting.currentOnly') }}</p >
167+ </el-radio >
168+ <el-radio :value =" true" >
169+ <p class =" color-text-primary lighter" >{{ $t('views.system.resourceAuthorization.setting.includeAll') }}</p >
170+ </el-radio >
171+ </el-radio-group >
172+ </div >
138173 <template #footer >
139174 <div class =" dialog-footer mt-24" >
140175 <el-button @click =" closeDialog" > {{ $t('common.cancel') }}</el-button >
@@ -151,9 +186,11 @@ import { getPermissionOptions } from '@/views/system/resource-authorization/cons
151186import AuthorizationApi from ' @/api/system/resource-authorization'
152187import { MsgSuccess , MsgConfirm } from ' @/utils/message'
153188import { t } from ' @/locales'
189+ import permissionMap from ' @/permission'
154190import { loadSharedApi } from ' @/utils/dynamics-api/shared-api'
155191const route = useRoute ()
156192import useStore from ' @/stores'
193+
157194const { user } = useStore ()
158195const props = defineProps <{
159196 type: string
@@ -169,6 +206,57 @@ const apiType = computed(() => {
169206 }
170207})
171208
209+ const folderType = computed (() => {
210+ if (route .path .includes (' application' )) {
211+ return ' application'
212+ }
213+ else if (route .path .includes (' knowledge' )) {
214+ return ' knowledge'
215+ }
216+ else if (route .path .includes (' tool' )) {
217+ return ' tool'
218+ }
219+ else {return ' application' }
220+ })
221+
222+ const permissionPrecise = computed (() => {
223+ return permissionMap [folderType .value ! ][' workspace' ]
224+ })
225+
226+ // 取出文件夹id
227+ function getAllFolderIds(data : any ) {
228+ if (! data ) return []
229+ return [data .id ,... (data .children ?.flatMap ((child : any ) => getAllFolderIds (child )) || [])]
230+ }
231+
232+ // 过滤没有Manage权限的文件夹ID
233+ function filterHasPermissionFolderIds(folderIds : string []) {
234+ return folderIds .filter (id => permissionPrecise .value .folderManage (id ))
235+ }
236+
237+ function confirmSinglePermission() {
238+ if (! pendingPermissionChange .value ) return
239+ const { val, row } = pendingPermissionChange .value
240+ let folderIds: string [] = []
241+ if (authAllChildren .value && folderData .value ) {
242+ const allFolderIds = getAllFolderIds (folderData .value )
243+ folderIds = filterHasPermissionFolderIds (allFolderIds )
244+ }
245+ const obj = [
246+ {
247+ user_id: row .id ,
248+ permission: val ,
249+ include_children: authAllChildren .value ,
250+ ... (folderIds .length > 0 && {folder_ids: folderIds })
251+ },
252+ ]
253+ submitPermissions (obj )
254+ singleSelectDialogVisible .value = false
255+ authAllChildren .value = false
256+ pendingPermissionChange .value = null
257+ getPermissionList ()
258+ }
259+
172260const permissionOptionMap = computed (() => {
173261 return {
174262 rootFolder: getPermissionOptions (true , true ),
@@ -207,6 +295,7 @@ watch(drawerVisible, (bool) => {
207295
208296const loading = ref (false )
209297const targetId = ref (' ' )
298+ const folderData = ref <any >(null )
210299const permissionData = ref <any []>([])
211300const searchType = ref (' nick_name' )
212301const searchForm = ref <any >({
@@ -241,32 +330,59 @@ const handleSelectionChange = (val: any[]) => {
241330}
242331
243332const dialogVisible = ref (false )
333+ const singleSelectDialogVisible = ref (false )
334+ const pendingPermissionChange = ref <{ val: any ; row: any ; } | null >(null )
244335const radioPermission = ref (' ' )
336+ const authAllChildren = ref (false )
245337function openMulConfigureDialog() {
246338 if (multipleSelection .value .length === 0 ) {
247339 return
248340 }
249341 dialogVisible .value = true
250342}
343+
344+ const batchAuthAllChildren = ref (false )
251345function submitDialog() {
252346 if (multipleSelection .value .length === 0 || ! radioPermission .value ) {
253347 return
254348 }
349+ let folderIds: string [] = []
350+ if (props .isFolder && batchAuthAllChildren .value && folderData .value ) {
351+ const allFolderIds = getAllFolderIds (folderData .value )
352+ folderIds = filterHasPermissionFolderIds (allFolderIds )
353+ }
354+
255355 const obj = multipleSelection .value .map ((item ) => ({
256356 user_id: item .id ,
257357 permission: radioPermission .value ,
358+ include_children: batchAuthAllChildren .value ,
359+ ... (folderIds .length > 0 && { folder_ids: folderIds })
258360 }))
259361 submitPermissions (obj )
260362 closeDialog ()
261363}
364+
365+ function closeSingleSelectDialog() {
366+ singleSelectDialogVisible .value = false
367+ authAllChildren .value = false
368+ pendingPermissionChange .value = null
369+ getPermissionList ()
370+ }
371+
262372function closeDialog() {
263373 dialogVisible .value = false
264374 radioPermission .value = ' '
375+ batchAuthAllChildren .value = false
265376 multipleSelection .value = []
266377 multipleTableRef .value ?.clearSelection ()
267378}
268379
269380function permissionsHandle(val : any , row : any ) {
381+ if (props .isFolder ) {
382+ singleSelectDialogVisible .value = true
383+ pendingPermissionChange .value = {val , row }
384+ return
385+ }
270386 const obj = [
271387 {
272388 user_id: row .id ,
@@ -276,7 +392,7 @@ function permissionsHandle(val: any, row: any) {
276392 submitPermissions (obj )
277393}
278394
279- function submitPermissions(obj : any ) {
395+ function submitPermissions( obj : any ) {
280396 const workspaceId = user .getWorkspaceId () || ' default'
281397 loadSharedApi ({ type: ' resourceAuthorization' , systemType: apiType .value })
282398 .putResourceAuthorization (workspaceId , targetId .value , props .type , obj , loading )
@@ -311,8 +427,9 @@ const getPermissionList = () => {
311427 })
312428}
313429
314- const open = (id : string ) => {
430+ const open = (id : string , folder_data ? : any ) => {
315431 targetId .value = id
432+ folderData .value = folder_data
316433 drawerVisible .value = true
317434 getPermissionList ()
318435}
0 commit comments