แก้อัพไฟล์

This commit is contained in:
setthawutttty 2025-01-30 10:21:39 +07:00
parent f4d11d6686
commit 81cfb48b8e
4 changed files with 28 additions and 28 deletions

View file

@ -228,7 +228,6 @@ function addData() {
reference: dutyData.reference,
refCommandNo: dutyData.refCommandNo,
refCommandDate: dutyData.refCommandDate,
isUpload: !edit.value ? undefined : isUpload.value,
};
http
.post(config.API.profileNewDuty(empType.value), body)
@ -255,10 +254,11 @@ function editData(idData: string) {
.patch(config.API.profileNewDutyByDutyId(idData, empType.value), {
...dutyData,
profileId: undefined,
isUpload: !edit.value ? undefined : isUpload.value,
})
.then(async (res) => {
if (fileUpload.value && id.value) {
await uploadProfile(id.value);
if (fileUpload.value && idData) {
await uploadProfile(idData);
}
await fetchData(profileId.value);
await success($q, "บันทึกข้อมูลสำเร็จ");
@ -296,7 +296,7 @@ async function uploadProfile(id: string) {
)
.then(async (res) => {
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
await uploadFileURL(uploadUrl.value, fileUpload.value);
await uploadFileURL(uploadUrl.value, fileUpload.value,id);
})
.catch((err) => {
messageError($q, err);
@ -308,7 +308,7 @@ async function uploadProfile(id: string) {
* @param uploadUrl Path ปโหลดไฟล
* @param file ไฟลเอกสาร
*/
async function uploadFileURL(uploadUrl: string, file: any) {
async function uploadFileURL(uploadUrl: string, file: any,id:string) {
await axios
.put(uploadUrl, file, {
headers: {
@ -317,7 +317,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
})
.then(async (res) => {
if (res.status == 200) {
await isUploadFn();
await isUploadFn(id);
}
fileUpload.value = null;
})
@ -326,9 +326,9 @@ async function uploadFileURL(uploadUrl: string, file: any) {
});
}
async function isUploadFn() {
async function isUploadFn(id:string) {
await http
.patch(config.API.profileNewDutyByDutyId(id.value, empType.value), {
.patch(config.API.profileNewDutyByDutyId(id, empType.value), {
isUpload: fileUpload.value ? true : false,
})
.then(async (res) => {})