嵌套表格图标换成箭头、无滚动条时拖拽行报错问题

This commit is contained in:
yangchch6 2019-04-28 15:02:03 +08:00
parent 274ab33ff6
commit d8dfd8de3e
10 changed files with 113 additions and 120 deletions

View File

@ -365,6 +365,13 @@ let dataSource = [
class Demo0501 extends Component {
constructor(props, context) {
super(props);
this.state = {
dataSource: dataSource,
editingRowsMap: {},
currentIndex: null,
errorEditFlag: false
};
this.columns = [
{
title: "员工编号",
@ -421,13 +428,6 @@ class Demo0501 extends Component {
}
];
this.state = {
dataSource: dataSource,
editingRowsMap: {},
currentIndex: null,
errorEditFlag: false
};
this.originData = {};
}
@ -448,6 +448,15 @@ class Demo0501 extends Component {
this.setState({ editingRowsMap, dataSource });
};
delete = index => () => {
if (index === null) return;
let { dataSource } = this.state;
dataSource.splice(index,1);
this.setState({
dataSource:dataSource
});
}
commitChange = index => () => {
if (this.state.errorEditFlag) return;
let editingRowsMap = { ...this.state.editingRowsMap };
@ -487,6 +496,9 @@ class Demo0501 extends Component {
<Button colors="dark" onClick={this.edit(currentIndex)}>
编辑
</Button>
<Button colors="dark" onClick={this.delete(currentIndex)}>
删除
</Button>
</div>
);
};

View File

@ -11,28 +11,11 @@ import {Button,Tooltip} from "tinper-bee";
import Table from "../../src";
const columns = [
{
title: "员工编号", dataIndex: "a", key: "a", width: 120, className: "rowClassName",
fixed:'left',
render: (text, record, index) => {
return (
<Tooltip inverse overlay={text}>
<span tootip={text} style={{
display: "block",
width: "80px",
textOverflow: "ellipsis",
overflow: "hidden",
whiteSpace: "nowrap",
verticalAlign: "middle",
}}>{text}</span>
</Tooltip>
);
}
},
{ title: "员工编号", dataIndex: "a", key: "a", width: 150 },
{ title: "员工姓名", dataIndex: "b", key: "b", width:200 },
{ title: "性别", dataIndex: "c", key: "c", width: 500 },
{ title: "部门", dataIndex: "d", key: "d", width: 100 },
{ title: "职级", dataIndex: "e", key: "e", width: 100,fixed:'right'}
{ title: "职级", dataIndex: "e", key: "e", width: 100 }
];
const data = [

File diff suppressed because one or more lines are too long

13
dist/demo.css vendored
View File

@ -143,25 +143,22 @@
cursor: pointer;
display: inline-block;
margin-right: 0px;
width: 16px;
height: 16px;
width: 14px;
height: 14px;
text-align: center;
line-height: 14px;
border: 1px solid rgb(193, 199, 208);
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
background: #fff;
margin-right: 10px; }
.u-table-row-expand-icon.uf, .u-table-expanded-row-expand-icon.uf {
font-size: 12px;
padding: 0; }
.u-table-row-spaced, .u-table-expanded-row-spaced {
visibility: hidden; }
.u-table-row-spaced:after, .u-table-expanded-row-spaced:after {
content: "."; }
.u-table-row-expanded:after, .u-table-expanded-row-expanded:after {
content: "-"; }
.u-table-row-collapsed:after, .u-table-expanded-row-collapsed:after {
content: "+"; }
.u-table-row.selected {
background: #FFF7E7; }
.u-table tr.u-table-expanded-row {

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

65
dist/demo.js vendored

File diff suppressed because one or more lines are too long

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -1,40 +1,42 @@
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import shallowequal from 'shallowequal';
const propTypes = {
record: PropTypes.object,
clsPrefix: PropTypes.string,
expandable: PropTypes.any,
expanded: PropTypes.bool,
needIndentSpaced: PropTypes.bool,
onExpand: PropTypes.func,
};
class ExpandIcon extends Component{
constructor(props){
super(props);
}
shouldComponentUpdate(nextProps) {
return !shallowequal(nextProps, this.props);
}
render() {
const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon } = this.props;
if (expandable && !isHiddenExpandIcon) {
const expandClassName = expanded ? 'expanded' : 'collapsed';
return (
<span
className={`${clsPrefix}-expand-icon ${clsPrefix}-${expandClassName}`}
onClick={(e) => onExpand(!expanded, record, e)}
/>
);
} else if (needIndentSpaced || isHiddenExpandIcon) {
return <span className={`${clsPrefix}-expand-icon ${clsPrefix}-spaced`} />;
}
return null;
}
};
ExpandIcon.propTypes = propTypes;
export default ExpandIcon;
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import shallowequal from 'shallowequal';
import Icon from 'bee-icon';
const propTypes = {
record: PropTypes.object,
clsPrefix: PropTypes.string,
expandable: PropTypes.any,
expanded: PropTypes.bool,
needIndentSpaced: PropTypes.bool,
onExpand: PropTypes.func,
};
class ExpandIcon extends Component{
constructor(props){
super(props);
}
shouldComponentUpdate(nextProps) {
return !shallowequal(nextProps, this.props);
}
render() {
const { expandable, clsPrefix, onExpand, needIndentSpaced, expanded, record, isHiddenExpandIcon } = this.props;
if (expandable && !isHiddenExpandIcon) {
const expandClassName = expanded ? 'expanded' : 'collapsed';
return (
<Icon
className={`${clsPrefix}-expand-icon ${clsPrefix}-${expandClassName}`}
type={expanded ? 'uf-triangle-down' : 'uf-triangle-right'}
onClick={(e) => onExpand(!expanded, record, e)}
/>
);
} else if (needIndentSpaced || isHiddenExpandIcon) {
return <span className={`${clsPrefix}-expand-icon ${clsPrefix}-spaced`} />;
}
return null;
}
};
ExpandIcon.propTypes = propTypes;
export default ExpandIcon;

View File

@ -267,14 +267,16 @@ $icon-color:#505F79;
cursor: pointer;
display: inline-block;
margin-right: 0px;
width: 16px;
height: 16px;
width: 14px;
height: 14px;
text-align: center;
line-height: 14px;
border: 1px solid $table-border-color;
user-select: none;
background: #fff;
margin-right: 10px;
&.uf{
font-size: 12px;
padding: 0;
}
}
&-spaced {
visibility: hidden;
@ -282,14 +284,6 @@ $icon-color:#505F79;
&-spaced:after {
content: ".";
}
&-expanded:after {
content: "-";
}
&-collapsed:after {
content: "+";
}
}
&-row{
&.selected{

View File

@ -199,6 +199,8 @@ class TableRow extends Component{
let _table_trs = contentTable.querySelector('.u-table-scroll table tbody'),
_table_fixed_left_trs = contentTable.querySelector('.u-table-fixed-left table tbody'),
_table_fixed_right_trs = contentTable.querySelector('.u-table-fixed-right table tbody');
_table_trs = _table_trs?_table_trs:contentTable.querySelector('.u-table table tbody');
this.synchronizeTrStyle(_table_trs,currentIndex,type);
if(_table_fixed_left_trs){