แก้อัพไฟล์
This commit is contained in:
parent
f4d11d6686
commit
81cfb48b8e
4 changed files with 28 additions and 28 deletions
|
|
@ -535,7 +535,7 @@ async function addEditData(editStatus: boolean = false) {
|
||||||
try {
|
try {
|
||||||
await http[method](url, reqBody).then(async (res) => {
|
await http[method](url, reqBody).then(async (res) => {
|
||||||
if ((fileUpload.value && id.value) || res.data.result) {
|
if ((fileUpload.value && id.value) || res.data.result) {
|
||||||
await uploadProfile(id.value);
|
await uploadProfile(editStatus ? id.value:res.data.result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -568,7 +568,7 @@ async function uploadProfile(id: string) {
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||||
await uploadFileURL(uploadUrl.value, fileUpload.value);
|
await uploadFileURL(uploadUrl.value, fileUpload.value,id);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -580,7 +580,7 @@ async function uploadProfile(id: string) {
|
||||||
* @param uploadUrl Path อัปโหลดไฟล์
|
* @param uploadUrl Path อัปโหลดไฟล์
|
||||||
* @param file ไฟล์เอกสาร
|
* @param file ไฟล์เอกสาร
|
||||||
*/
|
*/
|
||||||
async function uploadFileURL(uploadUrl: string, file: any) {
|
async function uploadFileURL(uploadUrl: string, file: any,id:string) {
|
||||||
await axios
|
await axios
|
||||||
.put(uploadUrl, file, {
|
.put(uploadUrl, file, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -589,7 +589,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
await isUploadFn();
|
await isUploadFn(id);
|
||||||
}
|
}
|
||||||
fileUpload.value = null;
|
fileUpload.value = null;
|
||||||
})
|
})
|
||||||
|
|
@ -598,9 +598,9 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isUploadFn() {
|
async function isUploadFn(id:string) {
|
||||||
await http
|
await http
|
||||||
.patch(config.API.profileNewInsignById(id.value, empType.value), {
|
.patch(config.API.profileNewInsignById(id, empType.value), {
|
||||||
isUpload: fileUpload.value ? true : false,
|
isUpload: fileUpload.value ? true : false,
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => {})
|
||||||
|
|
|
||||||
|
|
@ -301,7 +301,7 @@ async function addEditData(editStatus: boolean = false) {
|
||||||
try {
|
try {
|
||||||
await http[method](url, reqBody).then(async (res) => {
|
await http[method](url, reqBody).then(async (res) => {
|
||||||
if ((fileUpload.value && id.value) || res.data.result) {
|
if ((fileUpload.value && id.value) || res.data.result) {
|
||||||
await uploadProfile(id.value);
|
await uploadProfile(editStatus ? id.value:res.data.result);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
await fetchData();
|
await fetchData();
|
||||||
|
|
@ -338,7 +338,7 @@ async function uploadProfile(id: string) {
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||||
await uploadFileURL(uploadUrl.value, fileUpload.value);
|
await uploadFileURL(uploadUrl.value, fileUpload.value,id);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -350,7 +350,7 @@ async function uploadProfile(id: string) {
|
||||||
* @param uploadUrl Path อัปโหลดไฟล์
|
* @param uploadUrl Path อัปโหลดไฟล์
|
||||||
* @param file ไฟล์เอกสาร
|
* @param file ไฟล์เอกสาร
|
||||||
*/
|
*/
|
||||||
async function uploadFileURL(uploadUrl: string, file: any) {
|
async function uploadFileURL(uploadUrl: string, file: any,id:string) {
|
||||||
await axios
|
await axios
|
||||||
.put(uploadUrl, file, {
|
.put(uploadUrl, file, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -359,7 +359,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
await isUploadFn();
|
await isUploadFn(id);
|
||||||
}
|
}
|
||||||
fileUpload.value = null;
|
fileUpload.value = null;
|
||||||
})
|
})
|
||||||
|
|
@ -368,9 +368,9 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isUploadFn() {
|
async function isUploadFn(id:string) {
|
||||||
await http
|
await http
|
||||||
.patch(config.API.profileNewHonorById(id.value, empType.value), {
|
.patch(config.API.profileNewHonorById(id, empType.value), {
|
||||||
isUpload: fileUpload.value ? true : false,
|
isUpload: fileUpload.value ? true : false,
|
||||||
isDate: declHonorForm.isDate === "true" ? true : false,
|
isDate: declHonorForm.isDate === "true" ? true : false,
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -228,7 +228,6 @@ function addData() {
|
||||||
reference: dutyData.reference,
|
reference: dutyData.reference,
|
||||||
refCommandNo: dutyData.refCommandNo,
|
refCommandNo: dutyData.refCommandNo,
|
||||||
refCommandDate: dutyData.refCommandDate,
|
refCommandDate: dutyData.refCommandDate,
|
||||||
isUpload: !edit.value ? undefined : isUpload.value,
|
|
||||||
};
|
};
|
||||||
http
|
http
|
||||||
.post(config.API.profileNewDuty(empType.value), body)
|
.post(config.API.profileNewDuty(empType.value), body)
|
||||||
|
|
@ -255,10 +254,11 @@ function editData(idData: string) {
|
||||||
.patch(config.API.profileNewDutyByDutyId(idData, empType.value), {
|
.patch(config.API.profileNewDutyByDutyId(idData, empType.value), {
|
||||||
...dutyData,
|
...dutyData,
|
||||||
profileId: undefined,
|
profileId: undefined,
|
||||||
|
isUpload: !edit.value ? undefined : isUpload.value,
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (fileUpload.value && id.value) {
|
if (fileUpload.value && idData) {
|
||||||
await uploadProfile(id.value);
|
await uploadProfile(idData);
|
||||||
}
|
}
|
||||||
await fetchData(profileId.value);
|
await fetchData(profileId.value);
|
||||||
await success($q, "บันทึกข้อมูลสำเร็จ");
|
await success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
|
@ -296,7 +296,7 @@ async function uploadProfile(id: string) {
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||||
await uploadFileURL(uploadUrl.value, fileUpload.value);
|
await uploadFileURL(uploadUrl.value, fileUpload.value,id);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -308,7 +308,7 @@ async function uploadProfile(id: string) {
|
||||||
* @param uploadUrl Path อัปโหลดไฟล์
|
* @param uploadUrl Path อัปโหลดไฟล์
|
||||||
* @param file ไฟล์เอกสาร
|
* @param file ไฟล์เอกสาร
|
||||||
*/
|
*/
|
||||||
async function uploadFileURL(uploadUrl: string, file: any) {
|
async function uploadFileURL(uploadUrl: string, file: any,id:string) {
|
||||||
await axios
|
await axios
|
||||||
.put(uploadUrl, file, {
|
.put(uploadUrl, file, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -317,7 +317,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
await isUploadFn();
|
await isUploadFn(id);
|
||||||
}
|
}
|
||||||
fileUpload.value = null;
|
fileUpload.value = null;
|
||||||
})
|
})
|
||||||
|
|
@ -326,9 +326,9 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isUploadFn() {
|
async function isUploadFn(id:string) {
|
||||||
await http
|
await http
|
||||||
.patch(config.API.profileNewDutyByDutyId(id.value, empType.value), {
|
.patch(config.API.profileNewDutyByDutyId(id, empType.value), {
|
||||||
isUpload: fileUpload.value ? true : false,
|
isUpload: fileUpload.value ? true : false,
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => {})
|
||||||
|
|
|
||||||
|
|
@ -305,7 +305,6 @@ async function addData() {
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
profileId: empType.value === "" ? id.value : undefined,
|
profileId: empType.value === "" ? id.value : undefined,
|
||||||
profileEmployeeId: empType.value !== "" ? id.value : undefined,
|
profileEmployeeId: empType.value !== "" ? id.value : undefined,
|
||||||
isUpload: !isEdit.value ? undefined : isUpload.value,
|
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (fileUpload.value && res.data.result) {
|
if (fileUpload.value && res.data.result) {
|
||||||
|
|
@ -335,10 +334,11 @@ async function editData(idData: string) {
|
||||||
dateStart: null,
|
dateStart: null,
|
||||||
dateEnd: null,
|
dateEnd: null,
|
||||||
profileId: undefined,
|
profileId: undefined,
|
||||||
|
isUpload: !isEdit.value ? undefined : isUpload.value,
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (fileUpload.value && id.value) {
|
if (fileUpload.value && idData) {
|
||||||
await uploadProfile(id.value);
|
await uploadProfile(idData);
|
||||||
}
|
}
|
||||||
await fetchData(id.value);
|
await fetchData(id.value);
|
||||||
await success($q, "บันทึกข้อมูลสำเร็จ");
|
await success($q, "บันทึกข้อมูลสำเร็จ");
|
||||||
|
|
@ -376,7 +376,7 @@ async function uploadProfile(id: string) {
|
||||||
)
|
)
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
uploadUrl.value = res.data["เอกสารหลักฐาน"].uploadUrl;
|
||||||
await uploadFileURL(uploadUrl.value, fileUpload.value);
|
await uploadFileURL(uploadUrl.value, fileUpload.value, id);
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
messageError($q, err);
|
messageError($q, err);
|
||||||
|
|
@ -388,7 +388,7 @@ async function uploadProfile(id: string) {
|
||||||
* @param uploadUrl Path อัปโหลดไฟล์
|
* @param uploadUrl Path อัปโหลดไฟล์
|
||||||
* @param file ไฟล์เอกสาร
|
* @param file ไฟล์เอกสาร
|
||||||
*/
|
*/
|
||||||
async function uploadFileURL(uploadUrl: string, file: any) {
|
async function uploadFileURL(uploadUrl: string, file: any, id: string) {
|
||||||
await axios
|
await axios
|
||||||
.put(uploadUrl, file, {
|
.put(uploadUrl, file, {
|
||||||
headers: {
|
headers: {
|
||||||
|
|
@ -397,7 +397,7 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
})
|
})
|
||||||
.then(async (res) => {
|
.then(async (res) => {
|
||||||
if (res.status == 200) {
|
if (res.status == 200) {
|
||||||
await isUploadFn();
|
await isUploadFn(id);
|
||||||
}
|
}
|
||||||
fileUpload.value = null;
|
fileUpload.value = null;
|
||||||
})
|
})
|
||||||
|
|
@ -406,9 +406,9 @@ async function uploadFileURL(uploadUrl: string, file: any) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function isUploadFn() {
|
async function isUploadFn(id: string) {
|
||||||
await http
|
await http
|
||||||
.patch(config.API.profileNewAbilityByAbilityId(editId.value, empType.value), {
|
.patch(config.API.profileNewAbilityByAbilityId(id, empType.value), {
|
||||||
isUpload: fileUpload.value ? true : false,
|
isUpload: fileUpload.value ? true : false,
|
||||||
})
|
})
|
||||||
.then(async (res) => {})
|
.then(async (res) => {})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue