0
0
Fork 0

feat #7271 Zone Components boilerplate

This commit is contained in:
Javier Segarra 2024-04-25 14:30:16 +02:00
parent b4e3157887
commit b1871c33fd
8 changed files with 1330 additions and 0 deletions

View File

@ -0,0 +1,6 @@
<script setup>
import VnCard from 'components/common/VnCard.vue';
</script>
<template>
<VnCard data-key="Zone" base-url="Zones" />
</template>

View File

@ -0,0 +1,432 @@
<script setup>
import { computed, ref, onMounted, onUpdated } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
onMounted(() => fetch());
onUpdated(() => fetch());
const { t } = useI18n();
const route = useRoute();
const quasar = useQuasar();
const router = useRouter();
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
});
const entityId = computed(() => $props.id || route.params.id);
const zone = ref([]);
const divisible = ref(false);
const name = ref('');
const colorPickerActive = ref(false);
let originalData = { trays: [] };
let zoneConfig;
let zoneDeliveryColors;
let currentTrayColorPicked;
async function fetch() {
try {
await axios.get('ZoneConfigs').then(async (res) => {
if (res.data) {
zoneConfig = res.data[0];
}
});
await axios.get(`ZoneDeliveryColors`).then(async (res) => {
if (res.data) {
zoneDeliveryColors = res.data;
if (!entityId.value)
zone.value.push({
id: 0,
position: 0,
color: { ...zoneDeliveryColors[0] },
action: 'add',
});
else {
await axios
.get(`ZoneDeliveryTrays`, {
params: { filter: { where: { typeFk: entityId.value } } },
})
.then(async (res) => {
if (res.data) {
for (let i = 0; i < res.data.length; i++) {
const tray = res.data[i];
zone.value.push({
id: res.data.length - i - 1,
position: tray.height,
color: {
...zoneDeliveryColors.find((color) => {
return color.id === tray.colorFk;
}),
},
action: tray.height == 0 ? 'add' : 'delete',
});
}
zone.value.forEach((value) => {
originalData.trays.push({ ...value });
});
}
});
}
}
});
if (entityId.value) {
await axios.get(`ZoneDeliverys/${entityId.value}`).then((res) => {
if (res.data) {
originalData.name = name.value = res.data.name;
originalData.divisible = divisible.value = res.data.divisible;
}
});
}
} catch (e) {
//
}
}
function addTray() {
if (
zone.value.find((tray) => {
return tray.position == null;
})
) {
quasar.notify({
message: t('zone.warnings.uncompleteTrays'),
type: 'warning',
});
return;
}
if (zone.value.length < zoneConfig.maxTrays) {
zone.value.unshift({
id: zone.value.length,
position: null,
color: { ...zoneDeliveryColors[0] },
action: 'delete',
});
} else {
quasar.notify({
message: t('zone.warnings.maxTrays'),
type: 'warning',
});
}
}
function deleteTray(trayToDelete) {
zone.value = zone.value.filter((tray) => tray.id !== trayToDelete.id);
reorderIds();
}
function reorderIds() {
for (let index = zone.value.length - 1; index >= 0; index--) {
zone.value[index].id = index;
}
}
async function onSubmit() {
try {
const path = entityId.value
? 'ZoneDeliverys/editZoneDelivery'
: 'ZoneDeliverys/createZoneDelivery';
const params = {
id: entityId.value,
name: name.value,
divisible: divisible.value,
trays: zone.value,
};
await axios.patch(path, params).then((res) => {
if (res.status == 204) router.push({ path: `/zone/type/list` });
});
} catch (error) {
//
}
}
function onReset() {
name.value = entityId.value ? originalData.name : null;
divisible.value = entityId.value ? originalData.divisible : false;
zone.value = entityId.value
? [...originalData.trays]
: [
{
id: 0,
position: 0,
color: { ...zoneDeliveryColors[0] },
action: 'add',
},
];
}
function doAction(tray) {
if (tray.action == 'add') {
addTray();
} else {
deleteTray(tray);
}
}
function showColorPicker(tray) {
colorPickerActive.value = true;
currentTrayColorPicked = zone.value.findIndex((val) => {
return val.id === tray.id;
});
}
function updateColor(newColor) {
zone.value[currentTrayColorPicked].color = {
...zoneDeliveryColors.find((color) => {
return color.rgb === newColor;
}),
};
}
function onPositionBlur(tray) {
if (tray.position) {
if (tray.position == '' || tray.position < 0) {
tray.position = null;
return;
}
tray.position = parseInt(tray.position);
zone.value.sort((a, b) => b.position - a.position);
reorderIds();
for (let index = zone.value.length - 1; index > 0; index--) {
if (exceedMaxHeight(index - 1)) continue;
if (
zone.value[index - 1].position - zone.value[index].position >=
zoneConfig.minHeightBetweenTrays
) {
continue;
} else {
zone.value[index - 1].position +=
zoneConfig.minHeightBetweenTrays -
(zone.value[index - 1].position - zone.value[index].position);
quasar.notify({
message:
t('zone.warnings.minHeightBetweenTrays') +
zoneConfig.minHeightBetweenTrays +
' cm',
type: 'warning',
});
exceedMaxHeight(index - 1);
}
}
}
}
function exceedMaxHeight(pos) {
if (zone.value[pos].position > zoneConfig.maxZoneHeight) {
zone.value.splice(pos, 1);
quasar.notify({
message: t('zone.warnings.maxZoneHeight') + zoneConfig.maxZoneHeight + ' cm',
type: 'warning',
});
return true;
}
return false;
}
</script>
<template>
<QPage class="q-pa-sm q-mx-xl">
<QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm">
<QCard class="q-pa-md">
<VnInput
filled
v-model="name"
:label="t('zone.delivery.name')"
:rules="[(val) => !!val || t('zone.warnings.nameNotEmpty')]"
/>
<QCheckbox class="q-mb-sm" v-model="divisible" label="Divisible" />
<div class="zone-tray q-mx-lg" v-for="tray in zone" :key="tray.id">
<div class="position">
<QInput
autofocus
filled
type="number"
:class="{ isVisible: tray.action == 'add' }"
v-model="tray.position"
@blur="onPositionBlur(tray)"
>
<QTooltip :delay="2000">
{{
t('zone.warnings.minHeightBetweenTrays') +
zoneConfig.minHeightBetweenTrays +
' cm'
}}
<QSpace />
{{
t('zone.warnings.maxZoneHeight') +
zoneConfig.maxZoneHeight +
' cm'
}}
</QTooltip>
</QInput>
</div>
<div class="shelving">
<div class="shelving-half">
<div class="shelving-up"></div>
<div
class="shelving-down"
:style="{ backgroundColor: tray.color.rgb }"
@click="showColorPicker(tray)"
></div>
</div>
<div
class="shelving-divisible"
:class="{ isVisible: !divisible }"
></div>
<div class="shelving-half">
<div class="shelving-up"></div>
<div
class="shelving-down"
:style="{ backgroundColor: tray.color.rgb }"
@click="showColorPicker(tray)"
></div>
</div>
</div>
<div class="action-button">
<QBtn
flat
round
color="primary"
:icon="tray.action"
@click="doAction(tray)"
/>
</div>
</div>
<div class="q-mb-sm wheels">
<QIcon color="grey-6" name="trip_origin" size="xl" />
<QIcon color="grey-6" name="trip_origin" size="xl" />
</div>
<QDialog
v-model="colorPickerActive"
position="right"
:no-backdrop-dismiss="false"
>
<QCard>
<QCardSection>
<div class="text-h6">{{ t('zone.delivery.trayColor') }}</div>
</QCardSection>
<QCardSection class="row items-center no-wrap">
<QColor
flat
v-model="zone[currentTrayColorPicked].color.rgb"
no-header
no-footer
default-view="palette"
:palette="
zoneDeliveryColors.map((color) => {
return color.rgb;
})
"
@change="updateColor($event)"
/>
<QBtn flat round icon="close" v-close-popup />
</QCardSection>
</QCard>
</QDialog>
</QCard>
<div class="q-mt-md">
<QBtn :label="t('zone.delivery.submit')" type="submit" color="primary" />
<QBtn
:label="t('zone.delivery.reset')"
type="reset"
color="primary"
flat
class="q-ml-sm"
/>
</div>
</QForm>
</QPage>
</template>
<style lang="scss" scoped>
.q-page {
display: flex;
justify-content: center;
align-items: flex-start;
}
.q-form {
width: 70%;
}
.q-dialog {
.q-card {
width: 100%;
}
}
.wheels {
margin-left: 5%;
display: flex;
justify-content: space-around;
}
.zone-tray {
display: flex;
height: 6rem;
.position {
width: 20%;
border-right: 1rem solid gray;
display: flex;
align-items: flex-end;
justify-content: flex-end;
padding-right: 1rem;
}
.shelving {
display: flex;
width: 75%;
.shelving-half {
width: 50%;
height: 100%;
.shelving-up {
height: 80%;
width: 100%;
}
.shelving-down {
height: 20%;
width: 100%;
}
}
.shelving-divisible {
width: 1%;
height: 100%;
border-left: 0.5rem dashed grey;
border-right: 0.5rem dashed grey;
}
}
.action-button {
width: 10%;
border-left: 1rem solid gray;
display: flex;
align-items: flex-end;
justify-content: flex-start;
padding-left: 1rem;
}
.isVisible {
display: none;
}
}
</style>

View File

@ -0,0 +1,81 @@
<script setup>
import axios from 'axios';
import { useQuasar } from 'quasar';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue';
const quasar = useQuasar();
const arrayData = useArrayData('ZoneDeliveryList');
const store = arrayData.store;
const router = useRouter();
const { t } = useI18n();
function navigate(id) {
router.push({ path: `/zone/type/${id}/edit` });
}
function create() {
router.push({ path: `/zone/type/create` });
}
async function remove(row) {
try {
const id = row.id;
await axios
.delete(`ZoneDeliverys/deleteZoneDelivery`, { params: { id } })
.then(async () => {
quasar.notify({
message: t('zone.delivery.removeItem'),
type: 'positive',
});
store.data.splice(store.data.indexOf(row), 1);
});
} catch (error) {
//
}
}
</script>
<template>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
data-key="ZoneDeliveryList"
url="/ZoneDeliverys"
order="id DESC"
auto-load
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:key="row.id"
:title="(row.name || '').toString()"
:id="row.id"
@click="navigate(row.id)"
>
<template #actions>
<QBtn
:label="t('components.smartCard.openCard')"
@click.stop="navigate(row.id)"
outline
/>
<QBtn
:label="t('zone.list.remove')"
@click.stop="remove(row)"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn @click="create" fab icon="add" color="primary" />
</QPageSticky>
</QPage>
</template>

