ปรับสิทธิ์
This commit is contained in:
parent
b356eef92f
commit
c8a9dbb259
3 changed files with 27 additions and 22 deletions
|
|
@ -5,6 +5,7 @@ import { useQuasar } from "quasar";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { setAuthen, authenticated, tokenParsed } from "@/plugins/auth";
|
||||
|
||||
import type { QTableProps } from "quasar";
|
||||
import type {
|
||||
|
|
@ -193,13 +194,13 @@ function fetchUserDetail(id: string) {
|
|||
function fetchlistRole() {
|
||||
http
|
||||
.get(config.API.managementRole)
|
||||
.then((res) => {
|
||||
roleOptions.value = res.data.filter(
|
||||
(e: Roles) =>
|
||||
e.name === "STAFF" ||
|
||||
e.name === "SUPER_ADMIN" ||
|
||||
e.name === "ADMIN" ||
|
||||
e.name === "USER"
|
||||
.then(async (res) => {
|
||||
const checkToken: any = await tokenParsed();
|
||||
const roleSuper = await checkToken.role.includes("SUPER_ADMIN");
|
||||
roleOptions.value = res.data.filter((e: Roles) =>
|
||||
roleSuper
|
||||
? ["STAFF", "SUPER_ADMIN", "ADMIN", "USER"].includes(e.name)
|
||||
: ["STAFF", "USER"].includes(e.name)
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ import { useQuasar } from "quasar";
|
|||
import http from "@/plugins/http";
|
||||
import config from "@/app.config";
|
||||
import { useCounterMixin } from "@/stores/mixin";
|
||||
import { setAuthen, authenticated, tokenParsed } from "@/plugins/auth";
|
||||
|
||||
import type { QTableProps } from "quasar";
|
||||
import type { Roles } from "@/modules/02_users/interface/request/Main";
|
||||
|
|
@ -25,6 +26,7 @@ const {
|
|||
|
||||
/** props*/
|
||||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const roleSuper = defineModel<boolean>("roleSuper", { required: true });
|
||||
const userId = defineModel<string>("userId", { required: true });
|
||||
const roles = defineModel<any[]>("roles");
|
||||
const props = defineProps({
|
||||
|
|
@ -69,13 +71,12 @@ function fetchlistRole() {
|
|||
.get(config.API.managementRole)
|
||||
.then((res) => {
|
||||
const rolesIds = roles.value?.map((e) => e.id);
|
||||
const item = roleSuper.value
|
||||
? ["USER", "ADMIN", "SUPER_ADMIN", "STAFF"]
|
||||
: ["USER", "STAFF"];
|
||||
|
||||
rows.value = res.data.filter(
|
||||
(v: Roles) =>
|
||||
!rolesIds?.includes(v.id) &&
|
||||
(v.name == "USER" ||
|
||||
v.name == "ADMIN" ||
|
||||
v.name == "SUPER_ADMIN" ||
|
||||
v.name == "STAFF")
|
||||
(v: Roles) => !rolesIds?.includes(v.id) && item.includes(v.name)
|
||||
);
|
||||
})
|
||||
.catch((err) => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue