File tree 2 files changed +15
-11
lines changed 2 files changed +15
-11
lines changed Original file line number Diff line number Diff line change @@ -146,6 +146,19 @@ export default {
146
146
this .selcetRecursion (child, select, children)
147
147
})
148
148
}
149
+ },
150
+ updateTreeNode (item ) {
151
+ return new Promise (resolve => {
152
+ const { _id , _parent } = item
153
+ const index = _id .split (' -' ).slice (- 1 )[0 ] // get last index
154
+ if (_parent) {
155
+ _parent .children .splice (index, 1 , item)
156
+ resolve (this .data )
157
+ } else {
158
+ this .data .splice (index, 1 , item)
159
+ resolve (this .data )
160
+ }
161
+ })
149
162
}
150
163
}
151
164
}
Original file line number Diff line number Diff line change @@ -127,17 +127,8 @@ export default {
127
127
this .tempItem = Object .assign ({}, row)
128
128
this .dialogFormVisible = true
129
129
},
130
- updateItem () {
131
- const data = this .$refs .TreeTable .getData ()
132
- const { _id } = this .tempItem
133
-
134
- for (let i = 0 ; i < data .length ; i++ ) {
135
- if (data[i]._id === _id) {
136
- data .splice (i, 1 , Object .assign ({}, this .tempItem ))
137
- break
138
- }
139
- }
140
-
130
+ async updateItem () {
131
+ await this .$refs .TreeTable .updateTreeNode (this .tempItem )
141
132
this .dialogFormVisible = false
142
133
},
143
134
addMenuItem (row , type ) {
You can’t perform that action at this time.
0 commit comments