zhangtao
laozt 1 year ago
parent e5a5d6e87d
commit 9d1823eda5

@ -8,6 +8,7 @@
<script> <script>
import ThemePicker from "@/components/ThemePicker"; import ThemePicker from "@/components/ThemePicker";
import { xzTree } from "@/api/yingji/keyEnterprise.js";
export default { export default {
name: "App", name: "App",
@ -27,6 +28,12 @@ export default {
}, },
}; };
}, },
created () {
//
xzTree().then((res) => {
localStorage.setItem("TREE_DATA",JSON.stringify(res.data))
});
},
}; };
</script> </script>
<style scoped> <style scoped>

@ -24,30 +24,28 @@ router.beforeEach((to, from, next) => {
if (store.getters.roles.length === 0) { if (store.getters.roles.length === 0) {
isRelogin.show = true; isRelogin.show = true;
// 判断当前用户是否已拉取完user_info信息 // 判断当前用户是否已拉取完user_info信息
store store.dispatch("GetInfo").then((res) => {
.dispatch("GetInfo") isRelogin.show = false;
.then((res) => { store.dispatch("GenerateRoutes").then((accessRoutes) => {
isRelogin.show = false; // 根据roles权限生成可访问的路由表
store.dispatch("GenerateRoutes").then((accessRoutes) => { // console.log(res);
// 根据roles权限生成可访问的路由表 router.addRoutes(accessRoutes); // 动态添加可访问路由表
// console.log(res); //刷新之后,要去的路由肯定是自己已经保存过的新路由
router.addRoutes(accessRoutes); // 动态添加可访问路由表 let refresh = "";
//刷新之后,要去的路由肯定是自己已经保存过的新路由 if (store.state.user.new1.indexOf(to.path) != -1) {
let refresh = ""; refresh = to.path;
if (store.state.user.new1.indexOf(to.path) != -1) { }
refresh = to.path; // console.log(to.path);
} //进入添加的第一个路由
// console.log(to.path); next({ path: refresh || res[0].path });
//进入添加的第一个路由
next({ path: refresh || res[0].path });
});
})
.catch((err) => {
store.dispatch("LogOut").then(() => {
Message.error(err);
next({ path: "/" });
});
}); });
});
// .catch((err) => {
// store.dispatch("LogOut").then(() => {
// Message.error(err);
// next({ path: "/" });
// });
// });
} else { } else {
if ( if (
store.state.user.old1.indexOf(to.path) != -1 && store.state.user.old1.indexOf(to.path) != -1 &&

@ -108,10 +108,13 @@ service.interceptors.response.use(
password: "admin@123Jichuang", password: "admin@123Jichuang",
}) })
.then((res) => { .then((res) => {
next("/home"); location.href = "/home";
}); });
} else { } else {
location.href = "/login?redirect=%2Findex"; //token过期重新登录跳转路由不需要提示
store.dispatch("LogOut").then(() => {
location.href = "/login?redirect=%2Findex";
});
} }
// if (!isRelogin.show) { // if (!isRelogin.show) {

@ -577,9 +577,10 @@ export default {
// //
async open(item, dept) { async open(item, dept) {
this.dialogVisible = true; this.dialogVisible = true;
// this.dept = dept // let data = await this.$api.yingji.tree();
let data = await this.$api.yingji.tree(); // this.district = data.data;
this.district = data.data; let treeData = JSON.parse(localStorage.getItem("TREE_DATA"))
this.district = treeData
this.commentData(this.district, dept); this.commentData(this.district, dept);
this.bPlanEnterprise(); this.bPlanEnterprise();
this.filtrate(); this.filtrate();

@ -198,8 +198,9 @@ export default {
}, },
// //
xzList() { xzList() {
xzTree().then((res) => { // xzTree().then((res) => {
res.data.forEach((value, index) => { let treeData = JSON.parse(localStorage.getItem("TREE_DATA"))
treeData.forEach((value, index) => {
this.areaData.push({ this.areaData.push({
value: value.subdistrict, value: value.subdistrict,
label: value.institutionName, label: value.institutionName,
@ -214,7 +215,7 @@ export default {
}); });
} }
}); });
}); // });
}, },
// //
componendDistrict(district) { componendDistrict(district) {

@ -260,8 +260,10 @@ export default {
} }
}, },
async getDistrict(){ async getDistrict(){
let data = await this.$api.yingji.tree(); // let data = await this.$api.yingji.tree();
this.district = data.data; // this.district = data.data;
let treeData = JSON.parse(localStorage.getItem("TREE_DATA"))
this.district = treeData
}, },
// //
componendDistrict(district){ componendDistrict(district){

@ -123,7 +123,7 @@ export default {
watch: { watch: {
$route: { $route: {
handler: function (route) { handler: function (route) {
console.log(route); // console.log(route);
this.redirect = route.query && route.query.redirect; this.redirect = route.query && route.query.redirect;
}, },
immediate: true, immediate: true,

@ -54,9 +54,10 @@ export default {
}, },
methods: { methods: {
xzList() { xzList() {
xzTree().then((res) => { // xzTree().then((res) => {
if (this.dept.parentId == 0 || this.dept.leader == "admin") { if (this.dept.parentId == 0 || this.dept.leader == "admin") {
res.data.forEach((value, index) => { let treeData = JSON.parse(localStorage.getItem("TREE_DATA"))
treeData.forEach((value, index) => {
this.compartment.push({ this.compartment.push({
value: value.subdistrict, value: value.subdistrict,
label: value.institutionName, label: value.institutionName,
@ -73,7 +74,7 @@ export default {
}); });
} }
this.$emit("quhuadizhi", this.compartment); this.$emit("quhuadizhi", this.compartment);
}); // });
}, },
getData(e) { getData(e) {
if (!this.none) { if (!this.none) {

@ -475,9 +475,12 @@ export default {
}, },
}, },
async created() { async created() {
let data = await this.$api.yingji.tree(); // let data = await this.$api.yingji.tree();
this.myDistrict = data.data; // this.myDistrict = data.data;
this.commentData(data.data, this.dept); let treeData = JSON.parse(localStorage.getItem("TREE_DATA"))
this.myDistrict = treeData
this.commentData(treeData, this.dept);
if (this.dept.ancestors.split(",").length == 1) { if (this.dept.ancestors.split(",").length == 1) {
this.getList(this.pages); this.getList(this.pages);
} }

Loading…
Cancel
Save