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",
"lastUpdatedAt",
]);
const rows = ref<ResponseObject[]>([]); //
const rowsMain = ref<ResponseObject[]>([]); //
const keyword = ref<string>(""); //
@ -154,7 +153,6 @@ const visibleColumns = ref<string[]>(
const pagination = ref({
sortBy: "lastUpdatedAt",
});
//Table
const historyId = ref<string>("");
const columnsHistory = ref<QTableColumn[]>(baseColumns.value);
@ -169,10 +167,10 @@ const profesLicenseData = reactive<RequestItemsObject>({
profileId: id.value,
});
const fileGroup = ref<string>("เอกสารใบอนุญาตประกอบวิชาชีพ");
const fileUpload = ref<File | null>(null);
const fileData = ref<ResFileData | null>(null);
const isUpload = ref<boolean>(false);
const fileGroup = ref<string>("เอกสารใบอนุญาตประกอบวิชาชีพ"); //
const fileUpload = ref<File | null>(null); //
const fileData = ref<ResFileData | null>(null); //
const isUpload = ref<boolean>(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,

View file

@ -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");

View file

@ -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 แกไข , เพ