Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion frontend/src/api/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export const userApi = {
add: (data: any) => request.post('/user', data),
edit: (data: any) => request.put('/user', data),
clearErrorApi: (key: string) => request.get(`/user/clearErrorRecord/${key}`),
errorRecord: (key: string) => request.get(`/user/errorRecord/${key}`),
errorRecord: (key: string) => request.get(`/user/errorRecord/${key}`, { responseType: 'blob' }),
delete: (key: string) => request.delete(`/user/${key}`),
deleteBatch: (data: any) => request.delete(`/user`, { data }),
get: (key: string) => request.get(`/user/${key}`),
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/zh-CN.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"Details": "详情"
},
"sync": {
"integration": "Platform integration needs to be enabled.",
"integration": "需开启平台对接",
"the_existing_user": "若用户已存在,覆盖旧用户",
"sync_users": "同步用户",
"sync_wechat_users": "同步企业微信用户",
Expand Down
47 changes: 28 additions & 19 deletions frontend/src/views/system/user/SyncUserDing.vue
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ import Close from '@/assets/svg/icon_close_outlined_w.svg'
import Search from '@/assets/svg/icon_search-outline_outlined.svg'
import type { CheckboxValueType } from 'element-plus-secondary'
import type { FilterNodeMethodFunction } from 'element-plus-secondary'
import { cloneDeep } from 'lodash-es'
const checkAll = ref(false)
const existingUser = ref(false)
const isIndeterminate = ref(false)
Expand All @@ -134,7 +135,7 @@ const defaultProps = {
children: 'children',
label: 'name',
}

let rawTree: any = []
const organizationUserList = ref<any[]>([])
const loading = ref(false)
const centerDialogVisible = ref(false)
Expand All @@ -146,9 +147,23 @@ const workspaceWithKeywords = computed(() => {
)
})

watch(search, (val) => {
organizationUserRef.value!.filter(val)
const dfsTree = (arr: any) => {
return arr.filter((ele: any) => {
if (ele.children?.length) {
ele.children = dfsTree(ele.children)
}
if (
(ele.name.toLowerCase() as string).includes(search.value.toLowerCase()) ||
ele.children?.length
) {
return true
}
return false
})
}

watch(search, () => {
organizationUserList.value = dfsTree(cloneDeep(rawTree))
nextTick(() => {
organizationUserRef.value.setCheckedKeys(checkTableList.value.map((ele: any) => ele.id))
})
Expand All @@ -164,23 +179,16 @@ function isLeafNode(node: any) {
}

const handleCheck = () => {
const userList = organizationUserRef.value.getCheckedNodes()
const userList = [...organizationUserRef.value.getCheckedNodes(), ...checkTableList.value]
let idArr = [...new Set(userList.map((ele: any) => ele.id))]

checkTableList.value = userList
.filter((ele: any) => {
if (idArr.includes(ele.id) && isLeafNode(ele)) {
idArr = idArr.filter((itx: any) => itx !== ele.id)
return true
}
return false
})
.map((ele: any) => ({
name: ele.name,
id: ele.id,
account: ele.id,
email: ele.options.email,
}))
checkTableList.value = userList.filter((ele: any) => {
if (idArr.includes(ele.id) && isLeafNode(ele)) {
idArr = idArr.filter((itx: any) => itx !== ele.id)
return true
}
return false
})
}

const handleCheckedWorkspaceChange = (value: CheckboxValueType[]) => {
Expand Down Expand Up @@ -210,6 +218,7 @@ const open = async (id: any, title: any) => {
const loadingInstance = ElLoading.service({ fullscreen: true })
const systemWorkspaceList = await modelApi.platform(id)
organizationUserList.value = systemWorkspaceList.tree || []
rawTree = cloneDeep(systemWorkspaceList.tree)
loadingInstance?.close()
loading.value = false
centerDialogVisible.value = true
Expand All @@ -221,7 +230,7 @@ const handleConfirm = () => {
user_list: checkTableList.value.map((ele: any) => ({
id: ele.id,
name: ele.name,
email: ele.email || '',
email: ele.options.email || '',
})),
origin: oid,
cover: existingUser.value,
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/views/system/user/User.vue
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
</el-button>

<el-tooltip
v-if="!platformType.length"
v-if="platformType.length"
effect="dark"
:content="$t('sync.integration')"
placement="left"
Expand Down