diff --git a/CHANGELOG.md b/CHANGELOG.md index 7b47f73..51c8dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,20 @@ ## 更新日志 +### 1.1.8 + +*2020-02-10* + +#### 新增 + +- 新增级联模式(第一版, 欢迎测试Bug) + +#### Bug fixes + +- 修改class .hidden为.xm-hidden 避免冲突 +- 修改tree模式下只有一个子节点是的虚线样式错误 +- 修改tree非严格模式下的工具条操作数据错误 + + ### 1.1.7 *2020-01-02* diff --git a/dist/static/2.js b/dist/static/2.js index fe1ef26..49432c4 100644 --- a/dist/static/2.js +++ b/dist/static/2.js @@ -1,9 +1,9 @@ /*! * @Title: xm-select - * @Version: 1.1.7 + * @Version: 1.1.8 * @Description:基于layui的多选解决方案 * @Site: https://gitee.com/maplemei/xm-select * @Author: maplemei * @License:Apache License 2.0 */ -(window.webpackJsonp=window.webpackJsonp||[]).push([[2],{692:function(t,e,n){t.exports=n.p+"static/wx.b556b2e.jpg"},693:function(t,e){t.exports="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAA3gAAADLCAMAAAALBsE6AAAAAXNSR0IArs4c6QAAAFFQTFRF/////wAA/5WVmZOTVFRU/93d/3Fx//Hx//vl/9fX/8nJ8ePkta2t/7W1/1RUz8XF/+fn/Do739PUh4OD+evscnBw/2JiYGBg/xwc/IiKSIn0g0Gw+gAAEgRJREFUeNrtnQt7okoSQBPQdkdBFDQm9///0O16NDSKxpmYmMRzvrubUVBROVY/quin/wHAl/PERwCAeACPId4fAPhynhYA8OUgHgDiASAeAHyqePV6u13XfBoAXyle2CrhJx14sd5cs9t8W9/9GAAmxVtG5/S/5cnmOso4X8/fPwUL+xvq7JR/jhTTNsQt/yxE0GfVk76wp7lwhO+KF85vX74+byefOL0e4sFHxHvZhqcQ/9u+9HeXuw+Lt1hszrVer3nG8zq8bI69+cjzXRDv7KYPHT+AiyetzKcnaW/2d++7JheveHt9loZojDDrzWYt/y+ubV6WizoGr9dlEbZxB/l3FiRUvCJ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5oy/lHODpVcvWLWda3XUyTxWvMwE8/Xi5gSLy0RoeL1NcD+O/Z63Nv1t9m3h/Wz88p//Q0z8eb2NuMOsrePevU1XNrEfPXiEf3qVDwta46dhPSxMqr5raYTLkfFz5hFKz4v4/kvf9Q9IqQlxkarIWWcu//6HX0Ord7O7/fhM4/3Q8TzQeufovPiaPb4WlHt2koSmcSb09KIGLViyHq/uMKXp55cPMLatJv13xxeeL5tgKKH95MiHgAgHsA3FO8PAHw5TwAAAAAAAAAAAAA/kWbFZwDw5fz3H+YBYB7Ao5jX8iEAIB7Ar2dHUxOALh7AQ8B0AgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAMDT0/8B0p38SAf/3OIAAAAASUVORK5CYII="},695:function(t,e,n){"use strict";n.r(e);var a=function(){var t=this,e=t.$createElement,n=t._self._c||e;return n("section",{staticClass:"content element-doc"},[t._m(0),t._m(1),t._m(2),n("demo-block",[n("div",[n("p",[n("code",[t._v("el")]),t._v("绑定的不一定是id, 也可以是其他css选择器")])]),n("template",{slot:"source"},[n("element-demo0")],1),n("template",{slot:"highlight"},[n("pre",{pre:!0},[n("code",{pre:!0,attrs:{class:"html"}},[t._v("
\n\n +``` +::: diff --git a/docs/mds/ZTEST.md b/docs/mds/ZTEST.md index 8411cc8..952766f 100644 --- a/docs/mds/ZTEST.md +++ b/docs/mds/ZTEST.md @@ -7,43 +7,27 @@ ``` ::: diff --git a/docs/mds/options.md b/docs/mds/options.md index 35a2b99..74cd70b 100644 --- a/docs/mds/options.md +++ b/docs/mds/options.md @@ -48,6 +48,7 @@ | disabled | 是否禁用多选 | boolean | true / false | false | | create | 创建条目 | function(val, data), val: 搜索的数据, data: 当前下拉数据 | - | null | | tree | 树形结构, 具体看下表 | object | - | - | +| cascader | 级联结构, 具体看下表 | object | - | - | ### prop @@ -173,6 +174,15 @@ list: [ "ALL", "CLEAR", | indent | 间距 | int | - | 20 | | expandedKeys | 默认展开的节点数组, 为true时展开所有节点 | array / boolean | - | [ ] | | strict | 是否遵循严格父子结构 | boolean | true / false | true | + + +### cascader + +| 参数 | 说明 | 类型 | 可选值 | 默认值 | +| ----------------- | --------------------- | ------------- | ------------- | ------ | +| show | 是否展示为级联结构 | boolean | true / false | false | +| indent | 每一级的宽度 | int | - | 100 | +| strict | 是否遵循严格父子结构 | boolean | true / false | true | ### 全局方法 diff --git a/docs/router.js b/docs/router.js index 1818b6d..ac55927 100644 --- a/docs/router.js +++ b/docs/router.js @@ -101,6 +101,7 @@ export default [{ { path: '/plugin/laydate', name: '下拉日期多选', component: importMd('/ZP03') }, { path: '/plugin/panel', name: '下拉折叠面板', component: importMd('/ZP04') }, { path: '/plugin/transfer', name: '下拉穿梭框', component: importMd('/ZP05') }, + { path: '/plugin/cascader', name: '级联模式 Cascader', component: importMd('/ZP06') }, ] }, { path: '/question', diff --git a/package.json b/package.json index c44f20b..41e1c42 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "xm-select", - "version": "1.1.7", + "version": "1.1.8", "description": "始于Layui的select多选解决方案", "main": "index.js", "scripts": { diff --git a/src/components/framework/index.js b/src/components/framework/index.js index fc3f3e1..05e455e 100644 --- a/src/components/framework/index.js +++ b/src/components/framework/index.js @@ -6,7 +6,7 @@ import Label from '../label'; import General from '../plugin/general'; import Custom from '../plugin/custom'; import Tree from '../plugin/tree'; -// import Cascader from '../plugin/cascader'; +import Cascader from '../plugin/cascader'; /** * 框架渲染类, 渲染基础的外边框 + 属性变化监听 @@ -384,8 +384,7 @@ class Framework extends Component{ const bodyProps = { ...config, data, dataObj, flatData, sels, ck: this.itemClick.bind(this), show, onReset: this.onReset.bind(this) } //渲染组件 - // let Body = content ? : tree.show ? : config.cascader.show ? : ; - let Body = content ? : tree.show ? : ; + let Body = content ? : tree.show ? : config.cascader.show ? : ; return ( diff --git a/src/components/plugin/cascader.js b/src/components/plugin/cascader.js index 1c38c8c..7cb7822 100644 --- a/src/components/plugin/cascader.js +++ b/src/components/plugin/cascader.js @@ -16,17 +16,30 @@ class Cascader extends Component{ e.stopPropagation(); } - optionClick(item, selected, disabled, index, e){ - - console.log(item, index); - - this.props.ck(item, selected, disabled); - - let expand = this.state.expand.slice(0, index + 1); - expand[index] = item[this.props.prop.value]; - - this.setState({ expand }); + optionClick(item, selected, disabled, type, index, e){ + if(type === 'line'){ + if(disabled){ + return ; + } + //加载中的不需要进行处理 + if(item.__node.loading === true){ + return; + } + + const { cascader, prop, sels } = this.props; + + //不是父节点的不需要处理 + if(!cascader.lazy && !item[prop.optgroup]){ + this.props.ck(item, selected, disabled); + return + } + let expand = this.state.expand.slice(0, index + 1); + expand[index] = item[this.props.prop.value]; + this.setState({ expand }); + }else if(type === 'checkbox'){ + this.props.ck(item, selected, disabled); + } //阻止父组件上的事件冒泡 this.blockClick(e); } @@ -47,7 +60,7 @@ class Cascader extends Component{ let { name, value, disabled, children } = prop; const showIcon = config.model.icon != 'hidden'; - const renderItem = (item, indent, index) => { + const renderItem = (item, indent, index, checked) => { //是否被选中 let selected = !!sels.find(sel => sel[value] == item[value]); //是否禁用 @@ -55,8 +68,11 @@ class Cascader extends Component{ // 是否半选 let half = item.__node.half === true; - selected = selected || half || item.__node.selected - dis = dis || item.__node.disabled; + //是否遵义严格父子结构 + if(cascader.strict){ + selected = selected || half || item.__node.selected + dis = dis || item.__node.disabled; + } const iconStyle = selected ? { color: theme.color, @@ -67,8 +83,19 @@ class Cascader extends Component{ const itemStyle = { backgroundColor: 'transparent' } const className = ['xm-option', (dis ? ' disabled' : ''), (selected ? ' selected' : ''), (showIcon ? 'show-icon' : 'hide-icon') ].join(' '); - const iconClass = ['xm-option-icon xm-iconfont', radio ? 'xm-icon-danx' : half ? 'xm-icon-banxuan' : 'xm-icon-duox'].join(' '); + const iconClass = ['xm-option-icon xm-iconfont', radio ? 'xm-icon-danx' : cascader.strict && half ? 'xm-icon-banxuan' : 'xm-icon-duox'].join(' '); + if(item[value] === this.state.val){ + itemStyle.backgroundColor = theme.hover + } + + const contentStyle = {}, checkedStyle = {}; + if(checked){ + contentStyle.color = theme.color + contentStyle.fontWeight = 700 + checkedStyle.color = theme.color + } + let checkedClass = 'xm-right-arrow'; //处理鼠标选择的背景色 const hoverChange = e => { @@ -83,31 +110,30 @@ class Cascader extends Component{ return (
- { showIcon && } -
+ { showIcon && } +
+ { item[children] &&
}
) } + let boxArr = []; const renderGroup = (item, indent, index) => { - const child = item[children]; + indent = indent + cascader.indent + 6 - indent = cascader.indent + 10 - - return ( -
- { renderItem(item, indent, index) } - { child && this.state.expand[index] === item[value] && -
{ child.map(c => renderGroup(c, indent, index + 1)) }
- } + const checked = child && this.state.expand[index] === item[value]; + checked && boxArr.push( +
+
{ child.map(c => renderGroup(c, indent, index + 1)) }
) + return renderItem(item, indent, index, checked) } - let arr = data.map(item => renderGroup(item, 0, 0)).filter(a => a); + let arr = data.map(item => renderGroup(item, 2, 0)).concat(boxArr).filter(a => a); // let safetyArr = deepMerge([], arr); // let safetySels = deepMerge([], sels); @@ -116,7 +142,7 @@ class Cascader extends Component{ } return ( -
+
{ arr }
) diff --git a/src/components/plugin/general.js b/src/components/plugin/general.js index 09182d7..4527cd9 100644 --- a/src/components/plugin/general.js +++ b/src/components/plugin/general.js @@ -194,7 +194,7 @@ class General extends Component{ } //组件将要接收新属性 - componentWillReceiveProps(props){ + componentWillReceiveProps(props){ if(this.props.show != props.show){ if(!props.show){ //清空输入框的值 diff --git a/src/components/plugin/tree.js b/src/components/plugin/tree.js index 197f224..9bedad8 100644 --- a/src/components/plugin/tree.js +++ b/src/components/plugin/tree.js @@ -237,7 +237,7 @@ class Tree extends Component{ } const className = ['xm-option', (dis ? ' disabled' : ''), (selected ? ' selected' : ''), (showIcon ? 'show-icon' : 'hide-icon') ].join(' '); const iconClass = ['xm-option-icon xm-iconfont', radio ? 'xm-icon-danx' : tree.strict && half ? 'xm-icon-banxuan' : 'xm-icon-duox'].join(' '); - const treeIconClass = ['xm-tree-icon', expand ? 'expand':'', item[children] && (item[children].length > 0 || (tree.lazy && item.__node.loading !== false)) ? 'visible':'hidden'].join(' '); + const treeIconClass = ['xm-tree-icon', expand ? 'expand':'', item[children] && (item[children].length > 0 || (tree.lazy && item.__node.loading !== false)) ? 'xm-visible':'xm-hidden'].join(' '); const iconArray = []; if(tree.showFolderIcon){ @@ -284,7 +284,7 @@ class Tree extends Component{ child.length === 0 && (expand = false) return (
- { tree.showFolderIcon && tree.showLine && expand && child.length > 1 && } + { tree.showFolderIcon && tree.showLine && expand && child.length > 0 && } { renderItem(item, indent, child.length === 0 && (!tree.lazy || tree.lazy && item.__node.loading === false) ? 0 : expand) } { expand &&
{ child.map(c => renderGroup(c, indent)) }
}
@@ -311,7 +311,7 @@ class Tree extends Component{ //工具条操作 function flat(list, array){ - array.forEach(item => item[optgroup] ? flat(list, item[children]) : list.push(item)) + array.forEach(item => item[optgroup] ? (!tree.strict && list.push(item), flat(list, item[children])) : list.push(item)) } const toolbar = (
diff --git a/src/config/options.js b/src/config/options.js index 832a501..90fd17f 100644 --- a/src/config/options.js +++ b/src/config/options.js @@ -107,7 +107,9 @@ export default function (lan = 'zn') { //是否展示级联 show: false, //间距 - indent: 200, + indent: 100, + //是否严格遵守父子模式 + strict: true, }, //自定义属性名称 prop: { diff --git a/src/style/index.less b/src/style/index.less index 97fca11..e225f00 100644 --- a/src/style/index.less +++ b/src/style/index.less @@ -401,7 +401,7 @@ xm-select{ margin-left: -2px; transform: rotate(90deg); } - &.visible{ + &.xm-visible{ visibility: visible; } } @@ -429,36 +429,57 @@ xm-select{ .xm-cascader{ // position: relative; - &-box{ position: absolute; left: 0; right: 0; top: 0; bottom: 0; + padding: 5px 0; + border: @border; + background-color: #fff; + border-radius: 2px; + box-shadow: 0 2px 4px rgba(0, 0, 0, .12); + margin: -1px; + + &::before{ + content: ' '; + position: absolute; + width: 0; + height: 0; + border: 6px solid transparent; + border-right-color: @defaultBorderColor; + top: 10px; + left: -12px; + } + &::after{ + content: ' '; + position: absolute; + width: 0; + height: 0; + border: 6px solid transparent; + border-right-color: #fff; + top: 10px; + left: -11px; + } + } + &-scroll{ + height: 100%; overflow-x: hidden; overflow-y: auto; - padding: 5px 0; - - } - &-box[index="0"]{ - background-color: #F5F5F5; - } - &-box[index="1"]{ - background-color: #FAFAFA; - } - &-box[index="2"]{ - background-color: #FFFFFF; - } - &-box[index="3"]{ - background-color: #EFEFEF; } } - + &.cascader{ - background-color: #EFEFEF; + width: unset; + min-width: unset; + .xm-option-content{ + padding-left: 8px; + } + .disabled .xm-right-arrow{ + color: #C2C2C2 !important; + } } - } .xm-input{ @@ -533,6 +554,19 @@ xm-select{ cursor: initial; } + .xm-right-arrow{ + position: absolute; + color: #666; + right: 5px; + top: -1px; + font-weight: 700; + transform: scale(0.6, 1); + + &::after{ + content: '>'; + } + } + } //不同尺寸下的数据调整 @@ -573,7 +607,7 @@ xm-select{ .left-line-group{ height: calc(100% - @size); } - .xm-tree-icon.hidden+.top-line{ + .xm-tree-icon.xm-hidden+.top-line{ top: @size / 2 - 1px; } }