From 47bd4637d85ec41cc9da0145fb0da8a2f5da428e Mon Sep 17 00:00:00 2001 From: Net Date: Thu, 29 Aug 2024 14:57:49 +0700 Subject: [PATCH] refactor: add function putAttachment --- src/pages/03_customer-management/MainPage.vue | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/pages/03_customer-management/MainPage.vue b/src/pages/03_customer-management/MainPage.vue index d19475e6..d98fd830 100644 --- a/src/pages/03_customer-management/MainPage.vue +++ b/src/pages/03_customer-management/MainPage.vue @@ -1865,6 +1865,29 @@ const emptyCreateDialog = ref(false); ); } + customerFormData.customerBranch[idx].file?.forEach( + async (v) => { + if (!v.file) return; + + const ext = v.file.name.split('.').at(-1); + let filename = v.group + '-' + new Date().getTime(); + if (ext) filename += `.${ext}`; + + const res = await customerStore.putAttachment({ + branchId: + customerFormData.customerBranch?.[idx].id || '', + file: v.file, + filename, + }); + + if (res) { + await customerFormStore.assignFormData( + customerFormState.editCustomerId, + ); + } + }, + ); + await customerFormStore.assignFormData( customerFormState.editCustomerId, );