"Add OrderBookings.vue for managing order bookings, integrate with SessionUser and dashboards, and enhance MyBookingsBook.vue with order booking creation logic"
This commit is contained in:
@@ -37,6 +37,7 @@ import {DepartmentVariables} from "@/components/session/token/SessionUser/Object
|
||||
import {XLVaskVehicleTypes} from "@/components/session/token/SessionUser/Objects/XLVaskVehicleTypes.vue";
|
||||
import {OpenAI} from "@/components/session/token/superUser/modules/openAI/OpenAI.vue";
|
||||
import {DepartmentLanes} from "@/components/session/token/SessionUser/Objects/DepartmentLanes.vue";
|
||||
import {OrderBookings} from "@/components/session/token/SessionUser/Objects/OrderBookings.vue";
|
||||
import {ObjectsGlobal} from "@/components/session/token/SessionUser/Objects/ObjectsGlobal.vue";
|
||||
import Swal from "sweetalert2";
|
||||
import router from "@/router.js";
|
||||
@@ -265,6 +266,7 @@ export const SessionUser = {
|
||||
xlvask_vehicle_types: XLVaskVehicleTypes,
|
||||
openai: OpenAI,
|
||||
department_lanes: DepartmentLanes,
|
||||
order_bookings: OrderBookings,
|
||||
global: ObjectsGlobal,
|
||||
},
|
||||
/** The user's token and authentication status */
|
||||
|
||||
@@ -0,0 +1,305 @@
|
||||
<script>
|
||||
import Swal from "sweetalert2";
|
||||
import { authenticatedRequest } from "@/components/session/authenticatedRequest.vue";
|
||||
import { ObjectsGlobal } from "@/components/session/token/SessionUser/Objects/ObjectsGlobal.vue";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
import {ref} from "vue";
|
||||
|
||||
/**
|
||||
* The OrderBookings object
|
||||
*/
|
||||
export const OrderBookings = {
|
||||
meta: {
|
||||
title: "Order Bookinger",
|
||||
icon: "fas fa-list",
|
||||
description: "Oversigt over order bookinger",
|
||||
endpoint: "/order-bookings",
|
||||
labels: {
|
||||
single: "orderbooking",
|
||||
multiple: "orderbookinger",
|
||||
fields: {
|
||||
names: {
|
||||
customer_number: {
|
||||
label: "E-conomic kundenummer",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
columns: {
|
||||
id: {
|
||||
label: "ID",
|
||||
type: "number",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
}
|
||||
},
|
||||
customer_number: {
|
||||
label: "Kundenummer",
|
||||
type: "number",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
department: {
|
||||
label: "Afdeling",
|
||||
type: "select",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
options: async () => {
|
||||
return SessionUser.objects.department_notification_sms.columns.department.options()
|
||||
}
|
||||
},
|
||||
reg_1: {
|
||||
label: "Reg. 1",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
reg_2: {
|
||||
label: "Reg. 2",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
reg_3: {
|
||||
label: "Reg. 3",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
datetime: {
|
||||
label: "Dato",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: true
|
||||
},
|
||||
},
|
||||
note: {
|
||||
label: "Notat",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
reference: {
|
||||
label: "Reference",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
po: {
|
||||
label: "PO Nummer",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
pickup: {
|
||||
label: "Hentning",
|
||||
type: "boolean",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
items: {
|
||||
label: "Varer",
|
||||
type: "array",
|
||||
sortable: false,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
/**
|
||||
* status: {
|
||||
* label: "Status",
|
||||
* type: "select",
|
||||
* sortable: true,
|
||||
* creation: {
|
||||
* required: false
|
||||
* },
|
||||
* options: async () => {
|
||||
* return [
|
||||
* { id: 'pending', name: "Afventer" },
|
||||
* { id: 'cancelled', name: "Annulleret" },
|
||||
* { id: 'completed', name: "Færdig" },
|
||||
* ];
|
||||
* }
|
||||
* },
|
||||
*/
|
||||
created_at: {
|
||||
label: "Oprettet",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
deleted_at: {
|
||||
label: "Slettet",
|
||||
type: "string",
|
||||
sortable: true,
|
||||
creation: {
|
||||
required: false
|
||||
},
|
||||
},
|
||||
},
|
||||
add: async (customer_number, department, reg_1, reg_2 = null, reg_3 = null, datetime, note = null, reference = null, po = null, pickup = false, items = []) => {
|
||||
return ObjectsGlobal.add.object(
|
||||
OrderBookings.meta.endpoint,
|
||||
{
|
||||
customer_number: parseInt(customer_number),
|
||||
department: parseInt(department),
|
||||
reg_1,
|
||||
reg_2,
|
||||
reg_3,
|
||||
datetime,
|
||||
note,
|
||||
reference,
|
||||
po,
|
||||
pickup,
|
||||
items,
|
||||
},
|
||||
{authenticated: SessionUser.functions.hasToken()}
|
||||
);
|
||||
},
|
||||
set: {
|
||||
customer_number: async (id, customer_number) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"customer_number",
|
||||
customer_number
|
||||
)
|
||||
},
|
||||
department: async (id, department) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"department",
|
||||
department
|
||||
)
|
||||
},
|
||||
reg_1: async (id, reg_1) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"reg_1",
|
||||
reg_1
|
||||
)
|
||||
},
|
||||
reg_2: async (id, reg_2) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"reg_2",
|
||||
reg_2
|
||||
)
|
||||
},
|
||||
reg_3: async (id, reg_3) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"reg_3",
|
||||
reg_3
|
||||
)
|
||||
},
|
||||
datetime: async (id, datetime) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"datetime",
|
||||
datetime
|
||||
)
|
||||
},
|
||||
note: async (id, note) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"note",
|
||||
note
|
||||
)
|
||||
},
|
||||
reference: async (id, reference) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"reference",
|
||||
reference
|
||||
)
|
||||
},
|
||||
po: async (id, po) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"po",
|
||||
po
|
||||
)
|
||||
},
|
||||
pickup: async (id, pickup) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"pickup",
|
||||
pickup
|
||||
)
|
||||
},
|
||||
items: async (id, items) => {
|
||||
return ObjectsGlobal.set.column(
|
||||
OrderBookings.meta.endpoint,
|
||||
id,
|
||||
"items",
|
||||
items
|
||||
)
|
||||
},
|
||||
},
|
||||
get: {
|
||||
single: async (identifier) => {
|
||||
return ObjectsGlobal.get.object(OrderBookings.meta.endpoint, identifier, {authenticated: SessionUser.functions.hasToken()});
|
||||
},
|
||||
},
|
||||
functions: {
|
||||
},
|
||||
/**
|
||||
* Show the create object form
|
||||
* @param onAfterSubmit
|
||||
* @returns {Promise<SweetAlertResult<Awaited<any>>>}
|
||||
*/
|
||||
showCreateObjectForm: (onAfterSubmit = null) => {
|
||||
return ObjectsGlobal.showCreateObjectForm(OrderBookings, onAfterSubmit);
|
||||
},
|
||||
/**
|
||||
* Show the edit object field form
|
||||
* @param id
|
||||
* @param column
|
||||
* @param value
|
||||
* @param onAfterSubmit
|
||||
* @returns {Promise<SweetAlertResult<Awaited<any>>>}
|
||||
*/
|
||||
showEditObjectFieldForm: (id, column, value, onAfterSubmit = null) => {
|
||||
return ObjectsGlobal.showEditObjectFieldForm(
|
||||
OrderBookings,
|
||||
id,
|
||||
column,
|
||||
value,
|
||||
onAfterSubmit
|
||||
);
|
||||
}
|
||||
};
|
||||
</script>
|
||||
@@ -13,6 +13,10 @@ import UserNavigation from "@/components/global/UserNavigation.vue";
|
||||
import RestrictedPageWrapper from "@/components/page/wrappers/RestrictedPageWrapper.vue";
|
||||
import { SessionUser } from "@/components/session/token/SessionUser.vue";
|
||||
import { showCreateUserDiscountForm } from "@/components/forms/superUser/createUserDiscountForm.vue";
|
||||
|
||||
const showCreateOrderBookingForm = () => {
|
||||
SessionUser.objects.order_bookings.showCreateObjectForm();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -29,6 +33,7 @@ import { showCreateUserDiscountForm } from "@/components/forms/superUser/createU
|
||||
<button class="button" @click="showCreateProductForm">Create product</button>
|
||||
<button class="button" @click="getOrders">Get orders</button>
|
||||
<button class="button" @click="showCreateOrderForm">Create order</button>
|
||||
<button class="button" @click="showCreateOrderBookingForm">Create order booking</button>
|
||||
<button class="button" @click="showCreateNumberPlateScanForm">Create number plate scan</button>
|
||||
<button class="button" @click="showCreateUserDiscountForm">Create user discount</button>
|
||||
<button class="button" @click="SessionUser.superUser.cron.runCron()">Run cron</button>
|
||||
|
||||
@@ -55,6 +55,7 @@ import PosDepartmentStepMobile2Addons
|
||||
from "@/components/displays/department/pos/steps/mobile/elements/PosDepartmentStepMobile2Addons.vue";
|
||||
import { setDepartment, getProductsCategory, setProductsCategory, nextStep } from "@/components/shop/POSDepartmentProcess.vue";
|
||||
|
||||
const customerNumber = ref<number | null>(null);
|
||||
const department = ref<any>(null);
|
||||
const isDepartmentInput = ref(false);
|
||||
const wash_type = ref("general"); // general or tankcleaning
|
||||
@@ -74,6 +75,7 @@ const isReferenceInput = ref(false);
|
||||
const isPoNumberInput = ref(false);
|
||||
const isNotesInput = ref(false);
|
||||
const dateTime = ref<Date | null>(null);
|
||||
const pickup = ref(false);
|
||||
const isDateTimeInput = ref(false);
|
||||
const hasDepartment = computed(() => !!(department.value && (department.value as any).id));
|
||||
const hasVehicle = computed(() => ((reg1.value !== '' && reg1Type.value !== null) || (reg2.value !== '' && reg2Type.value !== null)));
|
||||
@@ -637,7 +639,19 @@ const onSummaryBack = () => { showSummary.value = false; };
|
||||
const onSummaryConfirm = () => {
|
||||
showSummary.value = false;
|
||||
try {
|
||||
nextStep({ isMobile: false, orderCreation: true });
|
||||
SessionUser.objects.order_bookings.add(
|
||||
customerNumber.value,
|
||||
department.value.id,
|
||||
reg1.value,
|
||||
reg2.value,
|
||||
null, // reg3,
|
||||
dateTime.value.toISOString().split(' ')[0], // (e.g. 2025-11-05 11:45:12 OR 2025-11-05)
|
||||
notes.value,
|
||||
reference.value,
|
||||
poNumber.value,
|
||||
pickup.value,
|
||||
completeBasket.value,
|
||||
);
|
||||
} catch (e) {
|
||||
console.warn('Proceeding to next step failed', e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user