refactor: assign worker to selectedWorker
This commit is contained in:
parent
4e736a2c96
commit
d5c8ce85b6
3 changed files with 62 additions and 7 deletions
|
|
@ -4,7 +4,11 @@ import { useI18n } from 'vue-i18n';
|
|||
import { ref } from 'vue';
|
||||
|
||||
// NOTE: Import types
|
||||
import { QuotationPayload, EmployeeWorker } from 'src/stores/quotations/types';
|
||||
import {
|
||||
QuotationPayload,
|
||||
EmployeeWorker,
|
||||
QuotationFull,
|
||||
} from 'src/stores/quotations/types';
|
||||
|
||||
// NOTE: Import stores
|
||||
import { useQuotationStore } from 'stores/quotations';
|
||||
|
|
@ -34,6 +38,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
|||
|
||||
const quotationStore = useQuotationStore();
|
||||
const employeeStore = useEmployeeStore();
|
||||
const quotationFull = ref<QuotationFull | undefined>(undefined);
|
||||
const newWorkerList = ref<
|
||||
(EmployeeWorker & {
|
||||
attachment?: {
|
||||
|
|
@ -91,10 +96,25 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
|||
|
||||
if (!data) return; // NOTE: Error should be handled globally by axios instance
|
||||
|
||||
quotationFull.value = data;
|
||||
resetFormData = Object.assign(data, {
|
||||
productServiceList: data.productServiceList.map((v) => ({
|
||||
...v,
|
||||
worker: undefined,
|
||||
worker: v.worker.map((value, index) => ({
|
||||
// passportNo: obj.data.passportNo, wait api add
|
||||
//documentExpireDate: obj.data.documentExpireDate,
|
||||
id: value.id,
|
||||
lastNameEN: value.lastNameEN,
|
||||
lastName: value.lastName,
|
||||
middleNameEN: value.middleNameEN,
|
||||
middleName: value.middleName,
|
||||
firstNameEN: value.firstNameEN,
|
||||
firstName: value.firstName,
|
||||
namePrefix: value.namePrefix,
|
||||
nationality: value.nationality,
|
||||
gender: value.gender,
|
||||
dateOfBirth: value.dateOfBirth,
|
||||
})),
|
||||
workerIndex: v.worker.map((a) =>
|
||||
data.worker.findIndex((b) => b.employeeId === a.id),
|
||||
),
|
||||
|
|
@ -110,6 +130,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
|||
|
||||
currentFormData.value = structuredClone(resetFormData);
|
||||
|
||||
console.log('ทำงาน');
|
||||
currentFormState.value.mode = mode;
|
||||
}
|
||||
|
||||
|
|
@ -192,6 +213,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
|||
currentFormData,
|
||||
newWorkerList,
|
||||
fileItemNewWorker,
|
||||
quotationFull,
|
||||
|
||||
isFormDataDifferent,
|
||||
injectNewEmployee,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue