เครื่องราชฯ

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2023-09-19 14:58:16 +07:00
parent 8ebbef05d9
commit 1530da36cf
22 changed files with 159 additions and 777 deletions

View file

@ -27,7 +27,6 @@ const $q = useQuasar();
const DataStore = useInsigniaDataStore();
const roleDataStore = useroleUserDataStore();
const modalNote = ref<boolean>(false);
const modelPopupReject = ref<boolean>(false);
const modelPopupDelete = ref<boolean>(false);
const modalAdd = ref<boolean>(false);
@ -233,6 +232,7 @@ onMounted(async () => {
}
}
});
//
const checkStatus = computed(() => {
if (
roleDataStore.insignia1Role &&
@ -241,6 +241,7 @@ const checkStatus = computed(() => {
return true;
} else return false;
});
//
const changtypeOc = () => {
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(
@ -252,26 +253,14 @@ const changtypeOc = () => {
}
DataStore.typeOc = organization.value;
};
//
const clickmodalAdd = () => {
showLoader();
fecthlistRetire();
fecthInsignia();
fecthlistperson(DataStore.typeOc);
insigniaType.value = "";
};
// fecth profile
const fecthlistRetire = async () => {
await http
.get(config.API.profileOrganizRoot)
.then((res) => {
const id = res.data.result[0].id;
if (id !== "") {
fecthlistperson(id);
}
})
.catch((e) => {
messageError($q, e);
});
};
//
const fecthlistperson = async (id: string) => {
let data = [{}];
data = [
@ -295,10 +284,9 @@ const fecthlistperson = async (id: string) => {
position: e.position == null ? "-" : e.position,
level: e.positionEmployeeLevel == null ? "-" : e.positionEmployeeLevel,
organizationOrganization: e.oc == null ? "-" : e.oc,
ocId: DataStore.convertOcid(e.oc),
}));
modalAdd.value = true;
rows2.value = data.filter((e: any) => e.ocId === DataStore.typeOc);
rows2.value = data;
})
.catch((e) => {
messageError($q, e);
@ -307,6 +295,7 @@ const fecthlistperson = async (id: string) => {
hideLoader();
});
};
//
const clickAdd = async (id: string) => {
if (insigniaType.value !== "") {
dialogConfirm(
@ -319,7 +308,7 @@ const clickAdd = async (id: string) => {
);
} else dialogMessageNotify($q, "กรุณาเลือกรายชื่อขอพระราชทานเครื่องราชฯ");
};
//
const addlistperson = async (id: string) => {
showLoader();
let data = {
@ -348,14 +337,14 @@ const addlistperson = async (id: string) => {
hideLoader();
});
};
// POP
const clickmodalEdit = (props: any) => {
insignia.value = props.insigniaSend;
person.value = props;
modalEdit.value = true;
fecthInsignia();
};
// downloadfile
const downloadFile = (response: any, filename: string) => {
const link = document.createElement("a");
var fileName = filename;
@ -365,6 +354,7 @@ const downloadFile = (response: any, filename: string) => {
link.click();
document.body.removeChild(link);
};
// file
const downloadFileexcel = async () => {
showLoader();
await http
@ -378,35 +368,13 @@ const downloadFileexcel = async () => {
);
})
.catch((err) => {
console.log(err);
messageError($q, err);
})
.finally(() => {
hideLoader();
});
};
// const downloadReport = async (type: string = "pdf") => {
// showLoader();
// await http
// .get(config.API.reportInsignia("45", type, props.roundId!), {
// responseType: "blob",
// })
// .then(async (res) => {
// console.log(res);
// downloadFile(
// res,
// ` ${props.roundName}.${type}`
// );
// })
// .catch((e) => {
// messageError($q, e);
// })
// .finally(() => {
// hideLoader();
// });
// };
//
const clickSave = () => {
dialogConfirm(
$q,
@ -417,7 +385,7 @@ const clickSave = () => {
"ต้องการยืนยันการแก้ไขเครื่องราชฯ ที่ยื่นขอนี้หรือไม่ ?"
);
};
// API
const listEdit = async (profileId: string) => {
let data: any = {
insigniaId: insignia.value,
@ -442,11 +410,16 @@ const listEdit = async (profileId: string) => {
}
});
};
// POPUP
const clickReject = (id: string) => {
modelPopupReject.value = true;
rowid.value = id;
};
// POPUP
const closemodelPopupReject = () => {
modelPopupReject.value = false;
};
//
const savaReasonReject = (reason: string) => {
dialogConfirm(
$q,
@ -460,10 +433,7 @@ const savaReasonReject = (reason: string) => {
"ต้องการยืนยันการย้ายข้อมูลนี้หรือไม่ ?"
);
};
const closemodelPopupReject = () => {
modelPopupReject.value = false;
};
// API
const listreject = async (profileId: string, reason: string) => {
await http
.put(config.API.insigniaReject(profileId), { reason: reason })
@ -485,14 +455,16 @@ const listreject = async (profileId: string, reason: string) => {
await closemodelPopupReject();
});
};
// POPUP
const clickDelete = (id: string) => {
modelPopupDelete.value = true;
rowid.value = id;
};
// POPUP
const closemodelPopupDelete = () => {
modelPopupDelete.value = false;
};
//
const savaReasonDelete = (reason: string) => {
dialogConfirm(
$q,
@ -506,7 +478,7 @@ const savaReasonDelete = (reason: string) => {
"ต้องการยืนยันการลบข้อมูลนี้หรือไม่ ?"
);
};
// API
const listdelete = async (id: string, reason: string) => {
await http
.put(config.API.insigniaDelete(id), { reason: reason })
@ -532,7 +504,7 @@ const listdelete = async (id: string, reason: string) => {
const insignia = ref<string>("");
const insigniaOptions = ref<any>([]);
const insigniaType = ref<string>("");
//
const fecthInsignia = async () => {
await http
.get(config.API.insignia)
@ -662,30 +634,7 @@ const closeModalEdit = () => {
color="primary"
@click="downloadFileexcel"
>
<!-- @click="downloadReport('pdf')" -->
<q-tooltip>ดาวนโหลด</q-tooltip>
<!-- <q-menu>
<q-list style="min-width: 150px">
<q-item clickable v-close-popup @click="downloadReport('pdf')">
<q-item-section avatar
><q-icon color="red" name="mdi-file-pdf"
/></q-item-section>
<q-item-section>ไฟล .PDF</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadReport('docx')">
<q-item-section avatar
><q-icon color="blue" name="mdi-file-word"
/></q-item-section>
<q-item-section>ไฟล .docx</q-item-section>
</q-item>
<q-item clickable v-close-popup @click="downloadReport('xlsx')">
<q-item-section avatar
><q-icon color="green" name="mdi-file-excel"
/></q-item-section>
<q-item-section>ไฟล .xlsx</q-item-section>
</q-item>
</q-list>
</q-menu> -->
</q-btn>
<q-btn
size="12px"
@ -814,7 +763,7 @@ const closeModalEdit = () => {
<q-td key="dateSend" :props="props">
{{ props.row.dateSend }}
</q-td>
<q-td
auto-width
v-if="
@ -896,16 +845,16 @@ const closeModalEdit = () => {
</q-btn>
</q-td>
<q-td
auto-width
v-if="props.row.insigniaSend == 'เหรียญจักรพรรดิมาลา'"
>
<btnDownloadFile
:profileId="props.row.profileId"
:round="DataStore.roundId"
:optionRound="DataStore.optionRound"
/>
</q-td>
<q-td v-else auto-width></q-td>
auto-width
v-if="props.row.insigniaSend == 'เหรียญจักรพรรดิมาลา'"
>
<btnDownloadFile
:profileId="props.row.profileId"
:round="DataStore.roundId"
:optionRound="DataStore.optionRound"
/>
</q-td>
<q-td v-else auto-width></q-td>
</q-tr>
</template>
<template v-slot:pagination="scope">
@ -1087,6 +1036,7 @@ const closeModalEdit = () => {
</q-card>
</q-dialog>
<!-- popup เหตผลไมนขอ -->
<DialogPopupReason
:modal="modelPopupReject"
title="เหตุผลไม่ยื่นขอ"
@ -1094,6 +1044,7 @@ const closeModalEdit = () => {
:click-close="closemodelPopupReject"
:savaForm="savaReasonReject"
/>
<!-- เหตผลทลบออก -->
<DialogPopupReason
:modal="modelPopupDelete"
title="เหตุผลที่ลบออก"

View file

@ -161,7 +161,7 @@ onMounted(async () => {
}
}
});
//
const changtypeOc = () => {
if (props.fecthInsigniaByOc) {
props.fecthInsigniaByOc(

View file

@ -48,24 +48,18 @@ onMounted(async () => {
await fecthOrg();
DataStore.mainTab = props.tab;
});
watch(props, async () => {
if (props.tab === "organization") {
await fecthOrg();
}
});
//
const fecthOrg = async () => {
showLoader();
await http
.get(config.API.insigniaNosend(props.roundId))
.then((res) => {
console.log(res);
let data = res.data.result;
rows.value = data.map((e: any) => ({
orgId: e.orgId,
orgName: e.orgName,
}));
console.log(rows.value);
})
.catch((err) => {
messageError($q, err);

View file

@ -1,7 +1,6 @@
<script setup lang="ts">
import { onMounted, ref } from "vue";
import { useQuasar } from "quasar";
import { useRouter } from "vue-router";
import http from "@/plugins/http";
import config from "@/app.config";
@ -15,9 +14,6 @@ import tab2 from "@/modules/07_insignia/components/2_Manage/Tab2.vue";
import tab3 from "@/modules/07_insignia/components/2_Manage/Tab3.vue";
import tab4 from "@/modules/07_insignia/components/2_Manage/Tab4.vue";
import DialogPopupReason from "@/components/Dialogs/PopupReason.vue";
import keycloak from "@/plugins/keycloak";
const roleUser = ref<string>("admin");
const roleDataStore = useroleUserDataStore();
const DataStore = useInsigniaDataStore();
@ -39,12 +35,14 @@ const stat = ref<any>({
orgNoSendCount: 0,
orgSendCount: 0,
});
const modalPopupBackToEdit = ref<boolean>(false); //model
onMounted(async () => {
tab.value = DataStore.mainTab;
await fecthlistRound();
});
//
const fecthlistRound = async () => {
await http
.get(config.API.listRoundInsignia())
@ -54,13 +52,14 @@ const fecthlistRound = async () => {
year: e.period_year,
name: e.period_name,
}));
// UI
if (optionRound.value.length !== 0) {
DataStore.optionRound = optionRound.value;
const lastValue = optionRound.value[0];
if (DataStore.roundId) {
round.value = DataStore.roundId;
round.value = DataStore.roundId; //
} else {
round.value = lastValue.id.toString();
round.value = lastValue.id.toString(); //
}
DataStore.roundId = round.value;
roundName.value = lastValue.name;
@ -69,11 +68,11 @@ const fecthlistRound = async () => {
}
})
.catch((err) => {
console.log(err);
messageError($q, err);
});
};
// Stat
const fecthStat = async (id: string) => {
showLoader();
await http
@ -89,6 +88,7 @@ const fecthStat = async (id: string) => {
});
};
//
const fecthAgency = async () => {
showLoader();
await http
@ -97,11 +97,10 @@ const fecthAgency = async () => {
DataStore.agency = res.data.result;
loadview.value = true;
if (roleDataStore.adminRole) {
await fecthType();
await fecthType(); //
}
})
.catch((err) => {
console.log(err);
messageError($q, err);
})
.finally(() => {
@ -109,7 +108,7 @@ const fecthAgency = async () => {
hideLoader();
});
};
//
const fecthType = async () => {
await http
.get(config.API.typeOc())
@ -118,23 +117,21 @@ const fecthType = async () => {
id: e.organizationId,
name: e.organizationName,
}));
DataStore.fetchOption(optiontypeOc.value);
DataStore.fetchOption(optiontypeOc.value); // DataStore
})
.catch((err) => {
messageError($q, err);
})
.finally(() => {
// loading.value = true;
});
};
//
const changround = async () => {
DataStore.roundId = round.value;
fecthStat(round.value);
var organization = await (DataStore.agency != null
fecthStat(round.value); // Stat
var organization = await (DataStore.agency != null // agency agency Oc
? DataStore.agency
: DataStore.typeOc);
fecthInsigniaByOc(round.value, organization, "officer", tab.value);
fecthInsigniaByOc(round.value, organization, "officer", tab.value); //
// get round name
const roundFilter = await optionRound.value.find(
(x: any) => round.value === x.id
@ -145,6 +142,8 @@ const changround = async () => {
};
const requestNote = ref<string>("");
const requestStatus = ref<string>("");
//
const fecthInsigniaByOc = async (
roundId: string,
ocId: string,
@ -157,20 +156,15 @@ const fecthInsigniaByOc = async (
.then(async (res) => {
requestNote.value = res.data.result.requestNote;
requestStatus.value = res.data.result.requestStatus;
await DataStore.fetchData(res.data.result.items);
await DataStore.fetchDataInsignia(res.data.result);
await DataStore.fetchData(res.data.result.items); //
await DataStore.fetchDataInsignia(res.data.result); //
loading.value = true;
//
if (res.data.result.items !== null) {
if (res.data.result.items.length !== 0) {
hideBottom.value = true;
} else hideBottom.value = false;
}
// if (res.data.result.items.length !== 0) {
// hideBottom.value = true;
// }
// DataStore.isLock = await res.data.result.isLock;
// DataStore.requestId = await res.data.result.requestId;
})
.catch((err) => {
messageError($q, err);
@ -180,6 +174,7 @@ const fecthInsigniaByOc = async (
});
};
// requestStatus st1 st4
const sendToDirector = async () => {
dialogConfirm($q, async () => {
showLoader();
@ -203,15 +198,16 @@ const sendToDirector = async () => {
});
});
};
const modalPopupBackToEdit = ref<boolean>(false);
// popup
const popupBackToEdit = async () => {
modalPopupBackToEdit.value = true;
};
// popup
const closeModalPopupBackToEdit = async () => {
modalPopupBackToEdit.value = false;
};
// requestStatus st3 insignia2Role
const backToEdit = async (reason: string) => {
dialogConfirm(
$q,
@ -246,6 +242,7 @@ const backToEdit = async (reason: string) => {
);
};
// requestStatus st3 insignia2Role
const directorApproved = async () => {
dialogConfirm(
$q,
@ -274,7 +271,7 @@ const directorApproved = async () => {
"ต้องการยืนยันการอนุมัติใช่หรือไม่?"
);
};
//
const requestSendNote = async () => {
var organization = await (DataStore.agency != null
? DataStore.agency