@@ -176,37 +176,41 @@ export default {
176176 }
177177 },
178178 created () {
179- list ().then (res => {
180- const data = res .data
181- this .dataSource = listToTree (data, 0 )
182- const onlyMenuTree = listToTree (data .filter (x => x .type !== 2 ), 0 , (treeNode , item ) => {
183- // 为了使用 treeSelect 的自定义 titleSlot,这里必须删除掉 title 属性
184- // @see https://github.com/vueComponent/ant-design-vue/issues/2826
185- treeNode .titleName = treeNode .title
186- delete treeNode .title
187- treeNode .scopedSlots = { title: ' title' }
188- })
189- this .$set (this .nonButtonMenuTree [0 ], ' children' , onlyMenuTree);
190- })
179+ this .loadData ()
191180 },
192181 methods: {
193- reloadTable () {
182+ loadData () {
183+ this .loading = true
194184 list (this .queryParam ).then (res => {
195- this .dataSource = listToTree (res .data , 0 )
185+ const data = res .data
186+ this .dataSource = listToTree (data, 0 )
187+ const onlyMenuTree = listToTree (data .filter (x => x .type !== 2 ), 0 , (treeNode , item ) => {
188+ // 为了使用 treeSelect 的自定义 titleSlot,这里必须删除掉 title 属性
189+ // @see https://github.com/vueComponent/ant-design-vue/issues/2826
190+ treeNode .titleName = treeNode .title
191+ delete treeNode .title
192+ treeNode .scopedSlots = { title: ' title' }
193+ })
194+ this .$set (this .nonButtonMenuTree [0 ], ' children' , onlyMenuTree)
195+ }).finally (() => {
196+ this .loading = false
196197 })
197198 },
199+ reloadTable () {
200+ this .loadData ()
201+ },
198202 /**
199203 * 新建菜单权限
200204 */
201205 handleAdd (record ) {
202206 const attributes = { title: ' 新建菜单权限' }
203207 // 按钮类型不允许有子级,所以默认变成创建平级
204- if ( record ) {
208+ if ( record) {
205209 attributes .formData = {
206- parentId: record .type === 2 ? record .parentId : record .id ,
210+ parentId: record .type === 2 ? record .parentId : record .id ,
207211 type: record .type === 2 ? 2 : record .type + 1
208212 }
209- }else {
213+ } else {
210214 attributes .formData = {
211215 type: 0
212216 }
0 commit comments