ทะเบียนประวัติ 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

@ -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 () => {