แก้ประวัติรูป

This commit is contained in:
Kittapath 2024-05-15 18:35:47 +07:00
parent 52dd70ac4c
commit e95048fe26

View file

@ -93,26 +93,27 @@ function selectFile() {
imageActive(null);
}
function imageActive(n: any){
function imageActive(n: any) {
activeImage.value = n;
};
function uploadImg(){
http
.post(config.API.orgProfileAvatar,{
profileId:profileId.value
})
.then((res)=>{
console.log(res.data)
uploadProfile(res.data.result.avatar)
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
})
}
async function uploadProfile(path:string) {
function uploadImg() {
http
.post(config.API.orgProfileAvatar, {
profileId: profileId.value,
})
.then((res) => {
console.log(res.data);
fileName.value = res.data.result.avatarName;
uploadProfile(res.data.result.avatar);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
}
async function uploadProfile(path: string) {
await http
.post(config.API.fileByPath(path), {
replace: true,
@ -125,7 +126,7 @@ async function uploadProfile(path:string) {
.then(async (res) => {
uploadUrl.value = res.data[fileName.value].uploadUrl;
uploadFileURL(uploadUrl.value, profileFile.value);
dialogImage.value = false
dialogImage.value = false;
})
.catch((err) => {
messageError($q, err);
@ -176,6 +177,7 @@ async function fetchDataPersonal() {
.get(config.API.registryNewByProfileId(profileId.value, empType.value))
.then((res) => {
formDetail.value = res.data.result;
fileName.value = res.data.result.avatarName;
})
.catch((err) => {
messageError($q, err);
@ -335,32 +337,34 @@ async function clickSaveDeceased() {
function openDialogImg() {
dialogImage.value = true;
showLoader()
showLoader();
http
.get(config.API.orgProfileAvatar+`/${profileId.value}`)
.then((res)=>{
let data = res.data.result;
for(let i = 0;i < data.length; i++){
getImg(data[i])
}
.get(config.API.orgProfileAvatar + `/${profileId.value}`)
.then((res) => {
let data = res.data.result;
for (let i = 0; i < data.length; i++) {
getImg(data[i]);
}
// images.value = data
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
hideLoader()
})
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {
hideLoader();
});
}
function getImg(dataList:any){
function getImg(dataList: any) {
http
.get(config.API.fileByPath(`${dataList.avatar}/${dataList.avatarName}`))
.then((res)=>{
console.log(res)
}).catch((e)=>{
messageError($q,e)
}).finally(()=>{
})
.get(config.API.fileByPath(`${dataList.avatar}/${dataList.avatarName}`))
.then((res) => {
console.log(res);
})
.catch((e) => {
messageError($q, e);
})
.finally(() => {});
}
function closeImage() {
@ -399,7 +403,7 @@ async function selectAvatarHistory() {
})
.then((res) => {
dialogImage.value = false;
fileName.value = `profile-${profileId.value}`;
// fileName.value = `profile-${profileId.value}`;
fetchProfile(profileId.value);
fetchDataPersonal();
})
@ -407,14 +411,14 @@ async function selectAvatarHistory() {
messageError($q, e);
})
.finally(() => {
hideLoader()
hideLoader();
});
}
onMounted(async () => {
fileName.value = `profile-${profileId.value}`;
fetchProfile(profileId.value);
fetchDataPersonal();
// fileName.value = `profile-${profileId.value}`;
await fetchDataPersonal();
await fetchProfile(profileId.value);
});
</script>