Merge branch 'dev' of https://gitea.verdnatura.es/verdnatura/salix-front into 7274-fixCustomer
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-05-15 11:22:23 +02:00
commit 31573c0f0b
7 changed files with 140 additions and 204 deletions

View File

@ -1238,16 +1238,10 @@ item/itemType:
itemType: Item type itemType: Item type
basicData: Basic data basicData: Basic data
summary: Summary summary: Summary
zone:
pageTitles:
zones: Zone
zonesList: Zones
deliveryList: Delivery days
upcomingList: Upcoming deliveries
monitor: monitor:
pageTitles: pageTitles:
monitors: Monitores monitors: Monitors
list: Listado list: List
components: components:
topbar: {} topbar: {}
itemsFilterPanel: itemsFilterPanel:

View File

@ -60,7 +60,7 @@ const setData = (entity) => {
flat flat
dense dense
size="md" size="md"
icon="preview" icon="vn:zone"
color="white" color="white"
class="link" class="link"
:to="{ name: 'ZoneList' }" :to="{ name: 'ZoneList' }"

View File

@ -32,7 +32,7 @@ const filter = computed(() => {
fields: ['name'], fields: ['name'],
}, },
where: { where: {
id: route.params.id, id: entityId,
}, },
}; };
return filter; return filter;

View File

