จัดการผู้ใช้งาน => fix role

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-06-13 13:02:41 +07:00
parent 4ebad6fc60
commit baaa75f4da
5 changed files with 38 additions and 10 deletions

View file

@ -7,7 +7,10 @@ import config from "@/app.config";
/** importType*/
import type { QTableProps } from "quasar";
import type { ItemsMenu } from "@/modules/02_users/interface/index/Main";
import type {
ItemsMenu,
Pagination,
} from "@/modules/02_users/interface/index/Main";
import type { Users, Roles } from "@/modules/02_users/interface/response/Main";
/** importComponents*/
@ -84,7 +87,7 @@ const columns = ref<QTableProps["columns"]>([
headerStyle: "font-size: 14px",
style: "font-size: 14px",
field: (row) => {
const names = row.roles.map((role: Roles) => role.roleName);
const names = row.roles.map((role: Roles) => role.name);
return names.join(", ");
},
},
@ -138,9 +141,22 @@ function fetchListUsers() {
)
.then((res) => {
const data = res.data.data;
console.log(data);
total.value = res.data.total;
maxPage.value = Math.ceil(total.value / pageSize.value);
rows.value = data;
rows.value = data.map((e: Users) => ({
...e,
roles: e.roles.filter(
(e: Roles) =>
e.name === "STAFF" ||
e.name === "SUPER_ADMIN" ||
e.name === "ADMIN" ||
e.name === "USER"
),
}));
console.log(rows.value);
})
.catch((err) => {
messageError($q, err);
@ -199,7 +215,7 @@ function onDeleteUser(id: string) {
* function ปเดท paging
* @param initialPagination อม pagination
*/
async function updatePagination(initialPagination: any) {
async function updatePagination(initialPagination: Pagination) {
currentPage.value = 1;
pageSize.value = initialPagination.rowsPerPage;
}