update isupload
This commit is contained in:
parent
32deed4e9a
commit
2f6b495d43
3 changed files with 84 additions and 9 deletions
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
|
|
|
|||
|
|
@ -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 แก้ไข , เพิ่ม
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue