Browse Source

:bug: 模态选择框单选会选中多个bug

zhanghe 6 years ago
parent
commit
a27cf82372
2 changed files with 10 additions and 10 deletions
  1. 1 1
      package.json
  2. 9 9
      src/components/AXTableSelector/SingleSelectTable.js

+ 1 - 1
package.json

@@ -22,7 +22,7 @@
   "dependencies": {
     "@antv/data-set": "^0.8.0",
     "@babel/polyfill": "^7.0.0-beta.36",
-    "antd": "^3.6.2",
+    "antd": "^3.6.3",
     "babel-runtime": "^6.9.2",
     "bizcharts": "^3.1.3-beta.1",
     "bizcharts-plugin-slider": "^2.0.1",

+ 9 - 9
src/components/AXTableSelector/SingleSelectTable.js

@@ -1,15 +1,9 @@
 import React, { Component } from 'react';
 import PropTypes from 'prop-types';
-import { Table, Radio, Pagination } from 'antd';
+import { Table, Pagination } from 'antd';
 import styles from './SingleSelectTable.less';
 
 export default class SingleSelectTable extends Component {
-  static defaultProps = {
-    loading: false,
-    columns: [],
-    dataSource: [],
-    pagination: false,
-  };
   static propTypes = {
     loading: PropTypes.bool,
     columns: PropTypes.array,
@@ -19,13 +13,19 @@ export default class SingleSelectTable extends Component {
       PropTypes.bool,
     ]),
   };
+  static defaultProps = {
+    loading: false,
+    columns: [],
+    dataSource: [],
+    pagination: false,
+  };
   state = {
     selectedRowKeys: null,
   };
 
   handleRowSelectChange = (record) => {
     this.setState({
-      selectedRowKeys: record.key,
+      selectedRowKeys: [record.key],
     });
     this.props.onSingleTransfer(record);
   };
@@ -40,7 +40,7 @@ export default class SingleSelectTable extends Component {
     const rowSelection = {
       type: 'radio',
       selectedRowKeys,
-      onChange: this.handleRowSelectChange,
+      onChange: (_, rows) => this.handleRowSelectChange(rows[0]),
     };
     const onRowClick = (record) => {
       return {