1818 </el-input >
1919 <div class =" mt-8 max-height_workspace" >
2020 <el-checkbox
21- v-if =" !search"
2221 v-model =" checkAll"
2322 class =" mb-8"
2423 :indeterminate =" isIndeterminate"
5554 <div class =" p-16 w-full" >
5655 <div class =" flex-between mb-16" >
5756 <span class =" lighter" >
58- {{ $t('workspace.selected_2_people', { msg: checkedWorkspace .length }) }}
57+ {{ $t('workspace.selected_2_people', { msg: checkTableList .length }) }}
5958 </span >
6059
6160 <el-button text @click =" clearWorkspaceAll" >
6261 {{ $t('workspace.clear') }}
6362 </el-button >
6463 </div >
65- <div v-for =" ele in checkedWorkspace " :key =" ele.name" class =" flex-between" >
64+ <div v-for =" ele in checkTableList " :key =" ele.name" class =" flex-between" >
6665 <div class =" flex align-center ellipsis" style =" width : 100% " >
6766 <el-icon size =" 28" >
6867 <avatar _personal ></avatar _personal >
8483</template >
8584
8685<script lang="ts" setup>
87- import { ref , computed } from ' vue'
86+ import { ref , computed , watch } from ' vue'
8887import { workspaceUserList } from ' @/api/workspace'
8988import avatar_personal from ' @/assets/svg/avatar_personal.svg'
9089import Close from ' @/assets/svg/icon_close_outlined_w.svg'
@@ -97,32 +96,63 @@ const workspace = ref<any[]>([])
9796const search = ref (' ' )
9897const loading = ref (false )
9998const centerDialogVisible = ref (false )
99+ const checkTableList = ref ([] as any [])
100100
101101const workspaceWithKeywords = computed (() => {
102102 return workspace .value .filter ((ele : any ) => (ele .name as string ).includes (search .value ))
103103})
104+
105+ watch (search , () => {
106+ const tableNameArr = workspaceWithKeywords .value .map ((ele : any ) => ele .name )
107+ checkedWorkspace .value = checkTableList .value .filter ((ele ) => tableNameArr .includes (ele .name ))
108+ const checkedCount = checkedWorkspace .value .length
109+ checkAll .value = checkedCount === workspaceWithKeywords .value .length
110+ isIndeterminate .value = checkedCount > 0 && checkedCount < workspaceWithKeywords .value .length
111+ })
104112const handleCheckAllChange = (val : CheckboxValueType ) => {
105- checkedWorkspace .value = val ? workspace .value : []
113+ const tableNameArr = workspaceWithKeywords .value .map ((ele : any ) => ele .name )
114+ checkedWorkspace .value = val
115+ ? [
116+ ... new Set ([
117+ ... workspaceWithKeywords .value ,
118+ ... checkedWorkspace .value .filter ((ele ) => ! tableNameArr .includes (ele .name )),
119+ ]),
120+ ]
121+ : []
106122 isIndeterminate .value = false
107- if (! val ) {
108- clearWorkspaceAll ()
109- }
123+ checkTableList .value = val
124+ ? [
125+ ... new Set ([
126+ ... workspaceWithKeywords .value ,
127+ ... checkTableList .value .filter ((ele ) => ! tableNameArr .includes (ele .name )),
128+ ]),
129+ ]
130+ : checkTableList .value .filter ((ele ) => ! tableNameArr .includes (ele .name ))
110131}
111132const handleCheckedWorkspaceChange = (value : CheckboxValueType []) => {
112133 const checkedCount = value .length
113- checkAll .value = checkedCount === workspace .value .length
114- isIndeterminate .value = checkedCount > 0 && checkedCount < workspace .value .length
134+ checkAll .value = checkedCount === workspaceWithKeywords .value .length
135+ isIndeterminate .value = checkedCount > 0 && checkedCount < workspaceWithKeywords .value .length
136+ const tableNameArr = workspaceWithKeywords .value .map ((ele : any ) => ele .name )
137+ checkTableList .value = [
138+ ... new Set ([
139+ ... checkTableList .value .filter ((ele ) => ! tableNameArr .includes (ele .name )),
140+ ... value ,
141+ ]),
142+ ]
115143}
116144
117145const open = async (user : any ) => {
118146 loading .value = true
119147 checkedWorkspace .value = []
120148 checkAll .value = false
149+ checkTableList .value = []
121150 isIndeterminate .value = false
122151 const systemWorkspaceList = await workspaceUserList ({}, 1 , 1000 )
123152 workspace .value = systemWorkspaceList .items as any
124153 if (user ?.length ) {
125154 checkedWorkspace .value = workspace .value .filter ((ele ) => user .includes (ele .id ))
155+ checkTableList .value = [... checkedWorkspace .value ]
126156 handleCheckedWorkspaceChange (checkedWorkspace .value )
127157 }
128158 loading .value = false
0 commit comments