penambahan tabel pencarian, form tambah, form ubah
This commit is contained in:
138
stores/users.ts
138
stores/users.ts
@@ -1,4 +1,4 @@
|
||||
interface Subspesialis {
|
||||
interface ListSubspesialis {
|
||||
id: number;
|
||||
Kode: string;
|
||||
Subspesialis: string;
|
||||
@@ -6,30 +6,129 @@ interface Subspesialis {
|
||||
Spesialis: string;
|
||||
}
|
||||
|
||||
interface Surkon {
|
||||
idxdaftar:number;
|
||||
noSEP:string;
|
||||
kodeHFIS:number;
|
||||
id_dokter:string;
|
||||
kodePoli:string;
|
||||
subspesialis:string;
|
||||
tglRencanaKontrol:Date;
|
||||
user:string;
|
||||
kode_diagnosa:string;
|
||||
nama_diagnosa:string;
|
||||
tipe_surkon:number;
|
||||
tipe_rawat:string;
|
||||
}
|
||||
|
||||
interface data{
|
||||
Idx_daftar:number;
|
||||
Kode_dokter:number;
|
||||
Kode_dpjp:number;
|
||||
Kode_poli:string;
|
||||
}
|
||||
|
||||
export const useSubspesialisStore = defineStore("Subspesialises", () => {
|
||||
const subspesialis = ref<any[]>([]);
|
||||
const subspesialis_ = ref<any[]>([]);
|
||||
const subspesialis = reactive<ListSubspesialis[]>([]);
|
||||
const loadSubspesialis = async () => {
|
||||
try {
|
||||
subspesialis.value = await $fetch("/api/surkon/get");
|
||||
subspesialis_.value = await $fetch("/api/surkon/get");
|
||||
} catch (error) {
|
||||
console.error("Failed to load subspesialis:", error);
|
||||
}
|
||||
};
|
||||
|
||||
const loadSubspesialisData = async () => {
|
||||
try {
|
||||
const response = await $fetch("/api/subspesialis/get");
|
||||
subspesialis.push(...response);
|
||||
} catch (error) {
|
||||
console.error("Failed to load subspesialis:", error);
|
||||
}
|
||||
// console.log(payload)
|
||||
};
|
||||
// console.log(subspesialis)
|
||||
return {
|
||||
subspesialis,
|
||||
subspesialis_,
|
||||
loadSubspesialis,
|
||||
loadSubspesialisData,
|
||||
};
|
||||
});
|
||||
|
||||
export const useSubspesialisStorePost = defineStore("SuratKontrol", () => {
|
||||
// export const useSurkonStore = defineStore("Surkon", () => {
|
||||
// const subspesialis = ref<any[]>([]);
|
||||
// const loadSubspesialis = async () => {
|
||||
// try {
|
||||
// subspesialis.value = await $fetch("/api/surkon/get");
|
||||
// } catch (error) {
|
||||
// console.error("Failed to load subspesialis:", error);
|
||||
// }
|
||||
// };
|
||||
|
||||
// return {
|
||||
// subspesialis,
|
||||
// loadSubspesialis,
|
||||
// };
|
||||
// });
|
||||
|
||||
export const useSubspesialisStorePost = defineStore("SubspesialisProses", () => {
|
||||
// Create state for holding users
|
||||
const surkon = ref<any[]>([]);
|
||||
// const data_edit = ref<any[]>([]);
|
||||
const data_edit = ref<any>(null);
|
||||
const proses_edit = async (payload: Record<string, any>) => {
|
||||
// try {
|
||||
// surkon.value = await $fetch("/api/surkon/post", {
|
||||
// method: "POST",
|
||||
// headers: {
|
||||
// "Content-Type": "application/json",
|
||||
// },
|
||||
// body: JSON.stringify(payload)
|
||||
// });
|
||||
// } catch (error) {
|
||||
// console.error("Failed to load surkon:", error);
|
||||
// }
|
||||
// data_edit.value = [payload]
|
||||
data_edit.value = payload
|
||||
};
|
||||
|
||||
// Function to load user data
|
||||
/*const loadSurKon = async (payload: Record<string, any>) => {
|
||||
try {
|
||||
// console.log("APA INI")
|
||||
surkon.value = await $fetch("/api/surkon/post",{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
// body: JSON.stringify(payload._value)
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to load surkon:", error);
|
||||
}
|
||||
// console.log(payload)
|
||||
};*/
|
||||
|
||||
return {
|
||||
surkon,
|
||||
// loadSurKon,
|
||||
proses_edit,
|
||||
data_edit
|
||||
};
|
||||
});
|
||||
|
||||
export const useSurkonStorePost = defineStore("SuratKontrol", () => {
|
||||
// Create state for holding users
|
||||
const surkon = ref<any[]>([]);
|
||||
// const data_edit = ref<any[]>([]);
|
||||
const data_edit = ref<any>(null);
|
||||
|
||||
//tabel
|
||||
const loadSurKon = async (payload: Record<string, any>) => {
|
||||
try {
|
||||
surkon.value = await $fetch("/api/surkon/post", {
|
||||
surkon.value = await $fetch("/api/surkon/post2", {
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
@@ -41,9 +140,34 @@ export const useSubspesialisStorePost = defineStore("SuratKontrol", () => {
|
||||
}
|
||||
};
|
||||
|
||||
const proses_edit = async (payload: Record<string, any>) => {
|
||||
data_edit.value = payload
|
||||
};
|
||||
|
||||
// simpan
|
||||
const simpan_SurKon = async (payload: Record<string, any>) => {
|
||||
try {
|
||||
// console.log("APA INI")
|
||||
surkon.value = await $fetch("/api/surkon/post",{
|
||||
method: "POST",
|
||||
headers: {
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
// body: JSON.stringify(payload._value)
|
||||
body: JSON.stringify(payload)
|
||||
});
|
||||
} catch (error) {
|
||||
console.error("Failed to load surkon:", error);
|
||||
}
|
||||
// console.log(payload)
|
||||
};
|
||||
|
||||
return {
|
||||
surkon,
|
||||
data_edit,
|
||||
loadSurKon,
|
||||
simpan_SurKon,
|
||||
proses_edit,
|
||||
};
|
||||
});
|
||||
|
||||
@@ -52,4 +176,6 @@ if (import.meta.hot) {
|
||||
// import.meta.hot.accept(acceptHMRUpdate(useUsersStore, import.meta.hot))
|
||||
import.meta.hot.accept(acceptHMRUpdate(useSubspesialisStore, import.meta.hot));
|
||||
import.meta.hot.accept(acceptHMRUpdate(useSubspesialisStorePost, import.meta.hot));
|
||||
import.meta.hot.accept(acceptHMRUpdate(useSurkonStorePost, import.meta.hot));
|
||||
// import.meta.hot.accept(acceptHMRUpdate(useSurkonStore, import.meta.hot));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user