Skip to content

Commit 7a7d353

Browse files
dataeaseShuliuruibin
authored andcommitted
fix(system): bug fix
1 parent e24a200 commit 7a7d353

File tree

1 file changed

+15
-46
lines changed

1 file changed

+15
-46
lines changed

ui/src/views/system-shared/AuthorizedWorkspaceDialog.vue

Lines changed: 15 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
</template>
77

88
<p class="mb-8 lighter">类型</p>
9-
<el-radio-group v-model="listType" @change="handleListTypeChange">
9+
<el-radio-group v-model="listType">
1010
<el-radio value="WHITE_LIST">白名单</el-radio>
1111
<el-radio value="BLACK_LIST">黑名单</el-radio>
1212
</el-radio-group>
@@ -71,7 +71,7 @@
7171
<AppIcon iconName="app-wordspace"></AppIcon>
7272
<span class="ml-4 lighter">{{ ele.name }}</span>
7373
</div>
74-
<el-button @click="clearWorkspaceAll" link>
74+
<el-button link>
7575
<el-icon @click="clearWorkspace(ele)" :size="18"><Close /></el-icon>
7676
</el-button>
7777
</div>
@@ -90,7 +90,7 @@
9090
import { ref, computed } from 'vue'
9191
import type { CheckboxValueType } from 'element-plus'
9292
import authorizationApi from '@/api/system-shared/authorization'
93-
93+
import workspaceApi from '@/api/workspace/workspace'
9494
const checkAll = ref(false)
9595
const isIndeterminate = ref(true)
9696
const checkedWorkspace = ref([])
@@ -101,60 +101,37 @@ let knowledge_id = ''
101101
let currentType = 'Knowledge'
102102
const loading = ref(false)
103103
const centerDialogVisible = ref(false)
104-
let auth_list: any[] = []
105-
let un_auth_list = []
106104
107105
const workspaceWithKeywords = computed(() => {
108106
return workspace.value.filter((ele: any) => (ele.name as string).includes(search.value))
109107
})
110108
const handleCheckAllChange = (val: CheckboxValueType) => {
111109
checkedWorkspace.value = val ? workspace.value : []
112110
isIndeterminate.value = false
113-
if (val) {
111+
if (!val) {
114112
clearWorkspaceAll()
115-
} else {
116-
auth_list = [
117-
...workspace.value.map((ele) => ({ authentication_type: listType.value, workspace_id: ele })),
118-
...auth_list.filter((ele) => ele.authentication_type !== listType.value),
119-
]
120113
}
121114
}
122115
const handleCheckedWorkspaceChange = (value: CheckboxValueType[]) => {
123116
const checkedCount = value.length
124117
checkAll.value = checkedCount === workspace.value.length
125118
isIndeterminate.value = checkedCount > 0 && checkedCount < workspace.value.length
126-
auth_list = [
127-
...value.map((ele: any) => ({
128-
authentication_type: listType.value,
129-
workspace_id: ele.id,
130-
name: ele.name,
131-
})),
132-
...auth_list.filter((ele) => ele.authentication_type !== listType.value),
133-
]
134119
}
135120
136-
const open = ({ id }: any, type = 'Knowledge') => {
121+
const open = async ({ id }: any, type = 'Knowledge') => {
137122
knowledge_id = id
138-
auth_list = []
139-
un_auth_list = []
140-
listType.value = 'WHITE_LIST'
141123
loading.value = true
142124
currentType = type
143-
authorizationApi[`getSharedAuthorization${type}`](id)
144-
.then((res: any) => {
145-
auth_list = (res.data || {}).auth_list || []
146-
un_auth_list = (res.data || {}).un_auth_list || []
147-
// auth_list 中None表示没选中工作空间, 黑名单中表示所有工作空间都可用,白名单表示所有工作空间都不可用
148-
auth_list = auth_list.filter((ele) => ele.workspace_id !== 'None')
149-
workspace.value = [
150-
...un_auth_list,
151-
...auth_list.map((ele) => ({ id: ele.workspace_id, name: ele.name })),
152-
] as any
153-
handleListTypeChange(listType.value)
154-
})
155-
.finally(() => {
156-
loading.value = false
157-
})
125+
const [authList, systemWorkspaceList] = await Promise.all([
126+
authorizationApi[`getSharedAuthorization${type}`](id),
127+
workspaceApi.getSystemWorkspaceList(),
128+
])
129+
workspace.value = systemWorkspaceList.data as any
130+
listType.value = (authList.data || {}).authentication_type || 'WHITE_LIST'
131+
let workspace_id_list = (authList.data || {}).workspace_id_list || []
132+
checkedWorkspace.value = workspace.value.filter((ele) => workspace_id_list.includes(ele.id))
133+
handleCheckedWorkspaceChange(checkedWorkspace.value)
134+
loading.value = false
158135
centerDialogVisible.value = true
159136
}
160137
@@ -169,21 +146,13 @@ const handleConfirm = () => {
169146
170147
const clearWorkspace = (val: any) => {
171148
checkedWorkspace.value = checkedWorkspace.value.filter((ele: any) => ele.id !== val.id)
172-
auth_list = auth_list.filter((ele) => ele.workspace_id !== val.id)
173149
}
174150
175151
const clearWorkspaceAll = () => {
176152
checkedWorkspace.value = []
177-
auth_list = auth_list.filter((ele) => ele.authentication_type !== listType.value)
178153
handleCheckedWorkspaceChange([])
179154
}
180155
181-
const handleListTypeChange = (val: any) => {
182-
checkedWorkspace.value = auth_list
183-
.filter((ele) => ele.authentication_type === val)
184-
.map((ele) => ({ id: ele.workspace_id, name: ele.name })) as any
185-
handleCheckedWorkspaceChange(checkedWorkspace.value)
186-
}
187156
defineExpose({
188157
open,
189158
})

0 commit comments

Comments
 (0)