feat: show real actor

This commit is contained in:
Methapon Metanipat 2024-10-16 13:10:58 +07:00
parent 5ee4deda98
commit f01e3d4ca9
2 changed files with 17 additions and 3 deletions

View file

@ -57,6 +57,7 @@ import {
} from 'src/pages/03_customer-management/constant';
import { precisionRound } from 'src/utils/arithmetic';
import { useConfigStore } from 'src/stores/config';
import { getName } from 'src/services/keycloak';
// defineProps<{
// readonly?: boolean;
@ -291,7 +292,6 @@ async function convertDataToFormSubmit() {
contactTel: quotationFormData.value.contactTel,
contactName: quotationFormData.value.contactName,
workName: quotationFormData.value.workName,
actorName: quotationFormData.value.actorName,
_count: quotationFormData.value._count,
status: quotationFormData.value.status,
};
@ -595,10 +595,14 @@ async function searchEmployee(text: string) {
);
if (retEmp) workerList.value = retEmp.data.result;
}
function printPDF() {
window.print();
}
</script>
<template>
<div class="fullscreen column surface-0">
<div class="column surface-0">
<div class="color-bar">
<div class="orange-segment"></div>
<div class="yellow-segment"></div>
@ -831,7 +835,7 @@ async function searchEmployee(text: string) {
<QuotationFormInfo
:quotation-no="(quotationFull && quotationFull.code) || ''"
v-model:urgent="quotationFormData.urgent"
v-model:actor="quotationFormData.actorName"
:actor="quotationFormState.createdBy?.($i18n.locale) || ''"
v-model:work-name="quotationFormData.workName"
v-model:contactor="quotationFormData.contactName"
v-model:telephone="quotationFormData.contactTel"
@ -870,8 +874,10 @@ async function searchEmployee(text: string) {
/>
<EditButton
v-else
class="no-print"
@click="
() => {
printPDF();
quotationFormState.mode = 'edit';
}
"

View file

@ -13,6 +13,7 @@ import {
// NOTE: Import stores
import { useQuotationStore } from 'stores/quotations';
import useEmployeeStore from 'stores/employee';
import { getName } from 'src/services/keycloak';
const DEFAULT_DATA: QuotationPayload = {
productServiceList: [],
@ -68,8 +69,10 @@ export const useQuotationForm = defineStore('form-quotation', () => {
);
const currentFormState = ref<{
mode: null | 'info' | 'create' | 'edit';
createdBy: (locale: string) => string;
}>({
mode: null,
createdBy: (_) => getName() || '',
});
function isFormDataDifferent() {
@ -115,6 +118,10 @@ export const useQuotationForm = defineStore('form-quotation', () => {
currentFormData.value = structuredClone(resetFormData);
currentFormState.value.createdBy = (locale) =>
locale === 'eng'
? data.createdBy.firstNameEN + ' ' + data.createdBy.lastNameEN
: data.createdBy.firstName + ' ' + data.createdBy.lastName;
currentFormState.value.mode = mode;
}
@ -149,6 +156,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
}
currentFormState.value.mode = 'info';
currentFormState.value.createdBy = (_) => getName() || '';
}
function injectNewEmployee(