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

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