From 684a97cef3b2baa95acc742f93f82fe8bc4aa197 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Mon, 20 Jan 2025 13:38:30 +0700 Subject: [PATCH 01/15] refactor: add parameters --- src/pages/10_invoice/MainPage.vue | 7 ++++++- src/stores/payment/index.ts | 12 ++++++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/pages/10_invoice/MainPage.vue b/src/pages/10_invoice/MainPage.vue index fd21a427..d2a96c74 100644 --- a/src/pages/10_invoice/MainPage.vue +++ b/src/pages/10_invoice/MainPage.vue @@ -53,6 +53,8 @@ async function fetchList(opts?: { rotateFlowId?: boolean }) { : pageState.statusFilter === PaymentDataStatus.Wait ? false : undefined, + quotationOnly: true, + debitNoteOnly: false, }); if (ret) { data.value = ret.result; @@ -64,7 +66,10 @@ async function fetchList(opts?: { rotateFlowId?: boolean }) { } async function fetchStats() { - const ret = await invoiceStore.getInvoiceStats(); + const ret = await invoiceStore.getInvoiceStats({ + quotationOnly: true, + debitNoteOnly: false, + }); if (ret) stats.value = ret; } diff --git a/src/stores/payment/index.ts b/src/stores/payment/index.ts index 10280b7c..e85de252 100644 --- a/src/stores/payment/index.ts +++ b/src/stores/payment/index.ts @@ -128,7 +128,12 @@ export const useInvoice = defineStore('invoice-store', () => { [PaymentDataStatus.Wait]: 0, }); - async function getInvoiceStats(params?: { quotationId?: string }) { + async function getInvoiceStats(params?: { + quotationId?: string; + quotationOnly?: boolean; + debitNoteId?: string; + debitNoteOnly?: boolean; + }) { const res = await api.get>( '/invoice/stats', { params }, @@ -149,8 +154,11 @@ export const useInvoice = defineStore('invoice-store', () => { page?: number; pageSize?: number; query?: string; - quotationId?: string; pay?: boolean; + quotationOnly?: boolean; + debitNoteOnly?: boolean; + quotationId?: string; + debitNoteId?: string; }) { const res = await api.get>('/invoice', { params, From 44476f8535e8042413acb65a998db75b835603c2 Mon Sep 17 00:00:00 2001 From: puriphatt Date: Mon, 20 Jan 2025 14:04:44 +0700 Subject: [PATCH 02/15] feat: 09, 11 => handle file upload & url on create --- .../09_task-order/order_view/MainPage.vue | 53 +++++++++++++++---- src/pages/11_credit-note/FormPage.vue | 13 ++++- 2 files changed, 55 insertions(+), 11 deletions(-) diff --git a/src/pages/09_task-order/order_view/MainPage.vue b/src/pages/09_task-order/order_view/MainPage.vue index 96896b04..218f6748 100644 --- a/src/pages/09_task-order/order_view/MainPage.vue +++ b/src/pages/09_task-order/order_view/MainPage.vue @@ -59,6 +59,7 @@ const fileData = ref< loaded: number; total: number; url?: string; + placeholder?: boolean; }[] >([]); @@ -397,6 +398,11 @@ async function submitForm() { }); if (res && currentFormData.value.id) { await taskOrderFormStore.assignFormData(currentFormData.value.id); + + if (fileList.value) { + await uploadFile(currentFormData.value.id, fileList.value); + } + router.push({ name: 'TaskOrderView', params: { id: currentFormData.value.id }, @@ -445,25 +451,29 @@ async function getFileList(taskId: string) { if (fileList) fileData.value = await Promise.all( fileList.map(async (v) => { - const rse = await taskOrderStore.headAttachment({ + const res = await taskOrderStore.headAttachment({ parentId: taskId, fileId: v, }); let contentLength = 0; - if (rse) contentLength = Number(rse['content-length']); + if (res) contentLength = Number(res['content-length']); return { name: v, progress: 1, loaded: contentLength, total: contentLength, - url: `/task/${taskId}/attachment/${v}`, + url: `/task-order/${taskId}/attachment/${v}`, }; }), ); } +function fileToUrl(file: File) { + return URL.createObjectURL(file); +} + async function remove(taskId: string, n: string) { dialogWarningClose(t, { message: t('dialog.message.confirmDelete'), @@ -508,8 +518,18 @@ async function uploadFile(taskId: string, list: FileList) { ); fileData?.value.push(data); } + fileList.value = undefined; - return await Promise.all(promises); + const beforeUnloadHandler = (e: Event) => { + e.preventDefault(); + }; + + window.addEventListener('beforeunload', beforeUnloadHandler); + + return await Promise.all(promises).then((v) => { + window.removeEventListener('beforeunload', beforeUnloadHandler); + return v; + }); } async function completeValidate() { @@ -821,8 +841,12 @@ watch([currentFormData.value.taskStatus], () => { v-model:file-data="fileData" :transform-url=" async (url: string) => { - const result = await api.get(url); - return result.data; + if (state.mode === 'create') { + return url; + } else { + const result = await api.get(url); + return result.data; + } } " @fetch-file-list=" @@ -833,9 +857,21 @@ watch([currentFormData.value.taskStatus], () => { " @upload=" async (f) => { - if (!currentFormData.id) return; - fileList = f; + fileData = []; + + Array.from(f).forEach((el) => { + fileData.push({ + name: el.name, + progress: 1, + loaded: 0, + total: el.size, + placeholder: true, + url: fileToUrl(el), + }); + }); + + if (!currentFormData.id) return; await uploadFile(currentFormData.id, f); } @@ -997,7 +1033,6 @@ watch([currentFormData.value.taskStatus], () => { fullTaskOrder?.userTask.find( (l) => l.userId === v.responsibleUser.id, )?.userTaskStatus; - console.log(_userStatus); return ( _userStatus !== UserTaskStatus.Submit && _userStatus !== UserTaskStatus.Restart diff --git a/src/pages/11_credit-note/FormPage.vue b/src/pages/11_credit-note/FormPage.vue index 0445c5f9..b775184f 100644 --- a/src/pages/11_credit-note/FormPage.vue +++ b/src/pages/11_credit-note/FormPage.vue @@ -490,6 +490,10 @@ async function getFileList(creditNoteId: string, slip?: boolean) { )); } +function fileToUrl(file: File) { + return URL.createObjectURL(file); +} + onMounted(async () => { initTheme(); initLang(); @@ -653,8 +657,12 @@ onMounted(async () => { v-model:file-data="attachmentData" :transform-url=" async (url: string) => { - const result = await api.get(url); - return result.data; + if (!creditNoteData?.id) { + return url; + } else { + const result = await api.get(url); + return result.data; + } } " @fetch-file-list=" @@ -675,6 +683,7 @@ onMounted(async () => { loaded: 0, total: el.size, placeholder: true, + url: fileToUrl(el), }); }); From 32a195770d13ac0d4bf8f3dd08d22bfd36d42e1e Mon Sep 17 00:00:00 2001 From: nwpptrs Date: Mon, 20 Jan 2025 14:23:08 +0700 Subject: [PATCH 03/15] feat: i18n quotation, taskorder --- src/i18n/eng.ts | 16 ++++++++++++++++ src/i18n/tha.ts | 16 ++++++++++++++++ .../05_quotation/preview/BankComponents.vue | 10 +++++----- src/pages/05_quotation/preview/ViewFooter.vue | 12 ++++++------ src/pages/05_quotation/preview/ViewForm.vue | 8 +++++--- src/pages/05_quotation/preview/ViewHeader.vue | 14 +++++++------- .../09_task-order/document_view/MainPage.vue | 4 +++- .../09_task-order/document_view/ViewFooter.vue | 12 ++++++------ .../09_task-order/document_view/ViewHeader.vue | 4 ++-- 9 files changed, 66 insertions(+), 30 deletions(-) diff --git a/src/i18n/eng.ts b/src/i18n/eng.ts index 36d0ff8a..acc85bb4 100644 --- a/src/i18n/eng.ts +++ b/src/i18n/eng.ts @@ -731,6 +731,16 @@ export default { }, quotation: { + quotationDate: 'Quotation Date', + seller: 'Seller', + paymentChannels: 'Payment Channels', + channelsThat: 'Channels That', + bankAccountNumber: 'Bank Account Number', + bankAccountName: 'Bank Account Name', + inTheNameOf: 'In The Name Of', + productOrderer: 'Product Orderer', + approver: 'Approver', + date: 'Date', tableColumnsRequest: { code: 'Request List Code', }, @@ -928,6 +938,12 @@ export default { receive: 'Job Receipt ', caption: 'All Task Order', code: 'Task Order Code', + workName: 'Work Name', + contacts: 'Contacts', + inTheNameOf: 'In The Name Of', + productOrderer: 'Product Orderer', + approver: 'Approver', + date: 'Date', receiveTaskOrder: 'Receive Task Order', tasktobeDone: 'Task to be Done', diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 82a286cc..5919f12c 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -725,6 +725,16 @@ export default { }, quotation: { + quotationDate: 'วันที่ใบเสนอราคา', + seller: 'ผู้ขาย', + paymentChannels: 'ช่องทางชำระเงิน', + channelsThat: 'ช่องทางที่', + bankAccountNumber: 'เลขบัญชีธนาคาร', + bankAccountName: 'ชื่อบัญชี', + inTheNameOf: 'ในนาม', + productOrderer: 'ผู้สั่งซื้อสินค้า', + approver: 'ผู้อนุมัติ', + date: 'วันที่', tableColumnsRequest: { code: 'รหัสใบรายการคำขอ', }, @@ -919,6 +929,12 @@ export default { receive: 'ใบรับงาน', caption: 'ใบสั่งงานทั้งหมด', code: 'เลขใบสั่งงาน', + workName: 'ชื่อใบงาน', + contacts: 'ผู้ติดต่อ', + inTheNameOf: 'ในนาม', + productOrderer: 'ผู้สั่งซื้อสินค้า', + approver: 'ผู้อนุมัติ', + date: 'วันที่', receiveTaskOrder: 'รับใบสั่งงาน', tasktobeDone: 'งานที่ต้องทำ', diff --git a/src/pages/05_quotation/preview/BankComponents.vue b/src/pages/05_quotation/preview/BankComponents.vue index 3f6396c4..972e2b5d 100644 --- a/src/pages/05_quotation/preview/BankComponents.vue +++ b/src/pages/05_quotation/preview/BankComponents.vue @@ -38,7 +38,7 @@ watch(