@beisen-platform/dropdown-list
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -9,8 +9,8 @@ import React from 'react' | ||
"isActive": false, | ||
"isChecked": false | ||
}, { "value": "ddddd3", "text": "333", "isActive": false, "isChecked": false }, { | ||
"isChecked": true | ||
}, { "value": "ddddd3", "text": "333", "isActive": false, "isChecked": true }, { | ||
"value": "ddddd4", | ||
"text": "444", | ||
"isActive": false, | ||
"isChecked": false | ||
"isChecked": true | ||
}] | ||
@@ -23,2 +23,4 @@ | ||
'sortDataActive': true, | ||
'text':'', | ||
'value':'ddddd3,ddddd4,ddddd1,ddddd2', | ||
"cmp_id": "bce4ff42-013a-4512-b260-1dd3e62dc89c", | ||
@@ -25,0 +27,0 @@ "hasClosebtn": true, |
import "core-js/modules/es6.function.name"; | ||
import _extends from "@babel/runtime/helpers/extends"; | ||
import _typeof from "@babel/runtime/helpers/typeof"; | ||
import "core-js/modules/es7.symbol.async-iterator"; | ||
import "core-js/modules/es6.symbol"; | ||
import "core-js/modules/web.dom.iterable"; | ||
import "core-js/modules/es6.regexp.split"; | ||
import _classCallCheck from "@babel/runtime/helpers/classCallCheck"; | ||
@@ -23,3 +27,3 @@ import _createClass from "@babel/runtime/helpers/createClass"; | ||
function App(props) { | ||
function App(_props) { | ||
var _this; | ||
@@ -29,4 +33,38 @@ | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, props)); | ||
_this = _possibleConstructorReturn(this, _getPrototypeOf(App).call(this, _props)); | ||
_this.getSortData = function (props) { | ||
if (!_this.props.sortDataActive) return []; | ||
var arr = props.value && props.value.split(','); | ||
var children = []; | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
try { | ||
for (var _iterator = arr[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var i = _step.value; | ||
var item = props.children.filter(function (item) { | ||
return item.isChecked && item.value == i; | ||
})[0]; | ||
if (item) children.push(item); | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator.return != null) { | ||
_iterator.return(); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
} | ||
return children; | ||
}; | ||
_this.clearToolTipDom = function () { | ||
@@ -115,12 +153,10 @@ var dom_1 = document.getElementById('DropdownList_ul'); | ||
_this.state = { | ||
defaultValue: props.defaultValue, | ||
defaultValue: _props.defaultValue, | ||
keepActive: false, | ||
sortData: props.children.filter(function (item) { | ||
sortData: _this.getSortData(_props), | ||
children: _props.children, | ||
selectDate: _props.children.filter(function (item) { | ||
return item.isChecked; | ||
}), | ||
children: props.children, | ||
selectDate: props.children.filter(function (item) { | ||
return item.isChecked; | ||
}), | ||
defaultPlaceholder: props && props.placeholder || '请选择' | ||
defaultPlaceholder: _props && _props.placeholder || '请选择' | ||
}; | ||
@@ -130,3 +166,3 @@ _this.CommonMount = new CommonMount({ | ||
// 容器ID | ||
containerClass: props.containerClass, | ||
containerClass: _props.containerClass, | ||
//容器自定义样式 | ||
@@ -150,5 +186,3 @@ follow: true, | ||
}), | ||
sortData: nextProps.children.filter(function (item) { | ||
return item.isChecked; | ||
}) | ||
sortData: this.getSortData(nextProps) | ||
}); | ||
@@ -155,0 +189,0 @@ } |
{ | ||
"name": "@beisen-platform/dropdown-list", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "表单下拉选择器,多选或单选,可直接用于表单中", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -22,3 +22,3 @@ import React, { Component } from 'react'; | ||
keepActive: false, | ||
sortData: props.children.filter((item) => item.isChecked), | ||
sortData: this.getSortData(props), | ||
children: props.children, | ||
@@ -35,2 +35,14 @@ selectDate: props.children.filter((item) => item.isChecked), | ||
} | ||
getSortData = (props) => { | ||
if(!this.props.sortDataActive) return [] | ||
let arr = props.value && props.value.split(',') | ||
let children = [] | ||
for(var i of arr){ | ||
let item = props.children.filter((item) => item.isChecked && item.value == i)[0] | ||
if(item) children.push(item) | ||
} | ||
return children | ||
} | ||
componentWillReceiveProps(nextProps) { | ||
@@ -41,3 +53,3 @@ if (JSON.stringify(nextProps.children) != JSON.stringify(this.props.children)) { | ||
selectDate: nextProps.children.filter((item) => item.isChecked), | ||
sortData: nextProps.children.filter((item) => item.isChecked) | ||
sortData: this.getSortData(nextProps) | ||
}); | ||
@@ -44,0 +56,0 @@ } |
718942
6113