128
128
</tr >
129
129
</template >
130
130
<tr
131
- v-if =" internalBusyFlag "
131
+ v-if =" busyBoolean "
132
132
class =" b-table-busy-slot"
133
133
:class =" {'b-table-static-busy': computedItems.length === 0}"
134
134
>
@@ -207,6 +207,7 @@ import type {
207
207
import BTableSimple from ' ./BTableSimple.vue'
208
208
import {filterEvent } from ' ./helpers/filter-event'
209
209
import useItemHelper from ' ./itemHelper'
210
+ import {useVModel } from ' @vueuse/core'
210
211
211
212
type NoProviderTypes = ' paging' | ' sorting' | ' filtering'
212
213
@@ -318,23 +319,26 @@ const emit = defineEmits<{
318
319
' filtered' : [value : TableItem []]
319
320
}>()
320
321
322
+ const sortByModel = useVModel (props , ' sortBy' , emit )
323
+ const busyModel = useVModel (props , ' busy' , emit , {passive: true })
324
+ const sortDescModel = useVModel (props , ' sortDesc' , emit , {passive: true })
325
+
321
326
const slots = useSlots ()
322
327
323
328
const itemHelper = useItemHelper ()
324
329
325
330
const footCloneBoolean = useBooleanish (() => props .footClone )
326
- const sortDescBoolean = useBooleanish (() => props . sortDesc )
331
+ const sortDescBoolean = useBooleanish (sortDescModel )
327
332
const sortInternalBoolean = useBooleanish (() => props .sortInternal )
328
333
const selectableBoolean = useBooleanish (() => props .selectable )
329
334
const stickySelectBoolean = useBooleanish (() => props .stickySelect )
330
335
const labelStackedBoolean = useBooleanish (() => props .labelStacked )
331
- const busyBoolean = useBooleanish (() => props . busy )
336
+ const busyBoolean = useBooleanish (busyModel )
332
337
const showEmptyBoolean = useBooleanish (() => props .showEmpty )
333
338
const noProviderPagingBoolean = useBooleanish (() => props .noProviderPaging )
334
339
const noProviderSortingBoolean = useBooleanish (() => props .noProviderSorting )
335
340
const noProviderFilteringBoolean = useBooleanish (() => props .noProviderFiltering )
336
341
337
- const internalBusyFlag = ref (busyBoolean .value )
338
342
itemHelper .filterEvent .value = async (items ) => {
339
343
if (usesProvider .value ) {
340
344
await callItemsProvider ()
@@ -352,7 +356,7 @@ const tableClasses = computed(() => ({
352
356
' b-table-selectable' : selectableBoolean .value ,
353
357
[` b-table-select-${props .selectMode } ` ]: selectableBoolean .value ,
354
358
' b-table-selecting user-select-none' : selectableBoolean .value && isSelecting .value ,
355
- ' b-table-busy' : internalBusyFlag .value ,
359
+ ' b-table-busy' : busyBoolean .value ,
356
360
' b-table-sortable' : isSortable .value ,
357
361
' b-table-sort-desc' : isSortable .value && sortDescBoolean .value === true ,
358
362
' b-table-sort-asc' : isSortable .value && sortDescBoolean .value === false ,
@@ -452,9 +456,9 @@ const handleFieldSorting = (field: TableField) => {
452
456
if (isSortable .value === true && fieldSortable === true ) {
453
457
const sortDesc = ! sortDescBoolean .value
454
458
if (fieldKey !== props .sortBy ) {
455
- emit ( ' update:sortBy ' , fieldKey )
459
+ sortByModel . value = fieldKey
456
460
}
457
- emit ( ' update:sortDesc ' , sortDesc )
461
+ sortDescModel . value = sortDesc
458
462
emit (' sorted' , fieldKey , sortDesc )
459
463
}
460
464
}
@@ -508,8 +512,8 @@ const handleRowSelection = (
508
512
}
509
513
510
514
const callItemsProvider = async () => {
511
- if (! usesProvider .value || ! props .provider || internalBusyFlag .value ) return
512
- internalBusyFlag .value = true
515
+ if (! usesProvider .value || ! props .provider || busyBoolean .value ) return
516
+ busyModel .value = true
513
517
const context = new Proxy (
514
518
{
515
519
currentPage: props .currentPage ,
@@ -536,8 +540,8 @@ const callItemsProvider = async () => {
536
540
const internalItems = await itemHelper .updateInternalItems (items )
537
541
return internalItems
538
542
} finally {
539
- if (internalBusyFlag .value ) {
540
- internalBusyFlag .value = false
543
+ if (busyBoolean .value ) {
544
+ busyModel .value = false
541
545
}
542
546
}
543
547
}
@@ -546,8 +550,8 @@ const callItemsProvider = async () => {
546
550
const internalItems = await itemHelper .updateInternalItems (response )
547
551
return internalItems
548
552
} finally {
549
- if (internalBusyFlag .value ) {
550
- internalBusyFlag .value = false
553
+ if (busyBoolean .value ) {
554
+ busyModel .value = false
551
555
}
552
556
}
553
557
}
@@ -659,14 +663,6 @@ watch(
659
663
}
660
664
)
661
665
662
- watch (
663
- internalBusyFlag ,
664
- () => internalBusyFlag .value !== busyBoolean .value && emit (' update:busy' , internalBusyFlag .value )
665
- )
666
- watch (
667
- busyBoolean ,
668
- () => internalBusyFlag .value !== busyBoolean .value && (internalBusyFlag .value = busyBoolean .value )
669
- )
670
666
watch (
671
667
() => props .filter ,
672
668
(val , oldVal ) => providerPropsWatch (' filter' , val , oldVal )
0 commit comments