fix: table defaultChecked not work
parent
695f4bbbb3
commit
0879463995
|
@ -11,7 +11,7 @@ export default {
|
||||||
props: SelectionBoxProps,
|
props: SelectionBoxProps,
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
sChecked: this.getCheckState(this.$props),
|
checked: this.getCheckState(this.$props),
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -28,8 +28,8 @@ export default {
|
||||||
subscribe () {
|
subscribe () {
|
||||||
const { store } = this
|
const { store } = this
|
||||||
this.unsubscribe = store.subscribe(() => {
|
this.unsubscribe = store.subscribe(() => {
|
||||||
const sChecked = this.getCheckState(this.$props)
|
const checked = this.getCheckState(this.$props)
|
||||||
this.setState({ sChecked })
|
this.setState({ checked })
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -48,7 +48,7 @@ export default {
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
const { type, rowIndex, ...rest } = getOptionProps(this)
|
const { type, rowIndex, ...rest } = getOptionProps(this)
|
||||||
const { sChecked: checked, $attrs, $listeners } = this
|
const { checked, $attrs, $listeners } = this
|
||||||
const checkboxProps = {
|
const checkboxProps = {
|
||||||
props: {
|
props: {
|
||||||
checked,
|
checked,
|
||||||
|
|
|
@ -60,7 +60,7 @@ export default {
|
||||||
if (type === 'every' || type === 'some') {
|
if (type === 'every' || type === 'some') {
|
||||||
return (
|
return (
|
||||||
byDefaultChecked
|
byDefaultChecked
|
||||||
? data[type]((item, i) => getCheckboxPropsByItem(item, i).defaultChecked)
|
? data[type]((item, i) => getCheckboxPropsByItem(item, i).props.defaultChecked)
|
||||||
: data[type]((item, i) =>
|
: data[type]((item, i) =>
|
||||||
store.getState().selectedRowKeys.indexOf(getRecordKey(item, i)) >= 0)
|
store.getState().selectedRowKeys.indexOf(getRecordKey(item, i)) >= 0)
|
||||||
)
|
)
|
||||||
|
|
|
@ -150,13 +150,14 @@ export default {
|
||||||
getCheckboxPropsByItem (item, index) {
|
getCheckboxPropsByItem (item, index) {
|
||||||
const { rowSelection = {}} = this
|
const { rowSelection = {}} = this
|
||||||
if (!rowSelection.getCheckboxProps) {
|
if (!rowSelection.getCheckboxProps) {
|
||||||
return {}
|
return { props: {}}
|
||||||
}
|
}
|
||||||
const key = this.getRecordKey(item, index)
|
const key = this.getRecordKey(item, index)
|
||||||
// Cache checkboxProps
|
// Cache checkboxProps
|
||||||
if (!this.CheckboxPropsCache[key]) {
|
if (!this.CheckboxPropsCache[key]) {
|
||||||
this.CheckboxPropsCache[key] = rowSelection.getCheckboxProps(item)
|
this.CheckboxPropsCache[key] = rowSelection.getCheckboxProps(item)
|
||||||
}
|
}
|
||||||
|
this.CheckboxPropsCache[key].props = this.CheckboxPropsCache[key].props || {}
|
||||||
return this.CheckboxPropsCache[key]
|
return this.CheckboxPropsCache[key]
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -166,7 +167,7 @@ export default {
|
||||||
return []
|
return []
|
||||||
}
|
}
|
||||||
return this.getFlatData()
|
return this.getFlatData()
|
||||||
.filter((item, rowIndex) => this.getCheckboxPropsByItem(item, rowIndex).defaultChecked)
|
.filter((item, rowIndex) => this.getCheckboxPropsByItem(item, rowIndex).props.defaultChecked)
|
||||||
.map((record, rowIndex) => this.getRecordKey(record, rowIndex))
|
.map((record, rowIndex) => this.getRecordKey(record, rowIndex))
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -449,7 +450,7 @@ export default {
|
||||||
const defaultSelection = this.store.getState().selectionDirty ? [] : this.getDefaultSelection()
|
const defaultSelection = this.store.getState().selectionDirty ? [] : this.getDefaultSelection()
|
||||||
const selectedRowKeys = this.store.getState().selectedRowKeys.concat(defaultSelection)
|
const selectedRowKeys = this.store.getState().selectedRowKeys.concat(defaultSelection)
|
||||||
const changeableRowKeys = data
|
const changeableRowKeys = data
|
||||||
.filter((item, i) => !this.getCheckboxPropsByItem(item, i).disabled)
|
.filter((item, i) => !this.getCheckboxPropsByItem(item, i).props.disabled)
|
||||||
.map((item, i) => this.getRecordKey(item, i))
|
.map((item, i) => this.getRecordKey(item, i))
|
||||||
|
|
||||||
const changeRowKeys = []
|
const changeRowKeys = []
|
||||||
|
@ -595,7 +596,7 @@ export default {
|
||||||
if (rowSelection) {
|
if (rowSelection) {
|
||||||
const data = this.getFlatCurrentPageData().filter((item, index) => {
|
const data = this.getFlatCurrentPageData().filter((item, index) => {
|
||||||
if (rowSelection.getCheckboxProps) {
|
if (rowSelection.getCheckboxProps) {
|
||||||
return !this.getCheckboxPropsByItem(item, index).disabled
|
return !this.getCheckboxPropsByItem(item, index).props.disabled
|
||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
})
|
})
|
||||||
|
@ -610,7 +611,7 @@ export default {
|
||||||
width: rowSelection.columnWidth,
|
width: rowSelection.columnWidth,
|
||||||
}
|
}
|
||||||
if (rowSelection.type !== 'radio') {
|
if (rowSelection.type !== 'radio') {
|
||||||
const checkboxAllDisabled = data.every((item, index) => this.getCheckboxPropsByItem(item, index).disabled)
|
const checkboxAllDisabled = data.every((item, index) => this.getCheckboxPropsByItem(item, index).props.disabled)
|
||||||
selectionColumn.title = (
|
selectionColumn.title = (
|
||||||
<SelectionCheckboxAll
|
<SelectionCheckboxAll
|
||||||
store={this.store}
|
store={this.store}
|
||||||
|
|
|
@ -174,8 +174,6 @@ export const SelectionBoxProps = {
|
||||||
name: PropTypes.string,
|
name: PropTypes.string,
|
||||||
disabled: PropTypes.bool,
|
disabled: PropTypes.bool,
|
||||||
id: PropTypes.string,
|
id: PropTypes.string,
|
||||||
defaultChecked: PropTypes.bool,
|
|
||||||
checked: PropTypes.bool,
|
|
||||||
// onChange: React.ChangeEventHandler<HTMLInputElement>;
|
// onChange: React.ChangeEventHandler<HTMLInputElement>;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue