From ef10b5d3f2c4367e44de6245c5f4cf11228bc295 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期五, 26 五月 2023 16:32:08 +0800
Subject: [PATCH] 解决拉取地图缓慢问题
---
src/main/webapp/static/js/role/rolePower.js | 51 ++++++++++++++++++++++++++++-----------------------
1 files changed, 28 insertions(+), 23 deletions(-)
diff --git a/src/main/webapp/static/js/role/rolePower.js b/src/main/webapp/static/js/role/rolePower.js
index 7689621..f9b9979 100644
--- a/src/main/webapp/static/js/role/rolePower.js
+++ b/src/main/webapp/static/js/role/rolePower.js
@@ -13,23 +13,27 @@
isJump: true
});
- $.ajax({
- url: baseUrl+"/power/"+parent.roleId+"/auth",
- headers: {'token': localStorage.getItem('token')},
- method: 'GET',
- async: false,
- beforeSend: function () {
- },
- success: function (res) {
- if (res.code === 200){
- tree.setChecked('powerTree', res.data);
- } else if (res.code === 403){
- top.location.href = "/";
- } else {
- layer.msg(res.msg)
+ loadPower();
+ function loadPower(){
+ $.ajax({
+ url: baseUrl+"/power/"+parent.roleId+"/auth",
+ headers: {'token': localStorage.getItem('token')},
+ method: 'GET',
+ beforeSend: function () {
+ layer.load(1, {shade: [0.1,'#fff']});
+ },
+ success: function (res) {
+ if (res.code === 200){
+ tree.setChecked('powerTree', res.data);
+ } else if (res.code === 403){
+ top.location.href = baseUrl+"/";
+ } else {
+ layer.msg(res.msg)
+ }
+ layer.closeAll("loading");
}
- }
- });
+ });
+ }
// 鏁版嵁淇敼鍔ㄤ綔
form.on('submit(save)', function () {
@@ -37,11 +41,12 @@
var checkData = tree.getChecked('powerTree');
checkData.map(function (obj) {
obj.children.map(function (resource) {
-
var childrens = [];
- resource.children.map(function (resource) {
- childrens.push(resource.id);
- });
+ if (resource.children) {
+ resource.children.map(function (resource) {
+ childrens.push(resource.id);
+ });
+ }
var one = {
'two': resource.id,
'three': childrens
@@ -49,7 +54,6 @@
param.push(one);
})
});
- // console.log(JSON.stringify(param));
$.ajax({
url: baseUrl+"/power/auth",
traditional: true,
@@ -62,8 +66,9 @@
success: function (res) {
if (res.code === 200){
parent.layer.closeAll();
+ parent.layer.msg(res.msg);
} else if (res.code === 403){
- top.location.href = "/";
+ top.location.href = baseUrl+"/";
} else {
layer.msg(res.msg)
}
@@ -75,4 +80,4 @@
// 鍏抽棴鍔ㄤ綔
$(document).on('click','#data-detail-close', function () {
parent.layer.closeAll();
-});
\ No newline at end of file
+});
--
Gitblit v1.9.1