前端异步请求

This commit is contained in:
橙子
2021-10-24 15:50:31 +08:00
parent 3ce0355a79
commit 5d49ad55f7
4 changed files with 58 additions and 44 deletions

View File

@@ -32,4 +32,10 @@ export default {
method: 'get'
})
},
GetRouterByUserId(router) {
return myaxios({
url: `/User/GetRouterByUserId?router=${router}`,
method: 'get'
})
}
}

View File

@@ -1,28 +1,36 @@
<template>
<material-card color="primary" icon="mdi-account-outline">
<material-card color="primary" icon="mdi-account-outline">
<template #title>
接口管理 <small class="text-body-1">接口可被菜单拥有</small>
</template>
<ccTable :defaultItem="defaultItem" :headers="headers" :axiosUrls="axiosUrls" ></ccTable>
<ccTable
:defaultItem="defaultItem"
:headers="headers"
:axiosUrls="axiosUrls"
></ccTable>
</material-card>
</template>
<script>
import userApi from "../api/userApi"
export default {
data: () => ({
axiosUrls:{
get:"mould/getmould",
update:"mould/updatemould",
del:"mould/delListmould",
add:"mould/addmould"
created(){this.init()},
methods:{
init(){
userApi.GetRouterByUserId(this.$route.path).then(resp=>{
this.axiosUrls=resp.data;
}
}
},
data: () => ({
axiosUrls: {
},
headers: [
{text: "编号",align: "start",value: "id"},
{ text: "编号", align: "start", value: "id" },
{ text: "接口名", value: "mould_name", sortable: false },
{ text: "接口地址", value: "url", sortable: false },
{ text: "操作", value: "actions", sortable: false }
{ text: "操作", value: "actions", sortable: false },
],
defaultItem: {
defaultItem: {
mould_name: "test",
url: "test/test",
},

View File

@@ -12,21 +12,26 @@
</material-card>
</template>
<script>
import userApi from "../api/userApi"
export default {
created() {
this.init();
},
methods: {
init() {
userApi.GetRouterByUserId(this.$route.path).then(resp=>{
this.axiosUrls=resp.data;
})
}
},
data: () => ({
start: true,
axiosUrls: {
get: "role/getrole",
update: "role/updaterole",
del: "role/delListrole",
add: "role/addrole",
// get: "role/getrole",
// update: "role/updaterole",
// del: "role/delListrole",
// add: "role/addrole",
},
headers: [
{ text: "编号", align: "start", value: "id" },

View File

@@ -36,31 +36,31 @@ export default {
methods: {
async showItem(item) {
var strInfo = "";
userApi.GetRolesByUserId(item.id).then(async(resp)=>{
userApi.GetRolesByUserId(item.id).then(async (resp) => {
const roleData = resp.data;
strInfo += "拥有的角色:<br>";
roleData.forEach((u) => {
strInfo += u.role_name + "<br>";
});
const roleData=resp.data;
strInfo+="拥有的角色:<br>"
roleData.forEach(u=>{strInfo+=u.role_name+"<br>"})
strInfo += "<hr>";
Object.keys(item).forEach(async function (key) {
strInfo += key + ":" + item[key] + "<br>";
});
strInfo+="<hr>"
Object.keys(item).forEach(async function (key) {
strInfo += key + ":" + item[key] + "<br>";
await this.$dialog.confirm({
text: strInfo,
title: "信息详情",
actions: {
true: "关闭",
},
});
});
await this.$dialog.confirm({
text: strInfo,
title: "信息详情",
actions: {
true: "关闭",
},
});
})
},
init() {
userApi.GetRouterByUserId(this.$route.path).then((resp) => {
this.axiosUrls = resp.data;
});
roleApi.getRole().then((resp) => {
this.roleItems = resp.data;
});
@@ -93,12 +93,7 @@ strInfo+="<hr>"
TableSelect: [],
select: [],
roleItems: [],
axiosUrls: {
get: "user/getuser",
update: "user/updateuser",
del: "user/delListuser",
add: "user/adduser",
},
axiosUrls: {},
headers: [
{ text: "编号", align: "start", value: "id" },
{ text: "用户名", value: "username", sortable: false },
@@ -118,8 +113,8 @@ strInfo+="<hr>"
icon: "mdi-lock",
nick: "橙子",
age: 18,
address:"中国",
phone:""
address: "中国",
phone: "",
},
}),
};