แก้ Popup ดูข้อมูลคำสั่งที่คลิกจากตำแหน่ง/เงินเดือนในทะเบียนประวัติ
This commit is contained in:
parent
78d033364d
commit
d44cc0d477
2 changed files with 24 additions and 61 deletions
|
|
@ -18,4 +18,7 @@ export default {
|
|||
`${command}/${tab}/recive/${commandReciveId}`,
|
||||
|
||||
checkIdofficer: `${env.API_URI}/org/profile/keycloak/idofficer`,
|
||||
|
||||
commandRegister:(id:string)=>`${command}/register-tab0/${id}`,
|
||||
commandRegisterByType:(id:string,type:string)=>`${command}/register-tab4/${type}/${id}`
|
||||
};
|
||||
|
|
|
|||
|
|
@ -24,22 +24,8 @@ const { showLoader, hideLoader, messageError } = useCounterMixin();
|
|||
const modal = defineModel<boolean>("modal", { required: true });
|
||||
const command = defineModel<string>("command", { required: true });
|
||||
const commandId = defineModel<string>("commandId", { required: true });
|
||||
|
||||
let formCommandList = reactive<FormDataDetail>({
|
||||
id: "",
|
||||
status: "",
|
||||
commandTypeName: "",
|
||||
commandNo: "",
|
||||
commandYear: null,
|
||||
detailHeader: "",
|
||||
detailBody: "",
|
||||
detailFooter: "",
|
||||
issue: null,
|
||||
commandAffectDate: null, //วันที่ลงนาม
|
||||
commandExcecuteDate: null, //วันที่คำสั่งมีผล
|
||||
commandSysId: "", // ประเภท คำสั่ง
|
||||
isAttachment: true,
|
||||
});
|
||||
const issue = ref<string | null>(null);
|
||||
const promises = ref<any>([]);
|
||||
|
||||
const tab = ref<string>("main"); //tab
|
||||
const page = ref<number>(1);
|
||||
|
|
@ -79,18 +65,14 @@ function getClass(val: boolean) {
|
|||
}
|
||||
|
||||
async function checkAttachment() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.commandAction(commandId.value, "tab0"))
|
||||
.get(config.API.commandRegister(commandId.value))
|
||||
.then(async (res) => {
|
||||
const data = res.data.result;
|
||||
isAttachment.value = data.isAttachment;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
if (isAttachment.value) {
|
||||
promises.value.push(fetchDataCommand("attachment"));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -102,14 +84,14 @@ async function downloadCover(type: string) {
|
|||
if (tab.value === "main") {
|
||||
genReport(
|
||||
dataCover.value,
|
||||
`คำสั่ง ${formCommandList.issue}`,
|
||||
`คำสั่ง ${issue.value}`,
|
||||
type,
|
||||
"?folder=command"
|
||||
);
|
||||
} else {
|
||||
genReportXLSX(
|
||||
dataAttachment.value,
|
||||
`เอกสารแนบท้าย ${formCommandList.issue}`,
|
||||
`เอกสารแนบท้าย ${issue.value}`,
|
||||
type,
|
||||
"?folder=command"
|
||||
);
|
||||
|
|
@ -122,18 +104,16 @@ async function downloadCover(type: string) {
|
|||
*/
|
||||
async function fetchDataCommand(type: string) {
|
||||
await http
|
||||
.get(config.API.commandAction(commandId.value, `tab4/${type}`))
|
||||
.get(config.API.commandRegisterByType(commandId.value, type))
|
||||
.then(async (res) => {
|
||||
const dataMain = await res.data.result;
|
||||
if (type === "cover") {
|
||||
dataCover.value = dataMain;
|
||||
issue.value = await res.data.result.data.commandTitle;
|
||||
await fetchPDF(dataCover.value);
|
||||
} else {
|
||||
dataAttachment.value = dataMain;
|
||||
}
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -164,41 +144,21 @@ async function fetchPDF(data: any, type: string = "docx?folder=command") {
|
|||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* ฟังก์ชันดึงข้อมูลรายละเอียดคำสั่ง
|
||||
*
|
||||
* กำหนดข้อมูลที่ได้รับมาให้กับตัวแปร `formData`
|
||||
*/
|
||||
async function fetchDataCommandList() {
|
||||
showLoader();
|
||||
await http
|
||||
.get(config.API.commandAction(commandId.value, "tab1"))
|
||||
.then(async (res) => {
|
||||
const data = await res.data.result;
|
||||
formCommandList = data;
|
||||
})
|
||||
.catch((err) => {
|
||||
messageError($q, err);
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
|
||||
watch(
|
||||
() => modal.value,
|
||||
async () => {
|
||||
if (modal.value) {
|
||||
await checkAttachment();
|
||||
await fetchDataCommandList();
|
||||
showLoader();
|
||||
const promises = [fetchDataCommand("cover")];
|
||||
if (isAttachment.value) {
|
||||
promises.push(fetchDataCommand("attachment"));
|
||||
}
|
||||
await Promise.all(promises).finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
promises.value = [checkAttachment(), fetchDataCommand("cover")];
|
||||
|
||||
await Promise.all(promises.value)
|
||||
.catch((e) => {
|
||||
messageError($q, e);
|
||||
hideLoader();
|
||||
})
|
||||
.finally(() => {
|
||||
hideLoader();
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
@ -221,7 +181,7 @@ watch(
|
|||
<template>
|
||||
<q-dialog v-model="modal" persistent>
|
||||
<q-card class="col-12" style="width: 80%">
|
||||
<DialogHeader :tittle="command" :close="closeDialog" />
|
||||
<DialogHeader :tittle="`คำสั่ง ${command}`" :close="closeDialog" />
|
||||
<q-separator />
|
||||
|
||||
<q-card-section>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue