v1.1.0.Beta-2
This commit is contained in:
parent
1e9d58f0e6
commit
ef56e82800
12
CHANGELOG.md
12
CHANGELOG.md
@ -1,6 +1,16 @@
|
||||
## 更新日志
|
||||
|
||||
### 1.1.0.Beta
|
||||
### 1.1.0.Beta-2
|
||||
|
||||
*2019-11-20*
|
||||
|
||||
#### Bug fixes
|
||||
|
||||
- 修改树状结构使用`setValue`数据错误
|
||||
- 修改树状结构中`children`属性为空数组时无法操作节点的问题
|
||||
|
||||
|
||||
### 1.1.0.Beta-1
|
||||
|
||||
*2019-11-19*
|
||||
|
||||
|
@ -1,3 +1,4 @@
|
||||
const pkg = require('../package.json');
|
||||
const path = require('path');
|
||||
const webpack = require('webpack');
|
||||
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||
@ -6,7 +7,15 @@ const {
|
||||
CleanWebpackPlugin
|
||||
} = require('clean-webpack-plugin');
|
||||
|
||||
const isProd = process.env.NODE_ENV === 'prod';
|
||||
const isProd = process.env.NODE_ENV === 'prod';
|
||||
|
||||
const banner =
|
||||
`@Title: ${pkg.name}
|
||||
@Version: ${pkg.version}
|
||||
@Description:基于layui的多选解决方案
|
||||
@Site: https://gitee.com/maplemei/xm-select
|
||||
@Author: maplemei
|
||||
@License:Apache License 2.0`;
|
||||
|
||||
const webpackConfig = {
|
||||
entry: {
|
||||
@ -81,7 +90,8 @@ const webpackConfig = {
|
||||
minify: {
|
||||
collapseWhitespace: true
|
||||
}
|
||||
}),
|
||||
}),
|
||||
new webpack.BannerPlugin(banner),
|
||||
new VueLoaderPlugin(),
|
||||
],
|
||||
devServer: {
|
||||
|
10
dist/static/2.js
vendored
10
dist/static/2.js
vendored
File diff suppressed because one or more lines are too long
10
dist/static/3.js
vendored
10
dist/static/3.js
vendored
File diff suppressed because one or more lines are too long
11
dist/static/docs.js
vendored
11
dist/static/docs.js
vendored
File diff suppressed because one or more lines are too long
9
dist/xm-select.js
vendored
9
dist/xm-select.js
vendored
File diff suppressed because one or more lines are too long
@ -24,7 +24,7 @@ const router = new VueRouter({
|
||||
|
||||
router.beforeEach((to, from, next) => {
|
||||
if (to.path) {
|
||||
_hmt.push(['_trackPageview', '/#' + to.fullPath]);
|
||||
_hmt.push(['_trackPageview', '/xm-select/#' + to.fullPath]);
|
||||
}
|
||||
next();
|
||||
});
|
||||
|
@ -83,7 +83,7 @@ var demo1 = xmSelect.render({
|
||||
data(){
|
||||
return [
|
||||
{name: '销售员', value: -1, disabled: true, children: [
|
||||
{name: '张三1', value: 1, selected: true},
|
||||
{name: '张三1', value: 1, selected: true, children: []},
|
||||
{name: '李四1', value: 2, selected: true},
|
||||
{name: '王五1', value: 3, disabled: true},
|
||||
]},
|
||||
|
@ -33,33 +33,54 @@ class Framework extends Component{
|
||||
}
|
||||
|
||||
init(props, refresh){
|
||||
let { data } = props;
|
||||
let { data } = props, sels;
|
||||
|
||||
//如果新数据和旧数据不同 或者 强制刷新 才进行数据处理
|
||||
if(refresh){
|
||||
let dataObj = {};
|
||||
let flatData = [];
|
||||
this.load(data, dataObj, flatData);
|
||||
let sels = props.initValue ? this.exchangeValue(props.initValue) : Object.values(dataObj).filter(item => item[props.prop.selected] === true).filter(item => item[this.props.prop.optgroup] !== true)
|
||||
sels = props.initValue ? this.exchangeValue(props.initValue) : Object.values(dataObj).filter(item => item[props.prop.selected] === true).filter(item => item[this.props.prop.optgroup] !== true)
|
||||
this.setState({ sels, dataObj, flatData });
|
||||
}
|
||||
|
||||
this.setState({ data });
|
||||
|
||||
return sels;
|
||||
}
|
||||
|
||||
exchangeValue(arr){
|
||||
return arr.map(sel => typeof sel === 'object' ? sel : this.state.dataObj[sel]).filter(a => a).filter(item => item[this.props.prop.optgroup] !== true)
|
||||
exchangeValue(arr, filterGroup = true){
|
||||
let list = arr.map(sel => typeof sel === 'object' ? sel : this.state.dataObj[sel]).filter(a => a)
|
||||
filterGroup && (list = list.filter(item => item[this.props.prop.optgroup] !== true))
|
||||
return list;
|
||||
}
|
||||
|
||||
value(sels, show, listenOn){
|
||||
if(show !== false && show !== true){
|
||||
show = this.state.show;
|
||||
}
|
||||
let changeData = this.exchangeValue(sels);
|
||||
|
||||
const { prop, tree } = this.props;
|
||||
let changeData = this.exchangeValue(sels, !tree.show);
|
||||
if(tree.show){
|
||||
let data = this.state.data;
|
||||
this.clearAndReset(data, changeData);
|
||||
changeData = this.init({ data, prop }, true);
|
||||
}
|
||||
|
||||
this.resetSelectValue(changeData, changeData, true, listenOn);
|
||||
this.setState({ show })
|
||||
}
|
||||
|
||||
clearAndReset(data, changeData){
|
||||
const { selected, children, value } = this.props.prop;
|
||||
data.forEach(item => {
|
||||
item[selected] = changeData.findIndex(c => c[value] === item[value]) != -1;
|
||||
let child = item[children];
|
||||
child && isArray(child) && this.clearAndReset(child, changeData)
|
||||
})
|
||||
}
|
||||
|
||||
load(data, dataObj, flatData, parent){
|
||||
const { children, optgroup, value, selected, disabled } = this.props.prop;
|
||||
data.forEach(item => {
|
||||
@ -70,20 +91,21 @@ class Framework extends Component{
|
||||
//遍历子级数据
|
||||
let child = item[children];
|
||||
if(child && isArray(child)){
|
||||
item[optgroup] = true;
|
||||
this.load(child, dataObj, flatData, item);
|
||||
|
||||
if(item[selected] === true){
|
||||
delete item[selected]
|
||||
child.forEach(c => c[selected] = true)
|
||||
}
|
||||
if(item[disabled] === true){
|
||||
delete item[disabled]
|
||||
child.forEach(c => c[disabled] = true)
|
||||
}
|
||||
|
||||
let len = child.length;
|
||||
if(len > 0){
|
||||
this.load(child, dataObj, flatData, item);
|
||||
|
||||
//严格的父子结构
|
||||
item[optgroup] = true;
|
||||
if(item[selected] === true){
|
||||
delete item[selected]
|
||||
child.forEach(c => c[selected] = true)
|
||||
}
|
||||
if(item[disabled] === true){
|
||||
delete item[disabled]
|
||||
child.forEach(c => c[disabled] = true)
|
||||
}
|
||||
|
||||
//检查子节点的数据是否都被选中
|
||||
let slen = child.filter(i => i[selected] === true || i.__node.selected === true).length;
|
||||
item.__node.selected = slen === len;
|
||||
|
@ -1,15 +1,10 @@
|
||||
/* 阿里巴巴矢量图标库 */
|
||||
@font-face {
|
||||
font-family: "xm-iconfont";
|
||||
src: url('//at.alicdn.com/t/font_792691_qxv28s6g1l9.eot?t=1534240067831');
|
||||
/* IE9*/
|
||||
src: url('//at.alicdn.com/t/font_792691_qxv28s6g1l9.eot?t=1534240067831#iefix') format('embedded-opentype'),
|
||||
/* IE6-IE8 */
|
||||
url('data:application/x-font-woff2;charset=utf-8;base64,d09GMgABAAAAAAksAAsAAAAAEYAAAAjdAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAHEIGVgCEUgqTXI8lATYCJAM0CxwABCAFhG0HgTwbZQ4jEbaCkVIj+4sD3pR1GFAIp4fcnExVznDkY6poTaP8+woHw+EnHMKNfx8836/9zn2yu1/EgGTS1ROhmYfkmVCZjoeiFUKEJB4yw9Op/w7VIXHBVNhnuwzCYWJuctqf/TUplM2JBwVtNxeeFQx2AiDNB/4P17SEuttU1NxT62pHHh0FLvkr5IKlv59TW4obkWUQatb9n+IL9BoYMarW7aYmNPmkDAMFbkZvwqsJoWdiWzFhTVpHrPQCa/bkkkMAP2WakcHXARTwMAhKsGENuYnAqwmYSLbgmZ1AUINAq/HDU6XqEcCx/335AZ3iARRWA5HS7ELPKaD3HXzK2/3fHaMPOHq+bmAhBxpoBsyCvQ5aTkHLLlfj346yC0gTpY847xAcSUAsQydd36d9yv8doE36aWJRSJOVRP6fPPBhcQmi0BiEAB5+HBAHgA6mV05q4jvQHL4dA4HDgsHB4YIhoeUyAnAoMGJwaDDp4DBgMkBxLqYTKMB0BYcHZhrq4IdPOcPXUYe254F20C7YVxCTvQ7224IspxVBtMQtU1AoRFlCNJYt4AWdhkSIBEQDkSCCUIBajocT8z+QgxgIAbq6bO3aSk0FRpQ51eXzie22O5F0tOgRJY1Hhv+jGMNySErrQ+SzskZNRdmIlkXF6NhTKKc6lS7XprOVmjSKYek5RFkdgNXNF5A/EIFYWpJQYnsTgM0NtTYLm4wpQwk8miQV6nJRPI+H8fN6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XL67PH35zu/Hynii9YihItRqw44oonPvFLQIISkjCT7cztRbscSY6K25XKdGkmfWvJGpH3YDg+1JuN5HTL9Kcixqjvvsw0PwMK5JSwKAZ1L80ILo5bNY6UY5vIDRzqPPFozZ4tjsVQvtMBAAA=') format('woff2'),
|
||||
url('//at.alicdn.com/t/font_792691_qxv28s6g1l9.ttf?t=1534240067831') format('truetype'),
|
||||
/* chrome, firefox, opera, Safari, Android, iOS 4.2+*/
|
||||
url('//at.alicdn.com/t/font_792691_qxv28s6g1l9.svg?t=1534240067831#iconfont') format('svg');
|
||||
/* iOS 4.1- */
|
||||
}
|
||||
|
||||
.xm-iconfont {
|
||||
|
Loading…
Reference in New Issue
Block a user