diff --git a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue index cd6686ccc..8fc8a1551 100644 --- a/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue +++ b/src/modules/04_registryPerson/components/detail/Achievement/01_ProfessionalLicense.vue @@ -141,7 +141,6 @@ const baseVisibleColumns = ref([ "lastUpdateFullName", "lastUpdatedAt", ]); - const rows = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ const rowsMain = ref([]); //รายการใบอนุญาตประกอบวิชาชีพ const keyword = ref(""); //คำค้นหา @@ -154,7 +153,6 @@ const visibleColumns = ref( const pagination = ref({ sortBy: "lastUpdatedAt", }); - //Table ประวัติแก้ไขใบอนุญาตประกอบวิชาชีพ const historyId = ref(""); const columnsHistory = ref(baseColumns.value); @@ -169,10 +167,10 @@ const profesLicenseData = reactive({ profileId: id.value, }); -const fileGroup = ref("เอกสารใบอนุญาตประกอบวิชาชีพ"); -const fileUpload = ref(null); -const fileData = ref(null); -const isUpload = ref(false); +const fileGroup = ref("เอกสารใบอนุญาตประกอบวิชาชีพ"); //กลุ่มไฟล์ +const fileUpload = ref(null); //ไฟล์อัพโหล +const fileData = ref(null); //ข้อมูลไฟล์ +const isUpload = ref(false); //สถานะการอัพโหล /** ยืนยันการบันทึกข้อมูล*/ function onSubmit() { @@ -193,6 +191,7 @@ function onSubmit() { ...profesLicenseData, issueDate: convertDateToAPI(profesLicenseData.issueDate), expireDate: convertDateToAPI(profesLicenseData.expireDate), + isUpload: !isEdit ? undefined : isUpload.value, profileId: isEdit ? undefined : empType.value === "" @@ -209,6 +208,7 @@ function onSubmit() { const isId = isEdit ? editId.value : res.data.result; await uploadfile(isId); } + await fetchData(id.value); success($q, "บันทึกข้อมูลสำเร็จ"); closeDialog(); @@ -225,21 +225,44 @@ function onSubmit() { ); } +/** + * ฟังก์ชันอัพโหลไฟล์ + * @param subId id รายการที่อัพโหลไฟล์ + */ async function uploadfile(subId: string) { try { + //สร้าง Path url อัพโหลด const uploadUrl = await createPathUploadFlie( fileGroup.value, id.value, subId ); + //อัพโหลไฟล์ await uploadFile(uploadUrl, fileUpload.value); - fileUpload.value = null; + await updateIsUpload(); } catch (err) { messageError($q, err); } } +/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/ +async function updateIsUpload() { + await http + .patch( + config.API.profileNewCertificateByCertificateId( + editId.value, + empType.value + ), + { + isUpload: fileUpload.value ? true : false, + } + ) + .then(() => { + fileUpload.value = null; + }); +} + /** fetch ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ*/ async function fetchData(id: string) { showLoader(); @@ -295,6 +318,10 @@ async function editForm(row: ResponseObject) { } } +/** + * ฟังก์ชันดูประวัติการแก้ไขข้อมูล + * @param id รายการที่ต้องการดูประวัติการแก้ไข + */ function onViewHistory(id: string) { historyId.value = id; historyDialog.value = true; @@ -318,11 +345,16 @@ async function fetchDataHistory() { } } +/** + * ฟังก์ชันโหลดไฟล์ + * @param subId id รายการที่ต้องการโหลดไฟล์ + */ async function onDownloadFile(subId: string) { const data = await getPathUploadFlie(fileGroup.value, id.value, subId); window.open(data.downloadUrl, "_blank"); } +/** ฟังก์ชันค้นหาข้อมูลในตาราง*/ function serchDataTable() { rows.value = onSearchDataTable( keyword.value, diff --git a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue b/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue index ee7050cf3..b754ac899 100644 --- a/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue +++ b/src/modules/04_registryPerson/components/detail/GovernmentInformation/02_Discipline.vue @@ -350,6 +350,7 @@ function onSubmit() { ...disciplineData, date: convertDateToAPI(disciplineData.date), refCommandDate: convertDateToAPI(disciplineData.refCommandDate), + isUpload: !edit.value ? undefined : isUpload.value, profileId: edit.value ? undefined : empType.value === "" @@ -384,21 +385,45 @@ function onSubmit() { ); } +/** + * ฟังก์ชันอัพโหลไฟล์ + * @param id id รายการที่อัพโหลไฟล์ + */ async function uploadfile(id: string) { try { + //สร้าง Path url อัพโหลด const uploadUrl = await createPathUploadFlie( fileGroup.value, profileId.value, id ); + //อัพโหลไฟล์ await uploadFile(uploadUrl, fileUpload.value); - fileUpload.value = null; + await updateIsUpload(); } catch (err) { messageError($q, err); } } +/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/ +async function updateIsUpload() { + await http + .patch( + config.API.profileNewDisciplineByDisciplineId(id.value, empType.value), + { + isUpload: fileUpload.value ? true : false, + } + ) + .then(() => { + fileUpload.value = null; + }); +} + +/** + * ฟังก์ชันโหลดไฟล์ + * @param id id รายการที่ต้องการโหลดไฟล์ + */ async function onDownloadFile(id: string) { const data = await getPathUploadFlie(fileGroup.value, profileId.value, id); window.open(data.downloadUrl, "_blank"); diff --git a/src/modules/04_registryPerson/components/detail/Salary/02_NotReceiveSalary.vue b/src/modules/04_registryPerson/components/detail/Salary/02_NotReceiveSalary.vue index 26d051470..51ecd7408 100644 --- a/src/modules/04_registryPerson/components/detail/Salary/02_NotReceiveSalary.vue +++ b/src/modules/04_registryPerson/components/detail/Salary/02_NotReceiveSalary.vue @@ -185,6 +185,7 @@ function onSubmit() { ...formData, date: convertDateToAPI(formData.date), refCommandDate: convertDateToAPI(formData.refCommandDate), + isUpload: !isStatusEdit.value ? undefined : isUpload.value, profileId: isStatusEdit.value ? undefined : empType.value === "" @@ -214,21 +215,38 @@ function onSubmit() { }); } +/** + * ฟังก์ชันอัพโหลไฟล์ + * @param id id รายการที่อัพโหลไฟล์ + */ async function uploadfile(id: string) { try { + //สร้าง Path url อัพโหลด const uploadUrl = await createPathUploadFlie( fileGroup.value, profileId.value, id ); + //อัพโหลไฟล์ await uploadFile(uploadUrl, fileUpload.value); - fileUpload.value = null; + await updateIsUpload(); } catch (err) { messageError($q, err); } } +/** ฟังก์ชันอัพเดทสถานะอัพโหลด*/ +async function updateIsUpload() { + await http + .patch(config.API.profileNewNoPaidById(id.value, empType.value), { + isUpload: fileUpload.value ? true : false, + }) + .then(() => { + fileUpload.value = null; + }); +} + /** * function เปิด Didalig บันทึกวันที่ไม่ได้รับเงินเดือนฯ * @param StatusEdit แก้ไข , เพิ่ม