65 lines
1.7 KiB
TypeScript
65 lines
1.7 KiB
TypeScript
import {defineStore} from "pinia";
|
|
|
|
export const useSettingStore = defineStore("SettingStore", () => {
|
|
const listMenu = ref<any>([]);
|
|
const getMenu = async () => {
|
|
await $fetch("/api/menu/listMenu", {
|
|
// mode: "no-cors",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "GET",
|
|
})
|
|
.then((res) => {
|
|
listMenu.value = res
|
|
console.log(listMenu.value);
|
|
});
|
|
};
|
|
|
|
|
|
const typeUser = ref<any>([]);
|
|
const roleMenuById = ref<any>([]);
|
|
const getRoleMenuById = async (body: Record<string, any>) => {
|
|
typeUser.value = body;
|
|
|
|
await $fetch(`/api/roleMenu/roleMenu`, {
|
|
// mode: "no-cors",
|
|
headers: {
|
|
"Content-Type": "application/json",
|
|
},
|
|
method: "POST",
|
|
body: JSON.stringify(body),
|
|
}).then((res) => {
|
|
roleMenuById.value = res;
|
|
});
|
|
};
|
|
|
|
const listTypeUser = ref<any>([]);
|
|
const getTypeUser = async () => {
|
|
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
|
|
});
|
|
};
|
|
|
|
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)
|
|
})
|
|
.then((res) => {console.log('success')})
|
|
.catch((err) => {console.log(err)})
|
|
}
|
|
|
|
return {getMenu,getRoleMenuById,getTypeUser,postRoleUserMenu, listMenu,roleMenuById, typeUser,listTypeUser};
|
|
}) |