View File

@ -0,0 +1,432 @@
<script setup>
import { computed, ref, onMounted, onUpdated } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useQuasar } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue';
import { useI18n } from 'vue-i18n';
import axios from 'axios';
onMounted(() => fetch());
onUpdated(() => fetch());
const { t } = useI18n();
const route = useRoute();
const quasar = useQuasar();
const router = useRouter();
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
});
const entityId = computed(() => $props.id || route.params.id);
const zone = ref([]);
const divisible = ref(false);
const name = ref('');
const colorPickerActive = ref(false);
let originalData = { trays: [] };
let zoneConfig;
let zoneUpcomingColors;
let currentTrayColorPicked;
async function fetch() {
try {
await axios.get('ZoneConfigs').then(async (res) => {
if (res.data) {
zoneConfig = res.data[0];
}
});
await axios.get(`ZoneUpcomingColors`).then(async (res) => {
if (res.data) {
zoneUpcomingColors = res.data;
if (!entityId.value)
zone.value.push({
id: 0,
position: 0,
color: { ...zoneUpcomingColors[0] },
action: 'add',
});
else {
await axios
.get(`ZoneUpcomingTrays`, {
params: { filter: { where: { typeFk: entityId.value } } },
})
.then(async (res) => {
if (res.data) {
for (let i = 0; i < res.data.length; i++) {
const tray = res.data[i];
zone.value.push({
id: res.data.length - i - 1,
position: tray.height,
color: {
...zoneUpcomingColors.find((color) => {
return color.id === tray.colorFk;
}),
},
action: tray.height == 0 ? 'add' : 'delete',
});
}
zone.value.forEach((value) => {
originalData.trays.push({ ...value });
});
}
});
}
}
});
if (entityId.value) {
await axios.get(`ZoneUpcomings/${entityId.value}`).then((res) => {
if (res.data) {
originalData.name = name.value = res.data.name;
originalData.divisible = divisible.value = res.data.divisible;
}
});
}
} catch (e) {
//
}
}
function addTray() {
if (
zone.value.find((tray) => {
return tray.position == null;
})
) {
quasar.notify({
message: t('zone.warnings.uncompleteTrays'),
type: 'warning',
});
return;
}
if (zone.value.length < zoneConfig.maxTrays) {
zone.value.unshift({
id: zone.value.length,
position: null,
color: { ...zoneUpcomingColors[0] },
action: 'delete',
});
} else {
quasar.notify({
message: t('zone.warnings.maxTrays'),
type: 'warning',
});
}
}
function deleteTray(trayToDelete) {
zone.value = zone.value.filter((tray) => tray.id !== trayToDelete.id);
reorderIds();
}
function reorderIds() {
for (let index = zone.value.length - 1; index >= 0; index--) {
zone.value[index].id = index;
}
}
async function onSubmit() {
try {
const path = entityId.value
? 'ZoneUpcomings/editZoneUpcoming'
: 'ZoneUpcomings/createZoneUpcoming';
const params = {
id: entityId.value,
name: name.value,
divisible: divisible.value,
trays: zone.value,
};
await axios.patch(path, params).then((res) => {
if (res.status == 204) router.push({ path: `/zone/type/list` });
});
} catch (error) {
//
}
}
function onReset() {
name.value = entityId.value ? originalData.name : null;
divisible.value = entityId.value ? originalData.divisible : false;
zone.value = entityId.value
? [...originalData.trays]
: [
{
id: 0,
position: 0,
color: { ...zoneUpcomingColors[0] },
action: 'add',
},
];
}
function doAction(tray) {
if (tray.action == 'add') {
addTray();
} else {
deleteTray(tray);
}
}
function showColorPicker(tray) {
colorPickerActive.value = true;
currentTrayColorPicked = zone.value.findIndex((val) => {
return val.id === tray.id;
});
}
function updateColor(newColor) {
zone.value[currentTrayColorPicked].color = {
...zoneUpcomingColors.find((color) => {
return color.rgb === newColor;
}),
};
}
function onPositionBlur(tray) {
if (tray.position) {
if (tray.position == '' || tray.position < 0) {
tray.position = null;
return;
}
tray.position = parseInt(tray.position);
zone.value.sort((a, b) => b.position - a.position);
reorderIds();
for (let index = zone.value.length - 1; index > 0; index--) {
if (exceedMaxHeight(index - 1)) continue;
if (
zone.value[index - 1].position - zone.value[index].position >=
zoneConfig.minHeightBetweenTrays
) {
continue;
} else {
zone.value[index - 1].position +=
zoneConfig.minHeightBetweenTrays -
(zone.value[index - 1].position - zone.value[index].position);
quasar.notify({
message:
t('zone.warnings.minHeightBetweenTrays') +
zoneConfig.minHeightBetweenTrays +
' cm',
type: 'warning',
});
exceedMaxHeight(index - 1);
}
}
}
}
function exceedMaxHeight(pos) {
if (zone.value[pos].position > zoneConfig.maxZoneHeight) {
zone.value.splice(pos, 1);
quasar.notify({
message: t('zone.warnings.maxZoneHeight') + zoneConfig.maxZoneHeight + ' cm',
type: 'warning',
});
return true;
}
return false;
}
</script>
<template>
<QPage class="q-pa-sm q-mx-xl">
<QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm">
<QCard class="q-pa-md">
<VnInput
filled
v-model="name"
:label="t('zone.upcoming.name')"
:rules="[(val) => !!val || t('zone.warnings.nameNotEmpty')]"
/>
<QCheckbox class="q-mb-sm" v-model="divisible" label="Divisible" />
<div class="zone-tray q-mx-lg" v-for="tray in zone" :key="tray.id">
<div class="position">
<QInput
autofocus
filled
type="number"
:class="{ isVisible: tray.action == 'add' }"
v-model="tray.position"
@blur="onPositionBlur(tray)"
>
<QTooltip :delay="2000">
{{
t('zone.warnings.minHeightBetweenTrays') +
zoneConfig.minHeightBetweenTrays +
' cm'
}}
<QSpace />
{{
t('zone.warnings.maxZoneHeight') +
zoneConfig.maxZoneHeight +
' cm'
}}
</QTooltip>
</QInput>
</div>
<div class="shelving">
<div class="shelving-half">
<div class="shelving-up"></div>
<div
class="shelving-down"
:style="{ backgroundColor: tray.color.rgb }"
@click="showColorPicker(tray)"
></div>
</div>
<div
class="shelving-divisible"
:class="{ isVisible: !divisible }"
></div>
<div class="shelving-half">
<div class="shelving-up"></div>
<div
class="shelving-down"
:style="{ backgroundColor: tray.color.rgb }"
@click="showColorPicker(tray)"
></div>
</div>
</div>
<div class="action-button">
<QBtn
flat
round
color="primary"
:icon="tray.action"
@click="doAction(tray)"
/>
</div>
</div>
<div class="q-mb-sm wheels">
<QIcon color="grey-6" name="trip_origin" size="xl" />
<QIcon color="grey-6" name="trip_origin" size="xl" />
</div>
<QDialog
v-model="colorPickerActive"
position="right"
:no-backdrop-dismiss="false"
>
<QCard>
<QCardSection>
<div class="text-h6">{{ t('zone.upcoming.trayColor') }}</div>
</QCardSection>
<QCardSection class="row items-center no-wrap">
<QColor
flat
v-model="zone[currentTrayColorPicked].color.rgb"
no-header
no-footer
default-view="palette"
:palette="
zoneUpcomingColors.map((color) => {
return color.rgb;
})
"
@change="updateColor($event)"
/>
<QBtn flat round icon="close" v-close-popup />
</QCardSection>
</QCard>
</QDialog>
</QCard>
<div class="q-mt-md">
<QBtn :label="t('zone.upcoming.submit')" type="submit" color="primary" />
<QBtn
:label="t('zone.upcoming.reset')"
type="reset"
color="primary"
flat
class="q-ml-sm"
/>
</div>
</QForm>
</QPage>
</template>
<style lang="scss" scoped>
.q-page {
display: flex;
justify-content: center;
align-items: flex-start;
}
.q-form {
width: 70%;
}
.q-dialog {
.q-card {
width: 100%;
}
}
.wheels {
margin-left: 5%;
display: flex;
justify-content: space-around;
}
.zone-tray {
display: flex;
height: 6rem;
.position {
width: 20%;
border-right: 1rem solid gray;
display: flex;
align-items: flex-end;
justify-content: flex-end;
padding-right: 1rem;
}
.shelving {
display: flex;
width: 75%;
.shelving-half {
width: 50%;
height: 100%;
.shelving-up {
height: 80%;
width: 100%;
}
.shelving-down {
height: 20%;
width: 100%;
}
}
.shelving-divisible {
width: 1%;
height: 100%;
border-left: 0.5rem dashed grey;
border-right: 0.5rem dashed grey;
}
}
.action-button {
width: 10%;
border-left: 1rem solid gray;
display: flex;
align-items: flex-end;
justify-content: flex-start;
padding-left: 1rem;
}
.isVisible {
display: none;
}
}
</style>

View File

@ -0,0 +1,81 @@
<script setup>
import axios from 'axios';
import { useQuasar } from 'quasar';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue';
const quasar = useQuasar();
const arrayData = useArrayData('ZoneUpcomingList');
const store = arrayData.store;
const router = useRouter();
const { t } = useI18n();
function navigate(id) {
router.push({ path: `/zone/type/${id}/edit` });
}
function create() {
router.push({ path: `/zone/type/create` });
}
async function remove(row) {
try {
const id = row.id;
await axios
.delete(`ZoneUpcomings/deleteZoneUpcoming`, { params: { id } })
.then(async () => {
quasar.notify({
message: t('zone.upcoming.removeItem'),
type: 'positive',
});
store.data.splice(store.data.indexOf(row), 1);
});
} catch (error) {
//
}
}
</script>
<template>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
data-key="ZoneUpcomingList"
url="/ZoneUpcomings"
order="id DESC"
auto-load
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:key="row.id"
:title="(row.name || '').toString()"
:id="row.id"
@click="navigate(row.id)"
>
<template #actions>
<QBtn
:label="t('components.smartCard.openCard')"
@click.stop="navigate(row.id)"
outline
/>
<QBtn
:label="t('zone.list.remove')"
@click.stop="remove(row)"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn @click="create" fab icon="add" color="primary" />
</QPageSticky>
</QPage>
</template>

View File

@ -0,0 +1,184 @@
<script setup>
import { computed, onMounted, onUpdated, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { QIcon, QInput, QItem, QItemSection, QSelect } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue';
import { useRoute, useRouter } from 'vue-router';
import axios from 'axios';
onMounted(() => fetch());
onUpdated(() => fetch());
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
});
const entityId = computed(() => $props.id || route.params.id);
let zoneTypes = [];
let originalData = {};
const zone = ref({});
const filteredZoneTypes = ref(zoneTypes);
async function onSubmit() {
try {
const params = {
id: entityId.value,
label: zone.value.label,
plate: zone.value.plate,
volume: zone.value.volume,
typeFk: zone.value.typeFk,
};
await axios.patch('Zones', params).then((res) => {
if (res.status == 200) router.push({ path: `/zone/list` });
});
} catch (error) {
//
}
}
async function onReset() {
if (entityId.value) {
zone.value = { ...originalData };
} else {
zone.value = {};
}
}
async function fetch() {
try {
await axios.get('ZoneTypes').then(async (res) => {
if (res.data) {
filteredZoneTypes.value = zoneTypes = res.data;
}
});
if (entityId.value) {
await axios.get(`Zones/${entityId.value}`).then(async (res) => {
const data = res.data;
if (data) {
zone.value.label = data.label;
zone.value.plate = data.plate;
zone.value.volume = data.volume;
zone.value.typeFk = data.typeFk;
originalData = { ...zone.value };
}
});
}
} catch (e) {
//
}
}
function filterType(val, update) {
update(() => {
const needle = val.toLowerCase();
filteredZoneTypes.value = zoneTypes.filter(
(v) => v.name.toLowerCase().indexOf(needle) > -1
);
});
}
</script>
<template>
<QPage class="q-pa-sm q-mx-xl">
<QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm">
<QCard class="q-pa-md">
<div class="row q-col-gutter-md">
<div class="col">
<QInput
filled
v-model="zone.label"
:label="t('zone.create.label')"
type="number"
min="0"
:rules="[(val) => !!val || t('zone.warnings.labelNotEmpty')]"
/>
</div>
<div class="col">
<VnInput
filled
v-model="zone.plate"
:label="t('zone.create.plate')"
:rules="[(val) => !!val || t('zone.warnings.plateNotEmpty')]"
/>
</div>
</div>
<div class="row q-col-gutter-md">
<div class="col">
<QInput
filled
v-model="zone.volume"
:label="t('zone.create.volume')"
type="number"
min="0"
:rules="[(val) => !!val || t('zone.warnings.volumeNotEmpty')]"
/>
</div>
<div class="col">
<QSelect
filled
v-model="zone.typeFk"
use-input
fill-input
hide-selected
input-debounce="0"
option-label="name"
option-value="id"
emit-value
map-options
:label="t('zone.create.type')"
:options="filteredZoneTypes"
:rules="[(val) => !!val || t('zone.warnings.typeNotEmpty')]"
@filter="filterType"
>
<template v-if="zone.typeFk" #append>
<QIcon
name="cancel"
@click.stop.prevent="zone.typeFk = null"
class="cursor-pointer"
/>
</template>
<template #no-option>
<QItem>
<QItemSection class="text-grey">
{{ t('zone.warnings.noData') }}
</QItemSection>
</QItem>
</template>
</QSelect>
</div>
</div>
</QCard>
<div class="q-mt-md">
<QBtn :label="t('zone.type.submit')" type="submit" color="primary" />
<QBtn
:label="t('zone.type.reset')"
type="reset"
color="primary"
flat
class="q-ml-sm"
/>
</div>
</QForm>
</QPage>
</template>
<style lang="scss" scoped>
.q-page {
display: flex;
justify-content: center;
align-items: flex-start;
}
.q-form {
width: 70%;
}
</style>

