|
6 | 6 | <div class="resource-authorization__left border-r p-8"> |
7 | 7 | <div class="p-8"> |
8 | 8 | <h4 class="mb-12">{{ $t('views.resourceAuthorization.member') }}</h4> |
9 | | - <el-input |
10 | | - v-model="filterText" |
11 | | - :placeholder="$t('common.search')" |
12 | | - prefix-icon="Search" |
13 | | - clearable |
14 | | - /> |
| 9 | + <el-input v-model="filterText" :placeholder="$t('common.search')" prefix-icon="Search" clearable /> |
15 | 10 | </div> |
16 | 11 | <div class="list-height-left"> |
17 | 12 | <el-scrollbar> |
18 | | - <common-list |
19 | | - :data="filterMember" |
20 | | - class="mt-8" |
21 | | - v-loading="loading" |
22 | | - @click="clickMemberHandle" |
23 | | - :default-active="currentUser" |
24 | | - > |
| 13 | + <common-list :data="filterMember" class="mt-8" v-loading="loading" @click="clickMemberHandle" |
| 14 | + :default-active="currentUser"> |
25 | 15 | <template #default="{ row }"> |
26 | 16 | <div class="flex-between"> |
27 | 17 | <div> |
28 | 18 | <span class="mr-8">{{ row.nick_name }}</span> |
29 | 19 | <el-tag v-if="isManage(row.type)" class="default-tag">{{ |
30 | 20 | $t('views.resourceAuthorization.manage') |
31 | | - }}</el-tag> |
| 21 | + }}</el-tag> |
32 | 22 | </div> |
33 | 23 | </div> |
34 | 24 | </template> |
|
40 | 30 | <div class="resource-authorization__table"> |
41 | 31 | <h4 class="mb-4">{{ $t('views.resourceAuthorization.permissionSetting') }}</h4> |
42 | 32 | <el-tabs v-model="activeName" class="resource-authorization__tabs"> |
43 | | - <el-tab-pane |
44 | | - v-for="(item, index) in settingTags" |
45 | | - :key="item.value" |
46 | | - :label="item.label" |
47 | | - :name="item.value" |
48 | | - > |
49 | | - <PermissionSetting |
50 | | - :key="index" |
51 | | - :data="item.data" |
52 | | - :type="item.value" |
53 | | - :tableHeight="tableHeight" |
54 | | - :manage="isManage(currentType)" |
55 | | - @refreshData="refreshData" |
56 | | - ></PermissionSetting> |
| 33 | + <el-tab-pane v-for="(item, index) in settingTags" :key="item.value" :label="item.label" |
| 34 | + :name="item.value"> |
| 35 | + <PermissionSetting :key="index" :data="item.data" :type="item.value" :tableHeight="tableHeight" |
| 36 | + :manage="isManage(currentType)" @refreshData="refreshData"></PermissionSetting> |
57 | 37 | </el-tab-pane> |
58 | 38 | </el-tabs> |
59 | 39 | </div> |
@@ -116,23 +96,31 @@ function isManage(type: string) { |
116 | 96 | return type === 'manage' |
117 | 97 | } |
118 | 98 |
|
| 99 | +const flotTree = (tree: Array<any>, result: Array<any>) => { |
| 100 | + tree.forEach(tItem => { |
| 101 | + result.push(tItem) |
| 102 | + if (tItem.children) { |
| 103 | + flotTree(tItem.children, result) |
| 104 | + } |
| 105 | + }) |
| 106 | + return result |
| 107 | +} |
119 | 108 | function submitPermissions() { |
120 | | - const obj: any = { |
121 | | - user_resource_permission_list: [], |
122 | | - } |
123 | | - settingTags.map((item: any) => { |
124 | | - item.data.map((v: any) => { |
125 | | - obj['user_resource_permission_list'].push({ |
| 109 | + const user_resource_permission_list = settingTags.map((item: any) => { |
| 110 | + return flotTree(item.data, []).filter((v: any) => !v.isFolder).map((v: any) => { |
| 111 | + return { |
126 | 112 | target_id: v.id, |
127 | | - auth_target_type: v.auth_target_type, |
| 113 | + auth_target_type: item.value, |
128 | 114 | permission: v.permission, |
129 | 115 | auth_type: 'RESOURCE_PERMISSION_GROUP', |
130 | | - }) |
| 116 | + } |
131 | 117 | }) |
132 | | - }) |
133 | | - AuthorizationApi.putResourceAuthorization(currentUser.value, obj, rLoading).then(() => { |
| 118 | + }).reduce((pre, next) => { |
| 119 | + return [...pre, ...next] |
| 120 | + }, []) |
| 121 | + AuthorizationApi.putResourceAuthorization(currentUser.value, { user_resource_permission_list: user_resource_permission_list }, rLoading).then(() => { |
134 | 122 | MsgSuccess(t('common.submitSuccess')) |
135 | | - ResourcePermissions(currentUser.value) |
| 123 | + getWholeTree(currentUser.value) |
136 | 124 | }) |
137 | 125 | } |
138 | 126 |
|
|
0 commit comments