Skip to content

Commit 06e759a

Browse files
committed
fix: chatUser authorization
1 parent 3eb5a49 commit 06e759a

File tree

1 file changed

+37
-22
lines changed

1 file changed

+37
-22
lines changed

ui/src/views/chat-user/index.vue

Lines changed: 37 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,14 @@
133133
row.source === 'LOCAL'
134134
? $t('views.userManage.source.local')
135135
: row.source === 'wecom'
136-
? $t('views.userManage.source.wecom')
137-
: row.source === 'lark'
138-
? $t('views.userManage.source.lark')
139-
: row.source === 'dingtalk'
140-
? $t('views.userManage.source.dingtalk')
141-
: row.source === 'OAUTH2' || row.source === 'OAuth2'
142-
? 'OAuth2'
143-
: row.source
136+
? $t('views.userManage.source.wecom')
137+
: row.source === 'lark'
138+
? $t('views.userManage.source.lark')
139+
: row.source === 'dingtalk'
140+
? $t('views.userManage.source.dingtalk')
141+
: row.source === 'OAUTH2' || row.source === 'OAuth2'
142+
? 'OAuth2'
143+
: row.source
144144
}}
145145
</template>
146146
</el-table-column>
@@ -267,7 +267,11 @@ watch(filterText, (val: string) => {
267267
filterList.value = filter(list.value, val)
268268
})
269269
270+
const checkedMap = reactive<Record<string, boolean>>({}) // 选中的
271+
270272
function clickUserGroup(item: ChatUserGroupItem) {
273+
// 清空跨组勾选缓存
274+
for (const key in checkedMap) delete checkedMap[key]
271275
current.value = item
272276
}
273277
@@ -317,6 +321,14 @@ async function getList() {
317321
searchForm.value.name,
318322
rightLoading,
319323
)
324+
// 更新缓存和回显状态
325+
res.data.records.forEach((item: any) => {
326+
if (checkedMap[item.id] === undefined) {
327+
checkedMap[item.id] = item.is_auth
328+
}
329+
item.is_auth = checkedMap[item.id]
330+
})
331+
320332
tableData.value = res.data.records
321333
paginationConfig.total = res.data.total
322334
} catch (error) {
@@ -329,36 +341,39 @@ function handleSizeChange() {
329341
getList()
330342
}
331343
332-
watch(
333-
() => current.value?.id,
334-
() => {
335-
getList()
336-
},
337-
)
344+
watch(() => current.value?.id, () => {
345+
paginationConfig.current_page = 1
346+
getList()
347+
})
338348
339-
const allChecked = computed(
340-
() =>
341-
tableData.value.length > 0 &&
342-
tableData.value.every((item: ChatUserGroupUserItem) => item.is_auth),
349+
const allChecked = computed(() =>
350+
tableData.value.length > 0 &&
351+
tableData.value.every(item => checkedMap[item.id])
343352
)
344353
345-
const allIndeterminate = computed(
346-
() => !allChecked.value && tableData.value.some((item: ChatUserGroupUserItem) => item.is_auth),
354+
const allIndeterminate = computed(() =>
355+
!allChecked.value &&
356+
tableData.value.some(item => checkedMap[item.id])
347357
)
348358
349359
const handleCheckAll = (checked: boolean) => {
350-
tableData.value.forEach((item: ChatUserGroupUserItem) => {
360+
tableData.value.forEach(item => {
351361
item.is_auth = checked
362+
checkedMap[item.id] = checked
352363
})
353364
}
354365
355366
const handleRowChange = (value: boolean, row: ChatUserGroupUserItem) => {
356367
row.is_auth = value
368+
checkedMap[row.id] = value
357369
}
358370
359371
async function handleSave() {
360372
try {
361-
const params = tableData.value.map((item) => ({ chat_user_id: item.id, is_auth: item.is_auth }))
373+
const params = Object.entries(checkedMap).map(([id, is_auth]) => ({
374+
chat_user_id: id,
375+
is_auth,
376+
}))
362377
await loadSharedApi({
363378
type: 'chatUser',
364379
systemType: apiType.value,

0 commit comments

Comments
 (0)