Skip to content

Commit

Permalink
fix(comp:table): select all check state isn't displayed correctly (#1936
Browse files Browse the repository at this point in the history
)
  • Loading branch information
sallerli1 authored Jun 11, 2024
1 parent 708f1f7 commit d1fb275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
11 changes: 7 additions & 4 deletions packages/components/table/demo/EditRowValidator.vue
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const createRecordGroup = (record: Data) => {
const nameValidator = (value: string, control: AbstractControl): ValidateErrors | undefined => {
const currentEditKey = control.parent?.get('key')?.getValue()
if(currentEditKey === undefined){
if (currentEditKey === undefined) {
return undefined
}
Expand Down Expand Up @@ -185,7 +185,7 @@ const nameValidator = (value: string, control: AbstractControl): ValidateErrors
const sidValidator = (value: string, control: AbstractControl): ValidateErrors | undefined => {
const gender = control.parent?.get('gender')?.getValue()
if(gender === undefined){
if (gender === undefined) {
return undefined
}
console.log(`value is ${value}`)
Expand Down Expand Up @@ -246,7 +246,10 @@ const onSave = (record: Data) => {
const copyData = [...data.value]
const targetIndex = copyData.findIndex(item => item.key === record.key)
copyData.splice(targetIndex, 1, {...formValue, key: formValue.key.startsWith(addKeyPrefix) ? uniqueId('ADDED') : formValue.key})
copyData.splice(targetIndex, 1, {
...formValue,
key: formValue.key.startsWith(addKeyPrefix) ? uniqueId('ADDED') : formValue.key,
})
data.value = copyData
success(`${formValue.name} saved successfully`)
formGroup.removeControl(record.key as never)
Expand Down Expand Up @@ -316,7 +319,7 @@ const onSaveAll = () => {
const result = newItem ? newItem : item
return {
...result,
key: result.key.startsWith(addKeyPrefix) ? uniqueId('ADDED') : result.key
key: result.key.startsWith(addKeyPrefix) ? uniqueId('ADDED') : result.key,
}
})
records.forEach(record => formGroup.removeControl(record.key as never))
Expand Down
5 changes: 4 additions & 1 deletion packages/components/table/src/composables/useSelectable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,14 +110,17 @@ export function useSelectable(
}
}

if (!allSelected && !someSelected) {
checked = false
}

return { checked, allSelected, someSelected }
})

// 当前页全选是否被勾选
const currentPageAllSelected = computed(() => currentPageAllSelectState.value.checked)

// 当前页是否部分被选中

const currentPageSomeSelected = computed(
() => !currentPageAllSelectState.value.allSelected && currentPageAllSelectState.value.someSelected,
)
Expand Down

0 comments on commit d1fb275

Please sign in to comment.