ทะเบียนประวัติ fetch api

This commit is contained in:
Thanit Konmek 2023-06-15 17:22:20 +07:00
parent 67e0f695c1
commit 5fbfaa9a88
3 changed files with 42 additions and 40 deletions

View file

@ -210,8 +210,6 @@ const {
changeManageColumns,
getPrefix,
dataPrefix,
storeIdVersion,
storeVersion,
} = store;
const rows = ref<RequestItemsHistoryObject[]>(dataPrefix); //list data table
const rowsHistory = ref<RequestItemsHistoryObject[]>([]); //select data history

View file

@ -60,9 +60,9 @@ import Occupation from "@/modules/03_recruiting/components/Occupation.vue";
import Education from "@/modules/03_recruiting/components/Education.vue";
import Career from "@/modules/03_recruiting/components/Career.vue";
import Document from "@/modules/03_recruiting/components/Document.vue";
import { useDataStore } from "@/stores/data";
import { useQuasar } from "quasar";
import { useCounterMixin } from "@/stores/mixin";
import { useManageDataStore } from "@/modules/01_metadata/store";
const props = defineProps({
status: {
@ -88,8 +88,9 @@ const props = defineProps({
});
const $q = useQuasar();
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const store = useManageDataStore();
const { getPrefix } = store;
const prefixOptions = ref<DataOption[]>([]);
const relationshipOptions = ref<DataOption[]>([]);
const provinceOptions = ref<DataOption[]>([]);
@ -131,23 +132,15 @@ onMounted(() => {
});
const fetchPrefix = async () => {
showLoader();
await http
.get(config.API.prefix)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
prefixOptions.value = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
const result = await getPrefix(true, false);
const data = result.data;
let option: DataOption[] = [];
if (data.length > 0) {
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
}
prefixOptions.value = option;
};
const fetchRelationship = async () => {

View file

@ -774,6 +774,7 @@ import type {
import http from "@/plugins/http";
import config from "@/app.config";
import { useRoute } from "vue-router";
import { useManageDataStore } from "@/modules/01_metadata/store";
const props = defineProps({
statusEdit: {
@ -789,8 +790,8 @@ const emit = defineEmits(["update:statusEdit"]);
const route = useRoute();
const $q = useQuasar();
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const store = useManageDataStore();
const { getPrefix } = store;
const mixin = useCounterMixin();
const { date2Thai, success, messageError, showLoader, hideLoader } = mixin;
const edit = ref<boolean>(false);
@ -857,24 +858,34 @@ const refreshData = async () => {
};
const fetchPrefix = async () => {
showLoader();
await http
.get(config.API.prefix)
.then((res) => {
const data = res.data.result;
let option: DataOption[] = [];
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
Ops.value.prefixOps = option;
OpsFilter.value.prefixOps = option;
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
const result = await getPrefix(true, false);
const data = result.data;
let option: DataOption[] = [];
if (data.length > 0) {
data.map((r: any) => {
option.push({ id: r.id.toString(), name: r.name.toString() });
});
}
Ops.value.prefixOps = option;
OpsFilter.value.prefixOps = option;
// showLoader();
// await http
// .get(config.API.prefix)
// .then((res) => {
// const data = res.data.result;
// let option: DataOption[] = [];
// data.map((r: any) => {
// option.push({ id: r.id.toString(), name: r.name.toString() });
// });
// Ops.value.prefixOps = option;
// OpsFilter.value.prefixOps = option;
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
};
const addChildren = async () => {