@@ -121,6 +121,7 @@ import Close from '@/assets/svg/icon_close_outlined_w.svg'
121121import Search from ' @/assets/svg/icon_search-outline_outlined.svg'
122122import type { CheckboxValueType } from ' element-plus-secondary'
123123import type { FilterNodeMethodFunction } from ' element-plus-secondary'
124+ import { cloneDeep } from ' lodash-es'
124125const checkAll = ref (false )
125126const existingUser = ref (false )
126127const isIndeterminate = ref (false )
@@ -134,7 +135,7 @@ const defaultProps = {
134135 children: ' children' ,
135136 label: ' name' ,
136137}
137-
138+ let rawTree : any = []
138139const organizationUserList = ref <any []>([])
139140const loading = ref (false )
140141const centerDialogVisible = ref (false )
@@ -146,9 +147,23 @@ const workspaceWithKeywords = computed(() => {
146147 )
147148})
148149
149- watch (search , (val ) => {
150- organizationUserRef .value ! .filter (val )
150+ const dfsTree = (arr : any ) => {
151+ return arr .filter ((ele : any ) => {
152+ if (ele .children ?.length ) {
153+ ele .children = dfsTree (ele .children )
154+ }
155+ if (
156+ (ele .name .toLowerCase () as string ).includes (search .value .toLowerCase ()) ||
157+ ele .children ?.length
158+ ) {
159+ return true
160+ }
161+ return false
162+ })
163+ }
151164
165+ watch (search , () => {
166+ organizationUserList .value = dfsTree (cloneDeep (rawTree ))
152167 nextTick (() => {
153168 organizationUserRef .value .setCheckedKeys (checkTableList .value .map ((ele : any ) => ele .id ))
154169 })
@@ -164,23 +179,16 @@ function isLeafNode(node: any) {
164179}
165180
166181const handleCheck = () => {
167- const userList = organizationUserRef .value .getCheckedNodes ()
182+ const userList = [ ... organizationUserRef .value .getCheckedNodes (), ... checkTableList . value ]
168183 let idArr = [... new Set (userList .map ((ele : any ) => ele .id ))]
169184
170- checkTableList .value = userList
171- .filter ((ele : any ) => {
172- if (idArr .includes (ele .id ) && isLeafNode (ele )) {
173- idArr = idArr .filter ((itx : any ) => itx !== ele .id )
174- return true
175- }
176- return false
177- })
178- .map ((ele : any ) => ({
179- name: ele .name ,
180- id: ele .id ,
181- account: ele .id ,
182- email: ele .options .email ,
183- }))
185+ checkTableList .value = userList .filter ((ele : any ) => {
186+ if (idArr .includes (ele .id ) && isLeafNode (ele )) {
187+ idArr = idArr .filter ((itx : any ) => itx !== ele .id )
188+ return true
189+ }
190+ return false
191+ })
184192}
185193
186194const handleCheckedWorkspaceChange = (value : CheckboxValueType []) => {
@@ -210,6 +218,7 @@ const open = async (id: any, title: any) => {
210218 const loadingInstance = ElLoading .service ({ fullscreen: true })
211219 const systemWorkspaceList = await modelApi .platform (id )
212220 organizationUserList .value = systemWorkspaceList .tree || []
221+ rawTree = cloneDeep (systemWorkspaceList .tree )
213222 loadingInstance ?.close ()
214223 loading .value = false
215224 centerDialogVisible .value = true
@@ -221,7 +230,7 @@ const handleConfirm = () => {
221230 user_list: checkTableList .value .map ((ele : any ) => ({
222231 id: ele .id ,
223232 name: ele .name ,
224- email: ele .email || ' ' ,
233+ email: ele .options . email || ' ' ,
225234 })),
226235 origin: oid ,
227236 cover: existingUser .value ,
0 commit comments