View File

@ -0,0 +1,97 @@
<script setup>
import axios from 'axios';
import { useQuasar } from 'quasar';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import { useArrayData } from 'src/composables/useArrayData';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import CardList from 'components/ui/CardList.vue';
import VnLv from 'components/ui/VnLv.vue';
const quasar = useQuasar();
const arrayData = useArrayData('ZoneList');
const store = arrayData.store;
const router = useRouter();
const { t } = useI18n();
const filter = {
include: {
relation: 'type',
scope: {
fields: 'name',
},
},
};
function navigate(id) {
router.push({ path: `/zone/${id}/edit` });
}
function create() {
router.push({ path: `/zone/create` });
}
async function remove(row) {
try {
await axios.delete(`Zones/${row.id}`).then(async () => {
quasar.notify({
message: t('zone.list.removeItem'),
type: 'positive',
});
store.data.splice(store.data.indexOf(row), 1);
});
} catch (error) {
//
}
}
</script>
<template>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
data-key="ZoneList"
url="/Zones"
order="id DESC"
:filter="filter"
auto-load
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:key="row.id"
:title="(row.label || '').toString()"
:id="row.id"
@click="navigate(row.id)"
>
<template #list-items>
<VnLv
:label="t('zone.list.plate')"
:title-label="t('zone.list.plate')"
:value="row.plate"
/>
<VnLv :label="t('zone.list.volume')" :value="row?.volume" />
<VnLv :label="t('zone.list.type')" :value="row?.type?.name" />
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.openCard')"
@click.stop="navigate(row.id)"
outline
/>
<QBtn
:label="t('zone.list.remove')"
@click.stop="remove(row)"
color="primary"
style="margin-top: 15px"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
<QPageSticky position="bottom-right" :offset="[18, 18]">
<QBtn @click="create" fab icon="add" color="primary" />
</QPageSticky>
</QPage>
</template>

View File

@ -0,0 +1,17 @@
<script setup>
import { useStateStore } from 'stores/useStateStore';
import LeftMenu from 'src/components/LeftMenu.vue';
const stateStore = useStateStore();
</script>
<template>
<QDrawer v-model="stateStore.leftDrawer" show-if-above :width="256">
<QScrollArea class="fit text-grey-8">
<LeftMenu />
</QScrollArea>
</QDrawer>
<QPageContainer>
<RouterView></RouterView>
</QPageContainer>
</template>