1
1
<template >
2
2
<div id =" app" >
3
- <Tree :tree-data =" demeData"
3
+ <Tree
4
+ :tree-data =" demeData"
4
5
expandedAll
5
6
show-checkbox
6
7
hasHalfelEction
@@ -35,6 +36,7 @@ export default {
35
36
},
36
37
data () {
37
38
return {
39
+ visible: true ,
38
40
baseData: [],
39
41
demeData: [
40
42
{
@@ -48,7 +50,7 @@ export default {
48
50
{
49
51
name: " 三级 1-1-1" ,
50
52
id: " 3" ,
51
- selected : true ,
53
+ checked : true ,
52
54
children: [
53
55
{
54
56
name: " 四级 1-1-1-1" ,
@@ -128,10 +130,25 @@ export default {
128
130
]
129
131
}
130
132
},
133
+ watch: {
134
+ visible: {
135
+ handler : function (val ) {
136
+ if (! val) {
137
+ this .genBaseData ()
138
+ } else {
139
+ this .genBaseData ()
140
+ }
141
+ }
142
+ }
143
+ },
131
144
created () {
132
145
this .genBaseData ()
146
+ console .log (this .baseData )
133
147
},
134
148
methods: {
149
+ toggleVisible () {
150
+ this .visible = ! this .visible
151
+ },
135
152
genBaseData () {
136
153
const start = Math .round (Math .random ())
137
154
const end = start + Math .round (Math .random () * 4 )
@@ -173,16 +190,88 @@ export default {
173
190
</style >
174
191
<style lang="less">
175
192
@transition-time : .2s ;
193
+ @primary-color : #409eff ;
194
+ @background-color-base : #F1F3F5 ;
195
+ @normal-color : #1F2E4D ;
196
+ @unimportance-color : #b7beca ;
197
+ @border-radius-small : 3px ;
198
+
199
+ .frame {
200
+ // position: absolute;
201
+ height : 300px ;
202
+ background : #eee ;
203
+
204
+ }
176
205
177
206
.icon {
178
207
display : inline-block ;
179
208
padding : 2px ;
180
209
font-size : 12px ;
181
- background : #eee ;
210
+ // background: #eee;
182
211
cursor : pointer ;
183
212
margin-right : 4px ;
184
213
}
185
214
215
+ .motion-common () {
216
+ animation-duration : .3s ;
217
+ animation-fill-mode : both ;
218
+ }
219
+
220
+ .move-motion (@className , @keyframeName ) {
221
+ .make-motion (@className , @keyframeName );
222
+ .@{className} -enter-active {
223
+ animation-timing-function : ease-in-out ;
224
+ }
225
+ .@{className} -leave-active {
226
+ animation-timing-function : ease-in-out ;
227
+ }
228
+ }
229
+
230
+ .make-motion (@className , @keyframeName ) {
231
+ .@{className} -enter-active {
232
+ .motion-common ();
233
+ animation-play-state : paused ;
234
+ }
235
+ .@{className} -leave-active {
236
+ .motion-common ();
237
+ animation-play-state : paused ;
238
+ }
239
+ .@{className} -enter-active {
240
+ animation-name : ~ " @{keyframeName} In" ;
241
+ animation-play-state : running ;
242
+ }
243
+ .@{className} -leave-active {
244
+ animation-name : ~ " @{keyframeName} Out" ;
245
+ animation-play-state : running ;
246
+ }
247
+ }
248
+
249
+ .move-motion (transition- drop, shTransitionDrop);
250
+
251
+ @keyframes shTransitionDropIn {
252
+ 0% {
253
+ opacity : 0 ;
254
+ transform : scaleY (0.8 );
255
+ }
256
+ 100% {
257
+ opacity : 1 ;
258
+ transform : scaleY (1 );
259
+ }
260
+ }
261
+
262
+ @keyframes shTransitionDropOut {
263
+ 0% {
264
+ opacity : 1 ;
265
+ transform : scaleY (1 );
266
+ }
267
+ 100% {
268
+ opacity : 0 ;
269
+ transform : scaleY (0.8 );
270
+ }
271
+ }
272
+
273
+
274
+
186
275
.rotate-motion (@className , @deg ) {
187
276
.transform {
188
277
transform-origin : center ;
@@ -222,4 +311,69 @@ export default {
222
311
color : #fff ;
223
312
}
224
313
}
314
+
315
+ .vue-tree {
316
+ user-select : none ;
317
+ position : relative ;
318
+ .drop-indicator {
319
+ position : absolute ;
320
+ left : 0 ;
321
+ right : 0 ;
322
+ height : 1px ;
323
+ background-color : @primary-color ;
324
+ }
325
+ .child-node {
326
+ padding-left : 22px ;
327
+ line-height : 28px ;
328
+ cursor : pointer ;
329
+ .node-content {
330
+ width : 100% ;
331
+ position : relative ;
332
+ display : inline-block ;
333
+ padding-left : 22px ;
334
+ .icon {
335
+ position : absolute ;
336
+ display : inline-block ;
337
+ left : 0px ;
338
+ &-expand {
339
+ color : @normal-color ;
340
+ }
341
+ &-unexpand {
342
+ color : @unimportance-color ;
343
+ }
344
+ }
345
+ .inner-wrap {
346
+ padding-left : 2px ;
347
+ display : flex ;
348
+ align-items : center ;
349
+ border-radius : @border-radius-small ;
350
+ border : 1px solid transparent ;
351
+ }
352
+ .drop-wrap {
353
+ border-color : @primary-color ;
354
+ }
355
+ .drop-inner {
356
+ border-bottom : 1px solid @primary-color ;
357
+ }
358
+ }
359
+ .active-li {
360
+ .inner-wrap {
361
+ background : @background-color-base ;
362
+ }
363
+ }
364
+ .inset {
365
+ cursor : move ;
366
+ }
367
+ .disabled {
368
+ cursor : no-drop ;
369
+ }
370
+ }
371
+ .add-node {
372
+ cursor : pointer ;
373
+ }
374
+ .is-drop-inner > .node-content > .inner-wrap > .node-name {
375
+ background-color : @primary-color ;
376
+ color : #fff ;
377
+ }
378
+ }
225
379
</style >
0 commit comments