new loader

This commit is contained in:
Thanit Konmek 2023-06-09 14:25:41 +07:00
parent fd7aae2f5d
commit fe6c712a18
95 changed files with 1189 additions and 950 deletions

View file

@ -431,7 +431,14 @@ const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
const mixin = useCounterMixin();
const { success, modalConfirm, modalError, modalDelete } = mixin;
const {
success,
modalConfirm,
modalError,
modalDelete,
showLoader,
hideLoader,
} = mixin;
const { date2Thai } = mixin;
const store = useOrganizationalDataStore();
const { organizationalData, changeOrganizationalColumns } = store;
@ -809,7 +816,7 @@ watch(visibleColumns, async (count: String[], prevCount: String[]) => {
});
onMounted(async () => {
loaderPage(false);
hideLoader();
await fetchPosition();
await fetchData();
await fetchHistory();
@ -819,7 +826,7 @@ onMounted(async () => {
* งก get data าส
*/
const fetchData = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.getPostionMasterDraft(true))
.then((res) => {
@ -862,7 +869,7 @@ const fetchData = async () => {
})
.finally(() => {
// updateData.value = false;
loaderPage(false);
hideLoader();
});
};
@ -870,7 +877,7 @@ const fetchData = async () => {
* งชนดอมลประวแกไขขอมลทงหมด
*/
const fetchHistory = async () => {
// loaderPage(true);
// showLoader();
// await http
// .get(config.API.listxxxxxxxxPublishedHistory)
// .then((res) => {
@ -902,7 +909,7 @@ const fetchHistory = async () => {
// statusCode.value = e.response.data.status;
// })
// .finally(async () => {
// loaderPage(false);
// hideLoader();
// });
};
@ -910,7 +917,7 @@ const fetchHistory = async () => {
* get รายการ ตำแหน
*/
const fetchPosition = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.position)
.then((res) => {
@ -1001,7 +1008,7 @@ const fetchPosition = async () => {
})
.catch((e: any) => {})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -1150,7 +1157,7 @@ const clickSave = async () => {
*/
const saveData = async () => {
modal.value = false;
loaderPage(true);
showLoader();
await http
.post(config.API.getPositionMaster, {
positionTypeId: positionTypeId.value,
@ -1182,7 +1189,7 @@ const saveData = async () => {
*/
const editData = async () => {
modal.value = false;
loaderPage(true);
showLoader();
await http
.put(config.API.getPositionMasterId(positionMasterId.value), {
positionMasterId: positionMasterId.value,
@ -1215,7 +1222,7 @@ const editData = async () => {
* เมอเรยก api เสรจแลวจะ get data มาใหม
*/
const clearPublishedData = async () => {
loaderPage(true);
showLoader();
await http
.put(config.API.getPositionMasterSync)
.then((res) => {
@ -1228,7 +1235,7 @@ const clearPublishedData = async () => {
statusCode.value = e.response.data.status;
})
.finally(async () => {
loaderPage(false);
hideLoader();
await fetchHistory();
await fetchData();
});
@ -1240,7 +1247,7 @@ const clearPublishedData = async () => {
*/
const publishedData = async () => {
// editvisible.value = false;
loaderPage(true);
showLoader();
await http
.put(config.API.getPositionMasterPublish)
.then((res) => {
@ -1250,7 +1257,7 @@ const publishedData = async () => {
statusCode.value = e.response.data.status;
})
.finally(async () => {
loaderPage(false);
hideLoader();
await fetchData();
});
};
@ -1344,7 +1351,7 @@ const clickAdd = () => {
* @param row อม row ประวการแกไข
*/
const clickHistory = async (row: RequestItemsObject) => {
loaderPage(true);
showLoader();
await http
.get(config.API.getPositionMasterHistoryId(row.id))
.then((res) => {
@ -1387,7 +1394,7 @@ const clickHistory = async (row: RequestItemsObject) => {
})
.finally(async () => {
modalHistory.value = true;
loaderPage(false);
hideLoader();
});
};
@ -1430,7 +1437,7 @@ const clickIsActive = async (val: string, status: boolean) => {
})
.onOk(async () => {
// edit.value = false;
loaderPage(true);
showLoader();
await http
.delete(config.API.getPositionMasterId(val) + `?Id=${val}`)
.then((res) => {

View file

@ -240,10 +240,14 @@ import { useDataStore } from "@/stores/data";
import http from "@/plugins/http";
import config from "@/app.config";
import type { DataOption } from "../../interface/index/Main";
import { useCounterMixin } from "@/stores/mixin";
const ddNoResultMsg = defineAsyncComponent(
() => import("@/components/DropDownNoResultMsg.vue")
); // Dropdown Filter
const mixin = useCounterMixin();
const { showLoader, hideLoader } = mixin;
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
@ -286,12 +290,12 @@ const positionFilter = ref<Array<any>>([]); //for DropDown
const position = ref<Array<any>>([]); //for DropDown
onMounted(async () => {
loaderPage(false);
hideLoader();
await fetchPositionMaster();
});
const fetchPositionMaster = async () => {
loaderPage(true);
showLoader();
await http
// .get(config.API.getPostionMasterDraft(false))
.get(config.API.getPostionMaster(false))
@ -329,7 +333,7 @@ const fetchPositionMaster = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};

View file

@ -339,6 +339,8 @@ import type {
} from "../../interface/index/Main";
import { log } from "console";
import { useDataStore } from "@/stores/data";
import { useCounterMixin } from "@/stores/mixin";
// import { organizationSet } from "../interface/index/Main";
const props = defineProps({
@ -348,6 +350,8 @@ const props = defineProps({
const emit = defineEmits(["update:organizprops", "update:formprops"]);
const mixin = useCounterMixin();
const {showLoader, hideLoader } = mixin;
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const $q = useQuasar(); // show dialog
@ -386,7 +390,7 @@ const organizationAgencyCode = ref<GovermentOption[]>([]);
const organizationAgencyCodeFilter = ref<GovermentOption[]>([]);
onMounted(async () => {
loaderPage(false);
hideLoader();
await fetchOrganizationOri();
await fetchOrganizationAgencyCode();
await fetchOrganizationGovernmentCode();
@ -405,7 +409,7 @@ onMounted(async () => {
* หนวยงาน
*/
const fetchOrganizationOri = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organization)
.then((res) => {
@ -421,14 +425,14 @@ const fetchOrganizationOri = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* รหสหนวยงาน
*/
const fetchOrganizationAgencyCode = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationCode)
.then((res) => {
@ -450,14 +454,14 @@ const fetchOrganizationAgencyCode = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* รหสสวนราชการ
*/
const fetchOrganizationGovernmentCode = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationShortName)
.then((res) => {
@ -479,14 +483,14 @@ const fetchOrganizationGovernmentCode = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
// /**
// *
// */
// const fetchOrganizationShortName = async () => {
// loaderPage(true);
// showLoader();
// await http
// .get(config.API.organizationShortName)
// .then((res) => {
@ -508,14 +512,14 @@ const fetchOrganizationGovernmentCode = async () => {
// console.log(e);
// })
// .finally(() => {
// loaderPage(false);
// hideLoader();
// });
// };
/**
* หนวยงานตนสงก
*/
const fetchOrganizationAgency = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.listOrganizationAgency("หน่วยงาน"))
.then((res) => {
@ -534,14 +538,14 @@ const fetchOrganizationAgency = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* วนราชการตนสงก
*/
const fetchOrganizationGovernmentAgency = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.listOrganizationAgency("ส่วนราชการ"))
.then((res) => {
@ -560,14 +564,14 @@ const fetchOrganizationGovernmentAgency = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* ประเภทหนวยงาน
*/
const fetchOrganizationType = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationType)
.then((res) => {
@ -583,14 +587,14 @@ const fetchOrganizationType = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* ระดบหนวยงาน
*/
const fetchOrganizationLevel = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationLevel)
.then((res) => {
@ -606,14 +610,14 @@ const fetchOrganizationLevel = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรดตอภายใน
*/
const fetchOrganizationTelInternal = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationTelInternal)
.then((res) => {
@ -629,14 +633,14 @@ const fetchOrganizationTelInternal = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรดตอภายนอก
*/
const fetchOrganizationTelExternal = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationTelExternal)
.then((res) => {
@ -652,14 +656,14 @@ const fetchOrganizationTelExternal = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรโทรสาร
*/
const fetchOrganizationFax = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationFax)
.then((res) => {
@ -675,7 +679,7 @@ const fetchOrganizationFax = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -776,7 +780,7 @@ const addOrganizationItem = async () => {
const fetchAgencyCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
showLoader();
await http
.get(config.API.organizationGovernmentCode(val))
.then((res) => {
@ -796,14 +800,14 @@ const fetchAgencyCode = async (val: string, item: OrganizaOption) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
return option;
};
const fetchGovernmentCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
showLoader();
await http
.get(config.API.organizationAgencyCode(val))
.then((res) => {
@ -823,7 +827,7 @@ const fetchGovernmentCode = async (val: string, item: OrganizaOption) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
return option;
};

View file

@ -318,6 +318,7 @@ import { log } from "console";
import { useDataStore } from "@/stores/data";
import type { EnumStringMember } from "@babel/types";
// import { organizationSet } from "../interface/index/Main";
import { useCounterMixin } from "@/stores/mixin";
const props = defineProps({
organizprops: Object as PropType<OrganizaOption>,
@ -328,6 +329,8 @@ const props = defineProps({
},
});
const mixin = useCounterMixin();
const { showLoader, hideLoader } = mixin;
const dataStore = useDataStore();
const { loaderPage } = dataStore;
const emit = defineEmits(["update:organizprops", "update:formprops"]);
@ -397,7 +400,7 @@ const organization = ref<OrganizaOption>({
emit("update:organizprops", organization.value);
onMounted(async () => {
loaderPage(false);
hideLoader();
// await fillOrgEdit(); // selector(q-select)
await fetchOrganizationOri();
// await fetchOrganizationShortName();
@ -431,7 +434,7 @@ const getClass = (val: boolean) => {
* @param node node that you want to edit data
*/
const fillOrgEdit = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.getOrgDraft(props.org.organizationId))
.then((res) => {
@ -503,7 +506,7 @@ const fillOrgEdit = async () => {
console.log(e);
})
.finally(async () => {
loaderPage(false);
hideLoader();
});
console.log("success");
};
@ -512,7 +515,7 @@ const fillOrgEdit = async () => {
* หนวยงาน
*/
const fetchOrganizationOri = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organization)
.then((res) => {
@ -528,14 +531,14 @@ const fetchOrganizationOri = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* รหสหนวยงาน
*/
const fetchOrganizationAgencyCode = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationCode)
.then((res) => {
@ -557,14 +560,14 @@ const fetchOrganizationAgencyCode = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* รหสสวนราชการ
*/
const fetchOrganizationGovernmentCode = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationShortName)
.then((res) => {
@ -589,14 +592,14 @@ const fetchOrganizationGovernmentCode = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
// /**
// *
// */
// const fetchOrganizationShortName = async () => {
// loaderPage(true);
// showLoader();
// await http
// .get(config.API.organizationShortName)
// .then((res) => {
@ -618,14 +621,14 @@ const fetchOrganizationGovernmentCode = async () => {
// console.log(e);
// })
// .finally(() => {
// loaderPage(false);
// hideLoader();
// });
// };
/**
* หนวยงานตนสงก
*/
const fetchOrganizationAgency = async () => {
loaderPage(true);
showLoader();
await http
// .get(config.API.organizationAgency)
.get(config.API.listOrganizationAgency("หน่วยงาน"))
@ -645,14 +648,14 @@ const fetchOrganizationAgency = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* วนราชการตนสงก
*/
const fetchOrganizationGovernmentAgency = async () => {
loaderPage(true);
showLoader();
await http
// .get(config.API.organizationGovernmentAgency)
.get(config.API.listOrganizationAgency("ส่วนราชการ"))
@ -673,14 +676,14 @@ const fetchOrganizationGovernmentAgency = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* ประเภทหนวยงาน
*/
const fetchOrganizationType = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationType)
.then((res) => {
@ -696,7 +699,7 @@ const fetchOrganizationType = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -704,7 +707,7 @@ const fetchOrganizationType = async () => {
* สถานะหนวยงาน
*/
const fetchOrganizationStatus = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationStatus)
.then((res) => {
@ -720,7 +723,7 @@ const fetchOrganizationStatus = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
@ -728,7 +731,7 @@ const fetchOrganizationStatus = async () => {
* ระดบหนวยงาน
*/
const fetchOrganizationLevel = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationLevel)
.then((res) => {
@ -744,14 +747,14 @@ const fetchOrganizationLevel = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรดตอภายใน
*/
const fetchOrganizationTelInternal = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationTelInternal)
.then((res) => {
@ -767,14 +770,14 @@ const fetchOrganizationTelInternal = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรดตอภายนอก
*/
const fetchOrganizationTelExternal = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationTelExternal)
.then((res) => {
@ -790,14 +793,14 @@ const fetchOrganizationTelExternal = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
/**
* เบอรโทรสาร
*/
const fetchOrganizationFax = async () => {
loaderPage(true);
showLoader();
await http
.get(config.API.organizationFax)
.then((res) => {
@ -813,13 +816,13 @@ const fetchOrganizationFax = async () => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
};
const fetchAgencyCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
showLoader();
await http
.get(config.API.organizationGovernmentCode(val))
.then((res) => {
@ -839,14 +842,14 @@ const fetchAgencyCode = async (val: string, item: OrganizaOption) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
return option;
};
const fetchGovernmentCode = async (val: string, item: OrganizaOption) => {
let option: GovermentOption[] = [];
loaderPage(true);
showLoader();
await http
.get(config.API.organizationAgencyCode(val))
.then((res) => {
@ -866,7 +869,7 @@ const fetchGovernmentCode = async (val: string, item: OrganizaOption) => {
console.log(e);
})
.finally(() => {
loaderPage(false);
hideLoader();
});
return option;
};