11<script lang="ts" setup>
2- import { ref , onMounted , reactive } from ' vue'
2+ import { ref , onMounted , reactive , nextTick } from ' vue'
33import {
44 uwsOption ,
55 workspaceUserList ,
@@ -24,7 +24,7 @@ const workspaceForm = reactive({
2424 name: ' ' ,
2525 id: ' ' ,
2626})
27- const selectable = (row : any ) => ! [userStore .getUid ].includes (row .id )
27+ const selectable = (row : any ) => ! [userStore .getUid ].includes (row .id ) && row . weight !== 1
2828
2929onMounted (() => {
3030 search ()
@@ -90,35 +90,42 @@ const deleteHandler = (row: any) => {
9090 })
9191}
9292const handleSelectionChange = (val : any []) => {
93- const ids = fieldList .value .map ((ele : any ) => ele .id )
93+ if (toggleRowLoading .value ) return
94+ const arr = fieldList .value .filter (selectable )
95+ const ids = arr .map ((ele : any ) => ele .id )
9496 multipleSelectionAll .value = [
9597 ... multipleSelectionAll .value .filter ((ele ) => ! ids .includes (ele .id )),
9698 ... val ,
9799 ]
98- isIndeterminate .value = ! (val .length === 0 || val .length === fieldList . value .length )
99- checkAll .value = val .length === fieldList . value .length
100+ isIndeterminate .value = ! (val .length === 0 || val .length === arr .length )
101+ checkAll .value = val .length === arr .length
100102}
101103const handleCheckAllChange = (val : any ) => {
102104 isIndeterminate .value = false
103- handleSelectionChange (val ? fieldList .value : [])
105+ handleSelectionChange (val ? fieldList .value . filter ( selectable ) : [])
104106 if (val ) {
105107 handleToggleRowSelection ()
106108 } else {
107109 multipleTableRef .value .clearSelection ()
108110 }
109111}
110112
113+ const toggleRowLoading = ref (false )
114+
111115const handleToggleRowSelection = (check : boolean = true ) => {
116+ toggleRowLoading .value = true
117+ const arr = fieldList .value .filter (selectable )
112118 let i = 0
113119 const ids = multipleSelectionAll .value .map ((ele : any ) => ele .id )
114- for (const key in fieldList . value ) {
115- if (ids .includes ((fieldList . value [key ] as any ).id )) {
120+ for (const key in arr ) {
121+ if (ids .includes ((arr [key ] as any ).id )) {
116122 i += 1
117- multipleTableRef .value .toggleRowSelection (fieldList . value [key ], check )
123+ multipleTableRef .value .toggleRowSelection (arr [key ], check )
118124 }
119125 }
120- checkAll .value = i === fieldList .value .length
121- isIndeterminate .value = ! (i === 0 || i === fieldList .value .length )
126+ toggleRowLoading .value = false
127+ checkAll .value = i === arr .length
128+ isIndeterminate .value = ! (i === 0 || i === arr .length )
122129}
123130
124131const search = () => {
@@ -127,8 +134,12 @@ const search = () => {
127134 pageInfo .currentPage ,
128135 pageInfo .pageSize
129136 ).then ((res ) => {
137+ toggleRowLoading .value = true
130138 fieldList .value = res .items
131139 pageInfo .total = res .total
140+ nextTick (() => {
141+ handleToggleRowSelection ()
142+ })
132143 })
133144}
134145
@@ -220,11 +231,10 @@ const handleCurrentChange = (val: number) => {
220231 <el-table
221232 ref =" multipleTableRef"
222233 :data =" fieldList"
223- :selectable =" selectable"
224234 style =" width : 100% "
225235 @selection-change =" handleSelectionChange"
226236 >
227- <el-table-column type =" selection" width =" 55" />
237+ <el-table-column :selectable = " selectable " type =" selection" width =" 55" />
228238 <el-table-column prop =" name" :label =" $t('user.name')" width =" 160" />
229239 <el-table-column prop =" account" :label =" $t('user.account')" width =" 160" />
230240 <el-table-column prop =" status" :label =" $t('user.user_status')" >
@@ -288,7 +298,7 @@ const handleCurrentChange = (val: number) => {
288298 </el-table >
289299 </div >
290300 </div >
291- <div class =" pagination-container" >
301+ <div v-if = " fieldList.length " class =" pagination-container" >
292302 <el-pagination
293303 v-model:current-page =" pageInfo.currentPage"
294304 v-model:page-size =" pageInfo.pageSize"
0 commit comments