Added delete record button and redefined stores/services

This commit is contained in:
2025-06-25 13:05:25 +02:00
parent d4724495e9
commit aedce50e6a
8 changed files with 190 additions and 116 deletions

View File

@@ -3,34 +3,47 @@ import { computed, ref } from 'vue';
import { KsDocumentService } from '../service/KsDocumentService';
import { LoadingStore } from './LoadingStore';
export const KsDocumentStore = defineStore('ksdocument_store', () => {
const lstKsDocument = ref([])
const selectedKsDocument = ref(null)
const loadingStore = LoadingStore()
const lstKsDocument = ref([]);
const selectedKsDocument = ref(null);
const loadingStore = LoadingStore();
async function fetchKsDocument() {
loadingStore.scenario_loading = true;
await KsDocumentService.getKsDocuments().then(resp => {
await KsDocumentService.getKsDocuments().then((resp) => {
lstKsDocument.value = resp.data;
loadingStore.scenario_loading = false;
});
}
const ksDocument = computed(() => {
return lstKsDocument.value
})
return lstKsDocument.value;
});
const getSelectedKsDocument = computed(() => {
return selectedKsDocument.value
})
return selectedKsDocument.value;
});
async function setSelectedKsDocument(ksDoc){
selectedKsDocument.value = ksDoc
console.log("selectedExecScenario", selectedKsDocument.value);
async function setSelectedKsDocument(ksDoc) {
selectedKsDocument.value = ksDoc;
console.log('selectedExecScenario', selectedKsDocument.value);
}
return { fetchKsDocument, selectedKsDocument, lstKsDocument, ksDocument, getSelectedKsDocument, setSelectedKsDocument}
})
async function deleteKsDocumentRecord(requestPayload) {
try {
const response = await KsDocumentService.deleteKsDocumentRecord(requestPayload);
return response;
} catch (error) {
throw error;
}
}
async function uploadKsDocument(formData, onUploadProgress) {
try {
const response = await KsDocumentService.uploadKsDocument(formData, onUploadProgress);
return response;
} catch (error) {
throw error;
}
}
return { fetchKsDocument, deleteKsDocumentRecord, uploadKsDocument, selectedKsDocument, lstKsDocument, ksDocument, getSelectedKsDocument, setSelectedKsDocument };
});