แก้เช็คและ loading สรรหา

This commit is contained in:
Warunee Tamkoo 2025-07-08 12:47:13 +07:00
parent d9f5661ac3
commit 8a87f084c9
6 changed files with 98 additions and 92 deletions

View file

@ -201,7 +201,7 @@ async function fetchData(actionType?: string) {
.finally(() => {
hideLoader();
if (actionType == "delete") {
success($q, "ลบข้อมูลการสอบสำเร็จ");
success($q, "ลบข้อมูลสำเร็จ");
}
});
}

View file

@ -127,32 +127,22 @@ async function fileRemoveDoc(files: any) {
/** อัพโหลด เอกสาร */
async function uploadDocData() {
const formData = new FormData();
if (fileDocDataUpload.value.length > 0) {
const formData = new FormData();
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodRecruitDoc(id.value), formData)
.then(() => {
success($q, "บันทึกข้อมูลสำเร็จ");
return true;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
setTimeout(async () => {
await clickBack();
}, 1200);
return false;
});
} else {
success($q, "บันทึกข้อมูลสำเร็จ");
setTimeout(async () => {
await clickBack();
}, 1200);
}
return true;
}
/** อัปโหลด รูปภาพ */
@ -162,17 +152,17 @@ async function uploadImgData() {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodRecruitImg(id.value), formData)
.then(() => {})
.then(() => {
return true;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
return false;
});
}
return true;
}
/** อัพโหลดไฟล์ immg */
@ -312,8 +302,12 @@ async function addData() {
.then(async (res) => {
const data = res.data.result;
id.value = data.id;
await uploadImgData();
await uploadDocData();
const imgUploadResult = await uploadImgData();
const docUploadResult = await uploadDocData();
if (imgUploadResult && docUploadResult) {
success($q, "บันทึกรอบสอบแข่งขันสำเร็จ");
await clickBack();
}
})
.catch((e) => {
messageError($q, e);
@ -332,8 +326,12 @@ async function editData(id: string) {
await http
.put(config.API.editPeriod(id), sendData())
.then(async () => {
await uploadImgData();
await uploadDocData();
const imgUploadResult = await uploadImgData();
const docUploadResult = await uploadDocData();
if (imgUploadResult && docUploadResult) {
success($q, "แก้ไขรอบสอบแข่งขันสำเร็จ");
await clickBack();
}
})
.catch((e) => {
messageError($q, e);

View file

@ -239,7 +239,7 @@ async function fetchData(actionType?: string) {
.finally(() => {
hideLoader();
if (actionType == "delete") {
success($q, "ลบข้อมูลการสอบสำเร็จ");
success($q, "ลบข้อมูลสำเร็จ");
}
});
}

View file

@ -170,12 +170,12 @@ async function addData() {
.then(async (res) => {
const data = res.data.result;
id.value = data;
await uploadImgData();
await uploadDocData();
success($q, "บันทึกรอบการสอบคนพิการสำเร็จ");
setTimeout(() => {
clickBack();
}, 1200);
const imgUpload = await uploadImgData();
const docUpload = await uploadDocData();
if (imgUpload && docUpload) {
success($q, "บันทึกรอบการสอบคัดเลือกคนพิการสำเร็จ");
await clickBack();
}
})
.catch((e) => {
messageError($q, e);
@ -194,9 +194,12 @@ async function editData(id: string) {
await http
.put(config.API.editDisablePeriod(id), sendData())
.then(async () => {
success($q, "แก้ไขรอบการสอบคนพิการสำเร็จ");
await uploadImgData();
await uploadDocData();
const imgUpload = await uploadImgData();
const docUpload = await uploadDocData();
if (imgUpload && docUpload) {
success($q, "แก้ไขรอบการสอบคัดเลือกคนพิการสำเร็จ");
await clickBack();
}
})
.catch((e) => {
messageError($q, e);
@ -238,17 +241,17 @@ async function uploadImgData() {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodExamImg(id.value), formData)
.then((res) => {})
.then(() => {
return true;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
return false;
});
}
return true;
}
/**
@ -316,24 +319,18 @@ async function uploadDocData() {
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodExamDoc(id.value), formData)
.then(() => {})
.then(() => {
return true;
})
.catch((e) => {
messageError($q, e);
})
.finally(async () => {
hideLoader();
setTimeout(() => {
clickBack();
}, 1200);
return false;
});
} else {
setTimeout(() => {
clickBack();
}, 1200);
}
return true;
}
/**

View file

@ -465,16 +465,19 @@ async function addData() {
.then(async (res) => {
const data = res.data.result;
id.value = data;
await uploadImgData();
await uploadDocData();
await uploadBarCodes();
await uploadQrCodes();
const uploadImg = await uploadImgData();
const uploadDoc = await uploadDocData();
const uploadBarCode = await uploadBarCodes();
const uploadQrCode = await uploadQrCodes();
hideLoader();
success($q, "บันทึกรอบคัดเลือกสำเร็จ");
setTimeout(async () => {
if (uploadImg && uploadDoc && uploadBarCode && uploadQrCode) {
success($q, "บันทึกรอบคัดเลือกสำเร็จ");
await clickBack();
}, 1200);
}
// setTimeout(async () => {
// await clickBack();
// }, 1200);
})
.catch((e) => {
messageError($q, e);
@ -492,16 +495,21 @@ async function editData(id: string) {
await http
.put(config.API.periodExamId(id), sendData())
.then(async () => {
await uploadImgData();
await uploadDocData();
await uploadBarCodes();
await uploadQrCodes();
const uploadImg = await uploadImgData();
const uploadDoc = await uploadDocData();
const uploadBarCode = await uploadBarCodes();
const uploadQrCode = await uploadQrCodes();
hideLoader();
success($q, "แก้ไขรอบคัดเลือกสำเร็จ");
setTimeout(async () => {
console.log(uploadImg, uploadDoc, uploadBarCode, uploadQrCode);
if (uploadImg && uploadDoc && uploadBarCode && uploadQrCode) {
success($q, "แก้ไขรอบคัดเลือกสำเร็จ");
await clickBack();
}, 1200);
}
// setTimeout(async () => {
// await clickBack();
// }, 1200);
})
.catch((e) => {
messageError($q, e);
@ -537,59 +545,60 @@ async function fileRemoveDoc(files: any) {
/** อัปโหลดไฟล์เอกสาร */
async function uploadDocData() {
const formData = new FormData();
if (fileDocDataUpload.value.length > 0) {
const formData = new FormData();
fileDocDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodExamDoc(id.value), formData)
.then((res) => {})
.catch((e) => {})
.finally(async () => {
hideLoader();
.then(() => {
return true;
})
.catch((e) => {
messageError($q, e);
return false;
});
}
return true;
}
/** อัปโหลดไฟล์เอกสาร */
async function uploadBarCodes() {
const formData = new FormData();
if (barCodes.value !== null) {
const formData = new FormData();
formData.append("", barCodes.value);
showLoader();
await http
.put(config.API.periodExambarcode(id.value), formData)
.then((res) => {
console.log(1);
.then(() => {
return true;
})
.catch((e) => {})
.finally(async () => {
hideLoader();
.catch((e) => {
messageError($q, e);
return false;
});
}
return true;
}
/** อัปโหลดไฟล์เอกสาร */
async function uploadQrCodes() {
const formData = new FormData();
if (qrCodes.value !== null) {
const formData = new FormData();
formData.append("", qrCodes.value);
showLoader();
await http
.put(config.API.periodExamqrcode(id.value), formData)
.then((res) => {
console.log(2);
.then(() => {
return true;
})
.catch((e) => {})
.finally(async () => {
hideLoader();
.catch((e) => {
messageError($q, e);
return false;
});
}
return true;
}
/**
@ -624,15 +633,17 @@ async function uploadImgData() {
fileImgDataUpload.value.forEach((file: any) => {
formData.append("", file);
});
showLoader();
await http
.put(config.API.periodExamImg(id.value), formData)
.then((res) => {})
.catch((e) => {})
.finally(async () => {
hideLoader();
.then(() => {
return true;
})
.catch((e) => {
messageError($q, e);
return false;
});
}
return true;
}
/**

View file

@ -396,7 +396,7 @@ onMounted(async () => {
@click="router.go(-1)"
/>
{{
`${name} ${round == null ? "" : 'ครั้งที่'+round+'/'}${
`${name} ${round == null ? "" : "ครั้งที่ " + round + "/"}${
yearly == null ? "" : yearly + 543
}`
}}