@ -1,184 +1,114 @@
<script setup> <script setup>
import { computed, onMounted, onUpdated, ref } from 'vue'; import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { QIcon, QInput, QItem, QItemSection, QSelect } from 'quasar'; import { useRouter } from 'vue-router';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import VnInputTime from 'components/common/VnInputTime.vue';
import { useRoute, useRouter } from 'vue-router'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import axios from 'axios';
onMounted(() => fetch());
onUpdated(() => fetch());
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute();
const router = useRouter(); const router = useRouter();
const $props = defineProps({
id: { const newZoneForm = reactive({
type: Number, travelingDays: 0,
required: false, price: 0.2,
default: null, bonus: 0.2,
}, hour: Date.vnNew(),
isVolumetric: false,
}); });
const entityId = computed(() => $props.id || route.params.id); const warehousesOptions = ref([]);
const agencyOptions = ref([]);
let zoneTypes = []; const redirectToZoneLocations = (_, { id }) => {
let originalData = {}; router.push({ name: 'ZoneLocations', params: { id } });
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> </script>
<template> <template>
<QPage class="q-pa-sm q-mx-xl"> <FetchData
<QForm @submit="onSubmit()" @reset="onReset()" class="q-pa-sm"> url="Warehouses"
<QCard class="q-pa-md"> :filter="{ order: ['name'] }"
<div class="row q-col-gutter-md"> @on-fetch="(data) => (warehousesOptions = data)"
<div class="col"> auto-load
<QInput />
filled <FetchData
v-model="zone.label" url="AgencyModes/isActive"
:label="t('create.name')" :filter="{ order: ['name'] }"
type="number" @on-fetch="(data) => (agencyOptions = data)"
min="0" auto-load
:rules="[(val) => !!val || t('zone.warnings.labelNotEmpty')]" />
/> <QPage>
</div> <VnSubToolbar />
<div class="col"> <FormModel
<VnInput url-create="Zones"
filled model="Zones"
v-model="zone.plate" :form-initial-data="newZoneForm"
:label="t('create.agency')" @on-data-saved="redirectToZoneLocations"
:rules="[(val) => !!val || t('zone.warnings.plateNotEmpty')]" >
/> <template #form="{ data }">
</div> <VnRow class="row q-gutter-md q-mb-md">
</div> <VnInput
<div class="row q-col-gutter-md"> v-model="data.name"
<div class="col"> :label="t('create.name')"
<QInput :required="true"
filled />
v-model="zone.volume" </VnRow>
:label="t('create.close')" <VnRow class="row q-gutter-md q-mb-md">
type="number" <VnSelect
min="0" :label="t('create.warehouse')"
:rules="[(val) => !!val || t('zone.warnings.volumeNotEmpty')]" :options="warehousesOptions"
/> hide-selected
</div> option-label="name"
<div class="col"> option-value="id"
<QSelect v-model="data.warehouseFk"
filled />
v-model="zone.typeFk" <VnSelect
use-input :label="t('create.agency')"
fill-input :options="agencyOptions"
hide-selected hide-selected
input-debounce="0" option-label="name"
option-label="name" option-value="id"
option-value="id" v-model="data.agencyModeFk"
emit-value :required="true"
map-options />
:label="t('create.price')" </VnRow>
:options="filteredZoneTypes" <VnRow class="row q-gutter-md q-mb-md">
:rules="[(val) => !!val || t('zone.warnings.typeNotEmpty')]" <VnInput
@filter="filterType" v-model="data.travelingDays"
> :label="t('create.travelingDays')"
<template v-if="zone.typeFk" #append> type="number"
<QIcon min="0"
name="cancel" />
@click.stop.prevent="zone.typeFk = null"
class="cursor-pointer" <VnInputTime v-model="data.hour" :label="t('create.closingHour')" />
/> </VnRow>
</template> <VnRow class="row q-gutter-md q-mb-md">
<template #no-option> <VnInput
<QItem> v-model="data.price"
<QItemSection class="text-grey"> :label="t('create.price')"
{{ t('zone.warnings.noData') }} type="number"
</QItemSection> min="0"
</QItem> />
</template> <VnInput
</QSelect> v-model="data.bonus"
</div> :label="t('create.bonus')"
</div> type="number"
</QCard> min="0"
<div class="q-mt-md"> />
<QBtn :label="t('type.submit')" type="submit" color="primary" /> </VnRow>
<QBtn <VnRow class="row q-gutter-md q-mb-md">
:label="t('type.reset')" <QCheckbox
type="reset" :label="t('create.volumetric')"
color="primary" v-model="data.isVolumetric"
flat :toggle-indeterminate="false"
class="q-ml-sm" />
/> </VnRow>
</div> </template>
</QForm> </FormModel>
</QPage> </QPage>
</template> </template>
<style lang="scss" scoped>
.q-page {
display: flex;
justify-content: center;
align-items: flex-start;
}
.q-form {
width: 70%;
}
</style>

View File

@ -2,6 +2,7 @@ zone:
pageTitles: pageTitles:
zones: Zone zones: Zone
zonesList: Zones zonesList: Zones
zoneCreate: Create zone
deliveryList: Delivery days deliveryList: Delivery days
upcomingList: Upcoming deliveries upcomingList: Upcoming deliveries
list: list:
@ -13,18 +14,19 @@ list:
price: Price price: Price
create: Create zone create: Create zone
openSummary: Details openSummary: Details
confirmCloneTitle: All it's properties will be copied
confirmCloneSubtitle: Do you want to clone this zone?
searchZone: Search zones searchZone: Search zones
searchInfo: Search zone by id or name searchInfo: Search zone by id or name
confirmCloneTitle: All it's properties will be copied
confirmCloneSubtitle: Do you want to clone this zone?
create: create:
name: Name name: Name
warehouse: Warehouse
agency: Agency agency: Agency
close: Close travelingDays: Traveling days
closingHour: Closing hour
price: Price price: Price
type: bonus: Bonus
submit: Save volumetric: Volumetric
reset: Reset
summary: summary:
agency: Agency agency: Agency
price: Price price: Price

View File

@ -2,6 +2,7 @@ zone:
pageTitles: pageTitles:
zones: Zonas zones: Zonas
zonesList: Zonas zonesList: Zonas
zoneCreate: Nueva zona
deliveryList: Días de entrega deliveryList: Días de entrega
upcomingList: Próximos repartos upcomingList: Próximos repartos
list: list:
@ -13,18 +14,19 @@ list:
price: Precio price: Precio
create: Crear zona create: Crear zona
openSummary: Detalles openSummary: Detalles
confirmCloneTitle: Todas sus propiedades serán copiadas
confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
searchZone: Buscar zonas searchZone: Buscar zonas
searchInfo: Buscar zonas por identificador o nombre searchInfo: Buscar zonas por identificador o nombre
confirmCloneTitle: Todas sus propiedades serán copiadas
confirmCloneSubtitle: ¿Seguro que quieres clonar esta zona?
create: create:
name: Nombre name: Nombre
warehouse: Almacén
agency: Agencia agency: Agencia
close: Cierre travelingDays: Días de viaje
closingHour: Hora de cierre
price: Precio price: Precio
type: bonus: Bonificación
submit: Guardar volumetric: Volumétrico
reset: Reiniciar
summary: summary:
agency: Agencia agency: Agencia
price: Precio price: Precio
@ -38,5 +40,3 @@ summary:
filterPanel: filterPanel:
name: Nombre name: Nombre
agencyModeFk: Agencia agencyModeFk: Agencia
Search zones: Buscar zonas
You can search by zone reference: Puedes buscar por referencia de la zona

View File

@ -12,7 +12,7 @@ export default {
redirect: { name: 'ZoneMain' }, redirect: { name: 'ZoneMain' },
menus: { menus: {
main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'], main: ['ZoneList', 'ZoneDeliveryList', 'ZoneUpcomingList'],
card: ['ZoneBasicData', 'ZoneHistory'], card: ['ZoneBasicData', 'ZoneHistory', 'ZoneLocations'],
}, },
children: [ children: [
{ {
@ -48,15 +48,15 @@ export default {
}, },
component: () => import('src/pages/Zone/ZoneCreate.vue'), component: () => import('src/pages/Zone/ZoneCreate.vue'),
}, },
{ // {
path: 'counter', // path: 'counter',
name: 'ZoneCounter', // name: 'ZoneCounter',
meta: { // meta: {
title: 'zoneCounter', // title: 'zoneCounter',
icon: 'add_circle', // icon: 'add_circle',
}, // },
component: () => import('src/pages/Zone/ZoneCounter.vue'), // component: () => import('src/pages/Zone/ZoneCounter.vue'),
}, // },
], ],
}, },
{ {
@ -74,6 +74,15 @@ export default {
}, },
component: () => import('src/pages/Zone/Card/ZoneSummary.vue'), component: () => import('src/pages/Zone/Card/ZoneSummary.vue'),
}, },
{
name: 'ZoneLocations',
path: 'location',
meta: {
title: 'locations',
icon: 'vn:greuge',
},
component: () => import('src/pages/Zone/Card/ZoneLocations.vue'),
},
{ {
name: 'ZoneBasicData', name: 'ZoneBasicData',
path: 'basic-data', path: 'basic-data',
@ -92,6 +101,7 @@ export default {
}, },
component: () => import('src/pages/Zone/Card/ZoneLog.vue'), component: () => import('src/pages/Zone/Card/ZoneLog.vue'),
}, },
// { // {
// path: '/zone/delivery', // path: '/zone/delivery',
// name: 'ZoneDeliveryMain', // name: 'ZoneDeliveryMain',