From 6c5818615b1ae45609c1b1fef1b026f303e04fd2 Mon Sep 17 00:00:00 2001 From: Jepp9350 <2jepp9350@gmail.com> Date: Tue, 29 Apr 2025 15:50:06 +0200 Subject: [PATCH] Update vehicle and customer selection workflows in POS form Refactored `SelectVehicleFormPOS` and related components to improve vehicle and customer selection, including new UI elements for license plate input, dropdown suggestions, and customer search. Introduced reusable `ExpandableContentBox` and optimized handling of vehicle objects and focus states. --- .../displays/boxes/ElementTabsBox.vue | 40 +- .../displays/boxes/ExpandableContentBox.vue | 44 ++ .../pos/PosLastScannedLicensePlatesV2.vue | 442 ++++++++++++++++++ .../department/pos/PosSelectedCustomer.vue | 6 +- .../pos/displays/PayWithStripeButton.vue | 9 +- .../pos/steps/PosDepartmentStep1.vue | 24 +- .../superuser/tables/OrderContentTable.vue | 62 ++- .../department/pos/SelectVehicleFormPOS.vue | 243 +++++++++- .../pos/input/LicensePlateReg1Input.vue | 324 +++++++++++-- .../pos/input/LicensePlateReg2Suggestions.vue | 45 ++ .../pos/input/customerSearchFieldPos.vue | 106 +++++ .../SessionUser/Objects/ObjectsGlobal.vue | 5 + src/components/shop/POSDepartmentProcess.vue | 34 +- 13 files changed, 1313 insertions(+), 71 deletions(-) create mode 100644 src/components/displays/boxes/ExpandableContentBox.vue create mode 100644 src/components/displays/department/pos/PosLastScannedLicensePlatesV2.vue create mode 100644 src/components/forms/department/pos/input/LicensePlateReg2Suggestions.vue create mode 100644 src/components/forms/department/pos/input/customerSearchFieldPos.vue diff --git a/src/components/displays/boxes/ElementTabsBox.vue b/src/components/displays/boxes/ElementTabsBox.vue index be8a2e46..0c303f6f 100644 --- a/src/components/displays/boxes/ElementTabsBox.vue +++ b/src/components/displays/boxes/ElementTabsBox.vue @@ -1,5 +1,5 @@ diff --git a/src/components/forms/department/pos/SelectVehicleFormPOS.vue b/src/components/forms/department/pos/SelectVehicleFormPOS.vue index 66cc5e8f..3756d0cf 100644 --- a/src/components/forms/department/pos/SelectVehicleFormPOS.vue +++ b/src/components/forms/department/pos/SelectVehicleFormPOS.vue @@ -8,21 +8,262 @@ import { isSearching } from "@/components/search/economic/customerSearch.vue"; import { SessionUser } from "@/components/session/token/SessionUser.vue"; import LicensePlateInput from "@/components/forms/department/pos/input/LicensePlateInput.vue"; import LicensePlateReg1Input from "@/components/forms/department/pos/input/LicensePlateReg1Input.vue"; +import CustomerSearchFieldPos from "@/components/forms/department/pos/input/customerSearchFieldPos.vue"; +import ExpandableContentBox from "@/components/displays/boxes/ExpandableContentBox.vue"; +import WhiteBox from "@/components/displays/boxes/WhiteBox.vue"; +import OrderContentTable from "@/components/displays/superuser/tables/OrderContentTable.vue"; +import OrderItemsTable from "@/components/displays/department/pos/order/orderItemsTable.vue"; +const isRegistrationNumbersExpanded = ref(false); +const isOtherExpanded = ref(false); + +const keyDownNextInput = (event, field_id) => { + if (event.key === 'Enter') { + event.preventDefault(); + document.getElementById(field_id).focus(); + } +}; + +const keyDownNextTabIndexButton = (event, tabIndex) => { + if (event.key === 'Enter') { + event.preventDefault(); + // First unfocus the input field. This is to ensure the sync between the input field and the POSDepartmentProcess.vue data. + event.target.blur(); + document.querySelector(`button[tabindex="${tabIndex}"]`).click(); + } +}; + +const vehicleObject = ref(null); + +// debug: +//vehicleObject.value = { "id": 324, "user_id": 1952, "customer_id": 12345679, "type": 1, "reg": "EC21233", "wash_subscription": true, "addons": { "enabled": 1, "available": 2, "list": [ { "id": 287, "vehicle_id": 324, "addon_id": 14, "amount": 1, "product": { "id": 24, "name": "Spot Free- Lastbil", "description": " ", "price": 39, "subscription_allowed": 1, "category": "4", "piktogram": "", "economic_product_id": "33", "apply_category_discount": false, "requires_note": false, "created_at": "2024-12-09 14:31:49", "updated_at": "2025-04-08 14:07:41" } } ] }, "last_order_id": 6249 } +// debug end + +const setVehicleObject = (emittedVehicleObject) => { + //console.log(vehicleObject, 'Emitted vehicleObject'); + // Set the vehicle object to the ref + vehicleObject.value = emittedVehicleObject; +}; + +const ucFirst = (str) => { + return str.charAt(0).toUpperCase() + str.slice(1); +}; + +const isUserCurrentlyInFocusReg1 = ref(false); +const setFocusStateReg1 = (isFocused) => { + isUserCurrentlyInFocusReg1.value = isFocused; +}; + + +const customerHasAttribute = (attribute) => { + // Check if the user has the attribute + if (customer_attributes.value === null) { + return false; + } + if (customer_attributes.value.length === 0) { + return false; + } + // Check if the attribute is in the list + for (let i = 0; i < customer_attributes.value.length; i++) { + if (customer_attributes.value[i].attribute === attribute) { + return true; + } + } +}; \ No newline at end of file diff --git a/src/components/forms/department/pos/input/customerSearchFieldPos.vue b/src/components/forms/department/pos/input/customerSearchFieldPos.vue new file mode 100644 index 00000000..e607af39 --- /dev/null +++ b/src/components/forms/department/pos/input/customerSearchFieldPos.vue @@ -0,0 +1,106 @@ + + + + + \ No newline at end of file diff --git a/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue b/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue index 7eb86ff0..a535d8d8 100644 --- a/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue +++ b/src/components/session/token/SessionUser/Objects/ObjectsGlobal.vue @@ -19,9 +19,14 @@ export const ObjectsGlobal = { split: "Opdel", save: "Gem", invalid: "Ugyldig", + last_wash: "Sidste vask", + have_not: "Har ikke", + have: "Har", + hide: "Skjul", cancel: "Annuller", select: "Vælg", month: "Måned", + copy: "Kopier", yes: "Ja", no: "Nej", email: "Email", diff --git a/src/components/shop/POSDepartmentProcess.vue b/src/components/shop/POSDepartmentProcess.vue index 8da3157e..17e65e0f 100644 --- a/src/components/shop/POSDepartmentProcess.vue +++ b/src/components/shop/POSDepartmentProcess.vue @@ -441,21 +441,11 @@ export const selectScan = (scan) => { showSelectedScanDialog(scan); console.log(scan); // Check which registration number is empty - if (!Object.keys(reg_1.value).length > 0 || !reg_1.value) { + //if (!Object.keys(reg_1.value).length > 0 || !reg_1.value) { // Set the registration number 1 - reg_1.value = scan.plate; - return; - } - if (!reg_2.value) { - // Set the registration number 2 - reg_2.value = scan.plate; - return; - } - if (!reg_3.value) { - // Set the registration number 3 - reg_3.value = scan.plate; - return; - } + //reg_1.value = scan.plate; + //return; + //} // Set the registration number 1 reg_1.value = scan.plate; }; @@ -489,6 +479,7 @@ export const searchAndSelectCustomer = async (customerNumber) => { /** Show selected scan dialog */ export const showSelectedScanDialog = (scan) => { + return; // Show a loading swal Swal.fire({ title: 'Henter nummerplade', @@ -688,9 +679,7 @@ export const clearCache = () => { // Reset the query parameters window.history.pushState({}, '', `?step=1`); // Clear the customer data - customer_id.value = ''; - customer_name.value = ''; - customer_data.value = []; + clearCustomerSelection(); // Clear the order data order_id.value = null; order_items.value = []; @@ -698,13 +687,20 @@ export const clearCache = () => { reg_1.value = ''; reg_2.value = ''; reg_3.value = ''; + // Clear the scans + scans.value = []; +}; + +export const clearCustomerSelection = () => { + // Clear the customer data + customer_id.value = ''; + customer_name.value = ''; + customer_data.value = []; // Clear the notes notes.value = []; order_notes.value = ''; // Clear the attributes customer_attributes.value = []; - // Clear the scans - scans.value = []; }; /** Show delete order dialog */