fix: chatUser authorization
This commit is contained in:
parent
3eb5a49e63
commit
06e759a320
@ -133,14 +133,14 @@
|
|||||||
row.source === 'LOCAL'
|
row.source === 'LOCAL'
|
||||||
? $t('views.userManage.source.local')
|
? $t('views.userManage.source.local')
|
||||||
: row.source === 'wecom'
|
: row.source === 'wecom'
|
||||||
? $t('views.userManage.source.wecom')
|
? $t('views.userManage.source.wecom')
|
||||||
: row.source === 'lark'
|
: row.source === 'lark'
|
||||||
? $t('views.userManage.source.lark')
|
? $t('views.userManage.source.lark')
|
||||||
: row.source === 'dingtalk'
|
: row.source === 'dingtalk'
|
||||||
? $t('views.userManage.source.dingtalk')
|
? $t('views.userManage.source.dingtalk')
|
||||||
: row.source === 'OAUTH2' || row.source === 'OAuth2'
|
: row.source === 'OAUTH2' || row.source === 'OAuth2'
|
||||||
? 'OAuth2'
|
? 'OAuth2'
|
||||||
: row.source
|
: row.source
|
||||||
}}
|
}}
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
@ -267,7 +267,11 @@ watch(filterText, (val: string) => {
|
|||||||
filterList.value = filter(list.value, val)
|
filterList.value = filter(list.value, val)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
const checkedMap = reactive<Record<string, boolean>>({}) // 选中的
|
||||||
|
|
||||||
function clickUserGroup(item: ChatUserGroupItem) {
|
function clickUserGroup(item: ChatUserGroupItem) {
|
||||||
|
// 清空跨组勾选缓存
|
||||||
|
for (const key in checkedMap) delete checkedMap[key]
|
||||||
current.value = item
|
current.value = item
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -317,6 +321,14 @@ async function getList() {
|
|||||||
searchForm.value.name,
|
searchForm.value.name,
|
||||||
rightLoading,
|
rightLoading,
|
||||||
)
|
)
|
||||||
|
// 更新缓存和回显状态
|
||||||
|
res.data.records.forEach((item: any) => {
|
||||||
|
if (checkedMap[item.id] === undefined) {
|
||||||
|
checkedMap[item.id] = item.is_auth
|
||||||
|
}
|
||||||
|
item.is_auth = checkedMap[item.id]
|
||||||
|
})
|
||||||
|
|
||||||
tableData.value = res.data.records
|
tableData.value = res.data.records
|
||||||
paginationConfig.total = res.data.total
|
paginationConfig.total = res.data.total
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -329,36 +341,39 @@ function handleSizeChange() {
|
|||||||
getList()
|
getList()
|
||||||
}
|
}
|
||||||
|
|
||||||
watch(
|
watch(() => current.value?.id, () => {
|
||||||
() => current.value?.id,
|
paginationConfig.current_page = 1
|
||||||
() => {
|
getList()
|
||||||
getList()
|
})
|
||||||
},
|
|
||||||
|
const allChecked = computed(() =>
|
||||||
|
tableData.value.length > 0 &&
|
||||||
|
tableData.value.every(item => checkedMap[item.id])
|
||||||
)
|
)
|
||||||
|
|
||||||
const allChecked = computed(
|
const allIndeterminate = computed(() =>
|
||||||
() =>
|
!allChecked.value &&
|
||||||
tableData.value.length > 0 &&
|
tableData.value.some(item => checkedMap[item.id])
|
||||||
tableData.value.every((item: ChatUserGroupUserItem) => item.is_auth),
|
|
||||||
)
|
|
||||||
|
|
||||||
const allIndeterminate = computed(
|
|
||||||
() => !allChecked.value && tableData.value.some((item: ChatUserGroupUserItem) => item.is_auth),
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const handleCheckAll = (checked: boolean) => {
|
const handleCheckAll = (checked: boolean) => {
|
||||||
tableData.value.forEach((item: ChatUserGroupUserItem) => {
|
tableData.value.forEach(item => {
|
||||||
item.is_auth = checked
|
item.is_auth = checked
|
||||||
|
checkedMap[item.id] = checked
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleRowChange = (value: boolean, row: ChatUserGroupUserItem) => {
|
const handleRowChange = (value: boolean, row: ChatUserGroupUserItem) => {
|
||||||
row.is_auth = value
|
row.is_auth = value
|
||||||
|
checkedMap[row.id] = value
|
||||||
}
|
}
|
||||||
|
|
||||||
async function handleSave() {
|
async function handleSave() {
|
||||||
try {
|
try {
|
||||||
const params = tableData.value.map((item) => ({ chat_user_id: item.id, is_auth: item.is_auth }))
|
const params = Object.entries(checkedMap).map(([id, is_auth]) => ({
|
||||||
|
chat_user_id: id,
|
||||||
|
is_auth,
|
||||||
|
}))
|
||||||
await loadSharedApi({
|
await loadSharedApi({
|
||||||
type: 'chatUser',
|
type: 'chatUser',
|
||||||
systemType: apiType.value,
|
systemType: apiType.value,
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user