fix(01): upload image
This commit is contained in:
parent
bda2f0164d
commit
59436725f7
3 changed files with 21 additions and 38 deletions
|
|
@ -45,6 +45,7 @@ import {
|
|||
UndoButton,
|
||||
} from 'components/button';
|
||||
|
||||
const apiBaseUrl = import.meta.env.VITE_API_BASE_URL;
|
||||
const $q = useQuasar();
|
||||
const { t } = useI18n();
|
||||
const utilsStore = useUtilsStore();
|
||||
|
|
@ -122,13 +123,13 @@ const formBankBook = ref<BankBook[]>([
|
|||
|
||||
const refImageUpload = ref();
|
||||
const isImageEdit = ref(false);
|
||||
const profileFileImg = ref<File | undefined>(undefined);
|
||||
const profileFile = ref<File | undefined>(undefined);
|
||||
const imageUrl = ref<string>('');
|
||||
const prevImageUrl = ref<string>('');
|
||||
const currentNode = ref<BranchWithChildren>();
|
||||
const imageDialog = ref(false);
|
||||
|
||||
const profileFile = ref<File | undefined>(undefined);
|
||||
const qrFile = ref<File | undefined>(undefined);
|
||||
const qrCodeimageUrl = ref<string | null>('');
|
||||
const formBranchCount = ref<number>(0);
|
||||
|
||||
|
|
@ -143,9 +144,9 @@ const inputFile = (() => {
|
|||
});
|
||||
|
||||
element.addEventListener('change', () => {
|
||||
profileFile.value = element.files?.[0];
|
||||
if (profileFile.value) {
|
||||
reader.readAsDataURL(profileFile.value);
|
||||
qrFile.value = element.files?.[0];
|
||||
if (qrFile.value) {
|
||||
reader.readAsDataURL(qrFile.value);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -326,8 +327,8 @@ async function fetchBranchById(id: string) {
|
|||
const res = await branchStore.fetchById(id, { includeContact: true });
|
||||
|
||||
if (res) {
|
||||
qrCodeimageUrl.value = res.qrCodeImageUrl;
|
||||
imageUrl.value = res.imageUrl;
|
||||
qrCodeimageUrl.value = `${apiBaseUrl}/branch/${res.id}/line-image`;
|
||||
imageUrl.value = `${apiBaseUrl}/branch/${res.id}/branch-image`;
|
||||
prevImageUrl.value = res.imageUrl;
|
||||
|
||||
const updatedBank = res.bank.map((item) => {
|
||||
|
|
@ -368,7 +369,7 @@ function clearData() {
|
|||
id: '',
|
||||
code: '',
|
||||
};
|
||||
profileFile.value = undefined;
|
||||
qrFile.value = undefined;
|
||||
|
||||
formBankBook.value = [
|
||||
{
|
||||
|
|
@ -412,7 +413,7 @@ function triggerCreate(
|
|||
formData.value.headOfficeId = id;
|
||||
formData.value.code = code;
|
||||
formData.value.codeHeadOffice = code;
|
||||
formBranchCount.value = count;
|
||||
formBranchCount.value = count || 0;
|
||||
}
|
||||
|
||||
formType.value = 'create';
|
||||
|
|
@ -558,8 +559,8 @@ async function onSubmit() {
|
|||
...formData.value,
|
||||
status: undefined,
|
||||
},
|
||||
qrFile.value,
|
||||
profileFile.value,
|
||||
profileFileImg.value,
|
||||
formBankBook.value,
|
||||
);
|
||||
|
||||
|
|
@ -573,8 +574,8 @@ async function onSubmit() {
|
|||
await branchStore.create(
|
||||
{
|
||||
...formData.value,
|
||||
qrCodeImage: profileFile.value,
|
||||
imageUrl: profileFileImg.value,
|
||||
qrCodeImage: qrFile.value,
|
||||
imageUrl: profileFile.value,
|
||||
},
|
||||
formBankBook.value,
|
||||
);
|
||||
|
|
@ -600,7 +601,7 @@ async function onSubmit() {
|
|||
field: t('branch.form.abbrev'),
|
||||
name: formData.value.code,
|
||||
}),
|
||||
actionText: t('agree'),
|
||||
actionText: t('dialog.action.ok'),
|
||||
persistent: true,
|
||||
title: t('form.warning.title'),
|
||||
cancel: () => {},
|
||||
|
|
@ -657,9 +658,9 @@ function handleHold(node: BranchWithChildren) {
|
|||
}
|
||||
|
||||
watch(
|
||||
() => profileFileImg.value,
|
||||
() => profileFile.value,
|
||||
() => {
|
||||
if (profileFileImg.value !== null) isImageEdit.value = true;
|
||||
if (profileFile.value !== null) isImageEdit.value = true;
|
||||
},
|
||||
);
|
||||
|
||||
|
|
@ -1412,7 +1413,7 @@ watch(currentHq, () => {
|
|||
() => (
|
||||
(formBranchCount = 0),
|
||||
(modal = false),
|
||||
(profileFileImg = undefined),
|
||||
(profileFile = undefined),
|
||||
(isImageEdit = false),
|
||||
(isSubCreate = false)
|
||||
)
|
||||
|
|
@ -1965,7 +1966,7 @@ watch(currentHq, () => {
|
|||
<ImageUploadDialog
|
||||
ref="refImageUpload"
|
||||
v-model:dialogState="imageDialog"
|
||||
v-model:file="profileFileImg as File"
|
||||
v-model:file="profileFile as File"
|
||||
v-model:image-url="imageUrl"
|
||||
:hiddenFooter="!isImageEdit && !modal"
|
||||
@save="imageDialog = false"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue