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'];
|
||||
|
||||
watch(profileFileImg, () => {
|
||||
if (profileFileImg.value) reader.readAsDataURL(profileFileImg.value);
|
||||
});
|
||||
// watch(profileFileImg, () => {
|
||||
// if (profileFileImg.value) reader.readAsDataURL(profileFileImg.value);
|
||||
// });
|
||||
|
||||
async function openDialog(
|
||||
action?: 'FORM' | 'INFO',
|
||||
|
|
@ -392,11 +392,7 @@ function onClose() {
|
|||
flowStore.rotate();
|
||||
}
|
||||
async function onSubmit() {
|
||||
if (profileSubmit.value) {
|
||||
formData.value.profileImage = profileFileImg.value as File;
|
||||
} else {
|
||||
formData.value.profileImage = null;
|
||||
}
|
||||
formData.value.profileImage = profileFileImg.value as File;
|
||||
|
||||
if (isEdit.value && userId.value) {
|
||||
if (!userId.value) return;
|
||||
|
|
@ -445,7 +441,6 @@ async function onSubmit() {
|
|||
: hqId.value
|
||||
? hqId.value
|
||||
: '';
|
||||
|
||||
const result = await userStore.create(formData.value);
|
||||
|
||||
if (result && formData.value.userType === 'AGENCY') {
|
||||
|
|
|
|||
|
|
@ -280,13 +280,14 @@ const useUserStore = defineStore('api-user', () => {
|
|||
},
|
||||
);
|
||||
|
||||
profileImage &&
|
||||
(await axios
|
||||
.put(res.data.profileImageUploadUrl, profileImage, {
|
||||
if (profileImage && res.data.id) {
|
||||
await api
|
||||
.put(`/user/${res.data.id}/image`, profileImage, {
|
||||
headers: { 'Content-Type': profileImage.type },
|
||||
onUploadProgress: (e) => console.log(e),
|
||||
})
|
||||
.catch((e) => console.error(e)));
|
||||
.catch((e) => console.error(e));
|
||||
}
|
||||
|
||||
if (!res) return false;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue