修改loading

This commit is contained in:
shiziyuan9527 2020-02-19 15:15:53 +08:00
parent d3957e929e
commit 37001b2572
3 changed files with 12 additions and 128 deletions

View File

@ -1,114 +0,0 @@
<template>
<el-row>
<el-button type="text" @click="open">切换角色-{{ currentUserRole }}</el-button>
<el-dialog title="角色列表" :visible.sync="createVisible" width="30%">
<el-tree :data="userRoleList"
@node-click="handleNodeClick"
:props="defaultProps"
></el-tree>
<div style="text-align: center; margin-top: 20px;">
<el-button type="info" size="mini" class="ms-button" @click="closeDialog">取消</el-button>
<el-button type="primary" size="mini" style="margin-left: 50px;" @click="changeSubmit">保存</el-button>
</div>
</el-dialog>
</el-row>
</template>
<script>
import Cookies from "js-cookie"
import {TokenKey} from "../../common/constants"
export default {
name: "MsSwitchUser",
computed: {
currentUserRole() {
return this.userInfo.lastSourceId;
}
},
created() {
this.getUserRoleList();
this.getUserInfo();
},
data() {
return {
createVisible: false,
defaultProps: {
children: 'children',
label: 'switchInfo'
},
switchInfo: '',
userRoleList: [],
selectNode:[],
userInfo: {},
userId: JSON.parse(Cookies.get(TokenKey)).id
}
},
methods: {
open() {
this.createVisible = true;
},
getUserRoleList() {
this.$get('user/rolelist/' + this.userId).then(response => {
let roleList = response.data.data;
let newRoleList = [];
roleList.forEach(item => {
// item.current = item.id === this.userInfo.lastSourceId;
item.current = item.roleId;
if (item.current) {
if (item.name) {
item.switchInfo = item.name + " [" + item.desc + "]";
} else {
item.switchInfo = "MeterSphere[系统管理员]";
}
}
if (!item.parentId) {
item.hasChild = false;
item.children = [];
newRoleList.push(item);
} else {
newRoleList.forEach(userRole => {
if (userRole.id === item.parentId) {
userRole.children.push(item);
userRole.hasChild = true;
}
})
}
})
this.userRoleList = newRoleList;
})
},
closeDialog() {
this.createVisible = false;
},
switchRole(selectNode) {
if (!selectNode.switchable) {
return;
}
this.$post("user/switch/source/" + selectNode.roleId).then(() => {
this.getUserInfo();
// localStorage.setItem("lastSourceId", "bbbbb");
this.closeDialog();
});
localStorage.setItem("lastSourceId", selectNode.roleId);
window.location.reload();
},
changeSubmit() {
this.switchRole(this.selectNode);
},
handleNodeClick(data) {
this.selectNode = data;
window.console.log(data)
},
getUserInfo() {
this.$get("/user/info/" + this.userId).then(response => {
this.userInfo = response.data.data;
})
}
}
}
</script>
<style scoped>
</style>

View File

@ -1,5 +1,5 @@
<template>
<div v-loading="loading">
<div v-loading="result.loading">
<el-card>
<div slot="header">
@ -87,7 +87,7 @@
deletePath: '/organization/delete/',
createPath: '/organization/add',
updatePath: '/organization/update',
loading: false,
result: {},
createVisible: false,
updateVisible: false,
multipleSelection: [],
@ -133,7 +133,7 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$get(this.deletePath + row.id,() => {
this.result = this.$get(this.deletePath + row.id,() => {
this.$message({
type: 'success',
message: '删除成功!'
@ -150,7 +150,7 @@
createOrganization(createOrganizationForm) {
this.$refs[createOrganizationForm].validate( valide => {
if (valide) {
this.$post(this.createPath, this.form,() => {
this.result = this.$post(this.createPath, this.form,() => {
this.$message({
type: 'success',
message: '添加成功!'
@ -166,14 +166,13 @@
updateOrganization(udpateOrganizationForm) {
this.$refs[udpateOrganizationForm].validate(valide => {
if (valide) {
this.$post(this.updatePath, this.form,() => {
this.result = this.$post(this.updatePath, this.form,() => {
this.$message({
type: 'success',
message: '修改成功!'
});
this.updateVisible = false;
this.initTableData();
self.loading = false;
});
} else {
return false;
@ -181,7 +180,7 @@
})
},
initTableData() {
this.$post(this.buildPagePath(this.queryPath),{},response => {
this.result = this.$post(this.buildPagePath(this.queryPath),{},response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;

View File

@ -1,5 +1,5 @@
<template>
<div v-loading="loading">
<div v-loading="result.loading">
<el-card>
<div slot="header">
@ -115,7 +115,7 @@
deletePath: '/user/delete/',
createPath: '/user/add',
updatePath: '/user/update',
loading: false,
result: {},
createVisible: false,
updateVisible: false,
multipleSelection: [],
@ -180,7 +180,7 @@
cancelButtonText: '取消',
type: 'warning'
}).then(() => {
this.$get(this.deletePath + row.id, () => {
this.result = this.$get(this.deletePath + row.id, () => {
this.$message({
type: 'success',
message: '删除成功!'
@ -197,7 +197,7 @@
createUser(createUserForm) {
this.$refs[createUserForm].validate(valide => {
if (valide) {
this.$post(this.createPath, this.form, () => {
this.result = this.$post(this.createPath, this.form, () => {
this.$message({
type: 'success',
message: '添加成功!'
@ -213,14 +213,13 @@
updateUser(updateUserForm) {
this.$refs[updateUserForm].validate(valide => {
if (valide) {
this.$post(this.updatePath, this.form,() => {
this.result = this.$post(this.updatePath, this.form,() => {
this.$message({
type: 'success',
message: '修改成功!'
});
this.updateVisible = false;
this.initTableData();
self.loading = false;
});
} else {
return false;
@ -228,7 +227,7 @@
})
},
initTableData() {
this.$post(this.buildPagePath(this.queryPath),{},response => {
this.result = this.$post(this.buildPagePath(this.queryPath),{},response => {
let data = response.data;
this.total = data.itemCount;
this.tableData = data.listObject;