This commit is contained in:
wanghaoo 2018-12-05 13:47:31 +08:00
commit 7b377d8ec3
5 changed files with 66 additions and 31 deletions

46
dist/demo.js vendored
View File

@ -12690,10 +12690,7 @@
}; };
_this.onLineMouseUp = function (event) { _this.onLineMouseUp = function (event) {
var rows = _this.props.rows;
var data = { rows: rows[0], cols: _this.table.cols, currIndex: _this.drag.currIndex };
_this.props.afterDragColWidth && _this.props.afterDragColWidth(data);
_this.clearDragBorder(event); _this.clearDragBorder(event);
}; };
@ -12702,9 +12699,11 @@
}; };
_this.dragAbleMouseDown = function (e) { _this.dragAbleMouseDown = function (e) {
_utils.Event.stopPropagation(e); // Event.stopPropagation(e);
var event = _utils.Event.getEvent(e); var event = _utils.Event.getEvent(e);
if (!_this.props.draggable) return; if (!_this.props.draggable) return;
var th = _this.getThDome(event.target);
if (!th) return;
event.target.setAttribute('draggable', true); //添加交换列效果 event.target.setAttribute('draggable', true); //添加交换列效果
_this.drag.option = 'dragAble'; _this.drag.option = 'dragAble';
_this.currentDome = event.target; _this.currentDome = event.target;
@ -12729,7 +12728,6 @@
if (_this.drag.option === 'border') { if (_this.drag.option === 'border') {
return; return;
} }
console.log(_this.drag.option + ' -------onDragStart----------', event.target);
var th = _this.getThDome(event.target); var th = _this.getThDome(event.target);
if (!th) return; if (!th) return;
var currentIndex = parseInt(th.getAttribute("data-line-index")); var currentIndex = parseInt(th.getAttribute("data-line-index"));
@ -12753,7 +12751,6 @@
_this.currentDome.setAttribute('draggable', false); //添加交换列效果 _this.currentDome.setAttribute('draggable', false); //添加交换列效果
var data = _this.getCurrentEventData(e); var data = _this.getCurrentEventData(e);
if (!data) return; if (!data) return;
console.log(_this.drag.option + ' -------onDrop----------', event.target);
if (!_this.currentObj || _this.currentObj.key == data.key) return; if (!_this.currentObj || _this.currentObj.key == data.key) return;
if (!_this.props.onDrop) return; if (!_this.props.onDrop) return;
_this.props.onDrop(event, { dragSource: _this.currentObj, dragTarg: data }); _this.props.onDrop(event, { dragSource: _this.currentObj, dragTarg: data });
@ -13009,7 +13006,11 @@
TableHeader.prototype.clearDragBorder = function clearDragBorder() { TableHeader.prototype.clearDragBorder = function clearDragBorder() {
// if (!this.props.dragborder || !this.props.draggable) return; // if (!this.props.dragborder || !this.props.draggable) return;
if (!this.drag) return; if (!this.drag || !this.drag.option) return;
var rows = this.props.rows;
var data = { rows: rows[0], cols: this.table.cols, currIndex: this.drag.currIndex };
this.props.afterDragColWidth && this.props.afterDragColWidth(data);
this.drag = { this.drag = {
option: "" option: ""
}; };
@ -13082,6 +13083,7 @@
TableHeader.prototype.getThDome = function getThDome(element) { TableHeader.prototype.getThDome = function getThDome(element) {
var _tagName = element.tagName.toLowerCase(); var _tagName = element.tagName.toLowerCase();
if (element.getAttribute('data-filter-type') === 'filterContext') return null;
if (_tagName === 'i') return null; if (_tagName === 'i') return null;
if (_tagName != 'th') { if (_tagName != 'th') {
return this.getThDome(element.parentElement); return this.getThDome(element.parentElement);
@ -14433,7 +14435,11 @@
FilterType.prototype.render = function render() { FilterType.prototype.render = function render() {
var rendertype = this.props.rendertype; var rendertype = this.props.rendertype;
return this.renderControl(rendertype); return _react2['default'].createElement(
'div',
{ 'data-filter-type': 'filterContext' },
this.renderControl(rendertype)
);
}; };
return FilterType; return FilterType;
@ -51712,16 +51718,26 @@
_this.onSelectDropdown = function (item) { _this.onSelectDropdown = function (item) {
var _this$props = _this.props, var _this$props = _this.props,
onSelectDropdown = _this$props.onSelectDropdown, onSelectDropdown = _this$props.onSelectDropdown,
dataText = _this$props.dataText; dataText = _this$props.dataText,
filterDropdownType = _this$props.filterDropdownType;
if (onSelectDropdown) { if (onSelectDropdown) {
if (dataText != "") { if (dataText != "") {
if (filterDropdownType == 'string') {
_this.setState({ _this.setState({
selectValue: [item.key] selectValue: [item.key]
}, function () { }, function () {
onSelectDropdown(item); onSelectDropdown(item);
}); });
} }
if (filterDropdownType == 'number') {
_this.setState({
selectNumberValue: [item.key]
}, function () {
onSelectDropdown(item);
});
}
}
} }
}; };
@ -51730,7 +51746,8 @@
if (onClickClear) { if (onClickClear) {
_this.setState({ _this.setState({
selectValue: [] selectValue: [],
selectNumberValue: []
}, function () { }, function () {
onClickClear(); onClickClear();
}); });
@ -51738,7 +51755,9 @@
}; };
_this.getMenu = function () { _this.getMenu = function () {
var selectValue = _this.state.selectValue; var _this$state = _this.state,
selectValue = _this$state.selectValue,
selectNumberValue = _this$state.selectNumberValue;
var filterDropdownType = _this.props.filterDropdownType; var filterDropdownType = _this.props.filterDropdownType;
var locale = (0, _tool.getComponentLocale)(_this.props, _this.context, 'Table', function () { var locale = (0, _tool.getComponentLocale)(_this.props, _this.context, 'Table', function () {
@ -51788,7 +51807,7 @@
_beeMenus2['default'], _beeMenus2['default'],
{ {
onSelect: _this.onSelectDropdown, onSelect: _this.onSelectDropdown,
selectedKeys: selectValue selectedKeys: selectNumberValue
}, },
_react2['default'].createElement( _react2['default'].createElement(
Item, Item,
@ -51827,7 +51846,8 @@
}; };
_this.state = { _this.state = {
selectValue: [] //选择的条件的值 selectValue: ['LIKE'],
selectNumberValue: ['EQ']
}; };
return _this; return _this;
} }

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -17,7 +17,8 @@ class FilterDropDown extends Component {
constructor() { constructor() {
super(); super();
this.state = { this.state = {
selectValue: []//选择的条件的值 selectValue: ['LIKE'],
selectNumberValue: ['EQ']
} }
} }
/** /**
@ -26,15 +27,25 @@ class FilterDropDown extends Component {
* @param {*} s 选中的selectRecord * @param {*} s 选中的selectRecord
*/ */
onSelectDropdown = (item) => { onSelectDropdown = (item) => {
let { onSelectDropdown, dataText } = this.props; let { onSelectDropdown, dataText, filterDropdownType } = this.props;
if (onSelectDropdown) { if (onSelectDropdown) {
if (dataText != "") { if (dataText != "") {
if (filterDropdownType == 'string') {
this.setState({ this.setState({
selectValue: [item.key] selectValue: [item.key]
}, () => { }, () => {
onSelectDropdown(item); onSelectDropdown(item);
}); });
} }
if (filterDropdownType == 'number') {
this.setState({
selectNumberValue: [item.key]
}, () => {
onSelectDropdown(item);
});
}
}
} }
} }
@ -46,7 +57,8 @@ class FilterDropDown extends Component {
let { onClickClear } = this.props; let { onClickClear } = this.props;
if (onClickClear) { if (onClickClear) {
this.setState({ this.setState({
selectValue: [] selectValue: [],
selectNumberValue: []
}, () => { }, () => {
onClickClear(); onClickClear();
}); });
@ -59,7 +71,7 @@ class FilterDropDown extends Component {
* @returns JSX Menu * @returns JSX Menu
*/ */
getMenu = () => { getMenu = () => {
let { selectValue } = this.state; let { selectValue, selectNumberValue } = this.state;
let { filterDropdownType } = this.props; let { filterDropdownType } = this.props;
let locale = getComponentLocale(this.props, this.context, 'Table', () => i18n); let locale = getComponentLocale(this.props, this.context, 'Table', () => i18n);
switch (filterDropdownType) { switch (filterDropdownType) {
@ -78,7 +90,7 @@ class FilterDropDown extends Component {
case 'number': case 'number':
return <Menu return <Menu
onSelect={this.onSelectDropdown} onSelect={this.onSelectDropdown}
selectedKeys={selectValue} selectedKeys={selectNumberValue}
> >
<Item key="GT">{locale['greater_than']}</Item> <Item key="GT">{locale['greater_than']}</Item>
<Item key="GTEQ">{locale['great_than_equal_to']}</Item> <Item key="GTEQ">{locale['great_than_equal_to']}</Item>

View File

@ -281,7 +281,7 @@ class FilterType extends Component {
render() { render() {
let { rendertype } = this.props; let { rendertype } = this.props;
return ( return (
this.renderControl(rendertype) <div data-filter-type='filterContext'>{this.renderControl(rendertype)}</div>
); );
} }
} }

View File

@ -234,9 +234,11 @@ class TableHeader extends Component {
//---拖拽列宽代码逻辑----start----- //---拖拽列宽代码逻辑----start-----
dragAbleMouseDown = (e) => { dragAbleMouseDown = (e) => {
Event.stopPropagation(e); // Event.stopPropagation(e);
let event = Event.getEvent(e); let event = Event.getEvent(e);
if (!this.props.draggable) return; if (!this.props.draggable) return;
let th = this.getThDome(event.target);
if(!th)return;
event.target.setAttribute('draggable',true);//添加交换列效果 event.target.setAttribute('draggable',true);//添加交换列效果
this.drag.option = 'dragAble'; this.drag.option = 'dragAble';
this.currentDome = event.target; this.currentDome = event.target;
@ -348,6 +350,7 @@ class TableHeader extends Component {
*/ */
getThDome(element){ getThDome(element){
let _tagName = element.tagName.toLowerCase(); let _tagName = element.tagName.toLowerCase();
if(element.getAttribute('data-filter-type') === 'filterContext')return null;
if(_tagName === 'i')return null; if(_tagName === 'i')return null;
if(_tagName != 'th'){ if(_tagName != 'th'){
return this.getThDome(element.parentElement); return this.getThDome(element.parentElement);