จัดการบทบาทและสิทธิ์ => API
This commit is contained in:
parent
797d2015e7
commit
d90d4287c1
5 changed files with 224 additions and 1113 deletions
|
|
@ -1,12 +1,15 @@
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref } from "vue";
|
import { ref, watch } from "vue";
|
||||||
import { useQuasar } from "quasar";
|
import { useQuasar } from "quasar";
|
||||||
|
import http from "@/plugins/http";
|
||||||
|
import config from "@/app.config";
|
||||||
|
|
||||||
/** importComponents*/
|
/** importComponents*/
|
||||||
import DialogHeader from "@/components/DialogHeader.vue";
|
import DialogHeader from "@/components/DialogHeader.vue";
|
||||||
|
|
||||||
/** importType*/
|
/** importType*/
|
||||||
import type { QTableProps } from "quasar";
|
import type { QTableProps } from "quasar";
|
||||||
|
import type { Roles } from "@/modules/02_users/interface/response/Main";
|
||||||
import type { FilterReqMaster } from "@/modules/02_users/interface/request/Main";
|
import type { FilterReqMaster } from "@/modules/02_users/interface/request/Main";
|
||||||
|
|
||||||
/** importStore*/
|
/** importStore*/
|
||||||
|
|
@ -34,42 +37,61 @@ const props = defineProps({
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const rows = ref<any[]>([{ name: "ชื่อ", description: "คำอธิบาย" }]);
|
const rows = ref<Roles[]>([]);
|
||||||
const columns = ref<QTableProps["columns"]>([
|
const columns = ref<QTableProps["columns"]>([
|
||||||
{
|
{
|
||||||
name: "name",
|
name: "roleName",
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "ชื่อ",
|
label: "ชื่อ",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: "name",
|
field: "roleName",
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "roleDescription",
|
||||||
align: "left",
|
align: "left",
|
||||||
label: "คำอธิบาย",
|
label: "คำอธิบาย",
|
||||||
sortable: true,
|
sortable: true,
|
||||||
field: "description",
|
field: "roleDescription",
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
const visibleColumns = ref<string[]>(["name", "description"]);
|
const visibleColumns = ref<string[]>(["roleName", "roleDescription"]);
|
||||||
|
|
||||||
const keyword = ref<string>("");
|
const keyword = ref<string>("");
|
||||||
const selected = ref<any[]>([]);
|
const selected = ref<Roles[]>([]);
|
||||||
|
|
||||||
function closeDialog() {
|
function closeDialog() {
|
||||||
modal.value = false;
|
modal.value = false;
|
||||||
selected.value = [];
|
selected.value = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function fetchListRoles() {
|
||||||
|
showLoader();
|
||||||
|
http
|
||||||
|
.get(config.API.managementAuth + `/list`)
|
||||||
|
.then((res) => {
|
||||||
|
const data = res.data.result;
|
||||||
|
rows.value = data;
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
messageError($q, err);
|
||||||
|
})
|
||||||
|
.finally(() => {
|
||||||
|
hideLoader();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function onSubmit() {
|
function onSubmit() {
|
||||||
if (selected.value.length === 0) {
|
if (selected.value.length === 0) {
|
||||||
dialogMessageNotify($q, "กรุณาเลือกสิทธิ์อย่างน้อง 1 สิทธิ์");
|
dialogMessageNotify($q, "กรุณาเลือกสิทธิ์อย่างน้อง 1 สิทธิ์");
|
||||||
} else {
|
} else {
|
||||||
dialogConfirm($q, () => {
|
dialogConfirm($q, () => {
|
||||||
|
const arrayId = selected.value.map((e: Roles) => e.id);
|
||||||
|
console.log(arrayId);
|
||||||
|
|
||||||
showLoader();
|
showLoader();
|
||||||
closeDialog();
|
closeDialog();
|
||||||
props.fetchDataTable(
|
props.fetchDataTable(
|
||||||
|
|
@ -81,6 +103,13 @@ function onSubmit() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
watch(
|
||||||
|
() => modal.value,
|
||||||
|
() => {
|
||||||
|
modal.value && fetchListRoles();
|
||||||
|
}
|
||||||
|
);
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
||||||
|
|
@ -10,4 +10,46 @@ interface ItemsMenu {
|
||||||
type: string;
|
type: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { Pagination, ItemsMenu };
|
interface DataOption {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface SystemList {
|
||||||
|
attrIsCreate: boolean;
|
||||||
|
attrIsDelete: boolean;
|
||||||
|
attrIsGet: boolean;
|
||||||
|
attrIsList: boolean;
|
||||||
|
attrIsUpdate: boolean;
|
||||||
|
attrOwnership: string;
|
||||||
|
attrPrivilege: string;
|
||||||
|
id: string;
|
||||||
|
order: 1;
|
||||||
|
parentId: string | null;
|
||||||
|
selected: boolean;
|
||||||
|
sysDescription: string;
|
||||||
|
sysName: string;
|
||||||
|
children?: SystemList[];
|
||||||
|
}
|
||||||
|
|
||||||
|
interface DataSystem {
|
||||||
|
attrIsCreate: boolean;
|
||||||
|
attrIsDelete: boolean;
|
||||||
|
attrIsGet: boolean;
|
||||||
|
attrIsList: boolean;
|
||||||
|
attrIsUpdate: boolean;
|
||||||
|
attrOwnership: string;
|
||||||
|
attrPrivilege: string;
|
||||||
|
authRoleId: string;
|
||||||
|
authSysId: string;
|
||||||
|
createdAt: string;
|
||||||
|
createdFullName: string;
|
||||||
|
createdUserId: string;
|
||||||
|
id: string;
|
||||||
|
lastUpdateFullName: string;
|
||||||
|
lastUpdateUserId: string;
|
||||||
|
lastUpdatedAt: string;
|
||||||
|
parentNode: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { Pagination, ItemsMenu, DataOption, SystemList, DataSystem };
|
||||||
|
|
|
||||||
|
|
@ -99,4 +99,13 @@ interface Position {
|
||||||
positionName: string;
|
positionName: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type { Users, Roles, NodeTree, PosMaster, Position };
|
interface SysList {
|
||||||
|
id: string;
|
||||||
|
order: number;
|
||||||
|
parentId: string;
|
||||||
|
sysDescription: string;
|
||||||
|
sysName: string;
|
||||||
|
children: SysList[];
|
||||||
|
}
|
||||||
|
|
||||||
|
export type { Users, Roles, NodeTree, PosMaster, Position, SysList };
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,7 @@ const columns = ref<QTableProps["columns"]>([
|
||||||
headerStyle: "font-size: 14px",
|
headerStyle: "font-size: 14px",
|
||||||
style: "font-size: 14px",
|
style: "font-size: 14px",
|
||||||
field: (row) => {
|
field: (row) => {
|
||||||
const names = row.roles.map((role: Roles) => role.name);
|
const names = row.roles.map((role: Roles) => role.roleName);
|
||||||
return names.join(", ");
|
return names.join(", ");
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
|
||||||
File diff suppressed because it is too large
Load diff
Loading…
Add table
Add a link
Reference in a new issue