Implemented new components for product sales and daily report form. Enhanced existing report displays with dynamic transaction and product count data. Introduced backend integration for fetching product and transaction details and updated UI to display relevant metrics.
155 lines
4.8 KiB
Vue
155 lines
4.8 KiB
Vue
<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 DepartmentDailyReports object
|
|
*/
|
|
export const DepartmentDailyReports = {
|
|
meta: {
|
|
title: "Afdelingens dagsopgørelser",
|
|
icon: "fas fa-list",
|
|
description: "Oversigt over afdelingens dagsopgørelser",
|
|
endpoint: "/departments/daily-reports",
|
|
labels: {
|
|
single: "dagsopgørelse",
|
|
multiple: "dagsopgørelser"
|
|
}
|
|
},
|
|
columns: {
|
|
id: {
|
|
label: "ID",
|
|
type: "number",
|
|
sortable: true,
|
|
creation: {
|
|
required: false
|
|
}
|
|
},
|
|
department_id: {
|
|
label: "Afdelings ID",
|
|
type: "select",
|
|
sortable: true,
|
|
creation: {
|
|
required: true
|
|
},
|
|
options: async () => {
|
|
console.log("Getting departments");
|
|
return SessionUser.objects.departments.get.all();
|
|
}
|
|
},
|
|
water_usage: {
|
|
label: "Vandforbrug (m3)",
|
|
type: "number",
|
|
sortable: true,
|
|
creation: {
|
|
required: true
|
|
},
|
|
},
|
|
filled_by: {
|
|
label: "Udfyldt af",
|
|
type: "number",
|
|
sortable: true,
|
|
creation: {
|
|
required: false
|
|
},
|
|
},
|
|
created_at: {
|
|
label: "Oprettet",
|
|
type: "date",
|
|
sortable: true,
|
|
creation: {
|
|
required: false
|
|
}
|
|
},
|
|
},
|
|
add: async (department_id, category_id) => {
|
|
return ObjectsGlobal.add.object(
|
|
DepartmentDailyReports.meta.endpoint,
|
|
{
|
|
department_id: parseInt(department_id),
|
|
category_id: parseInt(category_id)
|
|
}
|
|
);
|
|
},
|
|
set: {
|
|
department_id: async (id, department_id) => {
|
|
return ObjectsGlobal.set.column(
|
|
DepartmentDailyReports.meta.endpoint,
|
|
id,
|
|
"department_id",
|
|
parseInt(department_id)
|
|
)
|
|
},
|
|
category_id: async (id, category_id) => {
|
|
return ObjectsGlobal.set.column(
|
|
DepartmentDailyReports.meta.endpoint,
|
|
id,
|
|
"category_id",
|
|
parseInt(category_id)
|
|
)
|
|
},
|
|
},
|
|
get: {
|
|
all: async () => {
|
|
return ObjectsGlobal.get.objects(DepartmentDailyReports.meta.endpoint);
|
|
},
|
|
single: async (id) => {
|
|
return ObjectsGlobal.get.object(DepartmentDailyReports.meta.endpoint, parseInt(id));
|
|
}
|
|
},
|
|
delete: async (id) => {
|
|
return ObjectsGlobal.delete.object(DepartmentDailyReports.meta.endpoint, parseInt(id));
|
|
},
|
|
functions: {
|
|
showCreateObjectFormDepartment: async (department_id, onAfterSubmit = null) => {
|
|
console.log("Department ID", department_id, "type", typeof department_id);
|
|
return ObjectsGlobal.showCreateObjectForm(DepartmentDailyReports, onAfterSubmit, {department_id: department_id});
|
|
},
|
|
showDeleteObjectForm: (id, onAfterSubmit = null) => {
|
|
return ObjectsGlobal.showDeleteObjectForm(DepartmentDailyReports, id, onAfterSubmit);
|
|
},
|
|
getProductCount: async (department_id,product_id, date) => {
|
|
return authenticatedRequest(
|
|
"/departments/daily-reports/product-count?product_id=" + product_id + "&date=" + date + "&department_id=" + department_id,
|
|
"GET"
|
|
);
|
|
},
|
|
getTransactionCount: async (department_id, date) => {
|
|
return authenticatedRequest(
|
|
"/departments/daily-reports/transaction-count?date=" + date + "&department_id=" + department_id,
|
|
"GET"
|
|
);
|
|
},
|
|
},
|
|
/**
|
|
* Show the create object form
|
|
* @param onAfterSubmit
|
|
* @returns {Promise<SweetAlertResult<Awaited<any>>>}
|
|
*/
|
|
showCreateObjectForm: (onAfterSubmit = null) => {
|
|
return ObjectsGlobal.showCreateObjectForm(DepartmentDailyReports, 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(
|
|
DepartmentDailyReports,
|
|
id,
|
|
column,
|
|
value,
|
|
onAfterSubmit
|
|
);
|
|
}
|
|
};
|
|
</script> |