多选逻辑调整主要是disabled计算

This commit is contained in:
wanghaoo 2018-12-05 10:03:11 +08:00
parent d6dcbad699
commit f2c99f0cc7
5 changed files with 43 additions and 59 deletions

View File

@ -99,13 +99,17 @@ function multiSelect(Table, Checkbox) {
if (!this.isArray(data)) return false; if (!this.isArray(data)) return false;
if (data.length == 0) return false; if (data.length == 0) return false;
var count = 0; var count = 0;
var disabledCount = 0;
data.forEach(function (da) { data.forEach(function (da) {
if (da._checked) { if (da._checked) {
count++; count++;
} }
if (da._disabled) {
disabledCount++;
}
}); });
if (data.length == count) { if (data.length == count + disabledCount) {
return "all"; return "all";
} }
return count == 0 ? false : "indeter"; return count == 0 ? false : "indeter";

2
dist/demo.css.map vendored

File diff suppressed because one or more lines are too long

72
dist/demo.js vendored
View File

@ -7237,7 +7237,7 @@
duration: _propTypes2["default"].number, duration: _propTypes2["default"].number,
onClose: _propTypes2["default"].func, onClose: _propTypes2["default"].func,
children: _propTypes2["default"].any, children: _propTypes2["default"].any,
color: _propTypes2["default"].oneOf(['info', 'success', 'danger', 'warning', 'light', 'dark', 'news', 'infolight', 'successlight', 'dangerlight', 'warninglight']), color: _propTypes2["default"].oneOf(['light']),
title: _propTypes2["default"].any title: _propTypes2["default"].any
}; };
@ -7336,7 +7336,7 @@
; ;
Notice.propTypes = propTypes; Notice.PropTypes = _propTypes2["default"];
Notice.defaultProps = defaultProps; Notice.defaultProps = defaultProps;
exports["default"] = Notice; exports["default"] = Notice;
@ -21693,7 +21693,7 @@
InputNumber.prototype.ComponentWillMount = function ComponentWillMount() {}; InputNumber.prototype.ComponentWillMount = function ComponentWillMount() {};
InputNumber.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) { InputNumber.prototype.componentWillReceiveProps = function componentWillReceiveProps(nextProps) {
if (!nextProps.hasOwnProperty('precision')) { // if(!nextProps.hasOwnProperty('precision')){//如果没有 precision
var data = judgeValue(nextProps); var data = judgeValue(nextProps);
this.setState({ this.setState({
value: data.value, value: data.value,
@ -21701,7 +21701,7 @@
plusDisabled: data.plusDisabled plusDisabled: data.plusDisabled
}); });
this.tempStorage = data.value; this.tempStorage = data.value;
} // }
}; };
InputNumber.prototype.ComponentWillUnMount = function ComponentWillUnMount() { InputNumber.prototype.ComponentWillUnMount = function ComponentWillUnMount() {
@ -53663,13 +53663,17 @@
if (!this.isArray(data)) return false; if (!this.isArray(data)) return false;
if (data.length == 0) return false; if (data.length == 0) return false;
var count = 0; var count = 0;
var disabledCount = 0;
data.forEach(function (da) { data.forEach(function (da) {
if (da._checked) { if (da._checked) {
count++; count++;
} }
if (da._disabled) {
disabledCount++;
}
}); });
if (data.length == count) { if (data.length == count + disabledCount) {
return "all"; return "all";
} }
return count == 0 ? false : "indeter"; return count == 0 ? false : "indeter";
@ -59506,18 +59510,18 @@
} }
}; };
Popconfirm.prototype.handleClose = function handleClose(e) { Popconfirm.prototype.handleClose = function handleClose() {
var onClose = this.props.onClose; var onClose = this.props.onClose;
this.hide(); this.hide();
onClose && onClose(e); onClose && onClose();
}; };
Popconfirm.prototype.handleCancel = function handleCancel(e) { Popconfirm.prototype.handleCancel = function handleCancel() {
var onCancel = this.props.onCancel; var onCancel = this.props.onCancel;
this.hide(); this.hide();
onCancel && onCancel(e); onCancel && onCancel();
}; };
Popconfirm.prototype.handleHide = function handleHide() { Popconfirm.prototype.handleHide = function handleHide() {
@ -59553,8 +59557,7 @@
content = _props.content, content = _props.content,
children = _props.children, children = _props.children,
onClick = _props.onClick, onClick = _props.onClick,
stopbubble = _props.stopbubble, props = _objectWithoutProperties(_props, ['content', 'children', 'onClick']);
props = _objectWithoutProperties(_props, ['content', 'children', 'onClick', 'stopbubble']);
delete props.defaultOverlayShown; delete props.defaultOverlayShown;
@ -59571,7 +59574,6 @@
_extends({}, confirmProps, { _extends({}, confirmProps, {
onClose: this.handleClose, onClose: this.handleClose,
onCancel: this.handleCancel, onCancel: this.handleCancel,
stopbubble: stopbubble,
placement: props.placement }), placement: props.placement }),
content content
); );
@ -59686,11 +59688,6 @@
*/ */
arrowOffsetLeft: _propTypes2["default"].oneOfType([_propTypes2["default"].number, _propTypes2["default"].string]), arrowOffsetLeft: _propTypes2["default"].oneOfType([_propTypes2["default"].number, _propTypes2["default"].string]),
/**
* 阻止冒泡
*/
stopbubble: _propTypes2["default"].number,
/** /**
* Title content * Title content
*/ */
@ -59701,7 +59698,6 @@
}; };
var defaultProps = { var defaultProps = {
stopbubble: 0,
placement: 'right', placement: 'right',
clsPrefix: 'u-popconfirm', clsPrefix: 'u-popconfirm',
locale: {} locale: {}
@ -59713,27 +59709,7 @@
function Confirm(props) { function Confirm(props) {
_classCallCheck(this, Confirm); _classCallCheck(this, Confirm);
var _this = _possibleConstructorReturn(this, _React$Component.call(this, props)); return _possibleConstructorReturn(this, _React$Component.call(this, props));
_this.cancel = function (e) {
var _this$props = _this.props,
stopbubble = _this$props.stopbubble,
onCancel = _this$props.onCancel;
stopbubble && e.stopPropagation();
onCancel(e);
};
_this.close = function (e) {
var _this$props2 = _this.props,
stopbubble = _this$props2.stopbubble,
onClose = _this$props2.onClose;
stopbubble && e.stopPropagation();
onClose(e);
};
return _this;
} }
Confirm.prototype.render = function render() { Confirm.prototype.render = function render() {
@ -59755,8 +59731,7 @@
onClose = _props.onClose, onClose = _props.onClose,
color = _props.color, color = _props.color,
onCancel = _props.onCancel, onCancel = _props.onCancel,
stopbubble = _props.stopbubble, props = _objectWithoutProperties(_props, ['placement', 'positionTop', 'positionLeft', 'arrowOffsetTop', 'arrowOffsetLeft', 'clsPrefix', 'trigger', 'title', 'className', 'style', 'children', 'locale', 'onClose', 'color', 'onCancel']);
props = _objectWithoutProperties(_props, ['placement', 'positionTop', 'positionLeft', 'arrowOffsetTop', 'arrowOffsetLeft', 'clsPrefix', 'trigger', 'title', 'className', 'style', 'children', 'locale', 'onClose', 'color', 'onCancel', 'stopbubble']);
var local = (0, _tool.getComponentLocale)(this.props, this.context, 'Popconfirm', function () { var local = (0, _tool.getComponentLocale)(this.props, this.context, 'Popconfirm', function () {
return _i18n2["default"]; return _i18n2["default"];
@ -59782,10 +59757,7 @@
_extends({}, props, { _extends({}, props, {
role: 'tooltip', role: 'tooltip',
className: (0, _classnames2["default"])(className, classes), className: (0, _classnames2["default"])(className, classes),
style: outerStyle, style: outerStyle
onClick: function onClick(e) {
return stopbubble && e.stopPropagation();
}
}), }),
_react2["default"].createElement('div', { className: 'arrow', style: arrowStyle }), _react2["default"].createElement('div', { className: 'arrow', style: arrowStyle }),
_react2["default"].createElement( _react2["default"].createElement(
@ -59798,13 +59770,13 @@
{ className: (0, _classnames2["default"])(clsPrefix + '-confirm') }, { className: (0, _classnames2["default"])(clsPrefix + '-confirm') },
_react2["default"].createElement( _react2["default"].createElement(
_beeButton2["default"], _beeButton2["default"],
{ onClick: this.cancel, size: 'sm', style: { minWidth: 50 }, { onClick: onCancel, size: 'sm', style: { minWidth: 50 },
shape: 'border' }, shape: 'border' },
local['cancel'] local['cancel']
), ),
_react2["default"].createElement( _react2["default"].createElement(
_beeButton2["default"], _beeButton2["default"],
{ onClick: this.close, size: 'sm', style: { minWidth: 50 }, colors: 'primary' }, { onClick: onClose, size: 'sm', style: { minWidth: 50 }, colors: 'primary' },
local['ok'] local['ok']
) )
) )
@ -64058,13 +64030,17 @@
if (!this.isArray(data)) return false; if (!this.isArray(data)) return false;
if (data.length == 0) return false; if (data.length == 0) return false;
var count = 0; var count = 0;
var disabledCount = 0;
data.forEach(function (da) { data.forEach(function (da) {
if (da._checked) { if (da._checked) {
count++; count++;
} }
if (da._disabled) {
disabledCount++;
}
}); });
if (data.length == count) { if (data.length == count + disabledCount) {
return "all"; return "all";
} }
return count == 0 ? false : "indeter"; return count == 0 ? false : "indeter";

2
dist/demo.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -65,13 +65,17 @@ export default function multiSelect(Table, Checkbox) {
if(!this.isArray(data))return false; if(!this.isArray(data))return false;
if(data.length == 0)return false; if(data.length == 0)return false;
let count = 0; let count = 0;
let disabledCount = 0;
data.forEach(da=>{ data.forEach(da=>{
if(da._checked){ if(da._checked){
count ++; count ++;
} }
if(da._disabled){
disabledCount ++;
}
}) })
if(data.length == count){ if(data.length == count + disabledCount){
return "all"; return "all";
} }
return count == 0?false:"indeter"; return count == 0?false:"indeter";