diff --git a/src/i18n/tha.ts b/src/i18n/tha.ts index 5919f12c..d019136b 100644 --- a/src/i18n/tha.ts +++ b/src/i18n/tha.ts @@ -746,7 +746,7 @@ export default { title: 'ใบเสนอราคา', caption: 'ใบเสนอราคาทั้งหมด', customerName: 'ชื่อลูกค้า', - actor: 'ผู้ที่ทำรายงาน', + actor: 'ผู้ที่ทำรายการ', totalPrice: 'ยอดรวมสุทธิ', totalPriceBaht: 'ยอดรวมสุทธิ (บาท)', receipt: 'ใบเสร็จ/กำกับภาษี', diff --git a/src/pages/08_request-list/RequestListView.vue b/src/pages/08_request-list/RequestListView.vue index f2edf357..ae826245 100644 --- a/src/pages/08_request-list/RequestListView.vue +++ b/src/pages/08_request-list/RequestListView.vue @@ -15,7 +15,12 @@ import DutyExpansion from './DutyExpansion.vue'; import MessengerExpansion from './MessengerExpansion.vue'; // NOTE: Store -import { baseUrl, dialog } from 'src/stores/utils'; +import { + baseUrl, + dialog, + getEmployeeName, + getCustomerName, +} from 'src/stores/utils'; import { dateFormatJS } from 'src/utils/datetime'; import { useRequestList } from 'src/stores/request-list'; import { @@ -79,47 +84,6 @@ async function fetchRequestWorkList(opts: { requestDataId: string }) { } } -function getCustomerName( - record: RequestData, - opts?: { - locale?: string; - noCode?: boolean; - }, -) { - const customer = record.quotation.customerBranch; - - return ( - { - ['CORP']: { - [Lang.English]: customer.registerNameEN, - [Lang.Thai]: customer.registerName, - }[opts?.locale || 'eng'], - ['PERS']: - { - [Lang.English]: `${optionStore.mapOption(customer.namePrefix)} ${customer.firstNameEN} ${customer.lastNameEN}`, - [Lang.Thai]: `${optionStore.mapOption(customer.namePrefix)} ${customer.firstName} ${customer.lastName}`, - }[opts?.locale || Lang.English] || '-', - }[customer.customer.customerType] + - (opts?.noCode ? '' : ' ' + `(${customer.code})`) - ); -} - -function getEmployeeName( - record: RequestData, - opts?: { - locale?: string; - }, -) { - const employee = record.employee; - - return ( - { - [Lang.English]: `${optionStore.mapOption(employee.namePrefix)} ${employee.firstNameEN} ${employee.lastNameEN}`, - [Lang.Thai]: `${optionStore.mapOption(employee.namePrefix)} ${employee.firstName} ${employee.lastName}`, - }[opts?.locale || Lang.English] || '-' - ); -} - async function getData() { const current = route.params['requestListId']; @@ -611,8 +575,10 @@ function goToQuotation( icon="mdi-account-settings-outline" :label="$t('customer.employer')" :value=" - getCustomerName(data, { locale: locale, noCode: true }) || - '-' + getCustomerName(data.quotation.customerBranch, { + locale: locale, + noCode: true, + }) || '-' " />
+ + {{ $t('general.contactName') }} + +
+ + + +
+
diff --git a/src/stores/utils/index.ts b/src/stores/utils/index.ts index 1052c17a..65dadfe3 100644 --- a/src/stores/utils/index.ts +++ b/src/stores/utils/index.ts @@ -18,6 +18,7 @@ import useOptionStore from '../options'; import { CustomerBranch } from '../customer/types'; import { CustomerBranchRelation } from '../quotations'; import { Employee } from '../employee/types'; +import { CreatedBy } from '../types'; export const baseUrl = import.meta.env.VITE_API_BASE_URL; @@ -596,7 +597,7 @@ export function getCustomerName( } export function getEmployeeName( - record: Employee, + record: Employee | CreatedBy, opts?: { locale?: string; }, @@ -604,7 +605,7 @@ export function getEmployeeName( const employee = record; return { - ['eng']: `${useOptionStore().mapOption(employee.namePrefix)} ${employee.firstNameEN} ${employee.lastNameEN}`, - ['tha']: `${useOptionStore().mapOption(employee.namePrefix)} ${employee.firstName} ${employee.lastName}`, + ['eng']: `${typeof employee.namePrefix === 'string' ? useOptionStore().mapOption(employee.namePrefix) : ''} ${employee.firstNameEN} ${employee.lastNameEN}`, + ['tha']: `${typeof employee.namePrefix === 'string' ? useOptionStore().mapOption(employee.namePrefix) : ''} ${employee.firstName} ${employee.lastName}`, }[opts?.locale || 'eng']; }