v-tree-scroll
Advanced tools
+35
-14
@@ -184,2 +184,4 @@ var name = "v-tree-scroll"; | ||
| // | ||
| // | ||
| // | ||
@@ -369,2 +371,13 @@ /** | ||
| }, | ||
| // 返回选中节点key | ||
| getCheckedKeys: function getCheckedKeys() { | ||
| var _this2 = this; | ||
| return this.selectedArr.map(function (item) { | ||
| return item[_this2.nodeKey]; | ||
| }); | ||
| }, | ||
| // 返回指定节点 | ||
| getNode: function getNode(id) { | ||
| return treeMap[id].data; | ||
| }, | ||
| // 返回半选中节点 | ||
@@ -395,2 +408,4 @@ getHalfCheckedNodes: function getHalfCheckedNodes() { | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange(); | ||
| }, | ||
@@ -401,12 +416,3 @@ // 搜索 | ||
| }, | ||
| _allChange: function _allChange(value) { | ||
| var _this2 = this; | ||
| this.listData.forEach(function (item) { | ||
| item.checked = value; | ||
| }); | ||
| this.$emit("change", this.selectedArr.map(function (item) { | ||
| return item[_this2.nodeKey]; | ||
| })); | ||
| }, | ||
| _nodeClick: function _nodeClick(data) { | ||
| _emitChange: function _emitChange() { | ||
| var _this3 = this; | ||
@@ -418,2 +424,17 @@ if (this.multiple) { | ||
| } else { | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| }, | ||
| // 全选 | ||
| allChange: function allChange(value) { | ||
| for (var index = 0; index < this.listData.length; index++) { | ||
| var item = this.listData[index]; | ||
| item.checked = value; | ||
| item.isIndeterminate = false; | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange(); | ||
| }, | ||
| _nodeClick: function _nodeClick(data) { | ||
| if (!this.multiple) { | ||
| if (this.selectedArr[0]) { | ||
@@ -423,4 +444,4 @@ this.selectedArr[0].checked = false; | ||
| data.checked = true; | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| this._emitChange(); | ||
| }, | ||
@@ -797,3 +818,3 @@ _changeBox: function _changeBox(item) { | ||
| /* template */ | ||
| var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"list",staticClass:"list"},[_c('div',{ref:"space",staticClass:"space",style:('height:' + _vm._listDataFilter.length * _vm.lineHeight + 'px')}),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.list.length),expression:"list.length"}],ref:"listUl"},_vm._l((_vm.list),function(item){return _c('li',{key:item[_vm.nodeKey] + _vm.key,class:item.checked && !_vm.multiple ? 'active-li' : '',style:('padding-left:' + 1.2 * item.level + 'em')},[(item.children)?_c('i',{staticClass:"el-icon-caret-bottom",class:item.collapse ? 'hide' : '',on:{"click":function($event){$event.stopPropagation();return _vm._changeStatus(item)}}}):_c('i',[_vm._v(" ")]),_vm._v(" "),(_vm.multiple)?_c('el-checkbox',{attrs:{"indeterminate":item.isIndeterminate,"checked":item.checked},on:{"change":function($event){return _vm._changeBox(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))]):_c('div',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }return _vm._nodeClick(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))])],1)}),0),_vm._v(" "),(!_vm.list.length)?_c('p',{staticClass:"no-data"},[_vm._v("暂无数据")]):_vm._e()])}; | ||
| var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"list",staticClass:"list"},[_c('div',{ref:"space",staticClass:"space",style:('height:' + _vm._listDataFilter.length * _vm.lineHeight + 'px')}),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.list.length),expression:"list.length"}],ref:"listUl"},_vm._l((_vm.list),function(item){return _c('li',{key:item[_vm.nodeKey] + _vm.key,class:item.checked && !_vm.multiple ? 'active-li' : '',style:('padding-left:' + 1.2 * item.level + 'em')},[(item.children)?_c('i',{staticClass:"el-icon-caret-bottom",class:item.collapse ? 'hide' : '',on:{"click":function($event){$event.stopPropagation();return _vm._changeStatus(item)}}}):_c('i',[_vm._v(" ")]),_vm._v(" "),(_vm.multiple)?_c('el-checkbox',{attrs:{"indeterminate":item.isIndeterminate,"checked":item.checked},on:{"change":function($event){return _vm._changeBox(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))]):_c('div',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }return _vm._nodeClick(item)}}},[_vm._v("\n "+_vm._s(item[_vm.props.label])+"\n ")])],1)}),0),_vm._v(" "),(!_vm.list.length)?_c('p',{staticClass:"no-data"},[_vm._v("暂无数据")]):_vm._e()])}; | ||
| var __vue_staticRenderFns__ = []; | ||
@@ -804,7 +825,7 @@ | ||
| if (!inject) return | ||
| inject("data-v-3f49356d_0", { source: ".list[data-v-3f49356d]{overflow:auto;flex:1;position:relative;height:100%}.list ul[data-v-3f49356d]{list-style:none;user-select:none;position:absolute;left:0;top:0;right:0}.list ul li[data-v-3f49356d]{line-height:30px;white-space:nowrap;display:flex;align-items:center;font-size:16px;height:30px;cursor:pointer}.list ul li.active-li[data-v-3f49356d]{background:#d7e5f9;color:#165ac6}.list ul li i[data-v-3f49356d]{display:inline-block;width:14px;color:#a9c4df;margin-right:5px;margin-top:2px}.list ul li i.el-icon-caret-bottom[data-v-3f49356d]{cursor:pointer}.list ul li i.hide[data-v-3f49356d]{transform-origin:50% 50%;transform:rotate(-90deg)}.list ul[data-v-3f49356d] .el-checkbox{display:flex;overflow:hidden;align-items:center;flex:1}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__input{position:relative;top:1px;margin:0}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__label{text-overflow:ellipsis;overflow:hidden;font-size:16px;color:#606266!important;line-height:16px!important}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__input.is-checked+.el-checkbox__label{color:#606266}.list .no-data[data-v-3f49356d]{text-align:center;line-height:50px;color:#999}", map: undefined, media: undefined }); | ||
| inject("data-v-d3d9b968_0", { source: ".list[data-v-d3d9b968]{overflow:auto;flex:1;position:relative;height:100%}.list ul[data-v-d3d9b968]{list-style:none;user-select:none;position:absolute;left:0;top:0;right:0}.list ul li[data-v-d3d9b968]{line-height:30px;white-space:nowrap;display:flex;align-items:center;font-size:16px;height:30px;cursor:pointer}.list ul li.active-li[data-v-d3d9b968]{background:#d7e5f9;color:#165ac6}.list ul li i[data-v-d3d9b968]{display:inline-block;width:14px;color:#a9c4df;margin-right:5px;margin-top:2px}.list ul li i.el-icon-caret-bottom[data-v-d3d9b968]{cursor:pointer}.list ul li i.hide[data-v-d3d9b968]{transform-origin:50% 50%;transform:rotate(-90deg)}.list ul[data-v-d3d9b968] .el-checkbox{display:flex;overflow:hidden;align-items:center;flex:1}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__input{position:relative;top:1px;margin:0}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__label{text-overflow:ellipsis;overflow:hidden;font-size:16px;color:#606266!important;line-height:16px!important}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__input.is-checked+.el-checkbox__label{color:#606266}.list .no-data[data-v-d3d9b968]{text-align:center;line-height:50px;color:#999}", map: undefined, media: undefined }); | ||
| }; | ||
| /* scoped */ | ||
| const __vue_scope_id__ = "data-v-3f49356d"; | ||
| const __vue_scope_id__ = "data-v-d3d9b968"; | ||
| /* module identifier */ | ||
@@ -811,0 +832,0 @@ const __vue_module_identifier__ = undefined; |
+35
-14
@@ -190,2 +190,4 @@ (function (global, factory) { | ||
| // | ||
| // | ||
| // | ||
@@ -375,2 +377,13 @@ /** | ||
| }, | ||
| // 返回选中节点key | ||
| getCheckedKeys: function getCheckedKeys() { | ||
| var _this2 = this; | ||
| return this.selectedArr.map(function (item) { | ||
| return item[_this2.nodeKey]; | ||
| }); | ||
| }, | ||
| // 返回指定节点 | ||
| getNode: function getNode(id) { | ||
| return treeMap[id].data; | ||
| }, | ||
| // 返回半选中节点 | ||
@@ -401,2 +414,4 @@ getHalfCheckedNodes: function getHalfCheckedNodes() { | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange(); | ||
| }, | ||
@@ -407,12 +422,3 @@ // 搜索 | ||
| }, | ||
| _allChange: function _allChange(value) { | ||
| var _this2 = this; | ||
| this.listData.forEach(function (item) { | ||
| item.checked = value; | ||
| }); | ||
| this.$emit("change", this.selectedArr.map(function (item) { | ||
| return item[_this2.nodeKey]; | ||
| })); | ||
| }, | ||
| _nodeClick: function _nodeClick(data) { | ||
| _emitChange: function _emitChange() { | ||
| var _this3 = this; | ||
@@ -424,2 +430,17 @@ if (this.multiple) { | ||
| } else { | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| }, | ||
| // 全选 | ||
| allChange: function allChange(value) { | ||
| for (var index = 0; index < this.listData.length; index++) { | ||
| var item = this.listData[index]; | ||
| item.checked = value; | ||
| item.isIndeterminate = false; | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange(); | ||
| }, | ||
| _nodeClick: function _nodeClick(data) { | ||
| if (!this.multiple) { | ||
| if (this.selectedArr[0]) { | ||
@@ -429,4 +450,4 @@ this.selectedArr[0].checked = false; | ||
| data.checked = true; | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| this._emitChange(); | ||
| }, | ||
@@ -803,3 +824,3 @@ _changeBox: function _changeBox(item) { | ||
| /* template */ | ||
| var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"list",staticClass:"list"},[_c('div',{ref:"space",staticClass:"space",style:('height:' + _vm._listDataFilter.length * _vm.lineHeight + 'px')}),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.list.length),expression:"list.length"}],ref:"listUl"},_vm._l((_vm.list),function(item){return _c('li',{key:item[_vm.nodeKey] + _vm.key,class:item.checked && !_vm.multiple ? 'active-li' : '',style:('padding-left:' + 1.2 * item.level + 'em')},[(item.children)?_c('i',{staticClass:"el-icon-caret-bottom",class:item.collapse ? 'hide' : '',on:{"click":function($event){$event.stopPropagation();return _vm._changeStatus(item)}}}):_c('i',[_vm._v(" ")]),_vm._v(" "),(_vm.multiple)?_c('el-checkbox',{attrs:{"indeterminate":item.isIndeterminate,"checked":item.checked},on:{"change":function($event){return _vm._changeBox(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))]):_c('div',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }return _vm._nodeClick(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))])],1)}),0),_vm._v(" "),(!_vm.list.length)?_c('p',{staticClass:"no-data"},[_vm._v("暂无数据")]):_vm._e()])}; | ||
| var __vue_render__ = function () {var _vm=this;var _h=_vm.$createElement;var _c=_vm._self._c||_h;return _c('div',{ref:"list",staticClass:"list"},[_c('div',{ref:"space",staticClass:"space",style:('height:' + _vm._listDataFilter.length * _vm.lineHeight + 'px')}),_vm._v(" "),_c('ul',{directives:[{name:"show",rawName:"v-show",value:(_vm.list.length),expression:"list.length"}],ref:"listUl"},_vm._l((_vm.list),function(item){return _c('li',{key:item[_vm.nodeKey] + _vm.key,class:item.checked && !_vm.multiple ? 'active-li' : '',style:('padding-left:' + 1.2 * item.level + 'em')},[(item.children)?_c('i',{staticClass:"el-icon-caret-bottom",class:item.collapse ? 'hide' : '',on:{"click":function($event){$event.stopPropagation();return _vm._changeStatus(item)}}}):_c('i',[_vm._v(" ")]),_vm._v(" "),(_vm.multiple)?_c('el-checkbox',{attrs:{"indeterminate":item.isIndeterminate,"checked":item.checked},on:{"change":function($event){return _vm._changeBox(item)}}},[_vm._v(_vm._s(item[_vm.props.label]))]):_c('div',{on:{"click":function($event){if($event.ctrlKey||$event.shiftKey||$event.altKey||$event.metaKey){ return null; }return _vm._nodeClick(item)}}},[_vm._v("\n "+_vm._s(item[_vm.props.label])+"\n ")])],1)}),0),_vm._v(" "),(!_vm.list.length)?_c('p',{staticClass:"no-data"},[_vm._v("暂无数据")]):_vm._e()])}; | ||
| var __vue_staticRenderFns__ = []; | ||
@@ -810,7 +831,7 @@ | ||
| if (!inject) return | ||
| inject("data-v-3f49356d_0", { source: ".list[data-v-3f49356d]{overflow:auto;flex:1;position:relative;height:100%}.list ul[data-v-3f49356d]{list-style:none;user-select:none;position:absolute;left:0;top:0;right:0}.list ul li[data-v-3f49356d]{line-height:30px;white-space:nowrap;display:flex;align-items:center;font-size:16px;height:30px;cursor:pointer}.list ul li.active-li[data-v-3f49356d]{background:#d7e5f9;color:#165ac6}.list ul li i[data-v-3f49356d]{display:inline-block;width:14px;color:#a9c4df;margin-right:5px;margin-top:2px}.list ul li i.el-icon-caret-bottom[data-v-3f49356d]{cursor:pointer}.list ul li i.hide[data-v-3f49356d]{transform-origin:50% 50%;transform:rotate(-90deg)}.list ul[data-v-3f49356d] .el-checkbox{display:flex;overflow:hidden;align-items:center;flex:1}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__input{position:relative;top:1px;margin:0}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__label{text-overflow:ellipsis;overflow:hidden;font-size:16px;color:#606266!important;line-height:16px!important}.list ul[data-v-3f49356d] .el-checkbox .el-checkbox__input.is-checked+.el-checkbox__label{color:#606266}.list .no-data[data-v-3f49356d]{text-align:center;line-height:50px;color:#999}", map: undefined, media: undefined }); | ||
| inject("data-v-d3d9b968_0", { source: ".list[data-v-d3d9b968]{overflow:auto;flex:1;position:relative;height:100%}.list ul[data-v-d3d9b968]{list-style:none;user-select:none;position:absolute;left:0;top:0;right:0}.list ul li[data-v-d3d9b968]{line-height:30px;white-space:nowrap;display:flex;align-items:center;font-size:16px;height:30px;cursor:pointer}.list ul li.active-li[data-v-d3d9b968]{background:#d7e5f9;color:#165ac6}.list ul li i[data-v-d3d9b968]{display:inline-block;width:14px;color:#a9c4df;margin-right:5px;margin-top:2px}.list ul li i.el-icon-caret-bottom[data-v-d3d9b968]{cursor:pointer}.list ul li i.hide[data-v-d3d9b968]{transform-origin:50% 50%;transform:rotate(-90deg)}.list ul[data-v-d3d9b968] .el-checkbox{display:flex;overflow:hidden;align-items:center;flex:1}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__input{position:relative;top:1px;margin:0}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__label{text-overflow:ellipsis;overflow:hidden;font-size:16px;color:#606266!important;line-height:16px!important}.list ul[data-v-d3d9b968] .el-checkbox .el-checkbox__input.is-checked+.el-checkbox__label{color:#606266}.list .no-data[data-v-d3d9b968]{text-align:center;line-height:50px;color:#999}", map: undefined, media: undefined }); | ||
| }; | ||
| /* scoped */ | ||
| const __vue_scope_id__ = "data-v-3f49356d"; | ||
| const __vue_scope_id__ = "data-v-d3d9b968"; | ||
| /* module identifier */ | ||
@@ -817,0 +838,0 @@ const __vue_module_identifier__ = undefined; |
+1
-1
| { | ||
| "name": "v-tree-scroll", | ||
| "description": "虚拟树滚动", | ||
| "version": "1.0.0", | ||
| "version": "1.0.1", | ||
| "author": "xyl <786549791@qq.com>", | ||
@@ -6,0 +6,0 @@ "license": "MIT", |
+34
-16
@@ -52,3 +52,5 @@ <!-- | ||
| <!-- 单选文本 --> | ||
| <div v-else @click.exact="_nodeClick(item)">{{ item[props.label] }}</div> | ||
| <div v-else @click.exact="_nodeClick(item)"> | ||
| {{ item[props.label] }} | ||
| </div> | ||
| </li> | ||
@@ -249,7 +251,15 @@ </ul> | ||
| }, | ||
| // 返回选中节点key | ||
| getCheckedKeys() { | ||
| return this.selectedArr.map((item) => item[this.nodeKey]); | ||
| }, | ||
| // 返回指定节点 | ||
| getNode(id) { | ||
| return treeMap[id].data; | ||
| }, | ||
| // 返回半选中节点 | ||
| getHalfCheckedNodes() { | ||
| return this.listData | ||
| .filter((item) => item.isIndeterminate) | ||
| .map((item) => item.data); | ||
| .filter((item) => item.isIndeterminate) | ||
| .map((item) => item.data); | ||
| }, | ||
@@ -261,3 +271,3 @@ // 设置选中节点 | ||
| item.checked = false; | ||
| if(vals.includes(item[this.nodeKey])) { | ||
| if (vals.includes(item[this.nodeKey])) { | ||
| this._changeBox(item); | ||
@@ -274,2 +284,4 @@ } | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange() | ||
| }, | ||
@@ -280,12 +292,3 @@ // 搜索 | ||
| }, | ||
| _allChange(value) { | ||
| this.listData.forEach((item) => { | ||
| item.checked = value; | ||
| }); | ||
| this.$emit( | ||
| "change", | ||
| this.selectedArr.map((item) => item[this.nodeKey]) | ||
| ); | ||
| }, | ||
| _nodeClick(data) { | ||
| _emitChange() { | ||
| if (this.multiple) { | ||
@@ -297,2 +300,17 @@ this.$emit( | ||
| } else { | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| }, | ||
| // 全选 | ||
| allChange(value) { | ||
| for (let index = 0; index < this.listData.length; index++) { | ||
| const item = this.listData[index]; | ||
| item.checked = value; | ||
| item.isIndeterminate = false; | ||
| } | ||
| this.key = Math.random(); | ||
| this._emitChange() | ||
| }, | ||
| _nodeClick(data) { | ||
| if (!this.multiple) { | ||
| if (this.selectedArr[0]) { | ||
@@ -302,4 +320,4 @@ this.selectedArr[0].checked = false; | ||
| data.checked = true; | ||
| this.$emit("change", this.selectedArr[0][this.nodeKey]); | ||
| } | ||
| this._emitChange() | ||
| }, | ||
@@ -544,3 +562,3 @@ _changeBox(item) { | ||
| // 选中默认 | ||
| if(this.selectedId && this.selectedId.length) { | ||
| if (this.selectedId && this.selectedId.length) { | ||
| this.setCheckedKeys(this.selectedId); | ||
@@ -547,0 +565,0 @@ } |
+4
-7
@@ -32,8 +32,5 @@ # v-tree-scroll | ||
| | props | \{ <br/>label: 'name', <br/> children: 'children' <br/>}(Object) | 默认数据级联结构 | | ||
| | filterNodeMethod | Null(Function) | 默认过滤函数 | | ||
| | defaultExpandAll | false(Boolean) | 是否默认展开 | | ||
| | showCheckbox | true (Boolean) | 是否显示选择框 | | ||
| | mutiple | true (Boolean) | 是否多选 | | ||
| | checkStrictly | false (Boolean) | 是否父子级不关联 | | ||
| | defaultCheckedKeys | \[](Array) | 默认选中节点 | | ||
| | filterNodeMethod | Null(Function) | 默认过滤函数 | | ||
@@ -44,9 +41,9 @@ ## 方法 | ||
| | ------------------ |:--------------: | | ||
| | doLayout() | 强制刷新布局 | | ||
| | getNode(key) | 获取指定节点 | | ||
| | getCheckedNodes(half) | 返回选中节点(half是否返回半选) | | ||
| | getCheckedKeys(half) | 返回选中节点key(half是否返回半选) | | ||
| | setCheckedKeys(keys, leafOnly) | 设置节点选中(keys 设置的节点key数组;leafOnly 只是改变状态不涉及逻辑) | | ||
| | setCheckedKeys(keys) | 设置节点选中(keys 设置的节点key数组) | | ||
| | clear() | 清空选中 | | ||
| | filter(value) | 过滤数据(需要配合filterNodeMethod使用) | | ||
| | filter(value) | 过滤数据 | | ||
| | allChange(value) | 全选数据 | | ||
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
Unpublished package
Supply chain riskPackage version was not found on the registry. It may exist on a different registry and need to be configured to pull from that registry.
Long strings
Supply chain riskContains long string literals, which may be a sign of obfuscated or packed code.
109167
1.02%2711
1.57%48
-5.88%