From 187ca4db0f6ef9aed100ce071ac3113fe2f6af1f Mon Sep 17 00:00:00 2001 From: puriphatt Date: Wed, 8 Jan 2025 12:58:42 +0700 Subject: [PATCH] feat: request list => PropertiesExpansion display employee name --- src/pages/08_request-list/PropertiesExpansion.vue | 6 +++++- src/stores/utils/index.ts | 15 +++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/pages/08_request-list/PropertiesExpansion.vue b/src/pages/08_request-list/PropertiesExpansion.vue index 48a6785a..257c3364 100644 --- a/src/pages/08_request-list/PropertiesExpansion.vue +++ b/src/pages/08_request-list/PropertiesExpansion.vue @@ -13,7 +13,7 @@ import { import { Attributes, RequestData } from 'src/stores/request-list/types'; -import { getCustomerName } from 'src/stores/utils'; +import { getCustomerName, getEmployeeName } from 'src/stores/utils'; import useOptionStore from 'src/stores/options'; import { useRequestList } from 'src/stores/request-list'; import { useI18n } from 'vue-i18n'; @@ -84,6 +84,7 @@ function triggerEdit() { function assignToForm() { const requestData = props.requestListData; + // console.log(requestData); formRemark.value = attributes.value?.remark || ''; formData.value = JSON.parse( JSON.stringify(attributes.value?.properties || {}), @@ -91,6 +92,9 @@ function assignToForm() { formData.value['quotationNo'] = requestData.quotation.code; formData.value['contactPerson'] = requestData.quotation.contactName; formData.value['telephone'] = requestData.quotation.contactTel; + formData.value['employee'] = getEmployeeName(requestData.employee, { + locale: locale.value, + }); formData.value['employer'] = getCustomerName( requestData.quotation.customerBranch, { locale: locale.value }, diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 22146493..857fff50 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -17,6 +17,7 @@ import DialogDuplicateData from 'components/DialogDuplicateData.vue'; import useOptionStore from '../options'; import { CustomerBranch } from '../customer/types'; import { CustomerBranchRelation } from '../quotations'; +import { Employee } from '../employee/types'; export const baseUrl = import.meta.env.VITE_API_BASE_URL; @@ -571,3 +572,17 @@ export function getCustomerName( (opts?.noCode ? '' : ' ' + `(${customer.code})`) ); } + +export function getEmployeeName( + record: Employee, + opts?: { + locale?: string; + }, +) { + const employee = record; + + return { + ['eng']: `${useOptionStore().mapOption(employee.namePrefix)} ${employee.firstNameEN} ${employee.lastNameEN}`, + ['tha']: `${useOptionStore().mapOption(employee.namePrefix)} ${employee.firstName} ${employee.lastName}`, + }[opts?.locale || 'eng']; +}