增加数据、接口权限列表懒加载

dev
smallchill 6 years ago
parent f1ab538714
commit ab2ce14f6c
  1. 10
      src/api/system/menu.js
  2. 19
      src/views/authority/apiscope.vue
  3. 19
      src/views/authority/datascope.vue
  4. 2
      src/views/system/dept.vue
  5. 2
      src/views/system/menu.vue

@ -23,6 +23,16 @@ export const getLazyList = (parentId, params) => {
}) })
} }
export const getLazyMenuList = (parentId, params) => {
return request({
url: '/api/blade-system/menu/lazy-menu-list',
method: 'get',
params: {
...params,
parentId
}
})
}
export const getMenuList = (current, size, params) => { export const getMenuList = (current, size, params) => {
return request({ return request({

@ -16,7 +16,8 @@
@current-change="currentChange" @current-change="currentChange"
@size-change="sizeChange" @size-change="sizeChange"
@refresh-change="refreshChange" @refresh-change="refreshChange"
@on-load="onLoad"> @on-load="onLoad"
@tree-load="treeLoad">
<template slot-scope="{row}" slot="menu"> <template slot-scope="{row}" slot="menu">
<el-button type="text" <el-button type="text"
icon="el-icon-setting" icon="el-icon-setting"
@ -29,7 +30,7 @@
</template> </template>
<template slot-scope="{row}" slot="source"> <template slot-scope="{row}" slot="source">
<div style="text-align:center"> <div style="text-align:center">
<i :class="row.source"></i> <i :class="row.source"/>
</div> </div>
</template> </template>
</avue-crud> </avue-crud>
@ -75,7 +76,7 @@
add, add,
remove, remove,
update, update,
getMenuList, getLazyMenuList,
getMenu getMenu
} from "@/api/system/menu"; } from "@/api/system/menu";
import { import {
@ -95,6 +96,7 @@
selectionList: [], selectionList: [],
query: {}, query: {},
loading: true, loading: true,
parentId: 0,
page: { page: {
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
@ -107,6 +109,7 @@
scopeMenuName: "菜单", scopeMenuName: "菜单",
menu: true, menu: true,
option: { option: {
lazy: true,
tip: false, tip: false,
searchShow: true, searchShow: true,
searchMenuSpan: 6, searchMenuSpan: 6,
@ -440,10 +443,12 @@
}, },
searchReset() { searchReset() {
this.query = {}; this.query = {};
this.parentId = 0;
this.onLoad(this.page); this.onLoad(this.page);
}, },
searchChange(params, done) { searchChange(params, done) {
this.query = params; this.query = params;
this.parentId = '';
this.page.currentPage = 1; this.page.currentPage = 1;
this.onLoad(this.page, params); this.onLoad(this.page, params);
done(); done();
@ -496,12 +501,18 @@
}, },
onLoad(page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true;
getMenuList(page.currentPage, page.pageSize, params).then(res => { getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data; this.data = res.data.data;
this.loading = false; this.loading = false;
this.selectionClear(); this.selectionClear();
}); });
}, },
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyMenuList(parentId).then(res => {
resolve(res.data.data);
});
},
// //
handleDataScope(row) { handleDataScope(row) {
this.drawerVisible = true; this.drawerVisible = true;

@ -16,7 +16,8 @@
@current-change="currentChange" @current-change="currentChange"
@size-change="sizeChange" @size-change="sizeChange"
@refresh-change="refreshChange" @refresh-change="refreshChange"
@on-load="onLoad"> @on-load="onLoad"
@tree-load="treeLoad">
<template slot-scope="{row}" slot="menu"> <template slot-scope="{row}" slot="menu">
<el-button type="text" <el-button type="text"
icon="el-icon-setting" icon="el-icon-setting"
@ -29,7 +30,7 @@
</template> </template>
<template slot-scope="{row}" slot="source"> <template slot-scope="{row}" slot="source">
<div style="text-align:center"> <div style="text-align:center">
<i :class="row.source"></i> <i :class="row.source"/>
</div> </div>
</template> </template>
</avue-crud> </avue-crud>
@ -75,7 +76,7 @@
add, add,
remove, remove,
update, update,
getMenuList, getLazyMenuList,
getMenu getMenu
} from "@/api/system/menu"; } from "@/api/system/menu";
import { import {
@ -96,6 +97,7 @@
selectionList: [], selectionList: [],
query: {}, query: {},
loading: true, loading: true,
parentId: 0,
page: { page: {
pageSize: 10, pageSize: 10,
currentPage: 1, currentPage: 1,
@ -110,6 +112,7 @@
menu: true, menu: true,
watchMode: true, watchMode: true,
option: { option: {
lazy: true,
tip: false, tip: false,
searchShow: true, searchShow: true,
searchMenuSpan: 6, searchMenuSpan: 6,
@ -517,10 +520,12 @@
}, },
searchReset() { searchReset() {
this.query = {}; this.query = {};
this.parentId = 0;
this.onLoad(this.page); this.onLoad(this.page);
}, },
searchChange(params, done) { searchChange(params, done) {
this.query = params; this.query = params;
this.parentId = '';
this.page.currentPage = 1; this.page.currentPage = 1;
this.onLoad(this.page, params); this.onLoad(this.page, params);
done(); done();
@ -573,12 +578,18 @@
}, },
onLoad(page, params = {}) { onLoad(page, params = {}) {
this.loading = true; this.loading = true;
getMenuList(page.currentPage, page.pageSize, params).then(res => { getLazyMenuList(this.parentId, Object.assign(params, this.query)).then(res => {
this.data = res.data.data; this.data = res.data.data;
this.loading = false; this.loading = false;
this.selectionClear(); this.selectionClear();
}); });
}, },
treeLoad(tree, treeNode, resolve) {
const parentId = tree.id;
getLazyMenuList(parentId).then(res => {
resolve(res.data.data);
});
},
// //
handleDataScope(row) { handleDataScope(row) {
this.drawerVisible = true; this.drawerVisible = true;

@ -294,8 +294,8 @@
}, },
searchChange(params, done) { searchChange(params, done) {
this.query = params; this.query = params;
this.page.currentPage = 1;
this.parentId = ''; this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params); this.onLoad(this.page, params);
done(); done();
}, },

@ -263,8 +263,8 @@
}, },
searchChange(params, done) { searchChange(params, done) {
this.query = params; this.query = params;
this.page.currentPage = 1;
this.parentId = ''; this.parentId = '';
this.page.currentPage = 1;
this.onLoad(this.page, params); this.onLoad(this.page, params);
done(); done();
}, },

Loading…
Cancel
Save