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
-21
View File
@@ -1,21 +0,0 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useMenu = defineStore("menu", () => {
const listMenu = ref<any>([]);
const getMenu = async () => {
// await $fetch("http://10.10.150.131:8080/api/menu/getlist", {
await $fetch("/api/menu/listMenu", {
// mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
method:"GET",
})
.then((res) => {
listMenu.value = res
console.log(listMenu.value);
});
// return listMenu;
};
return { getMenu,listMenu };
});
-24
View File
@@ -1,24 +0,0 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useRoleMode = defineStore("roleMode", () => {
const typeUser = ref<any>([]);
const roleMenuById = ref<any>([]);
const getRoleMenuById = async (body: Record<string, any>) => {
typeUser.value = body;
// console.log(typeUser.value);
// await $fetch("http://10.10.150.131:8080/api/menu/getlist", {
await $fetch(`/api/roleMenu/roleMenu`, {
// mode: "no-cors",
headers: {
"Content-Type": "application/json",
},
method: "POST",
body: JSON.stringify(body),
}).then((res) => {
roleMenuById.value = res;
// console.log(roleMenuById.value);
});
// return roleMenuById;
};
return { getRoleMenuById, roleMenuById, typeUser };
});
+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};
})
-28
View File
@@ -1,28 +0,0 @@
import axios from 'axios'
import { defineStore } from 'pinia'
// export const useMySidebarStore = defineStore({
// id: 'mySidebarStore',
// state: () => ({ }),
// actions: {}
// })
export const useSidebarStore = defineStore('SidebarStore', () => {
const getSidebar = async () => {
console.log('aaaaa')
const res = await $fetch(`http://10.10.150.131:8080/api/login/6835632801e46cf9c5551876`, {
mode: 'no-cors',
headers: {
'Access-Control-Allow-Origin': '*',
Accept: 'application/json',
'Content-Type': 'application/json',
},
})
.then((response) => {
console.log(response)
})
}
return {
getSidebar
}
})
-23
View File
@@ -1,23 +0,0 @@
import { defineStore } from "pinia";
import axios from "axios";
export const useTypeUser = defineStore("typeUser", () => {
const listTypeUser = ref<any>([]);
const getTypeUser = async () => {
// await $fetch("http://10.10.150.131:8080/api/menu/type", {
await $fetch("/api/typeUser/listTypeUser", {
// mode: 'no-cors',
// headers: {
// 'Access-Control-Allow-Origin': '*',
// Accept: 'application/json',
// 'Content-Type': 'application/json',
// },
method:"GET",
})
.then((res) => {
listTypeUser.value = res
// console.log(listTypeUser.value);
});
// return listTypeUser;
};
return { getTypeUser,listTypeUser };
});