เครื่องราช => ปรับการเรียกประเภทเครื่องราช

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2024-06-18 10:17:43 +07:00
parent 7041a9e050
commit 5a8f6d6434
9 changed files with 47 additions and 31 deletions

View file

@ -743,7 +743,6 @@ function clearInsigniaFilters(name: string) {
onMounted(async () => {
organizationOptions.value = await DataStore.optionsTypeOc;
organization.value = await DataStore.typeOc;
console.log(organization.value);
if (organization.value !== "" || organization.value !== undefined) {
if (props.fecthInsigniaByOc) {

View file

@ -63,7 +63,7 @@ async function fecthlistRound() {
DataStore.roundId = round.value;
roundName.value = lastValue.name;
await fecthStat(round.value);
await fecthAgency();
// await fecthAgency();
}
})
.catch((err) => {
@ -92,47 +92,59 @@ const fecthStat = async (id: string) => {
/** funcion เช็คหน่วยงาน*/
async function fecthAgency() {
showLoader();
await http
.get(config.API.insigniaAgency())
.get(config.API.keycloakPosition())
.then(async (res) => {
loadview.value = true;
DataStore.agency = res.data.result;
DataStore.agency = res.data.result.rootId;
DataStore.typeOc = DataStore.agency;
if (roleDataStore.adminRole) {
await fecthType(); //
} else {
}
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
loading.value = true;
hideLoader();
});
}
/** funcion เรียกหน่อยวงาน*/
async function fecthType() {
await http
.get(config.API.typeOc())
function fetchActiveId() {
http
.get(config.API.activeOrganization)
.then((res) => {
optiontypeOc.value = res.data.result.map((e: any) => ({
id: e.organizationId,
name: e.organizationName,
}));
DataStore.fetchOption(optiontypeOc.value); // DataStore
const data = res.data.result;
fetchListOrg(data.activeId);
})
.catch((err) => {
messageError($q, err);
});
}
function fetchListOrg(id: string) {
showLoader();
http
.get(config.API.orgByid(id))
.then(async (res) => {
const data = await res.data.result.map((item: any) => ({
id: item.orgTreeId,
name: item.orgName,
}));
optiontypeOc.value = data;
DataStore.fetchOption(optiontypeOc.value); // DataStore
fecthAgency();
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
hideLoader();
});
}
/**function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.get(config.API.insigniaOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchInsigniaType(data);
@ -397,6 +409,7 @@ async function uploadFile(event: any) {
onMounted(async () => {
tab.value = DataStore.mainTab;
await fecthlistRound();
await fetchActiveId();
DataStore.dataInsigniaType.length === 0 && (await fecthInsignia());
});
</script>
@ -652,13 +665,13 @@ onMounted(async () => {
<!-- popup หมายเหต -->
<DialogPopupReason
v-model:modal="modalPopupBackToEdit"
v-model:modal="modalPopupBackToEdit"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEdit"
/>
<DialogPopupReason
v-model:modal="modalbackInsignia2Role"
v-model:modal="modalbackInsignia2Role"
title="หมายเหตุการตีกลับ"
label="หมายเหตุ"
:savaForm="backToEditinsignia2Role"

View file

@ -134,7 +134,7 @@ async function fecthRound() {
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.get(config.API.insigniaOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsignia(data);
@ -151,7 +151,7 @@ async function fecthInsignia() {
/** function เรียก Tab*/
const fecthInsigniaType = async () => {
await http(config.API.insigniaType)
await http(config.API.insigniaTypeOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);

View file

@ -307,7 +307,7 @@ async function fecthRound() {
/** function เรียกประเภทเครื่องราชฯ*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.get(config.API.insigniaOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDataInsignia(data);
@ -324,7 +324,7 @@ async function fecthInsignia() {
/** function เรียกระดับเครื่องราชฯ Tab*/
async function fecthInsigniaType() {
await http(config.API.insigniaType)
await http(config.API.insigniaTypeOrg)
.then(async (res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);

View file

@ -23,7 +23,7 @@ export const useAllocateDataStore = defineStore("insigniaallocate", () => {
insigniaOp.value.push({
name: `${e.name} (${e.shortName})`,
id: e.id,
type: e.insigniaType.id,
type: e.insigniaTypeId,
});
});
data.forEach((e: any) => {

View file

@ -41,7 +41,7 @@ export const useBrrowDataStore = defineStore("insigniaBrrow", () => {
insigniaOp.value.push({
name: `${e.name} (${e.shortName})`,
id: e.id,
type: e.insigniaType.id,
type: e.insigniaTypeId,
});
});
data.forEach((e: any) => {

View file

@ -43,9 +43,10 @@ export const useResultDataStore = defineStore("insigniaResult", () => {
insigniaOp.value.push({
name: `${e.name} (${e.shortName})`,
id: e.id,
insigniaType: e.insigniaType.id,
insigniaType: e.insigniaTypeId,
});
});
data.forEach((e: any) => {
insigniaOp2.value.push({ name: `${e.name} (${e.shortName})`, id: e.id });
});

View file

@ -254,7 +254,7 @@ async function fecthRound() {
/** function เรียกประเภทเครื่องราช*/
async function fecthInsignia() {
await http
.get(config.API.insignia)
.get(config.API.insigniaOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsignia(data);
@ -266,7 +266,7 @@ async function fecthInsignia() {
/** function เรียกระดับเครื่องราช*/
async function fecthInsigniaType() {
await http(config.API.insigniaType)
await http(config.API.insigniaTypeOrg)
.then((res) => {
let data = res.data.result;
DataStore.fetchDatainsigniaType(data);
@ -299,6 +299,7 @@ watch(tab, () => {
if (tab.value !== "doc") {
DataStore.insignia = "";
fecthlistInsignia();
insigniaTypeOption.value = DataStore.insigniaOp.filter(
(e: any) => e.insigniaType == tab.value || e.name == "ทั้งหมด"
);