Files
apollo-fe/src/stores/KsDocumentStore.js

50 lines
1.7 KiB
JavaScript

import { defineStore } from 'pinia';
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();
async function fetchKsDocument() {
loadingStore.scenario_loading = true;
await KsDocumentService.getKsDocuments().then((resp) => {
lstKsDocument.value = resp.data;
loadingStore.scenario_loading = false;
});
}
const ksDocument = computed(() => {
return lstKsDocument.value;
});
const getSelectedKsDocument = computed(() => {
return selectedKsDocument.value;
});
async function setSelectedKsDocument(ksDoc) {
selectedKsDocument.value = ksDoc;
console.log('selectedExecScenario', selectedKsDocument.value);
}
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 };
});