1414 </span >
1515 <span v-if =" data.children && data.children.length > 0" style =" margin-left :20% ;width : 15px ;" >
1616 <el-button text @click.stop =" append(data)" type =" success" >添加</el-button >
17- <el-button text @click.stop =" remove (data.id,data.sk,data.db,1,node, data)" type =" danger" >删除</el-button >
17+ <el-button text @click.stop =" removeData (data.id,data.sk,data.db,1,node, data)" type =" danger" >删除</el-button >
1818 </span >
1919 <span v-else-if =" data.id != 'nextpagegrmtag'" style =" margin-left :20% ;width : 15px ;" >
20- <el-button text @click.stop =" remove (data.id,data.sk,data.db,0,node, data)" type =" danger" >删除</el-button >
20+ <el-button text @click.stop =" removeData (data.id,data.sk,data.db,0,node, data)" type =" danger" >删除</el-button >
2121 <el-button text @click.stop =" detail(node.label,data.id,data.sk,data.db)" type =" primary" >查看</el-button >
2222 </span >
2323 <span v-else >
@@ -65,7 +65,36 @@ export default {
6565 datas .value = [... datas .value ]
6666 };
6767
68- const remove = (key ,sk ,db ,single ,node , data )=> {
68+ const remove = (node ,data ) => {
69+ let parent = node .parent
70+ if (! parent){
71+ parent = datas .value
72+ let index = parent .findIndex ((d ) => d .id === data .id )
73+ parent .splice (index, 1 )
74+ }else {
75+ // 只有一个层目录时
76+ while (parent .children .length == 1 ){
77+ if (! parent .parent ){
78+ data = parent .data
79+ parent = datas .value
80+ break
81+ }
82+ data = parent .data
83+ parent = parent .parent
84+ }
85+ if (parent .isLeaf == undefined ){
86+ let index = parent .findIndex ((d ) => d .id === data .id )
87+ parent .splice (index, 1 )
88+ }else {
89+ let children = parent .data .children || parent .data
90+ let index = children .findIndex ((d ) => d .id === data .id )
91+ children .splice (index, 1 )
92+ }
93+ }
94+ datas .value = [... datas .value ]
95+ }
96+
97+ const removeData = (key ,sk ,db ,single ,node , data )=> {
6998 delKeys ({
7099 id: key,
71100 sk: sk,
@@ -79,20 +108,10 @@ export default {
79108 type: ' success' ,
80109 })
81110
82- let parent = node .parent
83- if (! parent){
84- parent = datas .value
85- let index = parent .findIndex ((d ) => d .id === data .id )
86- parent .splice (index, 1 )
87- }else {
88- let children = parent .data .children || parent .data
89- let index = children .findIndex ((d ) => d .id === data .id )
90- children .splice (index, 1 )
91- }
92- datas .value = [... datas .value ]
111+ remove (node,data)
112+ store .commit (" delTagsItem" ,sk+ db)
93113 }
94114 })
95- store .commit (" delTagsItem" ,sk+ db)
96115 };
97116
98117 const detail = (key ,idk ,sk ,db )=> {
@@ -166,7 +185,6 @@ export default {
166185 }
167186
168187 const loadMore = ()=> {
169- console .log (" load more ..." )
170188 getKeys ({" index" : props .index ," match" : props .match ," cursor" : cursor .value }).then ((res ) => {
171189 datas .value .pop ()
172190 datas .value .push (... res .data .data )
@@ -182,11 +200,9 @@ export default {
182200 datas .value = res .data .data
183201 if (res .data .cursor != 0 ){
184202 cursor .value = res .data .cursor
185- document .getElementById (" page#" + props .index ).style .display = " block"
186- }else {
187- document .getElementById (" page#" + props .index ).style .display = " none"
188203 }
189204 count .value += res .data .count
205+ console .log (count .value )
190206 document .getElementById (" dbnum#" + props .index ).innerHTML = count .value ;
191207 })
192208
@@ -195,6 +211,7 @@ export default {
195211 return {
196212 append,
197213 remove,
214+ removeData,
198215 detail,
199216 loadMore,
200217 datas
0 commit comments