Skip to content

Commit

Permalink
暂存一次
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo committed Oct 5, 2018
1 parent d8146d4 commit d4bf983
Show file tree
Hide file tree
Showing 5 changed files with 136 additions and 118 deletions.
26 changes: 21 additions & 5 deletions src/api/system/menu.js
Original file line number Diff line number Diff line change
@@ -1,40 +1,56 @@
import fetch from '@/utils/fetch'
export function List(){
export function MenuList(){
return fetch({
url: '/menu/list',
method: 'post'
})
}

export function Delete(id){
export function MenuTree(){
return fetch({
url: '/menu/treelist',
method: 'post'
})
}

export function DeleteMenu(id){
return fetch({
url: '/menu/delete',
method: 'post',
params:{id}
})
}

export function Detail(id){
export function GetMenuDetail(id){
return fetch({
url: '/menu/detail',
method: 'post',
params:{id}
})
}

export function Add(data){
export function AddMenu(data){
return fetch({
url: '/menu/add',
method: 'post',
data
})
}

export function Update(data){
export function UpdateMenu(data){
return fetch({
url: '/menu/update',
method: 'post',
data
})
}

export function GetMenuTreeByRoleID(roleid){
return fetch({
url: '/menu/MenuTreeByRoleID',
method: 'post',
params:{
roleid
}
})
}
6 changes: 3 additions & 3 deletions src/api/system/users.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import fetch from '@/utils/fetch'
export function GetUsers(params){
export function UsersList(params){
return fetch({
url: '/users/list',
method: 'post',
params
})
}

export function DeleteUser(ID){
export function DeleteUsers(ID){
return fetch({
url: '/users/delete',
method: 'post',
Expand All @@ -23,7 +23,7 @@ export function GetUsersDetail(ID){
})
}

export function SaveNewUsers(data){
export function AddUsers(data){
return fetch({
url: '/users/add',
method: 'post',
Expand Down
20 changes: 10 additions & 10 deletions src/views/system/menu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -83,11 +83,11 @@

<script>
import {
List,
Delete,
Detail,
Add,
Update,
MenuList,
DeleteMenu,
GetMenuDetail,
AddMenu,
UpdateMenu,
} from "@/api/system/menu";
export default {
Expand Down Expand Up @@ -130,7 +130,7 @@
methods: {
fetchData() {
this.listLoading = true;
List().then(response => {
MenuList().then(response => {
this.list = response.data.list;
console.log(this.list)
this.listLoading = false;
Expand All @@ -149,7 +149,7 @@
type: "warning"
})
.then(() => {
Delete(id).then(()=>{
DeleteMenu(id).then(()=>{
this.fetchData()
})
})
Expand All @@ -158,7 +158,7 @@
Edit(id) {
this.dialogStatus = "update";
Detail(id).then(response => {
GetMenuDetail(id).then(response => {
this.dialogStatus = "update";
this.temp = response.data;
console.log(this.temp)
Expand All @@ -170,7 +170,7 @@
create() {
Add(this.temp).then(response => {
AddMenu(this.temp).then(response => {
this.dialogFormVisible = false;
this.fetchData();
Expand All @@ -179,7 +179,7 @@
},
update() {
Update(this.temp).then(response => {
UpdateMenu(this.temp).then(response => {
this.dialogFormVisible = false;
Expand Down
113 changes: 53 additions & 60 deletions src/views/system/role.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,15 @@

<script>
import {
GetRoles,
RoleList,
DeleteRole,
GetRoleDetail,
SaveNewRole,
AddRole,
UpdateRole
} from "@/api/system/role";
import { mapGetters } from "vuex";
} from "@/api/system/role"
import {GetMenuTreeByRoleID,MenuTree} from "@/api/system/menu"
import { mapGetters } from "vuex"
import store from '@/store'
export default {
data() {
Expand All @@ -92,7 +94,7 @@ export default {
rolename: "",
rank: "",
isdeleted: false,
roleauthname: null,
menulist: "",
},
menu: null,
listQuery: {
Expand All @@ -104,48 +106,45 @@ export default {
children: "children",
label: "title"
}
};
}
},
created() {
this.fetchData(this.listQuery);
this.fetchData(this.listQuery)
MenuTree().then(response=>{
this.menu=response.data.list
})
let arr = store.getters.routers;
for (let i = 0; i < arr.length; i++) {
if (arr[i].hidden) {
arr.splice(i--, 1);
}
}
console.log(arr)
this.menu = arr;
this.menu = arr
},
methods: {
handleSizeChange(val) {
this.listQuery.pageSize = val;
this.fetchData(this.listQuery);
this.listQuery.pageSize = val
this.fetchData(this.listQuery)
},
handleCurrentChange(val) {
this.listQuery.pageNumber = val;
this.fetchData(this.listQuery);
this.listQuery.pageNumber = val
this.fetchData(this.listQuery)
},
fetchData(params) {
this.listLoading = true;
GetRoles(params).then(response => {
this.list = response.data.list;
this.listLoading = true
RoleList(params).then(response => {
this.list = response.data.list
console.log(this.list)
this.listQuery.totalCount = parseInt(response.data.total)
this.listLoading = false;
});
this.listLoading = false
})
},
New() {
this.dialogFormVisible = true;
this.temp.rolename = "";
this.temp.rank = "";
this.temp.roleauthname = "";
this.dialogStatus = "create";
this.dialogFormVisible = true
this.temp.rolename = ""
this.temp.rank = ""
this.temp.menulist = ""
this.temp.id=""
this.$refs.tree.setCheckedKeys([]);
this.dialogStatus = "create"
},
Delete(id) {
this.$confirm("确认删除?", "提示", {
Expand All @@ -155,45 +154,39 @@ export default {
}).then(() => {
DeleteRole(id).then(response => {
this.fetchData(this.listQuery);
});
});
this.fetchData(this.listQuery)
})
})
},
Edit(id) {
this.dialogStatus = "update";
this.dialogStatus = "update"
GetRoleDetail(id).then(response => {
this.dialogStatus = "update";
this.temp = response.data;
console.log(response)
this.dialogFormVisible = true;
});
this.dialogStatus = "update"
this.temp = response.data
this.$refs.tree.setCheckedKeys([this.temp.menulist]);
this.dialogFormVisible = true
})
},
create() {
this.temp.roleauthname = this.$refs.tree.getCheckedKeys().join(",");
SaveNewRole(this.temp).then(response => {
// this.$message({
// message: response.data.message,
// type: "success"
// });
this.dialogFormVisible = false;
this.fetchData(this.listQuery);
});
this.temp.menulist = this.$refs.tree.getCheckedKeys().join(",")
AddRole(this.temp).then(response => {
this.dialogFormVisible = false
this.fetchData(this.listQuery)
})
},
update() {
this.temp.roleauthname = this.$refs.tree.getCheckedKeys().join(",");
this.temp.roleauthname = this.$refs.tree.getCheckedKeys().join(",")
UpdateRole(this.temp).then(response => {
// this.$message({
// message: response.data.data.message,
// type: "success"
// });
this.dialogFormVisible = false;
this.fetchData(this.listQuery);
});
this.dialogFormVisible = false
this.fetchData(this.listQuery)
})
}
}
};
}
</script>
Loading

0 comments on commit d4bf983

Please sign in to comment.