7658-devToTest_2428 #508
|
@ -45,15 +45,18 @@ watch(
|
||||||
|
|
||||||
const columns = computed(() => [
|
const columns = computed(() => [
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.item'),
|
label: t('basicData.item'),
|
||||||
name: 'item',
|
name: 'item',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
format: (val) => val.name,
|
format: (val) => val.name,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.description'),
|
label: t('basicData.description'),
|
||||||
name: 'description',
|
name: 'description',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
|
hidden: true,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: t('basicData.movable'),
|
label: t('basicData.movable'),
|
||||||
|
@ -61,12 +64,14 @@ const columns = computed(() => [
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.quantity'),
|
label: t('basicData.quantity'),
|
||||||
name: 'quantity',
|
name: 'quantity',
|
||||||
field: 'quantity',
|
field: 'quantity',
|
||||||
align: 'left',
|
align: 'left',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.pricePPU'),
|
label: t('basicData.pricePPU'),
|
||||||
name: 'price',
|
name: 'price',
|
||||||
field: 'price',
|
field: 'price',
|
||||||
|
@ -74,6 +79,7 @@ const columns = computed(() => [
|
||||||
format: (val) => toCurrency(val),
|
format: (val) => toCurrency(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.newPricePPU'),
|
label: t('basicData.newPricePPU'),
|
||||||
name: 'newPrice',
|
name: 'newPrice',
|
||||||
field: (row) => row.component.newPrice,
|
field: (row) => row.component.newPrice,
|
||||||
|
@ -81,6 +87,7 @@ const columns = computed(() => [
|
||||||
format: (val) => toCurrency(val),
|
format: (val) => toCurrency(val),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
required: true,
|
||||||
label: t('basicData.difference'),
|
label: t('basicData.difference'),
|
||||||
name: 'difference',
|
name: 'difference',
|
||||||
field: (row) => row.component.difference,
|
field: (row) => row.component.difference,
|
||||||
|
@ -108,18 +115,18 @@ const totalNewPrice = computed(() => {
|
||||||
const totalDifference = computed(() => {
|
const totalDifference = computed(() => {
|
||||||
return rows.value.reduce((acc, item) => acc + item.component?.difference || 0, 0);
|
return rows.value.reduce((acc, item) => acc + item.component?.difference || 0, 0);
|
||||||
});
|
});
|
||||||
|
const showMovablecolumn = computed(() => (haveDifferences.value > 0 ? ['movable'] : []));
|
||||||
|
const haveDifferences = computed(() => _ticketData.value.sale.haveDifferences);
|
||||||
const ticketHaveNegatives = () => {
|
const ticketHaveNegatives = () => {
|
||||||
let _haveNegatives = false;
|
let _haveNegatives = false;
|
||||||
let haveNotNegatives = false;
|
let haveNotNegatives = false;
|
||||||
_ticketData.value.withoutNegatives = false;
|
_ticketData.value.withoutNegatives = false;
|
||||||
const haveDifferences = _ticketData.value.sale.haveDifferences;
|
|
||||||
_ticketData.value.sale.items.forEach((item) => {
|
_ticketData.value.sale.items.forEach((item) => {
|
||||||
if (item.quantity > item.movable) _haveNegatives = true;
|
if (item.quantity > item.movable) _haveNegatives = true;
|
||||||
else haveNotNegatives = true;
|
else haveNotNegatives = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
haveNegatives.value = _haveNegatives && haveNotNegatives && haveDifferences;
|
haveNegatives.value = _haveNegatives && haveNotNegatives && haveDifferences.value;
|
||||||
if (haveNegatives.value) _ticketData.value.withoutNegatives = true;
|
if (haveNegatives.value) _ticketData.value.withoutNegatives = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -216,12 +223,14 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
</template>
|
</template>
|
||||||
</RightMenu>
|
</RightMenu>
|
||||||
<QTable
|
<QTable
|
||||||
|
:visible-columns="showMovablecolumn"
|
||||||
:rows="rows"
|
:rows="rows"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
row-key="id"
|
row-key="id"
|
||||||
:pagination="{ rowsPerPage: 0 }"
|
:pagination="{ rowsPerPage: 0 }"
|
||||||
class="full-width q-mt-md"
|
class="full-width q-mt-md"
|
||||||
:no-data-label="t('globals.noResults')"
|
:no-data-label="t('globals.noResults')"
|
||||||
|
flat
|
||||||
>
|
>
|
||||||
<template #body-cell-item="{ row }">
|
<template #body-cell-item="{ row }">
|
||||||
<QTd>
|
<QTd>
|
||||||
|
|
|
@ -36,10 +36,10 @@ const companiesOptions = ref([]);
|
||||||
const agenciesOptions = ref([]);
|
const agenciesOptions = ref([]);
|
||||||
const zonesOptions = ref([]);
|
const zonesOptions = ref([]);
|
||||||
const addresses = ref([]);
|
const addresses = ref([]);
|
||||||
const _formData = ref($props.formData);
|
const formData = ref($props.formData);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => _formData.value,
|
() => formData.value,
|
||||||
(val) => emit('updateForm', val),
|
(val) => emit('updateForm', val),
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
@ -55,12 +55,12 @@ const agencyByWarehouseFilter = computed(() => ({
|
||||||
const zonesFilter = computed(() => ({
|
const zonesFilter = computed(() => ({
|
||||||
fields: ['id', 'name'],
|
fields: ['id', 'name'],
|
||||||
order: 'name ASC',
|
order: 'name ASC',
|
||||||
where: _formData.value?.agencyModeFk
|
where: formData.value?.agencyModeFk
|
||||||
? {
|
? {
|
||||||
shipped: _formData.value?.shipped,
|
shipped: formData.value?.shipped,
|
||||||
addressFk: _formData.value?.addressFk,
|
addressFk: formData.value?.addressFk,
|
||||||
agencyModeFk: _formData.value?.agencyModeFk,
|
agencyModeFk: formData.value?.agencyModeFk,
|
||||||
warehouseFk: _formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
}
|
}
|
||||||
: {},
|
: {},
|
||||||
}));
|
}));
|
||||||
|
@ -71,13 +71,13 @@ const getLanded = async (params) => {
|
||||||
shipped.value && addressId.value && agencyModeId.value && warehouseId.value;
|
shipped.value && addressId.value && agencyModeId.value && warehouseId.value;
|
||||||
if (!validParams) return;
|
if (!validParams) return;
|
||||||
|
|
||||||
_formData.value.zoneFk = null;
|
formData.value.zoneFk = null;
|
||||||
zonesOptions.value = [];
|
zonesOptions.value = [];
|
||||||
const { data } = await axios.get(`Agencies/getLanded`, { params });
|
const { data } = await axios.get(`Agencies/getLanded`, { params });
|
||||||
if (data) {
|
if (data) {
|
||||||
_formData.value.zoneFk = data.zoneFk;
|
formData.value.zoneFk = data.zoneFk;
|
||||||
_formData.value.landed = data.landed;
|
formData.value.landed = data.landed;
|
||||||
_formData.value.shipped = params.shipped;
|
formData.value.shipped = params.shipped;
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
|
@ -91,13 +91,13 @@ const getShipped = async (params) => {
|
||||||
landed.value && addressId.value && agencyModeId.value && warehouseId.value;
|
landed.value && addressId.value && agencyModeId.value && warehouseId.value;
|
||||||
if (!validParams) return;
|
if (!validParams) return;
|
||||||
|
|
||||||
_formData.value.zoneFk = null;
|
formData.value.zoneFk = null;
|
||||||
zonesOptions.value = [];
|
zonesOptions.value = [];
|
||||||
const { data } = await axios.get(`Agencies/getShipped`, { params });
|
const { data } = await axios.get(`Agencies/getShipped`, { params });
|
||||||
if (data) {
|
if (data) {
|
||||||
_formData.value.zoneFk = data.zoneFk;
|
formData.value.zoneFk = data.zoneFk;
|
||||||
_formData.value.landed = params.landed;
|
formData.value.landed = params.landed;
|
||||||
_formData.value.shipped = data.shipped;
|
formData.value.shipped = data.shipped;
|
||||||
} else {
|
} else {
|
||||||
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
|
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
|
||||||
}
|
}
|
||||||
|
@ -109,9 +109,9 @@ const getShipped = async (params) => {
|
||||||
|
|
||||||
const onChangeZone = async (zoneId) => {
|
const onChangeZone = async (zoneId) => {
|
||||||
try {
|
try {
|
||||||
_formData.value.agencyModeFk = null;
|
formData.value.agencyModeFk = null;
|
||||||
const { data } = await axios.get(`Zones/${zoneId}`);
|
const { data } = await axios.get(`Zones/${zoneId}`);
|
||||||
_formData.value.agencyModeFk = data.agencyModeFk;
|
formData.value.agencyModeFk = data.agencyModeFk;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -119,9 +119,9 @@ const onChangeZone = async (zoneId) => {
|
||||||
|
|
||||||
const onChangeAddress = async (addressId) => {
|
const onChangeAddress = async (addressId) => {
|
||||||
try {
|
try {
|
||||||
_formData.value.nickname = null;
|
formData.value.nickname = null;
|
||||||
const { data } = await axios.get(`Addresses/${addressId}`);
|
const { data } = await axios.get(`Addresses/${addressId}`);
|
||||||
_formData.value.nickname = data.nickname;
|
formData.value.nickname = data.nickname;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(error);
|
console.error(error);
|
||||||
}
|
}
|
||||||
|
@ -159,26 +159,26 @@ const clientAddressesList = async (value) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
const addressId = computed({
|
const addressId = computed({
|
||||||
get: () => _formData.value?.addressFk,
|
get: () => formData.value?.addressFk,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
if (val != _formData.value?.addressFk) {
|
if (val != formData.value?.addressFk) {
|
||||||
_formData.value.addressFk = val;
|
formData.value.addressFk = val;
|
||||||
onChangeAddress(val);
|
onChangeAddress(val);
|
||||||
getShipped({
|
getShipped({
|
||||||
landed: _formData.value?.landed,
|
landed: formData.value?.landed,
|
||||||
addressFk: val,
|
addressFk: val,
|
||||||
agencyModeFk: _formData.value?.agencyModeFk,
|
agencyModeFk: formData.value?.agencyModeFk,
|
||||||
warehouseFk: _formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const clientId = computed({
|
const clientId = computed({
|
||||||
get: () => _formData.value?.clientFk,
|
get: () => formData.value?.clientFk,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
_formData.value.clientFk = val;
|
formData.value.clientFk = val;
|
||||||
_formData.value.addressFk = null;
|
formData.value.addressFk = null;
|
||||||
if (!val) return;
|
if (!val) return;
|
||||||
getClientDefaultAddress(val);
|
getClientDefaultAddress(val);
|
||||||
clientAddressesList(val);
|
clientAddressesList(val);
|
||||||
|
@ -186,81 +186,81 @@ const clientId = computed({
|
||||||
});
|
});
|
||||||
|
|
||||||
const landed = computed({
|
const landed = computed({
|
||||||
get: () => _formData.value?.landed,
|
get: () => formData.value?.landed,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
_formData.value.landed = val;
|
formData.value.landed = val;
|
||||||
getShipped({
|
getShipped({
|
||||||
landed: val,
|
landed: val,
|
||||||
addressFk: _formData.value?.addressFk,
|
addressFk: formData.value?.addressFk,
|
||||||
agencyModeFk: _formData.value?.agencyModeFk,
|
agencyModeFk: formData.value?.agencyModeFk,
|
||||||
warehouseFk: _formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const agencyModeId = computed({
|
const agencyModeId = computed({
|
||||||
get: () => _formData.value.agencyModeFk,
|
get: () => formData.value.agencyModeFk,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
if (val != _formData.value.agencyModeFk) {
|
if (val != formData.value.agencyModeFk) {
|
||||||
_formData.value.agencyModeFk = val;
|
formData.value.agencyModeFk = val;
|
||||||
if (!val) return;
|
if (!val) return;
|
||||||
const agencyMode = agenciesOptions.value.find((a) => a.id == val);
|
const agencyMode = agenciesOptions.value.find((a) => a.id == val);
|
||||||
_formData.value.warehouseFk = agencyMode.warehouseFk;
|
formData.value.warehouseFk = agencyMode.warehouseFk;
|
||||||
|
|
||||||
getLanded({
|
getLanded({
|
||||||
shipped: _formData.value?.shipped,
|
shipped: formData.value?.shipped,
|
||||||
addressFk: _formData.value?.addressFk,
|
addressFk: formData.value?.addressFk,
|
||||||
agencyModeFk: val,
|
agencyModeFk: val,
|
||||||
warehouseFk: _formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const zoneId = computed({
|
const zoneId = computed({
|
||||||
get: () => _formData.value?.zoneFk,
|
get: () => formData.value?.zoneFk,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
if (val != _formData.value?.zoneFk) {
|
if (val != formData.value?.zoneFk) {
|
||||||
_formData.value.zoneFk = val;
|
formData.value.zoneFk = val;
|
||||||
onChangeZone(val);
|
onChangeZone(val);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const warehouseId = computed({
|
const warehouseId = computed({
|
||||||
get: () => _formData.value?.warehouseFk,
|
get: () => formData.value?.warehouseFk,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
if (val != _formData.value?.warehouseFk) {
|
if (val != formData.value?.warehouseFk) {
|
||||||
_formData.value.warehouseFk = val;
|
formData.value.warehouseFk = val;
|
||||||
getShipped({
|
getShipped({
|
||||||
landed: _formData.value?.landed,
|
landed: formData.value?.landed,
|
||||||
addressFk: _formData.value?.addressFk,
|
addressFk: formData.value?.addressFk,
|
||||||
agencyModeFk: _formData.value?.agencyModeFk,
|
agencyModeFk: formData.value?.agencyModeFk,
|
||||||
warehouseFk: val,
|
warehouseFk: val,
|
||||||
}).then(() => {
|
}).then(() => {
|
||||||
if (zoneId.value == null) _formData.value.agencyModeFk = null;
|
if (zoneId.value == null) formData.value.agencyModeFk = null;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const shipped = computed({
|
const shipped = computed({
|
||||||
get: () => _formData.value?.shipped,
|
get: () => formData.value?.shipped,
|
||||||
set: (val) => {
|
set: (val) => {
|
||||||
if (new Date(_formData.value?.shipped).toDateString() != val.toDateString())
|
if (new Date(formData.value?.shipped).toDateString() != val.toDateString())
|
||||||
val.setHours(0, 0, 0, 0);
|
val.setHours(0, 0, 0, 0);
|
||||||
_formData.value.shipped = val;
|
formData.value.shipped = val;
|
||||||
getLanded({
|
getLanded({
|
||||||
shipped: val,
|
shipped: val,
|
||||||
addressFk: _formData.value?.addressFk,
|
addressFk: formData.value?.addressFk,
|
||||||
agencyModeFk: _formData.value?.agencyModeFk,
|
agencyModeFk: formData.value?.agencyModeFk,
|
||||||
warehouseFk: _formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const onFormModelInit = () => {
|
const onFormModelInit = () => {
|
||||||
if (_formData.value?.clientFk) clientAddressesList(_formData.value?.clientFk);
|
if (formData.value?.clientFk) clientAddressesList(formData.value?.clientFk);
|
||||||
};
|
};
|
||||||
|
|
||||||
const redirectToCustomerAddress = () => {
|
const redirectToCustomerAddress = () => {
|
||||||
|
@ -398,14 +398,14 @@ onMounted(() => onFormModelInit());
|
||||||
</VnSelect>
|
</VnSelect>
|
||||||
<VnInput
|
<VnInput
|
||||||
:label="t('basicData.alias')"
|
:label="t('basicData.alias')"
|
||||||
v-model="_formData.nickname"
|
v-model="formData.nickname"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow class="row q-gutter-md q-mb-md no-wrap">
|
<VnRow class="row q-gutter-md q-mb-md no-wrap">
|
||||||
<VnSelect
|
<VnSelect
|
||||||
:label="t('basicData.company')"
|
:label="t('basicData.company')"
|
||||||
v-model="_formData.companyFk"
|
v-model="formData.companyFk"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="code"
|
option-label="code"
|
||||||
:options="companiesOptions"
|
:options="companiesOptions"
|
||||||
|
@ -450,17 +450,17 @@ onMounted(() => onFormModelInit());
|
||||||
<VnRow class="row q-gutter-md q-mb-md">
|
<VnRow class="row q-gutter-md q-mb-md">
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('basicData.shipped')"
|
:label="t('basicData.shipped')"
|
||||||
v-model="_formData.shipped"
|
v-model="formData.shipped"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
<VnInputTime
|
<VnInputTime
|
||||||
:label="t('basicData.shippedHour')"
|
:label="t('basicData.shippedHour')"
|
||||||
v-model="_formData.shipped"
|
v-model="formData.shipped"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
<VnInputDate
|
<VnInputDate
|
||||||
:label="t('basicData.landed')"
|
:label="t('basicData.landed')"
|
||||||
v-model="_formData.landed"
|
v-model="formData.landed"
|
||||||
:required="true"
|
:required="true"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
Loading…
Reference in New Issue