fix:querySelector容错处理

This commit is contained in:
yangchch6 2019-07-03 21:12:17 +08:00
parent aa69d8dfed
commit 8cb3aaee37
18 changed files with 364 additions and 90 deletions

View File

@ -218,6 +218,15 @@
color: #1565c0; } color: #1565c0; }
.u-table tr tr a:active { .u-table tr tr a:active {
color: #1565c0; } color: #1565c0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) {
display: flex;
flex-direction: row-reverse; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con {
height: 15px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf {
padding-left: 0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon {
width: 0; }
.u-table tr.tr-row-hover { .u-table tr.tr-row-hover {
background: rgb(235, 236, 240); } background: rgb(235, 236, 240); }
.u-table th, .u-table th,

View File

@ -119,6 +119,9 @@ var TableCell = function (_Component) {
if (typeof text == 'string' && bodyDisplayInRow) { if (typeof text == 'string' && bodyDisplayInRow) {
title = text; title = text;
} }
if (expandIcon && expandIcon.props.expandable) {
className = className + (' ' + clsPrefix + '-has-expandIcon');
}
return _react2["default"].createElement( return _react2["default"].createElement(
'td', 'td',
{ {

View File

@ -307,7 +307,7 @@ var TableHeader = function (_Component) {
if (!currentIndex || parseInt(currentIndex) === _this.drag.currIndex) return; if (!currentIndex || parseInt(currentIndex) === _this.drag.currIndex) return;
if (target.nodeName.toUpperCase() === "TH") { if (target.nodeName.toUpperCase() === "TH") {
// target.style.border = "2px dashed rgba(5,0,0,0.25)"; // target.style.border = "2px dashed rgba(5,0,0,0.25)";
target.setAttribute("style", "border-right:2px dashed rgba(5,0,0,0.25)"); target.setAttribute("style", "border-right:2px dashed rgb(30, 136, 229)");
// target.style.backgroundColor = 'rgb(235, 236, 240)'; // target.style.backgroundColor = 'rgb(235, 236, 240)';
} }
}; };
@ -515,7 +515,7 @@ var TableHeader = function (_Component) {
table.cols = tableDome.getElementsByTagName("col"); table.cols = tableDome.getElementsByTagName("col");
table.ths = tableDome.getElementsByTagName("th"); table.ths = tableDome.getElementsByTagName("th");
table.tr = tableDome.getElementsByTagName("tr"); table.tr = tableDome.getElementsByTagName("tr");
table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col"); table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body') && contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col");
} }
table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header'); table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header');

View File

@ -252,7 +252,7 @@ var TableRow = function (_Component) {
} }
} }
if (type) { if (type) {
currentObj && currentObj.setAttribute("style", "border-bottom:2px dashed rgba(5,0,0,0.25)"); currentObj && currentObj.setAttribute("style", "border-bottom:2px dashed rgb(30, 136, 229)");
} else { } else {
currentObj && currentObj.setAttribute("style", ""); currentObj && currentObj.setAttribute("style", "");
} }

View File

@ -214,6 +214,7 @@ function multiSelect(Table, Checkbox) {
}); });
var _defaultColumns = [{ var _defaultColumns = [{
className: 'u-table-multiSelect-column',
title: _react2["default"].createElement(Checkbox, _extends({ title: _react2["default"].createElement(Checkbox, _extends({
className: "table-checkbox" className: "table-checkbox"
}, checkAttr, { }, checkAttr, {

View File

@ -9,8 +9,7 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Popconfirm,Icon } from 'tinper-bee'; import { Popconfirm,Icon } from 'tinper-bee';
import Table from "../../src"; import Table from "../../src";
import dragColumn from '../../src/lib/dragColumn';
const DragColumnTable = dragColumn(Table);
const columns16 = [ const columns16 = [
{ {
title: "操作", title: "操作",
@ -60,7 +59,6 @@ const data16 = [
{ a: "NU0391003", b: "2019-05-03", c: "zz供应商", d: "操作", key: "3" } { a: "NU0391003", b: "2019-05-03", c: "zz供应商", d: "操作", key: "3" }
]; ];
class Demo16 extends Component { class Demo16 extends Component {
constructor(props){ constructor(props){
super(props); super(props);
@ -111,14 +109,13 @@ class Demo16 extends Component {
} }
render() { render() {
return ( return (
<DragColumnTable <Table
className="expanded-table"
columns={columns16} columns={columns16}
data={data16} data={data16}
onExpand={this.getData} onExpand={this.getData}
expandedRowRender={this.expandedRowRender} expandedRowRender={this.expandedRowRender}
scroll={{x:true}} scroll={{x:true}}
dragborder={true}
draggable={true}
collapsedIcon={<Icon type='uf-anglearrowpointingtoright'/>} collapsedIcon={<Icon type='uf-anglearrowpointingtoright'/>}
expandedIcon={<Icon type='uf-treearrow-down'/>} expandedIcon={<Icon type='uf-treearrow-down'/>}
/> />

View File

@ -0,0 +1,5 @@
.expanded-table{
.expand-icon-con .uf{
font-size: 12px;
}
}

File diff suppressed because one or more lines are too long

14
dist/demo.css vendored
View File

@ -203,6 +203,17 @@
color: #1565c0; } color: #1565c0; }
.u-table tr tr a:active { .u-table tr tr a:active {
color: #1565c0; } color: #1565c0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) {
display: -ms-flexbox;
display: flex;
-ms-flex-direction: row-reverse;
flex-direction: row-reverse; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con {
height: 15px; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .uf {
padding-left: 0; }
.u-table tr td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body) .expand-icon-con .u-table-row-expand-icon {
width: 0; }
.u-table tr.tr-row-hover { .u-table tr.tr-row-hover {
background: rgb(235, 236, 240); } background: rgb(235, 236, 240); }
.u-table th, .u-table th,
@ -1065,6 +1076,9 @@ th .drop-menu .uf {
th:hover .uf { th:hover .uf {
visibility: visible; } visibility: visible; }
.expanded-table .expand-icon-con .uf {
font-size: 12px; }
.demo8 .u-table { .demo8 .u-table {
margin-bottom: 11px; } margin-bottom: 11px; }

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

372
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,6 +1,6 @@
{ {
"name": "bee-table", "name": "bee-table",
"version": "2.1.4-alpha.4", "version": "2.1.4-alpha.5",
"description": "Table ui component for react", "description": "Table ui component for react",
"keywords": [ "keywords": [
"react", "react",
@ -93,4 +93,4 @@
"reqwest": "^2.0.5", "reqwest": "^2.0.5",
"tinper-bee": "latest" "tinper-bee": "latest"
} }
} }

View File

@ -102,6 +102,19 @@ $icon-color:#505F79;
color: #1565c0; color: #1565c0;
} }
} }
td.u-table-multiSelect-column.u-table-row-has-expandIcon:not(.u-table-row-fixed-columns-in-body){
display: flex;
flex-direction: row-reverse;
.expand-icon-con {
height: 15px;
.uf{
padding-left: 0;
}
.u-table-row-expand-icon {
width: 0;
}
}
}
} }
tr.tr-row-hover { tr.tr-row-hover {
background: $hover-bg-color-base; background: $hover-bg-color-base;

View File

@ -74,6 +74,9 @@ class TableCell extends Component{
if(typeof text == 'string' && bodyDisplayInRow){ if(typeof text == 'string' && bodyDisplayInRow){
title = text title = text
} }
if(expandIcon && expandIcon.props.expandable){
className = className+` ${clsPrefix}-has-expandIcon`
}
return ( return (
<td <td
colSpan={colSpan} colSpan={colSpan}

View File

@ -76,7 +76,7 @@ class TableHeader extends Component {
table.cols = tableDome.getElementsByTagName("col"); table.cols = tableDome.getElementsByTagName("col");
table.ths = tableDome.getElementsByTagName("th"); table.ths = tableDome.getElementsByTagName("th");
table.tr = tableDome.getElementsByTagName("tr"); table.tr = tableDome.getElementsByTagName("tr");
table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col"); table.tableBodyCols = contentTable.querySelector('.u-table-scroll .u-table-body') && contentTable.querySelector('.u-table-scroll .u-table-body').getElementsByTagName("col");
} }
table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ; table.fixedLeftHeaderTable = contentTable.querySelector('.u-table-fixed-left .u-table-header') ;
@ -475,7 +475,7 @@ class TableHeader extends Component {
if(!currentIndex || parseInt(currentIndex) === this.drag.currIndex)return; if(!currentIndex || parseInt(currentIndex) === this.drag.currIndex)return;
if(target.nodeName.toUpperCase() === "TH"){ if(target.nodeName.toUpperCase() === "TH"){
// target.style.border = "2px dashed rgba(5,0,0,0.25)"; // target.style.border = "2px dashed rgba(5,0,0,0.25)";
target.setAttribute("style","border-right:2px dashed rgba(5,0,0,0.25)"); target.setAttribute("style","border-right:2px dashed rgb(30, 136, 229)");
// target.style.backgroundColor = 'rgb(235, 236, 240)'; // target.style.backgroundColor = 'rgb(235, 236, 240)';
} }
} }

View File

@ -290,7 +290,7 @@ class TableRow extends Component{
} }
} }
if(type){ if(type){
currentObj && currentObj.setAttribute("style","border-bottom:2px dashed rgba(5,0,0,0.25)"); currentObj && currentObj.setAttribute("style","border-bottom:2px dashed rgb(30, 136, 229)");
}else{ }else{
currentObj && currentObj.setAttribute("style",""); currentObj && currentObj.setAttribute("style","");
} }

View File

@ -164,6 +164,7 @@ export default function multiSelect(Table, Checkbox) {
}) })
let _defaultColumns =[{ let _defaultColumns =[{
className: 'u-table-multiSelect-column',
title: ( title: (
<Checkbox <Checkbox
className="table-checkbox" className="table-checkbox"
@ -174,7 +175,7 @@ export default function multiSelect(Table, Checkbox) {
), ),
key: "checkbox", key: "checkbox",
dataIndex: "checkbox", dataIndex: "checkbox",
fixed:"left", fixed:"left",
width: 49, width: 49,
render: (text, record, index) => { render: (text, record, index) => {
let attr = {}; let attr = {};