From 0879463995e7e9f2af6ce839ac17b2638dfb784c Mon Sep 17 00:00:00 2001 From: tjz <415800467@qq.com> Date: Fri, 8 Jun 2018 22:30:25 +0800 Subject: [PATCH] fix: table defaultChecked not work --- components/table/SelectionBox.jsx | 8 ++++---- components/table/SelectionCheckboxAll.jsx | 2 +- components/table/Table.jsx | 11 ++++++----- components/table/interface.js | 2 -- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/components/table/SelectionBox.jsx b/components/table/SelectionBox.jsx index df05281a8..b29b85baf 100644 --- a/components/table/SelectionBox.jsx +++ b/components/table/SelectionBox.jsx @@ -11,7 +11,7 @@ export default { props: SelectionBoxProps, data () { return { - sChecked: this.getCheckState(this.$props), + checked: this.getCheckState(this.$props), } }, @@ -28,8 +28,8 @@ export default { subscribe () { const { store } = this this.unsubscribe = store.subscribe(() => { - const sChecked = this.getCheckState(this.$props) - this.setState({ sChecked }) + const checked = this.getCheckState(this.$props) + this.setState({ checked }) }) }, @@ -48,7 +48,7 @@ export default { render () { const { type, rowIndex, ...rest } = getOptionProps(this) - const { sChecked: checked, $attrs, $listeners } = this + const { checked, $attrs, $listeners } = this const checkboxProps = { props: { checked, diff --git a/components/table/SelectionCheckboxAll.jsx b/components/table/SelectionCheckboxAll.jsx index b51582e38..ab638c9bc 100644 --- a/components/table/SelectionCheckboxAll.jsx +++ b/components/table/SelectionCheckboxAll.jsx @@ -60,7 +60,7 @@ export default { if (type === 'every' || type === 'some') { return ( byDefaultChecked - ? data[type]((item, i) => getCheckboxPropsByItem(item, i).defaultChecked) + ? data[type]((item, i) => getCheckboxPropsByItem(item, i).props.defaultChecked) : data[type]((item, i) => store.getState().selectedRowKeys.indexOf(getRecordKey(item, i)) >= 0) ) diff --git a/components/table/Table.jsx b/components/table/Table.jsx index 683a3d28b..1ee0d8d4f 100755 --- a/components/table/Table.jsx +++ b/components/table/Table.jsx @@ -150,13 +150,14 @@ export default { getCheckboxPropsByItem (item, index) { const { rowSelection = {}} = this if (!rowSelection.getCheckboxProps) { - return {} + return { props: {}} } const key = this.getRecordKey(item, index) // Cache checkboxProps if (!this.CheckboxPropsCache[key]) { this.CheckboxPropsCache[key] = rowSelection.getCheckboxProps(item) } + this.CheckboxPropsCache[key].props = this.CheckboxPropsCache[key].props || {} return this.CheckboxPropsCache[key] }, @@ -166,7 +167,7 @@ export default { return [] } 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)) }, @@ -449,7 +450,7 @@ export default { const defaultSelection = this.store.getState().selectionDirty ? [] : this.getDefaultSelection() const selectedRowKeys = this.store.getState().selectedRowKeys.concat(defaultSelection) 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)) const changeRowKeys = [] @@ -595,7 +596,7 @@ export default { if (rowSelection) { const data = this.getFlatCurrentPageData().filter((item, index) => { if (rowSelection.getCheckboxProps) { - return !this.getCheckboxPropsByItem(item, index).disabled + return !this.getCheckboxPropsByItem(item, index).props.disabled } return true }) @@ -610,7 +611,7 @@ export default { width: rowSelection.columnWidth, } 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 = ( ; }