fix(02): upload image
This commit is contained in:
parent
59436725f7
commit
7476133bef
2 changed files with 9 additions and 13 deletions
|
|
@ -287,9 +287,9 @@ const columns = [
|
||||||
},
|
},
|
||||||
] satisfies QTableProps['columns'];
|
] satisfies QTableProps['columns'];
|
||||||
|
|
||||||
watch(profileFileImg, () => {
|
// watch(profileFileImg, () => {
|
||||||
if (profileFileImg.value) reader.readAsDataURL(profileFileImg.value);
|
// if (profileFileImg.value) reader.readAsDataURL(profileFileImg.value);
|
||||||
});
|
// });
|
||||||
|
|
||||||
async function openDialog(
|
async function openDialog(
|
||||||
action?: 'FORM' | 'INFO',
|
action?: 'FORM' | 'INFO',
|
||||||
|
|
@ -392,11 +392,7 @@ function onClose() {
|
||||||
flowStore.rotate();
|
flowStore.rotate();
|
||||||
}
|
}
|
||||||
async function onSubmit() {
|
async function onSubmit() {
|
||||||
if (profileSubmit.value) {
|
formData.value.profileImage = profileFileImg.value as File;
|
||||||
formData.value.profileImage = profileFileImg.value as File;
|
|
||||||
} else {
|
|
||||||
formData.value.profileImage = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (isEdit.value && userId.value) {
|
if (isEdit.value && userId.value) {
|
||||||
if (!userId.value) return;
|
if (!userId.value) return;
|
||||||
|
|
@ -445,7 +441,6 @@ async function onSubmit() {
|
||||||
: hqId.value
|
: hqId.value
|
||||||
? hqId.value
|
? hqId.value
|
||||||
: '';
|
: '';
|
||||||
|
|
||||||
const result = await userStore.create(formData.value);
|
const result = await userStore.create(formData.value);
|
||||||
|
|
||||||
if (result && formData.value.userType === 'AGENCY') {
|
if (result && formData.value.userType === 'AGENCY') {
|
||||||
|
|
|
||||||
|
|
@ -280,13 +280,14 @@ const useUserStore = defineStore('api-user', () => {
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
profileImage &&
|
if (profileImage && res.data.id) {
|
||||||
(await axios
|
await api
|
||||||
.put(res.data.profileImageUploadUrl, profileImage, {
|
.put(`/user/${res.data.id}/image`, profileImage, {
|
||||||
headers: { 'Content-Type': profileImage.type },
|
headers: { 'Content-Type': profileImage.type },
|
||||||
onUploadProgress: (e) => console.log(e),
|
onUploadProgress: (e) => console.log(e),
|
||||||
})
|
})
|
||||||
.catch((e) => console.error(e)));
|
.catch((e) => console.error(e));
|
||||||
|
}
|
||||||
|
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue