save roleMenuUser belum fix

This commit is contained in:
2025-06-07 12:46:53 +07:00
parent fe32e13ca4
commit 0cef51f13c
8 changed files with 110 additions and 181 deletions
+31 -9
View File
@@ -1,4 +1,5 @@
import {defineStore} from "pinia";
import type {RoleMenuUser} from "~/types/setting/RoleMenuUser";
export const useSettingStore = defineStore("SettingStore", () => {
const listMenu = ref<any>([]);
@@ -43,7 +44,7 @@ export const useSettingStore = defineStore("SettingStore", () => {
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
method:"GET",
method: "GET",
})
.then((res) => {
listTypeUser.value = res
@@ -51,15 +52,36 @@ export const useSettingStore = defineStore("SettingStore", () => {
};
const postRoleUserMenu = async (body: Record<string, any>) => {
console.log('asdasdasd',body)
await $fetch(`/api/setting/postRoleMenuUserMenu`, {
method:'POST',
headers:{'Content-Type': 'application/json'},
body:JSON.stringify(body)
// console.log('asdasdasd', body)
const roleUserMenu = body.menus.map((item) => ({
type_user_id: item.type_user_id,
menu_id: item.menu_id,
access: [
// item.access
{
add: parseInt(item.access[0].value),
update: parseInt(item.access[1].value),
read: parseInt(item.access[2].value),
delete: parseInt(item.access[3].value),
}
]
}))
{
}
console.log('role', roleUserMenu);
await $fetch(`/api/setting/postRoleMenuUser`, {
method: 'POST',
headers: {'Content-Type': 'application/json'},
body: JSON.stringify(roleUserMenu)
})
.then((res) => {console.log('success')})
.catch((err) => {console.log(err)})
.then((res) => {
console.log('success')
})
.catch((err) => {
console.log(err)
})
}
return {getMenu,getRoleMenuById,getTypeUser,postRoleUserMenu, listMenu,roleMenuById, typeUser,listTypeUser};
return {getMenu, getRoleMenuById, getTypeUser, postRoleUserMenu,typeUserSelected, listMenu, roleMenuById, typeUser, listTypeUser,listTypeUserSelected};
})