mirror of
https://gitee.com/ccnetcore/Yi
synced 2026-04-14 21:26:36 +08:00
完善动态菜单、设置角色等功能,修复登录问题
This commit is contained in:
@@ -31,7 +31,8 @@ export default {
|
||||
axiosUrls: {
|
||||
},
|
||||
headers: [
|
||||
{ text: "编号", align: "start", value: "id" },
|
||||
// { text: "编号", align: "start", value: "id" },
|
||||
{ text: "角色编号", value: "roleCode", sortable: false },
|
||||
{ text: "角色名", value: "roleName", sortable: false },
|
||||
// { text: "云盘地址", value: "file_path", sortable: false },
|
||||
// { text: "简介", value: "introduce", sortable: false },
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
headers="设置角色"
|
||||
:items="roleItems"
|
||||
@select="getSelect"
|
||||
itemText="role_name"
|
||||
itemText="roleName"
|
||||
>
|
||||
<template v-slot:save>
|
||||
<v-btn @click="setRole" color="blue darken-1" text> 保存</v-btn>
|
||||
@@ -27,6 +27,7 @@
|
||||
</template>
|
||||
<script>
|
||||
import userApi from "../api/userApi";
|
||||
import roleApi from "../api/roleApi";
|
||||
export default {
|
||||
created() {
|
||||
this.init();
|
||||
@@ -59,8 +60,7 @@ export default {
|
||||
});
|
||||
},
|
||||
init() {
|
||||
|
||||
//这里可以遍历后台的菜单code,根据对应的菜单code来给axiosUrls的增删改查赋值即可
|
||||
//这里可以遍历后台的菜单code,根据对应的菜单code来给axiosUrls的增删改查赋值即可
|
||||
|
||||
this.axiosUrls = {
|
||||
get: "/user/GetList",
|
||||
@@ -69,9 +69,10 @@ export default {
|
||||
add: "/user/Add",
|
||||
};
|
||||
|
||||
// roleApi.getRole().then((resp) => {
|
||||
// this.roleItems = resp.data;
|
||||
// });
|
||||
roleApi.getList().then((resp) => {
|
||||
console.log(resp.data)
|
||||
this.roleItems=JSON.parse(JSON.stringify(resp.data));
|
||||
});
|
||||
},
|
||||
setRole() {
|
||||
var userIds = [];
|
||||
@@ -82,8 +83,8 @@ export default {
|
||||
this.select.forEach((item) => {
|
||||
roleIds.push(item.id);
|
||||
});
|
||||
userApi.SetRoleByUser(userIds, roleIds).then((resp) => {
|
||||
this.$dialog.notify.success(resp.msg, {
|
||||
userApi.GiveUserSetRole(userIds, roleIds).then((resp) => {
|
||||
this.$dialog.notify.success(resp.message, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
|
||||
@@ -52,7 +52,16 @@
|
||||
<a href="javascript:void(0)" class="mt-1"> 忘记密码? </a>
|
||||
</div>
|
||||
|
||||
<v-btn block color="primary" @click="login" class="mt-6" :loading="loader" :disabled="btn_dis"> 登录 </v-btn>
|
||||
<v-btn
|
||||
block
|
||||
color="primary"
|
||||
@click="login"
|
||||
class="mt-6"
|
||||
:loading="loader"
|
||||
:disabled="btn_dis"
|
||||
>
|
||||
登录
|
||||
</v-btn>
|
||||
</v-form>
|
||||
</v-card-text>
|
||||
|
||||
@@ -70,7 +79,7 @@
|
||||
</v-card-text>
|
||||
|
||||
<!-- social links -->
|
||||
<v-card-actions class="d-flex justify-center ">
|
||||
<v-card-actions class="d-flex justify-center">
|
||||
<v-btn v-for="link in socialLink" :key="link.icon" icon class="ms-1">
|
||||
<v-icon :color="$vuetify.theme.dark ? link.colorInDark : link.color">
|
||||
{{ link.icon }}
|
||||
@@ -81,11 +90,11 @@
|
||||
</template>
|
||||
<script>
|
||||
export default {
|
||||
created(){
|
||||
created() {
|
||||
this.enterSearch();
|
||||
},
|
||||
data: () => ({
|
||||
btn_dis:false,
|
||||
btn_dis: false,
|
||||
loader: null,
|
||||
socialLink: [
|
||||
{
|
||||
@@ -122,8 +131,7 @@ export default {
|
||||
},
|
||||
}),
|
||||
methods: {
|
||||
enterSearch() {
|
||||
|
||||
enterSearch() {
|
||||
document.onkeydown = (e) => {
|
||||
//13表示回车键,baseURI是当前页面的地址,为了更严谨,也可以加别的,可以打印e看一下
|
||||
if (e.keyCode === 13 && e.target.baseURI.match("/")) {
|
||||
@@ -133,20 +141,29 @@ export default {
|
||||
};
|
||||
},
|
||||
login() {
|
||||
this.loader = true;
|
||||
this.btn_dis=true;
|
||||
this.$store.dispatch("Login", this.form).then((resp) => {
|
||||
if (resp.status) {
|
||||
this.$router.push("/");
|
||||
} else {
|
||||
this.loader=null;
|
||||
this.btn_dis=false;
|
||||
this.$dialog.notify.error(resp.msg, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
});
|
||||
this.loader = true;
|
||||
this.btn_dis = true;
|
||||
this.$store
|
||||
.dispatch("Login", this.form)
|
||||
.then((resp) => {
|
||||
if (resp.status) {
|
||||
|
||||
this.$router.push("/");
|
||||
} else {
|
||||
|
||||
this.loader = null;
|
||||
this.btn_dis = false;
|
||||
this.$dialog.notify.error(resp.message, {
|
||||
position: "top-right",
|
||||
timeout: 5000,
|
||||
});
|
||||
}
|
||||
})
|
||||
.catch((error) => {
|
||||
|
||||
this.loader = false;
|
||||
this.btn_dis = false;
|
||||
});
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user