update isupload

This commit is contained in:
DESKTOP-1R2VSQH\Lenovo ThinkPad E490 2025-03-18 17:06:21 +07:00
parent 32deed4e9a
commit 2f6b495d43
3 changed files with 84 additions and 9 deletions

View file

@ -141,7 +141,6 @@ const baseVisibleColumns = ref<string[]>([
"lastUpdateFullName", "lastUpdateFullName",
"lastUpdatedAt", "lastUpdatedAt",
]); ]);
const rows = ref<ResponseObject[]>([]); // const rows = ref<ResponseObject[]>([]); //
const rowsMain = ref<ResponseObject[]>([]); // const rowsMain = ref<ResponseObject[]>([]); //
const keyword = ref<string>(""); // const keyword = ref<string>(""); //
@ -154,7 +153,6 @@ const visibleColumns = ref<string[]>(
const pagination = ref({ const pagination = ref({
sortBy: "lastUpdatedAt", sortBy: "lastUpdatedAt",
}); });
//Table //Table
const historyId = ref<string>(""); const historyId = ref<string>("");
const columnsHistory = ref<QTableColumn[]>(baseColumns.value); const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
@ -169,10 +167,10 @@ const profesLicenseData = reactive<RequestItemsObject>({
profileId: id.value, profileId: id.value,
}); });
const fileGroup = ref<string>("เอกสารใบอนุญาตประกอบวิชาชีพ"); const fileGroup = ref<string>("เอกสารใบอนุญาตประกอบวิชาชีพ"); //
const fileUpload = ref<File | null>(null); const fileUpload = ref<File | null>(null); //
const fileData = ref<ResFileData | null>(null); const fileData = ref<ResFileData | null>(null); //
const isUpload = ref<boolean>(false); const isUpload = ref<boolean>(false); //
/** ยืนยันการบันทึกข้อมูล*/ /** ยืนยันการบันทึกข้อมูล*/
function onSubmit() { function onSubmit() {
@ -193,6 +191,7 @@ function onSubmit() {
...profesLicenseData, ...profesLicenseData,
issueDate: convertDateToAPI(profesLicenseData.issueDate), issueDate: convertDateToAPI(profesLicenseData.issueDate),
expireDate: convertDateToAPI(profesLicenseData.expireDate), expireDate: convertDateToAPI(profesLicenseData.expireDate),
isUpload: !isEdit ? undefined : isUpload.value,
profileId: isEdit profileId: isEdit
? undefined ? undefined
: empType.value === "" : empType.value === ""
@ -209,6 +208,7 @@ function onSubmit() {
const isId = isEdit ? editId.value : res.data.result; const isId = isEdit ? editId.value : res.data.result;
await uploadfile(isId); await uploadfile(isId);
} }
await fetchData(id.value); await fetchData(id.value);
success($q, "บันทึกข้อมูลสำเร็จ"); success($q, "บันทึกข้อมูลสำเร็จ");
closeDialog(); closeDialog();
@ -225,21 +225,44 @@ function onSubmit() {
); );
} }
/**
* งกนอพโหลไฟล
* @param subId id รายการทพโหลไฟล
*/
async function uploadfile(subId: string) { async function uploadfile(subId: string) {
try { try {
// Path url
const uploadUrl = await createPathUploadFlie( const uploadUrl = await createPathUploadFlie(
fileGroup.value, fileGroup.value,
id.value, id.value,
subId subId
); );
//
await uploadFile(uploadUrl, fileUpload.value); await uploadFile(uploadUrl, fileUpload.value);
fileUpload.value = null; await updateIsUpload();
} catch (err) { } catch (err) {
messageError($q, 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 ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ*/ /** fetch ข้อมูลรายการใบอนุญาตประกอบวิชาชีพ*/
async function fetchData(id: string) { async function fetchData(id: string) {
showLoader(); showLoader();
@ -295,6 +318,10 @@ async function editForm(row: ResponseObject) {
} }
} }
/**
* งกนดประวการแกไขขอม
* @param id รายการทองการดประวการแกไข
*/
function onViewHistory(id: string) { function onViewHistory(id: string) {
historyId.value = id; historyId.value = id;
historyDialog.value = true; historyDialog.value = true;
@ -318,11 +345,16 @@ async function fetchDataHistory() {
} }
} }
/**
* งกนโหลดไฟล
* @param subId id รายการทองการโหลดไฟล
*/
async function onDownloadFile(subId: string) { async function onDownloadFile(subId: string) {
const data = await getPathUploadFlie(fileGroup.value, id.value, subId); const data = await getPathUploadFlie(fileGroup.value, id.value, subId);
window.open(data.downloadUrl, "_blank"); window.open(data.downloadUrl, "_blank");
} }
/** ฟังก์ชันค้นหาข้อมูลในตาราง*/
function serchDataTable() { function serchDataTable() {
rows.value = onSearchDataTable( rows.value = onSearchDataTable(
keyword.value, keyword.value,

View file

@ -350,6 +350,7 @@ function onSubmit() {
...disciplineData, ...disciplineData,
date: convertDateToAPI(disciplineData.date), date: convertDateToAPI(disciplineData.date),
refCommandDate: convertDateToAPI(disciplineData.refCommandDate), refCommandDate: convertDateToAPI(disciplineData.refCommandDate),
isUpload: !edit.value ? undefined : isUpload.value,
profileId: edit.value profileId: edit.value
? undefined ? undefined
: empType.value === "" : empType.value === ""
@ -384,21 +385,45 @@ function onSubmit() {
); );
} }
/**
* งกนอพโหลไฟล
* @param id id รายการทพโหลไฟล
*/
async function uploadfile(id: string) { async function uploadfile(id: string) {
try { try {
// Path url
const uploadUrl = await createPathUploadFlie( const uploadUrl = await createPathUploadFlie(
fileGroup.value, fileGroup.value,
profileId.value, profileId.value,
id id
); );
//
await uploadFile(uploadUrl, fileUpload.value); await uploadFile(uploadUrl, fileUpload.value);
fileUpload.value = null; await updateIsUpload();
} catch (err) { } catch (err) {
messageError($q, 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) { async function onDownloadFile(id: string) {
const data = await getPathUploadFlie(fileGroup.value, profileId.value, id); const data = await getPathUploadFlie(fileGroup.value, profileId.value, id);
window.open(data.downloadUrl, "_blank"); window.open(data.downloadUrl, "_blank");

View file

@ -185,6 +185,7 @@ function onSubmit() {
...formData, ...formData,
date: convertDateToAPI(formData.date), date: convertDateToAPI(formData.date),
refCommandDate: convertDateToAPI(formData.refCommandDate), refCommandDate: convertDateToAPI(formData.refCommandDate),
isUpload: !isStatusEdit.value ? undefined : isUpload.value,
profileId: isStatusEdit.value profileId: isStatusEdit.value
? undefined ? undefined
: empType.value === "" : empType.value === ""
@ -214,21 +215,38 @@ function onSubmit() {
}); });
} }
/**
* งกนอพโหลไฟล
* @param id id รายการทพโหลไฟล
*/
async function uploadfile(id: string) { async function uploadfile(id: string) {
try { try {
// Path url
const uploadUrl = await createPathUploadFlie( const uploadUrl = await createPathUploadFlie(
fileGroup.value, fileGroup.value,
profileId.value, profileId.value,
id id
); );
//
await uploadFile(uploadUrl, fileUpload.value); await uploadFile(uploadUrl, fileUpload.value);
fileUpload.value = null; await updateIsUpload();
} catch (err) { } catch (err) {
messageError($q, 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 นทกวนทไมไดบเงนเดอนฯ * function เป Didalig นทกวนทไมไดบเงนเดอนฯ
* @param StatusEdit แกไข , เพ * @param StatusEdit แกไข , เพ