From 1d5f77f3a6e017ec247dd2683d46e0a479faa485 Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Fri, 11 Apr 2025 17:59:40 +0700 Subject: [PATCH] feat: copy goodbey --- src/components/button/index.ts | 1 + src/components/shared/KebabAction.vue | 23 +++++++ src/i18n/eng.ts | 6 ++ src/i18n/tha.ts | 5 ++ src/pages/04_product-service/MainPage.vue | 84 ++++++++++++++++++++++- 5 files changed, 118 insertions(+), 1 deletion(-) diff --git a/src/components/button/index.ts b/src/components/button/index.ts index d9b59582..9f3367ef 100644 --- a/src/components/button/index.ts +++ b/src/components/button/index.ts @@ -14,3 +14,4 @@ export { default as PrintButton } from './PrintButton.vue'; export { default as StateButton } from './StateButton.vue'; export { default as NextButton } from './NextButton.vue'; export { default as ImportButton } from './ImportButton.vue'; +export { default as PasteButton } from './PasteButton.vue'; diff --git a/src/components/shared/KebabAction.vue b/src/components/shared/KebabAction.vue index 4dd095db..7bea6b36 100644 --- a/src/components/shared/KebabAction.vue +++ b/src/components/shared/KebabAction.vue @@ -16,6 +16,7 @@ const props = withDefaults( useUpload?: boolean; useCancel?: boolean; useRejectCancel?: boolean; + useCopy?: boolean; disableCancel?: boolean; disableDelete?: boolean; }>(), @@ -31,6 +32,7 @@ defineEmits<{ (e: 'link'): void; (e: 'upload'): void; (e: 'delete'): void; + (e: 'copy'): void; (e: 'cancel'): void; (e: 'rejectCancel'): void; (e: 'changeStatus'): void; @@ -172,6 +174,27 @@ watch( + + + + {{ $t('general.copy') }} + + + (); const { workNameItems } = storeToRefs(productServiceStore); const allStat = ref<{ mode: string; count: number }[]>([]); const stat = ref< @@ -1831,6 +1837,67 @@ function handleSubmitSameWorkflow() { ); } +async function paste() { + if ( + !!currentCopy.value && + currentCopy.value.type === 'service' && + !!currentCopy.value.id + ) + dialogWarningClose(t, { + message: t('dialog.message.warningPaste'), + action: async () => { + const res = await fetchListServiceById(currentCopy.value.id); + if (res) { + formService.value = { + code: res.code, + name: res.name, + detail: res.detail, + attributes: res.attributes, + work: res.work.map((v) => ({ + id: v.id, + name: v.name, + attributes: v.attributes, + product: v.productOnWork.map((productOnWorkItem) => ({ + id: productOnWorkItem.product.id, + installmentNo: productOnWorkItem.installmentNo, + stepCount: productOnWorkItem.stepCount, + })), + })), + status: res.status, + productGroupId: res.productGroupId, + selectedImage: res.selectedImage, + installments: res.installments, + }; + + workItems.value = res.work.map((item) => { + return { + id: item.id, + name: item.name, + attributes: item.attributes, + product: item.productOnWork.map((productOnWorkItem) => { + return { + ...productOnWorkItem.product, + nameEn: productOnWorkItem.product.name, + installmentNo: productOnWorkItem.installmentNo, + }; + }), + }; + }); + } + }, + }); + else { + dialog({ + color: 'warning', + icon: 'mdi-alert', + title: t('form.warning.title'), + actionText: t('dialog.action.ok'), + message: t('dialog.message.warningCopyEmpty'), + action: async () => {}, + }); + } +} + watch( () => formService.value.attributes.workflowId, async (a, b) => { @@ -3127,8 +3194,18 @@ watch( " /> +