From 9c515d10cc9570f0a81ed185cfb5eeb73ec3dffa Mon Sep 17 00:00:00 2001 From: Net <93821485+somnetsak123@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:02:02 +0700 Subject: [PATCH] =?UTF-8?q?feat:=20by=20=E0=B8=84=E0=B9=88=E0=B8=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../04_product-service/FormServiceWork.vue | 95 ++++++++++--------- .../WorkManagementComponent.vue | 47 +++++---- src/pages/04_product-service/MainPage.vue | 86 ++++++++++++++--- 3 files changed, 153 insertions(+), 75 deletions(-) diff --git a/src/components/04_product-service/FormServiceWork.vue b/src/components/04_product-service/FormServiceWork.vue index 49b4f96c..3d8f3ae4 100644 --- a/src/components/04_product-service/FormServiceWork.vue +++ b/src/components/04_product-service/FormServiceWork.vue @@ -8,46 +8,51 @@ import WorkManagementComponent from './WorkManagementComponent.vue'; const { t } = useI18n(); -const serviceName = defineModel('serviceName'); +import { WorkItems, ProductList } from 'src/stores/product-service/types'; -const workItems = ref([ - { - id: '1', - product: [ - { - id: '1', - label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี', - labelEn: '2 year work permit fee', - code: 'AC101', - price: 1200, - time: '14', - }, - ], - }, - { - id: '2', - product: [ - { - id: '1', - label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี', - labelEn: '2 year work permit fee', - code: 'AC101', - price: 1200, - time: '14', - }, - { - id: '1', - label: - 'ค่าบริการและค่าดำเนินงานยื่นคำร้องขอใบอนุญาตทำงานแทน คนงานต่างด้าว MOU', - labelEn: - 'Service and processing fees for submitting a work permit application on behalf of an MOU foreign worker', - code: 'AC102', - price: 1200, - time: '14', - }, - ], - }, -]); +const serviceName = defineModel('serviceName'); +const product = defineModel(); + +const workItems = defineModel('workItems', { default: [] }); + +// const workItems = ref([ +// { +// id: '1', +// product: [ +// { +// id: '1', +// label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี 555', +// labelEn: '2 year work permit fee', +// code: 'AC101', +// price: 1200, +// time: '14', +// }, +// ], +// }, +// { +// id: '2', +// product: [ +// { +// id: '1', +// label: 'ค่าธรรมเนียมใบอนุญาตทำงาน 2 ปี', +// labelEn: '2 year work permit fee', +// code: 'AC101', +// price: 1200, +// time: '14', +// }, +// { +// id: '1', +// label: +// 'ค่าบริการและค่าดำเนินงานยื่นคำร้องขอใบอนุญาตทำงานแทน คนงานต่างด้าว MOU', +// labelEn: +// 'Service and processing fees for submitting a work permit application on behalf of an MOU foreign worker', +// code: 'AC102', +// price: 1200, +// time: '14', +// }, +// ], +// }, +// ]); defineProps<{ dense?: boolean; @@ -57,15 +62,16 @@ defineProps<{ }>(); defineEmits<{ - (e: 'addProduct'): void; + (e: 'addProduct', index: number): void; (e: 'manageWorkName'): void; - (e: 'workProperties'): void; + (e: 'workProperties', index: number): void; }>(); function addWork() { - console.log('hi'); workItems.value.push({ id: '', + name: '', + attributes: { additional: [] }, product: [], }); } @@ -108,8 +114,9 @@ function confirmDelete(items: unknown[], index: number) { :index="index" :length="workItems.length" :workIndex="index" + v-model:work-name="workItems[index].name" v-model:product-items="work.product" - @add-product="$emit('addProduct')" + @add-product="$emit('addProduct', index)" @move-work-up="moveItemUp(workItems, index)" @move-work-down="moveItemDown(workItems, index)" @delete-work="confirmDelete(workItems, index)" @@ -117,7 +124,7 @@ function confirmDelete(items: unknown[], index: number) { @move-product-down="moveItemDown" @delete-product="confirmDelete" @manage-work-name="$emit('manageWorkName')" - @work-properties="$emit('workProperties')" + @work-properties="$emit('workProperties', index)" > diff --git a/src/components/04_product-service/WorkManagementComponent.vue b/src/components/04_product-service/WorkManagementComponent.vue index 1ad50078..0422a810 100644 --- a/src/components/04_product-service/WorkManagementComponent.vue +++ b/src/components/04_product-service/WorkManagementComponent.vue @@ -2,6 +2,8 @@ import { Icon } from '@iconify/vue'; import { formatNumberDecimal } from 'src/stores/utils'; +import { ProductList } from 'src/stores/product-service/types'; + defineProps<{ workIndex: number; length: number; @@ -9,16 +11,20 @@ defineProps<{ }>(); const workName = defineModel('workName'); -const productItems = defineModel< +const productItems = defineModel<(ProductList & { nameEn: string })[]>( + 'productItems', { - id: string; - label: string; - labelEn: string; - code: string; - price: number; - time: string; - }[] ->('productItems', { required: true }); + required: true, + }, +); + +const testName = [ + 'ทดสอบการขาย 1', + 'ทดสอบการขาย 2', + 'ทดสอบการขาย 3', + 'ทดสอบการขาย 4', + 'ทดสอบการขาย 5', +]; defineEmits<{ (e: 'moveWorkUp'): void; @@ -87,7 +93,9 @@ defineEmits<{ {{ $t('workNo') }} {{ index + 1 }} : - {{ $t('workName') }} + + {{ $t('workName') + ' ' + workName }} + @@ -109,7 +117,12 @@ defineEmits<{ - +
- {{ 'asd' }} + {{ item }}
@@ -214,15 +227,13 @@ defineEmits<{ :style="`max-width: ${$q.screen.gt.sm ? '25vw' : '20vw'}`" > {{ - $i18n.locale === 'en-US' - ? product.labelEn - : product.label + $i18n.locale === 'en-US' ? product.nameEn : product.name }} {{ $i18n.locale === 'en-US' - ? product.labelEn - : product.label + ? product.nameEn + : product.name }} @@ -247,7 +258,7 @@ defineEmits<{ {{ $t('processTime') }} - {{ product.time }} {{ $t('day') }} + {{ product.process }} {{ $t('day') }} diff --git a/src/pages/04_product-service/MainPage.vue b/src/pages/04_product-service/MainPage.vue index 5a0f53a6..c2bbbf03 100644 --- a/src/pages/04_product-service/MainPage.vue +++ b/src/pages/04_product-service/MainPage.vue @@ -33,6 +33,8 @@ import { ServiceCreate, Service, ServiceById, + WorkItems, + Attributes, } from 'src/stores/product-service/types'; const productServiceStore = useProductServiceStore(); @@ -81,6 +83,7 @@ const stat = ref< import { useI18n } from 'vue-i18n'; import { onMounted } from 'vue'; +import { time } from 'console'; const { t } = useI18n(); @@ -100,7 +103,9 @@ const infoProductEdit = ref(false); const imageProduct = ref(undefined); const profileUrl = ref(''); -const groupName = ref('งาน MOU'); +const pathGroupName = ref(''); +const pathTypeName = ref(''); + const dialogProductServiceType = ref(false); const dialogTotalProduct = ref(false); const productMode = ref<'group' | 'type' | 'service' | 'product'>('group'); @@ -156,11 +161,16 @@ const serviceTab = [ label: 'workInformation', }, ]; + +const workItems = ref([]); + const currentServiceTab = ref('serviceInformation'); const propertiesDialog = ref(false); const selectProduct = ref([]); +const currentWorkIndex = ref(0); + const currentId = ref(''); const currentIdType = ref(''); const currentIdService = ref(''); @@ -532,6 +542,11 @@ async function submitGroup() { clearFormGroup(); } +const tempValueProperties = ref({ + additional: [], +}); +const currentPropertiesMode = ref<'service' | 'work'>('service'); + function openPropertiesDialog(type: 'service' | 'work') { if (type === 'service') { propertiesOption.value = @@ -541,6 +556,8 @@ function openPropertiesDialog(type: 'service' | 'work') { if (type === 'work') { propertiesOption.value = optionStore.globalOption.tha.workPropertiesField; } + + currentPropertiesMode.value = type; propertiesDialog.value = true; } @@ -676,7 +693,7 @@ watch(currentStatus, async () => { class="q-mr-md" />
- {{ groupName }} + {{ pathGroupName }}
/
@@ -696,11 +713,11 @@ watch(currentStatus, async () => { class="q-mr-md" />
- {{ groupName }} + {{ pathGroupName }}
/
- {{ 'บริการพิสูจน์สัญชาติ' }} + {{ pathTypeName }}
/
@@ -843,6 +860,7 @@ watch(currentStatus, async () => { " @on-click=" async () => { + pathTypeName = v.name; currentIdType = v.id; productMode = 'service'; await fetchListOfProduct(currentIdType); @@ -885,6 +903,7 @@ watch(currentStatus, async () => { " @on-click=" async () => { + pathGroupName = v.name; currentId = v.id; productMode = 'type'; await fetchListType(); @@ -917,7 +936,7 @@ watch(currentStatus, async () => { : 'app-text-muted' " > - ทั้งหมด + {{ $t('all') }} - บริการ + {{ $t('service') }} - สินค้า + {{ $t('product') }} { v-if="currentServiceTab === 'serviceInformation'" dense service - @service-properties="openPropertiesDialog('service')" + @service-properties=" + () => { + tempValueProperties = formDataProductService.attributes; + openPropertiesDialog('service'); + } + " /> @@ -1409,15 +1453,31 @@ watch(currentStatus, async () => {