@@ -76,16 +74,39 @@
import Checkbox from "@/components/UI/Checkbox.vue";
import Dropdown from "@/components/UI/Dropdown.vue";
import Tooltip from "@/components/UI/Tooltip.vue";
-import {set} from "@vueuse/core";
export default {
name: "PackagingEdit",
components: {Tooltip, Dropdown, Checkbox},
- emits: ['update:stackable', 'update:mixable' ],
+ emits: ['update:stackable', 'update:mixable', 'update:length', 'update:width', 'update:height', 'update:weight', 'update:unitCount', 'update:weightUnit', 'update:dimensionUnit'],
props: {
- handlingUnit: {
- type: Object,
+ length: {
required: true,
+ validator: (value) => value === null || typeof value === 'number'
+ },
+ width: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'number'
+ },
+ height: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'number'
+ },
+ weight: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'number'
+ },
+ dimensionUnit: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'string'
+ },
+ weightUnit: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'string'
+ },
+ unitCount: {
+ required: true,
+ validator: (value) => value === null || typeof value === 'number'
},
mixable: {
type: Boolean,
@@ -97,26 +118,131 @@ export default {
}
},
computed: {
+ huWeight() {
+ return this.weight?.toFixed(this.weightDecimals) ?? '';
+ },
+ huLength() {
+ return this.length?.toFixed(this.dimensionDecimals) ?? '';
+ },
+ huWidth() {
+ console.log("huWidth",this.width, this.width?.toFixed(this.dimensionDecimals));
+ return this.width?.toFixed(this.dimensionDecimals) ?? '';
+ },
+ huHeight() {
+ return this.height?.toFixed(this.dimensionDecimals) ?? '';
+ },
+ huUnitCount() {
+ return this.unitCount ?? '';
+ },
+ dimensionDecimals() {
+ const unitType = this.huDimensionUnits.find(unit => unit.id === this.huDimensionUnitSelected)?.value;
+ return (unitType === 'cm') ? 2 : ((unitType === 'm') ? 4 : 0);
+ },
+ weightDecimals() {
+ const unitType = this.huWeightUnits.find(unit => unit.id === this.huWeightUnitSelected)?.value;
+ return (unitType === 'kg') ? 4 : ((unitType === 't') ? 8 : 0);
+ },
huDimensionUnitSelected: {
get() {
- return this.huDimensionUnits.find(unit => unit.value.toLowerCase() === this.handlingUnit.dimension_unit.toLowerCase())?.id;
+ if(!this.dimensionUnit)
+ this.$emit('update:dimensionUnit', 'mm');
+
+ return this.huDimensionUnits.find(unit => unit.value.toLowerCase() === (this.dimensionUnit?.toLowerCase() ?? 'mm'))?.id;
},
set(value) {
- this.handlingUnit.dimension_unit = this.huDimensionUnits.find(unit => unit.id === value)?.value;
+ const unitType = this.huDimensionUnits.find(unit => unit.id === value)?.value;
+ const decimals = (unitType === 'cm') ? 2 : ((unitType === 'm') ? 4 : 0);
+
+ if (this.length) {
+ const parsedLength = parseFloat(this.length.toFixed(decimals));
+ this.$emit('update:length', parsedLength);
+ }
+
+ if (this.height) {
+ const parsedHeight = parseFloat(this.height.toFixed(decimals));
+ this.$emit('update:height', parsedHeight);
+ }
+
+ if (this.weight) {
+ const parsedWidth = parseFloat(this.width.toFixed(decimals));
+ this.$emit('update:width', parsedWidth);
+ }
+
+ this.$emit('update:dimensionUnit', unitType);
}
},
huWeightUnitSelected: {
- get()
- {
- return this.huWeightUnits.find(unit => unit.value.toLowerCase() === this.handlingUnit.weight_unit.toLowerCase())?.id;
+ get() {
+ if(!this.weightUnit)
+ this.$emit('update:weightUnit', 'kg');
+
+ return this.huWeightUnits.find(unit => unit.value.toLowerCase() === (this.weightUnit?.toLowerCase() ?? 'kg'))?.id;
},
set(value) {
- this.handlingUnit.weight_unit = this.huWeightUnits.find(unit => unit.id === value)?.value;
+ const unitType = this.huWeightUnits.find(unit => unit.id === value)?.value;
+ const decimals = (unitType === 'kg') ? 4 : ((unitType === 't') ? 8 : 0);
+
+ if (this.weight) {
+ const parsedWeight = parseFloat(this.weight.toFixed(decimals));
+ this.$emit('update:weight', parsedWeight);
+ }
+
+ this.$emit('update:weightUnit', unitType);
}
}
},
methods: {
+ parseNumberFromString(value, decimals = 2) {
+ if (typeof value === 'number') return value;
+ if (!value || typeof value !== 'string') return 0;
+
+ const normalizedValue = value.replace(',', '.').replace(/[^0-9.]/g, '');
+
+ const parsed = parseFloat(normalizedValue);
+
+ if (isNaN(parsed)) return 0;
+ return Math.round(parsed * Math.pow(10, decimals)) / Math.pow(10, decimals);
+ },
+ updateInputValue(inputRef, formattedValue) {
+ this.$nextTick(() => {
+ if (this.$refs[inputRef] && this.$refs[inputRef].value !== formattedValue) {
+ this.$refs[inputRef].value = formattedValue;
+ }
+ });
+ },
+ validateDimension(type, event) {
+ const decimals = (this.huDimensionUnitSelected === 2) ? 2 : ((this.huDimensionUnitSelected === 3) ? 4 : 0);
+ const parsed = this.parseNumberFromString(event.target.value, decimals);
+ console.log('validateDimension', type, event.target.value, parsed);
+
+ this.$emit(`update:${type}`, parsed);
+
+ // Force update the input field with the correctly formatted value
+ const formattedValue = parsed.toFixed(decimals);
+ const inputRef = `${type}Input`;
+ this.updateInputValue(inputRef, formattedValue);
+ },
+ validateWeight(type, event) {
+ const decimals = (this.huWeightUnitSelected === 2) ? 4 : ((this.huWeightUnitSelected === 3) ? 8 : 0);
+ const parsed = this.parseNumberFromString(event.target.value, decimals);
+ console.log('validateDimension', type, event.target.value, parsed);
+
+ this.$emit('update:weight', parsed);
+
+ // Force update the input field with the correctly formatted value
+ const formattedValue = parsed.toFixed(decimals);
+ this.updateInputValue('weightInput', formattedValue);
+ },
+ validateCount(event) {
+ const parsed = this.parseNumberFromString(event.target.value, 0);
+ console.log(parsed);
+ this.$emit('update:unitCount', parsed);
+
+ // Force update the input field with the correctly formatted value
+ const formattedValue = parsed.toString();
+ this.updateInputValue('unitCountInput', formattedValue);
+ },
updateStackable(value) {
this.$emit('update:stackable', value);
},
@@ -126,8 +252,8 @@ export default {
},
data() {
return {
- huDimensionUnits: [{id: 1, value: "cm"}, {id: 2, value: "mm"}, {id: 3, value: "m"}],
- huWeightUnits: [{id: 1, value: "kg"}, {id: 2, value: "g"}, {id: 3, value: "t"}],
+ huDimensionUnits: [{id: 1, value: "mm"}, {id: 2, value: "cm"}, {id: 3, value: "m"}],
+ huWeightUnits: [{id: 1, value: "g"}, {id: 2, value: "kg"}, {id: 3, value: "t"}],
}
}
}
@@ -137,7 +263,7 @@ export default {
\ No newline at end of file
diff --git a/src/frontend/src/components/layout/edit/destination/DestinationItem.vue b/src/frontend/src/components/layout/edit/destination/DestinationItem.vue
index 291b4f3..19043bb 100644
--- a/src/frontend/src/components/layout/edit/destination/DestinationItem.vue
+++ b/src/frontend/src/components/layout/edit/destination/DestinationItem.vue
@@ -1,34 +1,94 @@
-
-
{{ destination.name }}
+
+
{{ destination.destination_node.name }}
+
{{ destination.annual_amount }}
+
+
+
+
\ No newline at end of file
diff --git a/src/frontend/src/components/layout/edit/destination/DestinationRoute.vue b/src/frontend/src/components/layout/edit/destination/DestinationRoute.vue
new file mode 100644
index 0000000..35f7b06
--- /dev/null
+++ b/src/frontend/src/components/layout/edit/destination/DestinationRoute.vue
@@ -0,0 +1,118 @@
+
+
+
+
+
+
+
+
{{ element }}
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/src/frontend/src/components/layout/node/CreateNewNode.vue b/src/frontend/src/components/layout/node/CreateNewNode.vue
index 0357e90..41c2802 100644
--- a/src/frontend/src/components/layout/node/CreateNewNode.vue
+++ b/src/frontend/src/components/layout/node/CreateNewNode.vue
@@ -14,6 +14,9 @@
Coordinates:
{{ nodeCoordinates }}
+
+

+