fix: refs #6346 fix list and create #404

Merged
jon merged 15 commits from 6346-fixWagonModule into dev 2024-09-13 06:16:05 +00:00
2 changed files with 51 additions and 58 deletions
Showing only changes of commit 8a3b575157 - Show all commits

View File

@ -4,6 +4,7 @@ import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
@ -12,8 +13,8 @@ onMounted(() => fetch());
onUpdated(() => fetch()); onUpdated(() => fetch());
const { t } = useI18n(); const { t } = useI18n();
const { notify } = useQuasar();
const route = useRoute(); const route = useRoute();
const quasar = useQuasar();
const router = useRouter(); const router = useRouter();
const $props = defineProps({ const $props = defineProps({
id: { id: {
@ -29,29 +30,19 @@ const divisible = ref(false);
const name = ref(''); const name = ref('');
const colorPickerActive = ref(false); const colorPickerActive = ref(false);
let originalData = { trays: [] }; let originalData = { trays: [] };
let wagonConfig; let maxTrays, maxWagonHeight, minHeightBetweenTrays;
let wagonTypeColors; let wagonTypeColors;
let currentTrayColorPicked; let currentTrayColorPicked;
async function fetch() { async function fetch() {
try { try {
await axios.get('WagonConfigs').then(async (res) => { ({
if (res.data) { data: [{ maxTrays, maxWagonHeight, minHeightBetweenTrays }],
wagonConfig = res.data[0]; } = await axios.get('WagonConfigs'));
}
});
await axios.get(`WagonTypeColors`).then(async (res) => { await axios.get(`WagonTypeColors`).then(async (res) => {
if (res.data) { if ((wagonTypeColors = res.data)) {
wagonTypeColors = res.data; if (entityId.value) {
if (!entityId.value)
wagon.value.push({
id: 0,
position: 0,
color: { ...wagonTypeColors[0] },
action: 'add',
});
else {
await axios await axios
.get(`WagonTypeTrays`, { .get(`WagonTypeTrays`, {
params: { filter: { where: { typeFk: entityId.value } } }, params: { filter: { where: { typeFk: entityId.value } } },
@ -76,18 +67,23 @@ async function fetch() {
}); });
} }
}); });
} } else
wagon.value.push({
id: 0,
position: 0,
color: { ...wagonTypeColors[0] },
action: 'add',
});
} }
}); });
if (entityId.value) { if (entityId.value)
await axios.get(`WagonTypes/${entityId.value}`).then((res) => { await axios.get(`WagonTypes/${entityId.value}`).then((res) => {
if (res.data) { if (res.data) {
originalData.name = name.value = res.data.name; originalData.name = name.value = res.data.name;
originalData.divisible = divisible.value = res.data.divisible; originalData.divisible = divisible.value = res.data.divisible;
} }
}); });
}
} catch (e) { } catch (e) {
// //
} }
@ -98,27 +94,24 @@ function addTray() {
wagon.value.find((tray) => { wagon.value.find((tray) => {
return tray.position == null; return tray.position == null;
}) })
) { )
quasar.notify({ return notify({
message: t('wagon.warnings.uncompleteTrays'), message: t('wagon.warnings.uncompleteTrays'),
type: 'warning', type: 'warning',
}); });
return;
}
if (wagon.value.length < wagonConfig.maxTrays) { if (wagon.value.length < maxTrays)
wagon.value.unshift({ wagon.value.unshift({
id: wagon.value.length, id: wagon.value.length,
position: null, position: null,
color: { ...wagonTypeColors[0] }, color: { ...wagonTypeColors[0] },
action: 'delete', action: 'delete',
}); });
} else { else
quasar.notify({ notify({
message: t('wagon.warnings.maxTrays'), message: t('wagon.warnings.maxTrays'),
type: 'warning', type: 'warning',
}); });
}
} }
function deleteTray(trayToDelete) { function deleteTray(trayToDelete) {
@ -127,9 +120,8 @@ function deleteTray(trayToDelete) {
} }
function reorderIds() { function reorderIds() {
for (let index = wagon.value.length - 1; index >= 0; index--) { for (let index = wagon.value.length - 1; index >= 0; index--)
wagon.value[index].id = index; wagon.value[index].id = index;
}
} }
async function onSubmit() { async function onSubmit() {
@ -153,7 +145,7 @@ async function onSubmit() {
} }
} }
function onReset() { async function onReset() {
name.value = entityId.value ? originalData.name : null; name.value = entityId.value ? originalData.name : null;
divisible.value = entityId.value ? originalData.divisible : false; divisible.value = entityId.value ? originalData.divisible : false;
wagon.value = entityId.value wagon.value = entityId.value
@ -169,11 +161,8 @@ function onReset() {
} }
function doAction(tray) { function doAction(tray) {
if (tray.action == 'add') { if (tray.action == 'add') addTray();
addTray(); else deleteTray(tray);
} else {
deleteTray(tray);
}
} }
function showColorPicker(tray) { function showColorPicker(tray) {
@ -193,10 +182,8 @@ function updateColor(newColor) {
function onPositionBlur(tray) { function onPositionBlur(tray) {
if (tray.position) { if (tray.position) {
if (tray.position == '' || tray.position < 0) { if (tray.position == '' || tray.position < 0) return (tray.position = null);
tray.position = null;
return;
}
tray.position = parseInt(tray.position); tray.position = parseInt(tray.position);
wagon.value.sort((a, b) => b.position - a.position); wagon.value.sort((a, b) => b.position - a.position);
reorderIds(); reorderIds();
@ -204,18 +191,18 @@ function onPositionBlur(tray) {
if (exceedMaxHeight(index - 1)) continue; if (exceedMaxHeight(index - 1)) continue;
if ( if (
wagon.value[index - 1].position - wagon.value[index].position >= wagon.value[index - 1].position - wagon.value[index].position >=
wagonConfig.minHeightBetweenTrays minHeightBetweenTrays
) { )
continue; continue;
} else { else {
wagon.value[index - 1].position += wagon.value[index - 1].position +=
wagonConfig.minHeightBetweenTrays - minHeightBetweenTrays -
(wagon.value[index - 1].position - wagon.value[index].position); (wagon.value[index - 1].position - wagon.value[index].position);
quasar.notify({ notify({
message: message:
t('wagon.warnings.minHeightBetweenTrays') + t('wagon.warnings.minHeightBetweenTrays') +
wagonConfig.minHeightBetweenTrays + minHeightBetweenTrays +
' cm', ' cm',
type: 'warning', type: 'warning',
}); });
@ -227,20 +214,19 @@ function onPositionBlur(tray) {
} }
function exceedMaxHeight(pos) { function exceedMaxHeight(pos) {
if (wagon.value[pos].position > wagonConfig.maxWagonHeight) { if (wagon.value[pos].position < maxWagonHeight) return false;
wagon.value.splice(pos, 1);
quasar.notify({ wagon.value.splice(pos, 1);
message: notify({
t('wagon.warnings.maxWagonHeight') + wagonConfig.maxWagonHeight + ' cm', message: t('wagon.warnings.maxWagonHeight') + maxWagonHeight + ' cm',
type: 'warning', type: 'warning',
}); });
return true; return true;
}
return false;
} }
</script> </script>
<template> <template>
<VnSubToolbar />
<QPage class="q-pa-sm q-mx-xl"> <QPage class="q-pa-sm q-mx-xl">
<QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm"> <QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm">
<QCard class="q-pa-md"> <QCard class="q-pa-md">
@ -264,13 +250,13 @@ function exceedMaxHeight(pos) {
<QTooltip :delay="2000"> <QTooltip :delay="2000">
{{ {{
t('wagon.warnings.minHeightBetweenTrays') + t('wagon.warnings.minHeightBetweenTrays') +
wagonConfig.minHeightBetweenTrays + minHeightBetweenTrays +
' cm' ' cm'
}} }}
<QSpace /> <QSpace />
{{ {{
t('wagon.warnings.maxWagonHeight') + t('wagon.warnings.maxWagonHeight') +
wagonConfig.maxWagonHeight + maxWagonHeight +
' cm' ' cm'
}} }}
</QTooltip> </QTooltip>

View File

@ -56,6 +56,13 @@ async function remove(row) {
:id="row.id" :id="row.id"
@click="navigate(row.id)" @click="navigate(row.id)"
> >
<template #list-items>
<QCheckbox
:label="t('Divisble')"
:model-value="row.divisible"
disable
/>
</template>
<template #actions> <template #actions>
<QBtn <QBtn
:label="t('components.smartCard.openCard')" :label="t('components.smartCard.openCard')"