File tree Expand file tree Collapse file tree 2 files changed +15
-25
lines changed
Expand file tree Collapse file tree 2 files changed +15
-25
lines changed Original file line number Diff line number Diff line change @@ -141,11 +141,8 @@ export default {
141141 const dataOrr = {
142142 children : demeData
143143 }
144-
145-
146-
147-
148144 return {
145+ // isTree: true,
149146 dataMap : { } ,
150147 root : generateNode ( dataOrr )
151148
Original file line number Diff line number Diff line change @@ -11,6 +11,11 @@ export default {
1111 default : 0
1212 }
1313 } ,
14+ data ( ) {
15+ return {
16+ tree : { }
17+ }
18+ } ,
1419 // watch: {
1520 // 'node.data': {
1621 // handler: function(val) {
@@ -23,30 +28,18 @@ export default {
2328 // deep: true
2429 // }
2530 // },
31+ created ( ) {
32+ if ( this . $parent . $options . name === 'Tree' ) {
33+ this . tree = this . $parent
34+ } else {
35+ this . tree = this . $parent . tree
36+ }
37+ } ,
2638 methods : {
27- refreshUp ( { parent} ) {
28- if ( ! parent ) return
29- const toState = parent . isAllChildrenSelected ( )
30- // eslint-disable-next-line no-debugger
31- // debugger
32- Object . assign ( parent . data , { selected : toState , partialSelected : ! toState && parent . hasChildrenPartialSelected ( ) } )
33- this . refreshUp ( parent )
34- } ,
35- refreshDown ( node ) {
36- const toState = node . isSelected ( )
37- node ?. children . forEach ( ( child ) => {
38- const fromState = child . isSelected ( )
39- if ( fromState === toState ) {
40- return
41- }
42- Object . assign ( child . data , { selected : toState , partialSelected : false } )
43- this . refreshDown ( child )
44- } )
45- } ,
4639 selectToggle ( node ) {
4740 Object . assign ( node . data , { selected : ! node . isSelected ( ) , partialSelected : false } )
48- this . refreshUp ( node )
49- this . refreshDown ( node )
41+ this . tree . refreshUp ( node )
42+ this . tree . refreshDown ( node )
5043 } ,
5144 nodeView ( node , level ) {
5245 const { name, selected, disabled, partialSelected} = node ?. data ?? { }
You can’t perform that action at this time.
0 commit comments