Merge branch 'develop'
This commit is contained in:
commit
02bb682150
8 changed files with 336 additions and 143 deletions
|
|
@ -293,15 +293,11 @@ watch(
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:label="$t('form.birthDate')"
|
:label="$t('form.birthDate')"
|
||||||
:disabled-dates="disabledAfterToday"
|
:disabled-dates="disabledAfterToday"
|
||||||
:rules="
|
:rules="[
|
||||||
employee
|
|
||||||
? []
|
|
||||||
: [
|
|
||||||
(val: string) =>
|
(val: string) =>
|
||||||
!!val ||
|
!!val ||
|
||||||
$t('form.error.selectField', { field: $t('form.birthDate') }),
|
$t('form.error.selectField', { field: $t('form.birthDate') }),
|
||||||
]
|
]"
|
||||||
"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<q-input
|
<q-input
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ defineProps<{
|
||||||
outlined?: boolean;
|
outlined?: boolean;
|
||||||
disabled?: boolean;
|
disabled?: boolean;
|
||||||
dark?: boolean;
|
dark?: boolean;
|
||||||
|
color?: string;
|
||||||
|
|
||||||
label?: string;
|
label?: string;
|
||||||
icon?: string;
|
icon?: string;
|
||||||
|
|
@ -23,7 +24,7 @@ defineProps<{
|
||||||
@click="(e) => $emit('click', e)"
|
@click="(e) => $emit('click', e)"
|
||||||
v-bind="{ ...$props, ...$attrs }"
|
v-bind="{ ...$props, ...$attrs }"
|
||||||
:icon="icon || 'mdi-content-save-outline'"
|
:icon="icon || 'mdi-content-save-outline'"
|
||||||
color="207 96% 32%"
|
:color="color || '207 96% 32%'"
|
||||||
:title="iconOnly ? $t('general.save') : undefined"
|
:title="iconOnly ? $t('general.save') : undefined"
|
||||||
>
|
>
|
||||||
{{ label || $t('general.save') }}
|
{{ label || $t('general.save') }}
|
||||||
|
|
|
||||||
|
|
@ -102,6 +102,8 @@ const {
|
||||||
deleteWork,
|
deleteWork,
|
||||||
|
|
||||||
importProduct,
|
importProduct,
|
||||||
|
|
||||||
|
productExport,
|
||||||
} = productServiceStore;
|
} = productServiceStore;
|
||||||
|
|
||||||
const { workNameItems } = storeToRefs(productServiceStore);
|
const { workNameItems } = storeToRefs(productServiceStore);
|
||||||
|
|
@ -1896,6 +1898,25 @@ async function submitWorkName(
|
||||||
else await editWork(workId, data);
|
else await editWork(workId, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function triggerExport() {
|
||||||
|
productExport({
|
||||||
|
pageSize: 100_000,
|
||||||
|
productGroupId: currentIdGroup.value,
|
||||||
|
query: !!inputSearchProductAndService.value
|
||||||
|
? inputSearchProductAndService.value
|
||||||
|
: undefined,
|
||||||
|
status:
|
||||||
|
currentStatus.value === 'INACTIVE'
|
||||||
|
? 'INACTIVE'
|
||||||
|
: currentStatus.value === 'ACTIVE'
|
||||||
|
? 'ACTIVE'
|
||||||
|
: undefined,
|
||||||
|
|
||||||
|
startDate: new Date(searchDate.value[0]),
|
||||||
|
endDate: new Date(searchDate.value[1]),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => formService.value.attributes.workflowId,
|
() => formService.value.attributes.workflowId,
|
||||||
async (a, b) => {
|
async (a, b) => {
|
||||||
|
|
@ -2229,7 +2250,6 @@ watch(
|
||||||
</AdvanceSearch>
|
</AdvanceSearch>
|
||||||
</template>
|
</template>
|
||||||
</q-input>
|
</q-input>
|
||||||
|
|
||||||
<div class="row col-md-6" style="white-space: nowrap">
|
<div class="row col-md-6" style="white-space: nowrap">
|
||||||
<q-select
|
<q-select
|
||||||
v-show="$q.screen.gt.sm"
|
v-show="$q.screen.gt.sm"
|
||||||
|
|
@ -2780,6 +2800,13 @@ watch(
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
<SaveButton
|
||||||
|
icon-only
|
||||||
|
:icon="'material-symbols:download'"
|
||||||
|
color="var(--info-bg)"
|
||||||
|
@click.stop="triggerExport()"
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="row col-md-6" style="white-space: nowrap">
|
<div class="row col-md-6" style="white-space: nowrap">
|
||||||
|
|
@ -3632,7 +3659,7 @@ watch(
|
||||||
:delete-data="() => deleteGroupById()"
|
:delete-data="() => deleteGroupById()"
|
||||||
:close="
|
:close="
|
||||||
() => {
|
() => {
|
||||||
(drawerInfo = false), (currentIdGroupType = '');
|
((drawerInfo = false), (currentIdGroupType = ''));
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
hide-action
|
hide-action
|
||||||
|
|
|
||||||
|
|
@ -161,49 +161,7 @@ const selectedWorker = ref<
|
||||||
}[];
|
}[];
|
||||||
})[]
|
})[]
|
||||||
>([]);
|
>([]);
|
||||||
const selectedWorkerItem = computed(() => {
|
const selectedWorkerItem = ref([]);
|
||||||
return [
|
|
||||||
...selectedWorker.value.map((e) => ({
|
|
||||||
foreignRefNo: e.employeePassport
|
|
||||||
? e.employeePassport[0]?.number || '-'
|
|
||||||
: '-',
|
|
||||||
employeeName:
|
|
||||||
locale.value === Lang.English
|
|
||||||
? `${e.firstNameEN} ${e.lastNameEN}`
|
|
||||||
: e.firstName
|
|
||||||
? `${e.firstName} ${e.lastName}`
|
|
||||||
: `${e.firstNameEN} ${e.lastNameEN}`,
|
|
||||||
birthDate: dateFormatJS({ date: e.dateOfBirth }),
|
|
||||||
gender: e.gender,
|
|
||||||
age: calculateAge(e.dateOfBirth),
|
|
||||||
nationality: optionStore.mapOption(e.nationality),
|
|
||||||
documentExpireDate:
|
|
||||||
e.employeePassport !== undefined &&
|
|
||||||
e.employeePassport[0]?.expireDate !== undefined
|
|
||||||
? dateFormatJS({ date: e.employeePassport[0]?.expireDate })
|
|
||||||
: '-',
|
|
||||||
imgUrl: e.selectedImage
|
|
||||||
? `${API_BASE_URL}/employee/${e.id}/image/${e.selectedImage}`
|
|
||||||
: '',
|
|
||||||
status: e.status,
|
|
||||||
})),
|
|
||||||
|
|
||||||
...newWorkerList.value.map((v: any) => ({
|
|
||||||
foreignRefNo: v.passportNo,
|
|
||||||
employeeName:
|
|
||||||
locale.value === Lang.English
|
|
||||||
? `${v.firstNameEN} ${v.lastNameEN}`
|
|
||||||
: `${v.firstName} ${v.lastName}`,
|
|
||||||
birthDate: dateFormatJS({ date: v.dateOfBirth }),
|
|
||||||
gender: v.gender,
|
|
||||||
age: calculateAge(v.dateOfBirth),
|
|
||||||
nationality: optionStore.mapOption(v.nationality),
|
|
||||||
documentExpireDate: '-',
|
|
||||||
imgUrl: '',
|
|
||||||
status: 'CREATED',
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
const firstCodePayment = ref('');
|
const firstCodePayment = ref('');
|
||||||
const selectedProductGroup = ref('');
|
const selectedProductGroup = ref('');
|
||||||
const selectedInstallmentNo = ref<number[]>([]);
|
const selectedInstallmentNo = ref<number[]>([]);
|
||||||
|
|
@ -556,7 +514,7 @@ async function convertDataToFormSubmit() {
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
|
|
||||||
selectedWorker.value.forEach((v, i) => {
|
selectedWorkerItem.value.forEach((v, i) => {
|
||||||
if (v.attachment !== undefined) {
|
if (v.attachment !== undefined) {
|
||||||
v.attachment.forEach((value) => {
|
v.attachment.forEach((value) => {
|
||||||
fileItemNewWorker.value.push({
|
fileItemNewWorker.value.push({
|
||||||
|
|
@ -573,7 +531,7 @@ async function convertDataToFormSubmit() {
|
||||||
|
|
||||||
quotationFormData.value.worker = JSON.parse(
|
quotationFormData.value.worker = JSON.parse(
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
...selectedWorker.value.map((v) => {
|
...selectedWorkerItem.value.map((v) => {
|
||||||
{
|
{
|
||||||
return v.id;
|
return v.id;
|
||||||
}
|
}
|
||||||
|
|
@ -806,7 +764,40 @@ function toggleDeleteProduct(index: number) {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assignWorkerToSelectedWorker() {
|
async function assignWorkerToSelectedWorker() {
|
||||||
selectedWorker.value = quotationFormData.value.worker;
|
selectedWorkerItem.value = quotationFormData.value.worker.map((e) => {
|
||||||
|
return {
|
||||||
|
id: e.id,
|
||||||
|
foreignRefNo: e.employeePassport
|
||||||
|
? e.employeePassport[0]?.number || '-'
|
||||||
|
: '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${e.firstNameEN} ${e.lastNameEN}`
|
||||||
|
: `${e.firstName || e.firstNameEN} ${e.lastName || e.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: e.dateOfBirth }),
|
||||||
|
gender: e.gender,
|
||||||
|
age: calculateAge(e.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(e.nationality),
|
||||||
|
documentExpireDate:
|
||||||
|
e.employeePassport !== undefined &&
|
||||||
|
e.employeePassport[0]?.expireDate !== undefined
|
||||||
|
? dateFormatJS({ date: e.employeePassport[0]?.expireDate })
|
||||||
|
: '-',
|
||||||
|
imgUrl: e.selectedImage
|
||||||
|
? `${API_BASE_URL}/employee/${e.id}/image/${e.selectedImage}`
|
||||||
|
: '',
|
||||||
|
employeePassport: e.employeePassport,
|
||||||
|
status: e.status,
|
||||||
|
workerNew: false,
|
||||||
|
lastNameEN: e.lastNameEN,
|
||||||
|
lastName: e.lastName,
|
||||||
|
middleNameEN: e.middleNameEN,
|
||||||
|
middleName: e.middleName,
|
||||||
|
firstNameEN: e.firstNameEN,
|
||||||
|
firstName: e.firstName,
|
||||||
|
namePrefix: e.namePrefix,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function convertToTable(nodes: Node[]) {
|
function convertToTable(nodes: Node[]) {
|
||||||
|
|
@ -865,21 +856,21 @@ function convertToTable(nodes: Node[]) {
|
||||||
|
|
||||||
function convertEmployeeToTable(selected: Employee[]) {
|
function convertEmployeeToTable(selected: Employee[]) {
|
||||||
productServiceList.value.forEach((v) => {
|
productServiceList.value.forEach((v) => {
|
||||||
if (selectedWorker.value.length === 0 && v.amount === 1) v.amount -= 1;
|
if (selectedWorkerItem.value.length === 0 && v.amount === 1) v.amount -= 1;
|
||||||
|
|
||||||
v.amount = Math.max(
|
v.amount = Math.max(
|
||||||
v.amount + selected.length - selectedWorker.value.length,
|
v.amount + selected.length - selectedWorkerItem.value.length,
|
||||||
1,
|
1,
|
||||||
);
|
);
|
||||||
|
|
||||||
const oldWorkerId: string[] = [];
|
const oldWorkerId: string[] = [];
|
||||||
const newWorkerIndex: number[] = [];
|
const newWorkerIndex: number[] = [];
|
||||||
|
|
||||||
selectedWorker.value.forEach((item, i) => {
|
selectedWorkerItem.value.forEach((item, i) => {
|
||||||
if (v.workerIndex.includes(i)) oldWorkerId.push(item.id);
|
if (v.workerIndex.includes(i)) oldWorkerId.push(item.id);
|
||||||
});
|
});
|
||||||
selected.forEach((item, i) => {
|
selected.forEach((item, i) => {
|
||||||
if (selectedWorker.value.find((n) => item.id === n.id)) return;
|
if (selectedWorkerItem.value.find((n) => item.id === n.id)) return;
|
||||||
newWorkerIndex.push(i);
|
newWorkerIndex.push(i);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -892,7 +883,7 @@ function convertEmployeeToTable(selected: Employee[]) {
|
||||||
pageState.employeeModal = false;
|
pageState.employeeModal = false;
|
||||||
quotationFormData.value.workerMax = Math.max(
|
quotationFormData.value.workerMax = Math.max(
|
||||||
quotationFormData.value.workerMax || 1,
|
quotationFormData.value.workerMax || 1,
|
||||||
selectedWorker.value.length,
|
selectedWorkerItem.value.length,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -965,6 +956,71 @@ function viewProductFile(data: ProductRelation) {
|
||||||
pageState.imageDialogUrl = base64 ? base64[1] : '';
|
pageState.imageDialogUrl = base64 ? base64[1] : '';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function combineWorker(newWorker: any, oldWorker: any) {
|
||||||
|
selectedWorkerItem.value = [
|
||||||
|
...oldWorker.map((e) => ({
|
||||||
|
id: e.id,
|
||||||
|
foreignRefNo: e.employeePassport
|
||||||
|
? e.employeePassport[0]?.number || '-'
|
||||||
|
: '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${e.firstNameEN} ${e.lastNameEN}`
|
||||||
|
: `${e.firstName || e.firstNameEN} ${e.lastName || e.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: e.dateOfBirth }),
|
||||||
|
gender: e.gender,
|
||||||
|
age: calculateAge(e.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(e.nationality),
|
||||||
|
documentExpireDate:
|
||||||
|
e.employeePassport !== undefined &&
|
||||||
|
e.employeePassport[0]?.expireDate !== undefined
|
||||||
|
? dateFormatJS({ date: e.employeePassport[0]?.expireDate })
|
||||||
|
: '-',
|
||||||
|
imgUrl: e.selectedImage
|
||||||
|
? `${API_BASE_URL}/employee/${e.id}/image/${e.selectedImage}`
|
||||||
|
: '',
|
||||||
|
|
||||||
|
employeePassport: e.employeePassport,
|
||||||
|
status: e.status,
|
||||||
|
workerNew: false,
|
||||||
|
lastNameEN: e.lastNameEN,
|
||||||
|
lastName: e.lastName,
|
||||||
|
middleNameEN: e.middleNameEN,
|
||||||
|
middleName: e.middleName,
|
||||||
|
firstNameEN: e.firstNameEN,
|
||||||
|
firstName: e.firstName,
|
||||||
|
namePrefix: e.namePrefix,
|
||||||
|
})),
|
||||||
|
|
||||||
|
...newWorker.map((v: any) => ({
|
||||||
|
id: v.id,
|
||||||
|
foreignRefNo: v.passportNo || '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${v.firstNameEN} ${v.lastNameEN}`
|
||||||
|
: `${v.firstName || v.firstNameEN} ${v.lastName || v.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: v.dateOfBirth }),
|
||||||
|
gender: v.gender,
|
||||||
|
age: calculateAge(v.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(v.nationality),
|
||||||
|
documentExpireDate: '-',
|
||||||
|
imgUrl: '',
|
||||||
|
status: 'CREATED',
|
||||||
|
|
||||||
|
lastNameEN: v.lastNameEN,
|
||||||
|
lastName: v.lastName,
|
||||||
|
middleNameEN: v.middleNameEN,
|
||||||
|
middleName: v.middleName,
|
||||||
|
firstNameEN: v.firstNameEN,
|
||||||
|
firstName: v.firstName,
|
||||||
|
namePrefix: v.namePrefix,
|
||||||
|
|
||||||
|
dateOfBirth: v.dateOfBirth,
|
||||||
|
workerNew: true,
|
||||||
|
})),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
const sessionData = ref<Record<string, any>>();
|
const sessionData = ref<Record<string, any>>();
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
|
|
@ -1036,7 +1092,7 @@ watch(
|
||||||
() => quotationFormData.value.customerBranchId,
|
() => quotationFormData.value.customerBranchId,
|
||||||
async (v) => {
|
async (v) => {
|
||||||
if (!v) return;
|
if (!v) return;
|
||||||
selectedWorker.value = [];
|
selectedWorkerItem.value = [];
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
@ -1116,7 +1172,7 @@ function storeDataLocal() {
|
||||||
workName: quotationFormData.value.workName,
|
workName: quotationFormData.value.workName,
|
||||||
dueDate: quotationFormData.value.dueDate,
|
dueDate: quotationFormData.value.dueDate,
|
||||||
},
|
},
|
||||||
selectedWorker: selectedWorker.value,
|
selectedWorker: selectedWorkerItem.value,
|
||||||
createdBy: quotationFormState.value.createdBy('tha'),
|
createdBy: quotationFormState.value.createdBy('tha'),
|
||||||
agentPrice: agentPrice.value,
|
agentPrice: agentPrice.value,
|
||||||
},
|
},
|
||||||
|
|
@ -1201,10 +1257,10 @@ async function getWorkerFromCriteria(
|
||||||
if (!ret) return false; // error, do not close dialog
|
if (!ret) return false; // error, do not close dialog
|
||||||
|
|
||||||
const deduplicate = ret.result.filter(
|
const deduplicate = ret.result.filter(
|
||||||
(a) => !selectedWorker.value.find((b) => a.id === b.id),
|
(a) => !selectedWorkerItem.value.find((b) => a.id === b.id),
|
||||||
);
|
);
|
||||||
|
|
||||||
convertEmployeeToTable([...deduplicate, ...selectedWorker.value]);
|
convertEmployeeToTable([...deduplicate, ...selectedWorkerItem.value]);
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1594,15 +1650,15 @@ function covertToNode() {
|
||||||
(v) =>
|
(v) =>
|
||||||
(quotationFormData.workerMax = Math.max(
|
(quotationFormData.workerMax = Math.max(
|
||||||
v,
|
v,
|
||||||
selectedWorker.length,
|
selectedWorkerItem.length,
|
||||||
))
|
))
|
||||||
"
|
"
|
||||||
:employee-amount="
|
:employee-amount="
|
||||||
quotationFormData.workerMax || selectedWorker.length
|
quotationFormData.workerMax || selectedWorkerItem.length
|
||||||
"
|
"
|
||||||
:readonly="readonly"
|
:readonly="readonly"
|
||||||
:rows="selectedWorkerItem"
|
:rows="selectedWorkerItem"
|
||||||
@delete="(i) => deleteItem(selectedWorker, i)"
|
@delete="(i) => deleteItem(selectedWorkerItem, i)"
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</q-expansion-item>
|
</q-expansion-item>
|
||||||
|
|
@ -1846,7 +1902,7 @@ function covertToNode() {
|
||||||
installments: quotationFormData.paySplit,
|
installments: quotationFormData.paySplit,
|
||||||
},
|
},
|
||||||
'quotation-labor': {
|
'quotation-labor': {
|
||||||
name: selectedWorker.map(
|
name: selectedWorkerItem.map(
|
||||||
(v, i) =>
|
(v, i) =>
|
||||||
`${i + 1}. ` +
|
`${i + 1}. ` +
|
||||||
`${v.employeePassport.length !== 0 ? v.employeePassport[0].number + '_' : ''}${v.namePrefix}.${v.firstNameEN ? `${v.firstNameEN} ${v.lastNameEN}` : `${v.firstName} ${v.lastName}`} `.toUpperCase(),
|
`${v.employeePassport.length !== 0 ? v.employeePassport[0].number + '_' : ''}${v.namePrefix}.${v.firstNameEN ? `${v.firstNameEN} ${v.lastNameEN}` : `${v.firstName} ${v.lastName}`} `.toUpperCase(),
|
||||||
|
|
@ -2389,13 +2445,12 @@ function covertToNode() {
|
||||||
<!-- add employee quotation -->
|
<!-- add employee quotation -->
|
||||||
|
|
||||||
<QuotationFormWorkerSelect
|
<QuotationFormWorkerSelect
|
||||||
:preselect-worker="selectedWorker"
|
:preselect-worker="selectedWorkerItem"
|
||||||
:customerBranchId="quotationFormData.customerBranchId"
|
:customerBranchId="quotationFormData.customerBranchId"
|
||||||
v-model:open="pageState.employeeModal"
|
v-model:open="pageState.employeeModal"
|
||||||
v-model:new-worker-list="newWorkerList"
|
|
||||||
@success="
|
@success="
|
||||||
(v) => {
|
(v) => {
|
||||||
selectedWorker = v.worker;
|
combineWorker(v.newWorker, v.worker);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
@ -2438,7 +2493,7 @@ function covertToNode() {
|
||||||
<!-- add Worker -->
|
<!-- add Worker -->
|
||||||
<QuotationFormWorkerAddDialog
|
<QuotationFormWorkerAddDialog
|
||||||
v-if="quotationFormState.source"
|
v-if="quotationFormState.source"
|
||||||
:disabled-worker-id="selectedWorker.map((v) => v.id)"
|
:disabled-worker-id="selectedWorkerItem.map((v) => v.id)"
|
||||||
:product-service-list="quotationFormState.source.productServiceList"
|
:product-service-list="quotationFormState.source.productServiceList"
|
||||||
:quotation-id="quotationFormState.source.id"
|
:quotation-id="quotationFormState.source.id"
|
||||||
:customer-branch-id="quotationFormState.source.customerBranchId"
|
:customer-branch-id="quotationFormState.source.customerBranchId"
|
||||||
|
|
|
||||||
|
|
@ -113,7 +113,7 @@ const props = withDefaults(
|
||||||
defineProps<{
|
defineProps<{
|
||||||
customerBranchId?: string;
|
customerBranchId?: string;
|
||||||
disabledWorkerId?: string[];
|
disabledWorkerId?: string[];
|
||||||
preselectWorker?: Employee[];
|
preselectWorker?: (Employee & { workerNew: boolean })[];
|
||||||
}>(),
|
}>(),
|
||||||
{},
|
{},
|
||||||
);
|
);
|
||||||
|
|
@ -133,7 +133,7 @@ const optionStore = useOptionStore();
|
||||||
const employeeStore = useEmployeeStore();
|
const employeeStore = useEmployeeStore();
|
||||||
|
|
||||||
const open = defineModel<boolean>('open', { default: false });
|
const open = defineModel<boolean>('open', { default: false });
|
||||||
const newWorkerList = defineModel<
|
const newWorkerList = ref<
|
||||||
(EmployeeWorker & {
|
(EmployeeWorker & {
|
||||||
attachment?: {
|
attachment?: {
|
||||||
name?: string;
|
name?: string;
|
||||||
|
|
@ -143,7 +143,7 @@ const newWorkerList = defineModel<
|
||||||
_meta?: Record<string, any>;
|
_meta?: Record<string, any>;
|
||||||
}[];
|
}[];
|
||||||
})[]
|
})[]
|
||||||
>('newWorkerList', { default: [] });
|
>([]);
|
||||||
const workerSelected = ref<Employee[]>([]);
|
const workerSelected = ref<Employee[]>([]);
|
||||||
const workerList = ref<Employee[]>([]);
|
const workerList = ref<Employee[]>([]);
|
||||||
const importWorkerCriteria = ref<{
|
const importWorkerCriteria = ref<{
|
||||||
|
|
@ -208,7 +208,13 @@ function getEmployeeImageUrl(item: Employee) {
|
||||||
|
|
||||||
function init() {
|
function init() {
|
||||||
if (props.preselectWorker) {
|
if (props.preselectWorker) {
|
||||||
workerSelected.value = JSON.parse(JSON.stringify(props.preselectWorker));
|
workerSelected.value = JSON.parse(
|
||||||
|
JSON.stringify(props.preselectWorker.filter((v) => !v.workerNew)),
|
||||||
|
);
|
||||||
|
|
||||||
|
newWorkerList.value = JSON.parse(
|
||||||
|
JSON.stringify(props.preselectWorker.filter((v) => v.workerNew)),
|
||||||
|
);
|
||||||
}
|
}
|
||||||
getWorkerList();
|
getWorkerList();
|
||||||
}
|
}
|
||||||
|
|
@ -608,11 +614,14 @@ watch(
|
||||||
solid
|
solid
|
||||||
id="btn-success"
|
id="btn-success"
|
||||||
@click="
|
@click="
|
||||||
(emits('success', {
|
() => {
|
||||||
|
$emit('success', {
|
||||||
worker: workerSelected,
|
worker: workerSelected,
|
||||||
newWorker: newWorkerList,
|
newWorker: newWorkerList,
|
||||||
}),
|
});
|
||||||
(open = false))
|
|
||||||
|
open = false;
|
||||||
|
}
|
||||||
"
|
"
|
||||||
>
|
>
|
||||||
{{ $t('general.select', { msg: $t('quotation.employeeList') }) }}
|
{{ $t('general.select', { msg: $t('quotation.employeeList') }) }}
|
||||||
|
|
@ -634,9 +643,11 @@ watch(
|
||||||
if (employeeFormState.currentTab === 'personalInfo') {
|
if (employeeFormState.currentTab === 'personalInfo') {
|
||||||
const currentEmployeeId =
|
const currentEmployeeId =
|
||||||
await employeeFormStore.submitPersonal(onCreateImageList);
|
await employeeFormStore.submitPersonal(onCreateImageList);
|
||||||
|
newWorkerList.push(
|
||||||
quotationForm.injectNewEmployee({
|
quotationForm.injectNewEmployee({
|
||||||
data: { ...currentFromDataEmployee, id: currentEmployeeId },
|
data: { ...currentFromDataEmployee, id: currentEmployeeId },
|
||||||
});
|
}),
|
||||||
|
);
|
||||||
employeeFormState.isEmployeeEdit = false;
|
employeeFormState.isEmployeeEdit = false;
|
||||||
employeeFormState.dialogType = 'info';
|
employeeFormState.dialogType = 'info';
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
||||||
file?: File;
|
file?: File;
|
||||||
_meta?: Record<string, any>;
|
_meta?: Record<string, any>;
|
||||||
}[];
|
}[];
|
||||||
|
workerNew: boolean;
|
||||||
})[]
|
})[]
|
||||||
>([]);
|
>([]);
|
||||||
|
|
||||||
|
|
@ -220,7 +221,7 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
||||||
},
|
},
|
||||||
callback?: () => void,
|
callback?: () => void,
|
||||||
) {
|
) {
|
||||||
newWorkerList.value.push({
|
const temp = {
|
||||||
//passportNo: obj.data.passportNo,
|
//passportNo: obj.data.passportNo,
|
||||||
//documentExpireDate: obj.data.documentExpireDate,
|
//documentExpireDate: obj.data.documentExpireDate,
|
||||||
id: obj.data.id,
|
id: obj.data.id,
|
||||||
|
|
@ -235,9 +236,12 @@ export const useQuotationForm = defineStore('form-quotation', () => {
|
||||||
gender: obj.data.gender,
|
gender: obj.data.gender,
|
||||||
dateOfBirth: obj.data.dateOfBirth,
|
dateOfBirth: obj.data.dateOfBirth,
|
||||||
attachment: obj.data.attachment,
|
attachment: obj.data.attachment,
|
||||||
});
|
workerNew: true,
|
||||||
|
};
|
||||||
|
|
||||||
callback?.();
|
callback?.();
|
||||||
|
|
||||||
|
return temp;
|
||||||
}
|
}
|
||||||
|
|
||||||
function dialogDelete(callback: () => void) {
|
function dialogDelete(callback: () => void) {
|
||||||
|
|
|
||||||
|
|
@ -209,47 +209,7 @@ const selectedWorker = ref<
|
||||||
}[];
|
}[];
|
||||||
})[]
|
})[]
|
||||||
>([]);
|
>([]);
|
||||||
const selectedWorkerItem = computed(() => {
|
const selectedWorkerItem = ref([]);
|
||||||
return [
|
|
||||||
...selectedWorker.value.map((e) => ({
|
|
||||||
foreignRefNo: e.employeePassport
|
|
||||||
? e.employeePassport[0]?.number || '-'
|
|
||||||
: '-',
|
|
||||||
employeeName:
|
|
||||||
locale.value === Lang.English
|
|
||||||
? `${e.firstNameEN} ${e.lastNameEN}`
|
|
||||||
: `${e.firstName || e.firstNameEN} ${e.lastName || e.lastNameEN}`,
|
|
||||||
birthDate: dateFormatJS({ date: e.dateOfBirth }),
|
|
||||||
gender: e.gender,
|
|
||||||
age: calculateAge(e.dateOfBirth),
|
|
||||||
nationality: optionStore.mapOption(e.nationality),
|
|
||||||
documentExpireDate:
|
|
||||||
e.employeePassport !== undefined &&
|
|
||||||
e.employeePassport[0]?.expireDate !== undefined
|
|
||||||
? dateFormatJS({ date: e.employeePassport[0]?.expireDate })
|
|
||||||
: '-',
|
|
||||||
imgUrl: e.selectedImage
|
|
||||||
? `${API_BASE_URL}/employee/${e.id}/image/${e.selectedImage}`
|
|
||||||
: '',
|
|
||||||
status: e.status,
|
|
||||||
})),
|
|
||||||
|
|
||||||
...newWorkerList.value.map((v: any) => ({
|
|
||||||
foreignRefNo: v.passportNo || '-',
|
|
||||||
employeeName:
|
|
||||||
locale.value === Lang.English
|
|
||||||
? `${v.firstNameEN} ${v.lastNameEN}`
|
|
||||||
: `${v.firstName || v.firstNameEN} ${v.lastName || v.lastNameEN}`,
|
|
||||||
birthDate: dateFormatJS({ date: v.dateOfBirth }),
|
|
||||||
gender: v.gender,
|
|
||||||
age: calculateAge(v.dateOfBirth),
|
|
||||||
nationality: optionStore.mapOption(v.nationality),
|
|
||||||
documentExpireDate: '-',
|
|
||||||
imgUrl: '',
|
|
||||||
status: 'CREATED',
|
|
||||||
})),
|
|
||||||
];
|
|
||||||
});
|
|
||||||
|
|
||||||
const selectedInstallmentNo = ref<number[]>([]);
|
const selectedInstallmentNo = ref<number[]>([]);
|
||||||
const installmentAmount = ref<number>(0);
|
const installmentAmount = ref<number>(0);
|
||||||
|
|
@ -374,7 +334,39 @@ function assignProductServiceList() {
|
||||||
|
|
||||||
function assignSelectedWorker() {
|
function assignSelectedWorker() {
|
||||||
if (debitNoteData.value)
|
if (debitNoteData.value)
|
||||||
selectedWorker.value = debitNoteData.value.worker.map((v) => v.employee);
|
selectedWorkerItem.value = debitNoteData.value.worker.map((e) => {
|
||||||
|
return {
|
||||||
|
id: e.employee.id,
|
||||||
|
foreignRefNo: e.employee.employeePassport
|
||||||
|
? e.employee.employeePassport[0]?.number || '-'
|
||||||
|
: '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${e.employee.firstNameEN} ${e.employee.lastNameEN}`
|
||||||
|
: `${e.employee.firstName || e.employee.firstNameEN} ${e.employee.lastName || e.employee.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: e.employee.dateOfBirth }),
|
||||||
|
gender: e.employee.gender,
|
||||||
|
age: calculateAge(e.employee.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(e.employee.nationality),
|
||||||
|
documentExpireDate:
|
||||||
|
e.employee.employeePassport !== undefined &&
|
||||||
|
e.employee.employeePassport[0]?.expireDate !== undefined
|
||||||
|
? dateFormatJS({ date: e.employee.employeePassport[0]?.expireDate })
|
||||||
|
: '-',
|
||||||
|
imgUrl: e.employee.selectedImage
|
||||||
|
? `${API_BASE_URL}/employee/${e.id}/image/${e.employee.selectedImage}`
|
||||||
|
: '',
|
||||||
|
status: e.employee.status,
|
||||||
|
workerNew: false,
|
||||||
|
lastNameEN: e.employee.lastNameEN,
|
||||||
|
lastName: e.employee.lastName,
|
||||||
|
middleNameEN: e.employee.middleNameEN,
|
||||||
|
middleName: e.employee.middleName,
|
||||||
|
firstNameEN: e.employee.firstNameEN,
|
||||||
|
firstName: e.employee.firstName,
|
||||||
|
namePrefix: e.employee.namePrefix,
|
||||||
|
};
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async function assignFormData(id: string) {
|
async function assignFormData(id: string) {
|
||||||
|
|
@ -540,8 +532,6 @@ function getPrice(
|
||||||
) {
|
) {
|
||||||
if (filterHook) list = list.filter(filterHook);
|
if (filterHook) list = list.filter(filterHook);
|
||||||
|
|
||||||
console.log(list);
|
|
||||||
|
|
||||||
return list.reduce(
|
return list.reduce(
|
||||||
(a, c) => {
|
(a, c) => {
|
||||||
if (
|
if (
|
||||||
|
|
@ -815,15 +805,11 @@ async function submit() {
|
||||||
|
|
||||||
worker: JSON.parse(
|
worker: JSON.parse(
|
||||||
JSON.stringify([
|
JSON.stringify([
|
||||||
...selectedWorker.value.map((v) => {
|
...selectedWorkerItem.value.map((v) => {
|
||||||
{
|
{
|
||||||
return v.id;
|
return v.id;
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
...newWorkerList.value.map((v) => {
|
|
||||||
const { attachment, ...payload } = v;
|
|
||||||
return pageState.mode === 'edit' ? payload.id : payload;
|
|
||||||
}),
|
|
||||||
]),
|
]),
|
||||||
),
|
),
|
||||||
dueDate: currentFormData.value.dueDate,
|
dueDate: currentFormData.value.dueDate,
|
||||||
|
|
@ -902,7 +888,7 @@ function storeDataLocal() {
|
||||||
dueDate: currentFormData.value.dueDate,
|
dueDate: currentFormData.value.dueDate,
|
||||||
},
|
},
|
||||||
productServicelist: productService.value,
|
productServicelist: productService.value,
|
||||||
selectedWorker: selectedWorker.value,
|
selectedWorker: selectedWorkerItem.value,
|
||||||
createdBy: getName(),
|
createdBy: getName(),
|
||||||
},
|
},
|
||||||
}),
|
}),
|
||||||
|
|
@ -927,6 +913,69 @@ function closeAble() {
|
||||||
return window.opener !== null;
|
return window.opener !== null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function combineWorker(newWorker: any, oldWorker: any) {
|
||||||
|
selectedWorkerItem.value = [
|
||||||
|
...oldWorker.map((e) => ({
|
||||||
|
id: e.id,
|
||||||
|
foreignRefNo: e.employeePassport
|
||||||
|
? e.employeePassport[0]?.number || '-'
|
||||||
|
: '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${e.firstNameEN} ${e.lastNameEN}`
|
||||||
|
: `${e.firstName || e.firstNameEN} ${e.lastName || e.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: e.dateOfBirth }),
|
||||||
|
gender: e.gender,
|
||||||
|
age: calculateAge(e.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(e.nationality),
|
||||||
|
documentExpireDate:
|
||||||
|
e.employeePassport !== undefined &&
|
||||||
|
e.employeePassport[0]?.expireDate !== undefined
|
||||||
|
? dateFormatJS({ date: e.employeePassport[0]?.expireDate })
|
||||||
|
: '-',
|
||||||
|
imgUrl: e.selectedImage
|
||||||
|
? `${API_BASE_URL}/employee/${e.id}/image/${e.selectedImage}`
|
||||||
|
: '',
|
||||||
|
status: e.status,
|
||||||
|
workerNew: false,
|
||||||
|
lastNameEN: e.lastNameEN,
|
||||||
|
lastName: e.lastName,
|
||||||
|
middleNameEN: e.middleNameEN,
|
||||||
|
middleName: e.middleName,
|
||||||
|
firstNameEN: e.firstNameEN,
|
||||||
|
firstName: e.firstName,
|
||||||
|
namePrefix: e.namePrefix,
|
||||||
|
})),
|
||||||
|
|
||||||
|
...newWorker.map((v: any) => ({
|
||||||
|
id: v.id,
|
||||||
|
foreignRefNo: v.passportNo || '-',
|
||||||
|
employeeName:
|
||||||
|
locale.value === Lang.English
|
||||||
|
? `${v.firstNameEN} ${v.lastNameEN}`
|
||||||
|
: `${v.firstName || v.firstNameEN} ${v.lastName || v.lastNameEN}`,
|
||||||
|
birthDate: dateFormatJS({ date: v.dateOfBirth }),
|
||||||
|
gender: v.gender,
|
||||||
|
age: calculateAge(v.dateOfBirth),
|
||||||
|
nationality: optionStore.mapOption(v.nationality),
|
||||||
|
documentExpireDate: '-',
|
||||||
|
imgUrl: '',
|
||||||
|
status: 'CREATED',
|
||||||
|
|
||||||
|
lastNameEN: v.lastNameEN,
|
||||||
|
lastName: v.lastName,
|
||||||
|
middleNameEN: v.middleNameEN,
|
||||||
|
middleName: v.middleName,
|
||||||
|
firstNameEN: v.firstNameEN,
|
||||||
|
firstName: v.firstName,
|
||||||
|
namePrefix: v.namePrefix,
|
||||||
|
|
||||||
|
dateOfBirth: v.dateOfBirth,
|
||||||
|
workerNew: true,
|
||||||
|
})),
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => pageState.mode,
|
() => pageState.mode,
|
||||||
() => toggleMode(pageState.mode),
|
() => toggleMode(pageState.mode),
|
||||||
|
|
@ -1111,7 +1160,7 @@ async function submitAccepted() {
|
||||||
"
|
"
|
||||||
:row-worker="selectedWorkerItem"
|
:row-worker="selectedWorkerItem"
|
||||||
@add-worker="() => (pageState.employeeModal = true)"
|
@add-worker="() => (pageState.employeeModal = true)"
|
||||||
@delete="(i) => deleteItem(selectedWorker, i)"
|
@delete="(i) => deleteItem(selectedWorkerItem, i)"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<!-- #TODO add openProductDialog at @add-product-->
|
<!-- #TODO add openProductDialog at @add-product-->
|
||||||
|
|
@ -1376,13 +1425,12 @@ async function submitAccepted() {
|
||||||
<!-- add employee quotation -->
|
<!-- add employee quotation -->
|
||||||
|
|
||||||
<QuotationFormWorkerSelect
|
<QuotationFormWorkerSelect
|
||||||
:preselect-worker="selectedWorker"
|
:preselect-worker="selectedWorkerItem"
|
||||||
:customerBranchId="quotationData?.customerBranchId"
|
:customerBranchId="quotationData?.customerBranchId"
|
||||||
v-model:open="pageState.employeeModal"
|
v-model:open="pageState.employeeModal"
|
||||||
v-model:new-worker-list="newWorkerList"
|
|
||||||
@success="
|
@success="
|
||||||
(v) => {
|
(v) => {
|
||||||
selectedWorker = v.worker;
|
combineWorker(v.newWorker, v.worker);
|
||||||
}
|
}
|
||||||
"
|
"
|
||||||
/>
|
/>
|
||||||
|
|
|
||||||
|
|
@ -2,6 +2,7 @@ import { defineStore } from 'pinia';
|
||||||
import { api } from 'src/boot/axios';
|
import { api } from 'src/boot/axios';
|
||||||
|
|
||||||
import { Pagination } from 'stores/types';
|
import { Pagination } from 'stores/types';
|
||||||
|
import { getToken } from 'src/services/keycloak';
|
||||||
|
|
||||||
import {
|
import {
|
||||||
ProductGroup,
|
ProductGroup,
|
||||||
|
|
@ -19,6 +20,7 @@ import {
|
||||||
import { ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
|
|
||||||
const useProductServiceStore = defineStore('api-product-service', () => {
|
const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
|
const baseUrl = import.meta.env.VITE_API_BASE_URL;
|
||||||
const splitPay = ref<number>(0);
|
const splitPay = ref<number>(0);
|
||||||
const workNameItems = ref<
|
const workNameItems = ref<
|
||||||
{
|
{
|
||||||
|
|
@ -528,6 +530,53 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
if (!res) return false;
|
if (!res) return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async function productExport(params: {
|
||||||
|
status?: 'CREATED' | 'ACTIVE' | 'INACTIVE';
|
||||||
|
shared?: boolean;
|
||||||
|
productGroupId?: string;
|
||||||
|
query?: string;
|
||||||
|
page?: number;
|
||||||
|
pageSize?: number;
|
||||||
|
orderField?: string;
|
||||||
|
orderBy?: string;
|
||||||
|
activeOnly?: boolean;
|
||||||
|
startDate?: Date;
|
||||||
|
endDate?: Date;
|
||||||
|
}) {
|
||||||
|
let url = baseUrl + '/' + 'product-export';
|
||||||
|
|
||||||
|
const queryParams = new URLSearchParams(
|
||||||
|
Object.keys(params).reduce((acc: Record<string, string>, key) => {
|
||||||
|
const value = params[key as keyof typeof params];
|
||||||
|
if (value !== undefined && value !== null && value !== '') {
|
||||||
|
const stringValue =
|
||||||
|
typeof value === 'boolean' || typeof value === 'number'
|
||||||
|
? String(value)
|
||||||
|
: value instanceof Date
|
||||||
|
? value.toISOString()
|
||||||
|
: String(value);
|
||||||
|
acc[key] = stringValue;
|
||||||
|
}
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
);
|
||||||
|
|
||||||
|
url += '?' + queryParams.toString();
|
||||||
|
|
||||||
|
const res = await fetch(url, {
|
||||||
|
headers: { ['Authorization']: 'Bearer ' + (await getToken()) },
|
||||||
|
});
|
||||||
|
const text = await res.json();
|
||||||
|
const blob = new Blob([text], { type: 'text/csv' });
|
||||||
|
if (res.ok && blob) {
|
||||||
|
const a = document.createElement('a');
|
||||||
|
a.download = 'customer-report' + '.csv';
|
||||||
|
a.href = window.URL.createObjectURL(blob);
|
||||||
|
a.click();
|
||||||
|
a.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
workNameItems,
|
workNameItems,
|
||||||
splitPay,
|
splitPay,
|
||||||
|
|
@ -568,6 +617,8 @@ const useProductServiceStore = defineStore('api-product-service', () => {
|
||||||
deleteImageByName,
|
deleteImageByName,
|
||||||
|
|
||||||
importProduct,
|
importProduct,
|
||||||
|
|
||||||
|
productExport,
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue