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

View file

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