From cd1848c5fb8526d48aecfe9886bca2c85f4cf32c Mon Sep 17 00:00:00 2001 From: Thanaphon Frappet Date: Fri, 20 Dec 2024 09:46:19 +0700 Subject: [PATCH] feat: new worker select --- src/pages/05_quotation/QuotationForm.vue | 171 +-------- .../QuotationFormWorkerSelect.vue | 339 ++++++++++++++++++ 2 files changed, 355 insertions(+), 155 deletions(-) create mode 100644 src/pages/05_quotation/QuotationFormWorkerSelect.vue diff --git a/src/pages/05_quotation/QuotationForm.vue b/src/pages/05_quotation/QuotationForm.vue index d0a19395..ea09ffab 100644 --- a/src/pages/05_quotation/QuotationForm.vue +++ b/src/pages/05_quotation/QuotationForm.vue @@ -70,6 +70,7 @@ import { import QuotationFormReceipt from './QuotationFormReceipt.vue'; import QuotationFormProductSelect from './QuotationFormProductSelect.vue'; import QuotationFormInfo from './QuotationFormInfo.vue'; +import QuotationFormWorkerSelect from './QuotationFormWorkerSelect.vue'; import QuotationFormWorkerAddDialog from './QuotationFormWorkerAddDialog.vue'; import ProfileBanner from 'components/ProfileBanner.vue'; import DialogForm from 'components/DialogForm.vue'; @@ -161,6 +162,7 @@ const readonly = computed(() => { quotationFormState.value.mode === 'edit' ); }); +const test = ref(false); const selectedWorker = ref< (Employee & { @@ -721,10 +723,6 @@ function triggerCreateEmployee() { async function triggerSelectEmployeeDialog() { pageState.employeeModal = true; await nextTick(); - refSelectZoneEmployee.value?.assignSelect( - preSelectedWorker.value, - selectedWorker.value, - ); } function triggerProductServiceDialog() { @@ -926,12 +924,12 @@ function convertToTable(nodes: Node[]) { pageState.productServiceModal = false; } -function convertEmployeeToTable() { +function convertEmployeeToTable(selected: Employee[]) { productServiceList.value.forEach((v) => { if (selectedWorker.value.length === 0 && v.amount === 1) v.amount -= 1; v.amount = Math.max( - v.amount + preSelectedWorker.value.length - selectedWorker.value.length, + v.amount + selected.length - selectedWorker.value.length, 1, ); @@ -941,21 +939,17 @@ function convertEmployeeToTable() { selectedWorker.value.forEach((item, i) => { if (v.workerIndex.includes(i)) oldWorkerId.push(item.id); }); - preSelectedWorker.value.forEach((item, i) => { + selected.forEach((item, i) => { if (selectedWorker.value.find((n) => item.id === n.id)) return; newWorkerIndex.push(i); }); v.workerIndex = oldWorkerId - .map((id) => preSelectedWorker.value.findIndex((item) => item.id === id)) + .map((id) => selected.findIndex((item) => item.id === id)) .filter((idx) => idx !== -1) .concat(newWorkerIndex); }); - refSelectZoneEmployee.value?.assignSelect( - selectedWorker.value, - preSelectedWorker.value, - ); pageState.employeeModal = false; quotationFormData.value.workerMax = Math.max( quotationFormData.value.workerMax || 1, @@ -1253,9 +1247,7 @@ async function getWorkerFromCriteria( (a) => !selectedWorker.value.find((b) => a.id === b.id), ); - preSelectedWorker.value = [...deduplicate, ...selectedWorker.value]; - - convertEmployeeToTable(); + convertEmployeeToTable([...deduplicate, ...selectedWorker.value]); return true; } @@ -2277,148 +2269,17 @@ watch( - - - -
- - - - - -
-
+ @trigger-create-employee="() => triggerCreateEmployee()" + /> diff --git a/src/pages/05_quotation/QuotationFormWorkerSelect.vue b/src/pages/05_quotation/QuotationFormWorkerSelect.vue new file mode 100644 index 00000000..34194026 --- /dev/null +++ b/src/pages/05_quotation/QuotationFormWorkerSelect.vue @@ -0,0 +1,339 @@ + + + + +