0
0
Fork 0

feat: refs #4560 sin DeliveryMan

This commit is contained in:
Javi Gallego 2024-06-04 14:06:04 +02:00
parent f1df969fa6
commit 857aca49dd
9 changed files with 0 additions and 718 deletions

View File

@ -1,115 +0,0 @@
<script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import FormModel from 'components/FormModel.vue';
const route = useRoute();
const { t } = useI18n();
const suppliers = ref([]);
const agencyModes = ref([]);
function setSuppliers(data) {
suppliers.value = data;
}
function setAgencyModes(data) {
agencyModes.value = data;
}
const filter = {
include: [
{
relation: 'deliveryManAgency',
scope: {
include: {
relation: 'agencyMode',
},
},
},
{
relation: 'supplier',
},
],
};
</script>
<template>
<fetch-data url="Suppliers" @on-fetch="setSuppliers" auto-load />
<fetch-data url="AgencyModes" @on-fetch="setAgencyModes" auto-load />
<div class="container">
<q-card>
<form-model :url="`DeliveryMans/${route.params.id}`" :filter="filter" model="deliveryMan">
<template #form="{ data, validate }">
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-input v-model="data.id" :label="t('route.deliveryMan.basicData.id')" disable />
</div>
<div class="col">
<q-select
v-model="data.supplierFk"
:options="suppliers"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.supplier')"
map-options
use-input
:rules="validate('deliveryMan.supplierFk')"
:input-debounce="0"
>
</q-select>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-input
v-model="data.minCost"
:label="t('route.deliveryMan.basicData.minCost')"
:rules="validate('deliveryMan.minCost')"
/>
</div>
<div class="col">
<q-input
v-model="data.minM3"
:label="t('route.deliveryMan.basicData.minM3')"
:rules="validate('deliveryMan.minM3')"
/>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-select
v-model="data.deliveryManAgency.agencyModeFk"
:options="agencyModes"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.agency')"
map-options
use-input
:rules="validate('deliveryMan.deliveryManAgency.agencyModeFk')"
:input-debounce="0"
>
</q-select>
</div>
</div>
</template>
</form-model>
</q-card>
</div>
</template>
<style lang="scss" scoped>
.container {
display: flex;
justify-content: center;
}
.q-card {
width: 800px;
}
</style>

View File

@ -1,58 +0,0 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useState } from 'composables/useState';
import DeliveryManDescriptor from './DeliveryManDescriptor.vue';
const { t } = useI18n();
const state = useState();
</script>
<template>
<q-drawer v-model="state.drawer.value" show-if-above :width="256" :breakpoint="500">
<q-scroll-area class="fit">
<delivery-man-descriptor />
<q-separator />
<q-list>
<q-item :to="{ name: 'DeliveryManBasicData' }" clickable v-ripple>
<q-item-section avatar>
<q-icon name="vn:settings" />
</q-item-section>
<q-item-section>{{ t('route.pageTitles.basicData') }}</q-item-section>
</q-item>
</q-list>
</q-scroll-area>
</q-drawer>
<q-page-container>
<q-page class="q-pa-md">
<router-view></router-view>
</q-page>
</q-page-container>
</template>
<style lang="scss">
.q-scrollarea__content {
max-width: 100%;
}
</style>
<style lang="scss" scoped>
.descriptor {
max-width: 256px;
h5 {
margin: 0 15px;
}
.header {
display: flex;
justify-content: space-between;
}
.q-card__actions {
justify-content: center;
}
#descriptor-skeleton .q-card__actions {
justify-content: space-between;
}
}
</style>

View File

@ -1,82 +0,0 @@
<script setup>
import axios from 'axios';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
const $props = defineProps({
id: {
type: Number,
required: false,
default: null,
},
});
onMounted(async () => {
await fetch();
});
const route = useRoute();
const { t } = useI18n();
const entityId = computed(() => {
return $props.id || route.params.id;
});
const deliveryMan = ref();
async function fetch() {
const filter = {
include: [
{
relation: 'deliveryManAgency',
scope: {
include: {
relation: 'agencyMode',
},
},
},
{
relation: 'supplier',
},
],
};
const options = { params: { filter } };
const { data } = await axios.get(`DeliveryMans/${entityId.value}`, options);
if (data) deliveryMan.value = data;
}
</script>
<template>
<skeleton-descriptor v-if="!deliveryMan" />
<card-descriptor v-if="deliveryMan" module="DeliveryMan" :data="deliveryMan">
<template #body>
<q-list>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.card.supplier') }}</q-item-label>
<q-item-label>{{ deliveryMan.supplier.name }}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.card.agency') }}</q-item-label>
<q-item-label>{{ deliveryMan.deliveryManAgency.agencyMode.name }}</q-item-label>
</q-item-section>
</q-item>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.card.minCost') }}</q-item-label>
<q-item-label>{{ deliveryMan.minCost }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.card.minM3') }}</q-item-label>
<q-item-label>{{ deliveryMan.minM3 }}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</template>
</card-descriptor>
</template>

View File

@ -1,124 +0,0 @@
<script setup>
import axios from 'axios';
import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router';
onMounted(() => fetch());
const route = useRoute();
const { t } = useI18n();
const $props = defineProps({
id: {
type: Number,
default: 0,
},
});
const entityId = computed(() => $props.id || route.params.id);
const filter = {
include: [
{
relation: 'deliveryManAgency',
scope: {
include: {
relation: 'agencyMode',
},
},
},
{
relation: 'supplier',
},
],
};
const deliveryMan = ref(null);
function fetch() {
const id = entityId.value;
axios
.get(`DeliveryMans/${id}`, {
params: {
filter,
},
})
.then(({ data }) => {
deliveryMan.value = data;
});
}
</script>
<template>
<div class="summary container">
<q-card>
<skeleton-summary v-if="!deliveryMan" />
<template v-if="deliveryMan">
<div class="header bg-primary q-pa-sm q-mb-md">
{{ t('route.deliveryMan.summary.deliveryMan') }} #{{ deliveryMan.id }}
</div>
<q-list>
<q-item>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.summary.supplier') }}</q-item-label>
<q-item-label>{{ deliveryMan.supplier.name }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.summary.agency') }}</q-item-label>
<q-item-label>{{ deliveryMan.deliveryManAgency.agencyMode.name }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.summary.minCost') }}</q-item-label>
<q-item-label>{{ deliveryMan.minCost }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.summary.minM3') }}</q-item-label>
<q-item-label>{{ deliveryMan.minM3 }}</q-item-label>
</q-item-section>
</q-item>
<q-item> </q-item>
</q-list>
</template>
</q-card>
</div>
</template>
<style lang="scss" scoped>
.container {
display: flex;
justify-content: center;
}
.q-card {
width: 100%;
max-width: 950px;
}
.summary {
.header {
text-align: center;
font-size: 18px;
}
#slider-container {
max-width: 80%;
margin: 0 auto;
.q-slider {
.q-slider__marker-labels:nth-child(1) {
transform: none;
}
.q-slider__marker-labels:nth-child(2) {
transform: none;
left: auto !important;
right: 0%;
}
}
}
}
.q-dialog .summary {
max-width: 1200px;
}
</style>

View File

@ -1,126 +0,0 @@
<script setup>
import axios from 'axios';
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
const { t } = useI18n();
const deliveryMan = reactive({
supplierFk: null,
agencyModeFk: null,
minCost: null,
minM3: null,
});
const suppliers = ref([]);
const agencyModes = ref([]);
function setSuppliers(data) {
suppliers.value = data;
}
function setAgencyModes(data) {
agencyModes.value = data;
}
async function onSubmit() {
try {
const newDeliveryMan = await axios.post('DeliveryMans', {
supplierFk: deliveryMan.supplierFk,
minCost: deliveryMan.minCost,
minM3: deliveryMan.minM3,
});
if (deliveryMan.agencyModeFk) {
await axios.post(`DeliveryManAgencys/${newDeliveryMan.id}`, {
agencyModeFk: deliveryMan.agencyMode,
});
}
} catch (e) {
console.error(e);
}
}
</script>
<template>
<fetch-data url="Suppliers" @on-fetch="setSuppliers" auto-load />
<fetch-data url="AgencyModes" @on-fetch="setAgencyModes" auto-load />
<div class="container">
<q-card class="q-pa-md">
<q-banner v-if="hasChanges" class="text-white bg-warning">
<q-icon name="warning" size="md" class="q-mr-md" />
<span>{{ t('globals.changesToSave') }}</span>
</q-banner>
<q-form @submit="onSubmit" @reset="onReset" class="q-gutter-md">
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-input
filled
v-model="deliveryMan.minCost"
:label="t('route.deliveryMan.basicData.minCost')"
:rules="[(val) => val > 0]"
lazy-rules
/>
</div>
<div class="col">
<q-input
filled
v-model="deliveryMan.minM3"
:label="t('route.deliveryMan.basicData.minM3')"
:rules="[(val) => val > 0]"
lazy-rules
/>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-select
v-model="deliveryMan.supplierFk"
:options="suppliers"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.supplier')"
map-options
use-input
:input-debounce="0"
>
</q-select>
</div>
<div class="col">
<q-select
v-model="deliveryMan.agencyModeFk"
:options="agencyModes"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.agency')"
map-options
use-input
:input-debounce="0"
>
</q-select>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-btn label="Submit" type="submit" color="primary" />
<q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" />
</div>
</div>
</q-form>
</q-card>
</div>
</template>
<style lang="scss" scoped>
.q-card {
width: 800px;
}
.container {
display: flex;
justify-content: center;
}
</style>

View File

@ -1,83 +0,0 @@
<script setup>
import Paginate from 'components/Paginate.vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
const { t } = useI18n();
const router = useRouter();
const filter = {
include: [
{
relation: 'deliveryManAgency',
scope: {
include: {
relation: 'agencyMode',
},
},
},
{
relation: 'supplier',
},
],
};
function navigateCard(id) {
router.push({ path: `/route/${id}` });
}
function navigateCreate() {
router.push({ path: `/route/deliveryMan/create` });
}
</script>
<template>
<q-page class="q-pa-md">
<paginate url="DeliveryMans" :filter="filter" sort-by="id DESC" auto-load>
<template #body="{ rows }">
<q-card class="card" v-for="row of rows" :key="row.id">
<q-item class="q-pa-none items-start cursor-pointer q-hoverable" v-ripple clickable>
<q-item-section class="q-pa-md" @click="navigateCard(row.id)">
<div class="text-h6 link">{{ t('route.deliveryMan.list.deliveryMan') }}</div>
<q-item-label caption>#{{ row.id }}</q-item-label>
<q-list>
<q-item class="q-pa-none">
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.list.supplier') }}</q-item-label>
<q-item-label>{{ row.supplier.name }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.list.minCost') }}</q-item-label>
<q-item-label>{{ row.minCost }}</q-item-label>
</q-item-section>
</q-item>
<q-item class="q-pa-none">
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.list.minM3') }}</q-item-label>
<q-item-label>{{ row.minM3 }}</q-item-label>
</q-item-section>
<q-item-section>
<q-item-label caption>{{ t('route.deliveryMan.list.agency') }}</q-item-label>
<q-item-label v-if="row.deliveryManAgency">{{
row.deliveryManAgency.agencyMode.name
}}</q-item-label>
</q-item-section>
</q-item>
</q-list>
</q-item-section>
<q-separator vertical />
<q-card-actions vertical>
<q-btn flat round color="orange" icon="arrow_circle_right" @click="navigateCard(row.id)">
<q-tooltip>{{ t('components.smartCard.openCard') }}</q-tooltip>
</q-btn>
</q-card-actions>
</q-item>
</q-card>
</template>
</paginate>
<q-page-sticky position="bottom-right" :offset="[18, 18]" @click="navigateCreate()"
><q-tooltip>{{ t('route.pageTitles.deliveryManCreate') }}</q-tooltip>
<q-fab icon="person_add" direction="up" color="orange"> </q-fab>
</q-page-sticky>
</q-page>
</template>

View File

@ -1,126 +0,0 @@
<script setup>
import axios from 'axios';
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
const { t } = useI18n();
const deliveryMan = reactive({
supplierFk: null,
agencyModeFk: null,
minCost: null,
minM3: null,
});
const suppliers = ref([]);
const agencyModes = ref([]);
function setSuppliers(data) {
suppliers.value = data;
}
function setAgencyModes(data) {
agencyModes.value = data;
}
async function onSubmit() {
try {
const newDeliveryMan = await axios.post('DeliveryMans', {
supplierFk: deliveryMan.supplierFk,
minCost: deliveryMan.minCost,
minM3: deliveryMan.minM3,
});
if (deliveryMan.agencyModeFk) {
await axios.post(`DeliveryManAgencys/${newDeliveryMan.id}`, {
agencyModeFk: deliveryMan.agencyMode,
});
}
} catch (e) {
console.error(e);
}
}
</script>
<template>
<fetch-data url="Suppliers" @on-fetch="setSuppliers" auto-load />
<fetch-data url="AgencyModes" @on-fetch="setAgencyModes" auto-load />
<div class="container">
<q-card class="q-pa-md">
<q-banner v-if="hasChanges" class="text-white bg-warning">
<q-icon name="warning" size="md" class="q-mr-md" />
<span>{{ t('globals.changesToSave') }}</span>
</q-banner>
<q-form @submit="onSubmit" @reset="onReset" class="q-gutter-md">
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-input
filled
v-model="deliveryMan.minCost"
:label="t('route.deliveryMan.basicData.minCost')"
:rules="[(val) => val > 0]"
lazy-rules
/>
</div>
<div class="col">
<q-input
filled
v-model="deliveryMan.minM3"
:label="t('route.deliveryMan.basicData.minM3')"
:rules="[(val) => val > 0]"
lazy-rules
/>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-select
v-model="deliveryMan.supplierFk"
:options="suppliers"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.supplier')"
map-options
use-input
:input-debounce="0"
>
</q-select>
</div>
<div class="col">
<q-select
v-model="deliveryMan.agencyModeFk"
:options="agencyModes"
option-value="id"
option-label="name"
emit-value
:label="t('route.deliveryMan.basicData.agency')"
map-options
use-input
:input-debounce="0"
>
</q-select>
</div>
</div>
<div class="row q-gutter-md q-mb-md">
<div class="col">
<q-btn label="Submit" type="submit" color="primary" />
<q-btn label="Reset" type="reset" color="primary" flat class="q-ml-sm" />
</div>
</div>
</q-form>
</q-card>
</div>
</template>
<style lang="scss" scoped>
.q-card {
width: 800px;
}
.container {
display: flex;
justify-content: center;
}
</style>

View File

@ -3,7 +3,6 @@ import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import VnRow from 'components/ui/VnRow.vue'; import VnRow from 'components/ui/VnRow.vue';
import FormModel from 'components/FormModel.vue'; import FormModel from 'components/FormModel.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue'; import VnInput from 'components/common/VnInput.vue';
import VnInputTime from 'components/common/VnInputTime.vue'; import VnInputTime from 'components/common/VnInputTime.vue';
@ -22,7 +21,6 @@ const onSave = (data, response) => {
}; };
</script> </script>
<template> <template>
<VnSubToolbar />
<FetchData <FetchData
url="Suppliers" url="Suppliers"
auto-load auto-load

View File

@ -1,7 +1,6 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { ref } from 'vue'; import { ref } from 'vue';
import CrudModel from 'components/CrudModel.vue'; import CrudModel from 'components/CrudModel.vue';
@ -23,7 +22,6 @@ const updateDefaultStop = (data) => {
}; };
</script> </script>
<template> <template>
<VnSubToolbar />
<FetchData <FetchData
:url="`Roadmaps/${route.params?.id}`" :url="`Roadmaps/${route.params?.id}`"
auto-load auto-load