feat: refs #6919 sync order
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Jorge Penadés 2024-11-15 16:03:30 +01:00
parent c2e4380f18
commit 3477b24c93
4 changed files with 35 additions and 39 deletions

View File

@ -14,7 +14,6 @@ import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
const { t } = useI18n();
const route = useRoute();
const state = useState();
const ORDER_MODEL = 'order';
const isNew = Boolean(!route.params.id);
const clientList = ref([]);
@ -33,7 +32,7 @@ const fetchAddressList = async (addressId) => {
});
addressList.value = data;
if (addressList.value?.length === 1) {
state.get(ORDER_MODEL).addressFk = addressList.value[0].id;
state.get('Order').addressFk = addressList.value[0].id;
}
} catch (err) {
console.error(`Error fetching addresses`, err);
@ -105,9 +104,8 @@ const onClientChange = async (clientId) => {
<VnSubToolbar v-if="isNew" />
<div class="q-pa-md">
<FormModel
:url="`Orders/${route.params.id}`"
:url-update="`Orders/${route.params.id}/updateBasicData`"
:model="ORDER_MODEL"
model="Order"
:filter="orderFilter"
@on-fetch="fetchOrderDetails"
auto-load

View File

@ -6,6 +6,8 @@ import OrderDescriptor from 'pages/Order/Card/OrderDescriptor.vue';
import OrderFilter from './OrderFilter.vue';
import OrderSearchbar from './OrderSearchbar.vue';
import OrderCatalogFilter from './OrderCatalogFilter.vue';
import filter from './OrderFilter.js';
const config = {
OrderCatalog: OrderCatalogFilter,
};
@ -27,6 +29,7 @@ const customFilterPanel = computed(() => {
<VnCard
data-key="Order"
url="Orders"
:filter="filter"
:descriptor="OrderDescriptor"
:filter-panel="customFilterPanel"
:search-data-key="customRouteRedirectName"

View File

@ -4,8 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { toCurrency, toDate } from 'src/filters';
import { useState } from 'src/composables/useState';
import useCardDescription from 'src/composables/useCardDescription';
import filter from './OrderFilter.js';
import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import FetchData from 'components/FetchData.vue';
@ -25,45 +24,16 @@ const $props = defineProps({
const route = useRoute();
const state = useState();
const { t } = useI18n();
const data = ref(useCardDescription());
const getTotalRef = ref();
const entityId = computed(() => {
return $props.id || route.params.id;
});
const filter = {
include: [
{ relation: 'agencyMode', scope: { fields: ['name'] } },
{
relation: 'address',
scope: { fields: ['nickname'] },
},
{ relation: 'rows', scope: { fields: ['id'] } },
{
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
],
include: {
relation: 'salesPersonUser',
scope: { fields: ['id', 'name'] },
},
},
},
],
};
const setData = (entity) => {
if (!entity) return;
getTotalRef.value && getTotalRef.value.fetch();
data.value = useCardDescription(entity?.client?.name, entity?.id);
state.set('orderData', entity);
state.set('Order', entity);
};
const getConfirmationValue = (isConfirmed) => {
@ -84,10 +54,9 @@ const total = ref(null);
:url="`Orders/${entityId}`"
:filter="filter"
module="Order"
:title="data.title"
:subtitle="data.subtitle"
title="client.name"
@on-fetch="setData"
data-key="orderData"
data-key="Order"
>
<template #menu="{ entity }">
<OrderDescriptorMenu :order="entity" />

View File

@ -0,0 +1,26 @@
export default {
include: [
{ relation: 'agencyMode', scope: { fields: ['name'] } },
{
relation: 'address',
scope: { fields: ['nickname'] },
},
{ relation: 'rows', scope: { fields: ['id'] } },
{
relation: 'client',
scope: {
fields: [
'salesPersonFk',
'name',
'isActive',
'isFreezed',
'isTaxDataChecked',
],
include: {
relation: 'salesPersonUser',
scope: { fields: ['id', 'name'] },
},
},
},
],
};