Merge branch 'dev' into 8077-sumDefaulterFront
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Robert Ferrús 2024-11-19 12:59:37 +00:00
commit 7021c226b5
58 changed files with 588 additions and 596 deletions

View File

@ -1,6 +1,6 @@
{ {
"name": "salix-front", "name": "salix-front",
"version": "24.44.0", "version": "24.50.0",
"description": "Salix frontend", "description": "Salix frontend",
"productName": "Salix", "productName": "Salix",
"author": "Verdnatura", "author": "Verdnatura",

View File

@ -1,155 +0,0 @@
<script setup>
import { reactive, ref, computed } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FormModelPopup from './FormModelPopup.vue';
import VnInputDate from './common/VnInputDate.vue';
const emit = defineEmits(['onDataSaved']);
const { t } = useI18n();
const router = useRouter();
const manualInvoiceFormData = reactive({
maxShipped: Date.vnNew(),
});
const formModelPopupRef = ref();
const invoiceOutSerialsOptions = ref([]);
const taxAreasOptions = ref([]);
const ticketsOptions = ref([]);
const clientsOptions = ref([]);
const isLoading = computed(() => formModelPopupRef.value?.isLoading);
const onDataSaved = async (formData, requestResponse) => {
emit('onDataSaved', formData, requestResponse);
if (requestResponse && requestResponse.id)
router.push({ name: 'InvoiceOutSummary', params: { id: requestResponse.id } });
};
</script>
<template>
<FetchData
url="InvoiceOutSerials"
:filter="{ where: { code: { neq: 'R' } }, order: ['code'] }"
@on-fetch="(data) => (invoiceOutSerialsOptions = data)"
auto-load
/>
<FetchData
url="TaxAreas"
:filter="{ order: ['code'] }"
@on-fetch="(data) => (taxAreasOptions = data)"
auto-load
/>
<FormModelPopup
ref="formModelPopupRef"
:title="t('Create manual invoice')"
url-create="InvoiceOuts/createManualInvoice"
model="invoiceOut"
:form-initial-data="manualInvoiceFormData"
@on-data-saved="onDataSaved"
>
<template #form-inputs="{ data }">
<span v-if="isLoading" class="text-primary invoicing-text">
<QIcon name="warning" class="fill-icon q-mr-sm" size="md" />
{{ t('Invoicing in progress...') }}
</span>
<VnRow>
<VnSelect
:label="t('Ticket')"
:options="ticketsOptions"
hide-selected
option-label="id"
option-value="id"
v-model="data.ticketFk"
@update:model-value="data.clientFk = null"
url="Tickets"
:where="{ refFk: null }"
:fields="['id', 'nickname']"
:filter-options="{ order: 'shipped DESC' }"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel>
<QItemLabel caption>{{ scope.opt?.nickname }}</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<span class="row items-center" style="max-width: max-content">{{
t('Or')
}}</span>
<VnSelect
:label="t('Client')"
:options="clientsOptions"
hide-selected
option-label="name"
option-value="id"
v-model="data.clientFk"
@update:model-value="data.ticketFk = null"
url="Clients"
:fields="['id', 'name']"
:filter-options="{ order: 'name ASC' }"
/>
<VnInputDate :label="t('Max date')" v-model="data.maxShipped" />
</VnRow>
<VnRow>
<VnSelect
:label="t('Serial')"
:options="invoiceOutSerialsOptions"
hide-selected
option-label="description"
option-value="code"
v-model="data.serial"
/>
<VnSelect
:label="t('Area')"
:options="taxAreasOptions"
hide-selected
option-label="code"
option-value="code"
v-model="data.taxArea"
/>
</VnRow>
<VnRow>
<VnInput
:label="t('Reference')"
type="textarea"
v-model="data.reference"
fill-input
autogrow
/>
</VnRow>
</template>
</FormModelPopup>
</template>
<style lang="scss" scoped>
.invoicing-text {
display: flex;
justify-content: center;
align-items: center;
color: $primary;
font-size: 24px;
margin-bottom: 8px;
}
</style>
<i18n>
es:
Create manual invoice: Crear factura manual
Ticket: Ticket
Client: Cliente
Max date: Fecha límite
Serial: Serie
Area: Area
Reference: Referencia
Or: O
Invoicing in progress...: Facturación en progreso...
</i18n>

View File

@ -77,7 +77,7 @@ const isLoading = ref(false);
const hasChanges = ref(false); const hasChanges = ref(false);
const originalData = ref(); const originalData = ref();
const vnPaginateRef = ref(); const vnPaginateRef = ref();
const formData = ref(); const formData = ref([]);
const saveButtonRef = ref(null); const saveButtonRef = ref(null);
const watchChanges = ref(); const watchChanges = ref();
const formUrl = computed(() => $props.url); const formUrl = computed(() => $props.url);

View File

@ -25,7 +25,7 @@ const $props = defineProps({
}, },
searchUrl: { searchUrl: {
type: String, type: String,
default: 'params', default: 'table',
}, },
}); });

View File

@ -17,7 +17,7 @@ const $props = defineProps({
}, },
searchUrl: { searchUrl: {
type: String, type: String,
default: 'params', default: 'table',
}, },
vertical: { vertical: {
type: Boolean, type: Boolean,

View File

@ -162,9 +162,7 @@ onMounted(() => {
: $props.defaultMode; : $props.defaultMode;
stateStore.rightDrawer = quasar.screen.gt.xs; stateStore.rightDrawer = quasar.screen.gt.xs;
columnsVisibilitySkipped.value = [ columnsVisibilitySkipped.value = [
...splittedColumns.value.columns ...splittedColumns.value.columns.filter((c) => !c.visible).map((c) => c.name),
.filter((c) => c.visible == false)
.map((c) => c.name),
...['tableActions'], ...['tableActions'],
]; ];
createForm.value = $props.create; createForm.value = $props.create;
@ -237,7 +235,7 @@ function splitColumns(columns) {
if (col.create) splittedColumns.value.create.push(col); if (col.create) splittedColumns.value.create.push(col);
if (col.cardVisible) splittedColumns.value.cardVisible.push(col); if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
if ($props.isEditable && col.disable == null) col.disable = false; if ($props.isEditable && col.disable == null) col.disable = false;
if ($props.useModel && col.columnFilter != false) if ($props.useModel && col.columnFilter !== false)
col.columnFilter = { inWhere: true, ...col.columnFilter }; col.columnFilter = { inWhere: true, ...col.columnFilter };
splittedColumns.value.columns.push(col); splittedColumns.value.columns.push(col);
} }

View File

@ -1,8 +1,7 @@
<script setup> <script setup>
import { onMounted, watch, computed, ref } from 'vue'; import { onMounted, watch, computed, ref, useAttrs } from 'vue';
import { date } from 'quasar'; import { date } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useAttrs } from 'vue';
import VnDate from './VnDate.vue'; import VnDate from './VnDate.vue';
import { useRequired } from 'src/composables/useRequired'; import { useRequired } from 'src/composables/useRequired';

View File

@ -2,5 +2,12 @@
const model = defineModel({ type: Boolean, required: true }); const model = defineModel({ type: Boolean, required: true });
</script> </script>
<template> <template>
<QRadio v-model="model" v-bind="$attrs" dense :dark="true" class="q-mr-sm" /> <QRadio
v-model="model"
v-bind="$attrs"
dense
:dark="true"
class="q-mr-sm"
size="xs"
/>
</template> </template>

View File

@ -83,7 +83,7 @@ async function fetch() {
<slot name="header" :entity="entity" dense> <slot name="header" :entity="entity" dense>
<VnLv :label="`${entity.id} -`" :value="entity.name" /> <VnLv :label="`${entity.id} -`" :value="entity.name" />
</slot> </slot>
<slot name="header-right"> <slot name="header-right" :entity="entity">
<span></span> <span></span>
</slot> </slot>
</div> </div>

View File

@ -37,7 +37,7 @@ const $props = defineProps({
}, },
hiddenTags: { hiddenTags: {
type: Array, type: Array,
default: () => ['filter', 'search', 'or', 'and'], default: () => ['filter', 'or', 'and'],
}, },
customTags: { customTags: {
type: Array, type: Array,
@ -49,7 +49,7 @@ const $props = defineProps({
}, },
searchUrl: { searchUrl: {
type: String, type: String,
default: 'params', default: 'table',
}, },
redirect: { redirect: {
type: Boolean, type: Boolean,
@ -61,7 +61,6 @@ const emit = defineEmits([
'update:modelValue', 'update:modelValue',
'refresh', 'refresh',
'clear', 'clear',
'search',
'init', 'init',
'remove', 'remove',
'setUserParams', 'setUserParams',

View File

@ -44,7 +44,7 @@ const props = defineProps({
}, },
limit: { limit: {
type: Number, type: Number,
default: 10, default: 20,
}, },
userParams: { userParams: {
type: Object, type: Object,
@ -100,7 +100,7 @@ const arrayData = useArrayData(props.dataKey, {
const store = arrayData.store; const store = arrayData.store;
onMounted(async () => { onMounted(async () => {
if (props.autoLoad) await fetch(); if (props.autoLoad && !store.data?.length) await fetch();
mounted.value = true; mounted.value = true;
}); });
@ -115,7 +115,11 @@ watch(
watch( watch(
() => store.data, () => store.data,
(data) => emit('onChange', data) (data) => {
if (!mounted.value) return;
emit('onChange', data);
},
{ immediate: true }
); );
watch( watch(

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="vn-row q-gutter-md q-mb-md"> <div class="vn-row q-gutter-md">
<slot /> <slot />
</div> </div>
</template> </template>
@ -18,6 +18,9 @@
&:not(.wrap) { &:not(.wrap) {
flex-direction: column; flex-direction: column;
} }
&[fixed] {
flex-direction: row;
}
} }
} }
</style> </style>

View File

@ -45,7 +45,7 @@ const props = defineProps({
}, },
limit: { limit: {
type: Number, type: Number,
default: 10, default: 20,
}, },
userParams: { userParams: {
type: Object, type: Object,

View File

@ -75,18 +75,10 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
limit: store.limit, limit: store.limit,
}; };
let exprFilter;
let userParams = { ...store.userParams }; let userParams = { ...store.userParams };
if (store?.exprBuilder) {
const where = buildFilter(userParams, (param, value) => {
const res = store.exprBuilder(param, value);
if (res) delete userParams[param];
return res;
});
exprFilter = where ? { where } : null;
}
Object.assign(filter, store.userFilter, exprFilter); Object.assign(filter, store.userFilter);
let where; let where;
if (filter?.where || store.filter?.where) if (filter?.where || store.filter?.where)
where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {}); where = Object.assign(filter?.where ?? {}, store.filter?.where ?? {});
@ -96,11 +88,28 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
Object.assign(params, userParams); Object.assign(params, userParams);
params.filter.skip = store.skip; params.filter.skip = store.skip;
if (store.order && store.order.length) params.filter.order = store.order; if (store?.order && typeof store?.order == 'string') store.order = [store.order];
if (store.order?.length) params.filter.order = [...store.order];
else delete params.filter.order; else delete params.filter.order;
store.currentFilter = JSON.parse(JSON.stringify(params));
delete store.currentFilter.filter.include;
store.currentFilter.filter = JSON.stringify(store.currentFilter.filter);
let exprFilter;
if (store?.exprBuilder) {
exprFilter = buildFilter(params, (param, value) => {
if (param == 'filter') return;
const res = store.exprBuilder(param, value);
if (res) delete params[param];
return res;
});
}
if (params.filter.where || exprFilter)
params.filter.where = { ...params.filter.where, ...exprFilter };
params.filter = JSON.stringify(params.filter); params.filter = JSON.stringify(params.filter);
store.currentFilter = params;
store.isLoading = true; store.isLoading = true;
const response = await axios.get(store.url, { const response = await axios.get(store.url, {
signal: canceller.signal, signal: canceller.signal,
@ -271,7 +280,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
const pushUrl = { path: to }; const pushUrl = { path: to };
if (to.endsWith('/list') || to.endsWith('/')) if (to.endsWith('/list') || to.endsWith('/'))
pushUrl.query = newUrl.query; pushUrl.query = newUrl.query;
destroy(); else destroy();
return router.push(pushUrl); return router.push(pushUrl);
} }
} }

View File

@ -9,7 +9,7 @@ function parseJSON(str, fallback) {
} }
export default function (route, param) { export default function (route, param) {
// catch route query params // catch route query params
const params = parseJSON(route?.query?.params, {}); const params = parseJSON(route?.query?.table, {});
// extract and parse filter from params // extract and parse filter from params
const { filter: filterStr = '{}' } = params; const { filter: filterStr = '{}' } = params;

View File

@ -506,6 +506,7 @@ invoiceOut:
invoiceWithFutureDate: Exists an invoice with a future date invoiceWithFutureDate: Exists an invoice with a future date
noTicketsToInvoice: There are not tickets to invoice noTicketsToInvoice: There are not tickets to invoice
criticalInvoiceError: 'Critical invoicing error, process stopped' criticalInvoiceError: 'Critical invoicing error, process stopped'
invalidSerialTypeForAll: The serial type must be global when invoicing all clients
table: table:
addressId: Address id addressId: Address id
streetAddress: Street streetAddress: Street
@ -857,6 +858,7 @@ components:
downloadFile: Download file downloadFile: Download file
openCard: View openCard: View
openSummary: Summary openSummary: Summary
viewSummary: Summary
cardDescriptor: cardDescriptor:
mainList: Main list mainList: Main list
summary: Summary summary: Summary

View File

@ -509,6 +509,7 @@ invoiceOut:
invoiceWithFutureDate: Existe una factura con una fecha futura invoiceWithFutureDate: Existe una factura con una fecha futura
noTicketsToInvoice: No existen tickets para facturar noTicketsToInvoice: No existen tickets para facturar
criticalInvoiceError: Error crítico en la facturación proceso detenido criticalInvoiceError: Error crítico en la facturación proceso detenido
invalidSerialTypeForAll: El tipo de serie debe ser global cuando se facturan todos los clientes
table: table:
addressId: Id dirección addressId: Id dirección
streetAddress: Dirección fiscal streetAddress: Dirección fiscal

View File

@ -104,7 +104,7 @@ const exprBuilder = (param, value) => {
<template> <template>
<VnSearchbar <VnSearchbar
data-key="AccountUsers" data-key="AccountList"
:expr-builder="exprBuilder" :expr-builder="exprBuilder"
:label="t('account.search')" :label="t('account.search')"
:info="t('account.searchInfo')" :info="t('account.searchInfo')"
@ -112,12 +112,12 @@ const exprBuilder = (param, value) => {
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<AccountFilter data-key="AccountUsers" /> <AccountFilter data-key="AccountList" />
</template> </template>
</RightMenu> </RightMenu>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="AccountUsers" data-key="AccountList"
url="VnUsers/preview" url="VnUsers/preview"
:filter="filter" :filter="filter"
order="id DESC" order="id DESC"

View File

@ -82,14 +82,14 @@ const exprBuilder = (param, value) => {
<template> <template>
<VnSearchbar <VnSearchbar
data-key="Roles" data-key="AccountRolesList"
:expr-builder="exprBuilder" :expr-builder="exprBuilder"
:label="t('role.searchRoles')" :label="t('role.searchRoles')"
:info="t('role.searchInfo')" :info="t('role.searchInfo')"
/> />
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="Roles" data-key="AccountRolesList"
:url="`VnRoles`" :url="`VnRoles`"
:create="{ :create="{
urlCreate: 'VnRoles', urlCreate: 'VnRoles',

View File

@ -9,7 +9,7 @@ const { t } = useI18n();
<VnCard <VnCard
data-key="Role" data-key="Role"
:descriptor="RoleDescriptor" :descriptor="RoleDescriptor"
search-data-key="AccountRoles" search-data-key="AccountRolesList"
:searchbar-props="{ :searchbar-props="{
url: 'VnRoles', url: 'VnRoles',
label: t('role.searchRoles'), label: t('role.searchRoles'),

View File

@ -23,7 +23,7 @@ defineExpose({ states });
<template> <template>
<FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load /> <FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table"> <VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -37,6 +37,9 @@ const entityId = computed(() => {
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity?.name, entity?.id)); const setData = (entity) => (data.value = useCardDescription(entity?.name, entity?.id));
const debtWarning = computed(() => {
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary';
});
</script> </script>
<template> <template>
@ -117,7 +120,7 @@ const setData = (entity) => (data.value = useCardDescription(entity?.name, entit
v-if="customer.debt > customer.credit" v-if="customer.debt > customer.credit"
name="vn:risk" name="vn:risk"
size="xs" size="xs"
color="primary" :color="debtWarning"
> >
<QTooltip>{{ t('customer.card.hasDebt') }}</QTooltip> <QTooltip>{{ t('customer.card.hasDebt') }}</QTooltip>
</QIcon> </QIcon>

View File

@ -4,7 +4,7 @@ import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
import { toCurrency, toPercentage, toDate } from 'src/filters'; import { toCurrency, toPercentage, toDate, dashOrCurrency } from 'src/filters';
import CardSummary from 'components/ui/CardSummary.vue'; import CardSummary from 'components/ui/CardSummary.vue';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
@ -27,21 +27,16 @@ const $props = defineProps({
const entityId = computed(() => $props.id || route.params.id); const entityId = computed(() => $props.id || route.params.id);
const customer = computed(() => summary.value.entity); const customer = computed(() => summary.value.entity);
const summary = ref(); const summary = ref();
const clientUrl = ref(); const defaulterAmount = computed(() => customer.value.defaulters[0]?.amount);
onMounted(async () => {
clientUrl.value = (await getUrl('client/')) + entityId.value + '/';
});
const balanceDue = computed(() => { const balanceDue = computed(() => {
return ( const amount = defaulterAmount.value;
customer.value && if (!amount || amount < 0) {
customer.value.defaulters.length && return null;
customer.value.defaulters[0].amount }
); return amount;
}); });
const balanceDueWarning = computed(() => (balanceDue.value ? 'negative' : '')); const balanceDueWarning = computed(() => (defaulterAmount.value ? 'negative' : ''));
const claimRate = computed(() => { const claimRate = computed(() => {
return customer.value.claimsRatio?.claimingRate ?? 0; return customer.value.claimsRatio?.claimingRate ?? 0;
@ -305,7 +300,7 @@ const sumRisk = ({ clientRisks }) => {
<VnLv <VnLv
v-if="entity.defaulters" v-if="entity.defaulters"
:label="t('customer.summary.balanceDue')" :label="t('customer.summary.balanceDue')"
:value="toCurrency(balanceDue)" :value="dashOrCurrency(balanceDue)()"
:class="balanceDueWarning" :class="balanceDueWarning"
:info="t('customer.summary.balanceDueInfo')" :info="t('customer.summary.balanceDueInfo')"
/> />

View File

@ -11,10 +11,24 @@ defineProps({
required: true, required: true,
}, },
}); });
const handleSalesModelValue = (val) => ({
or: [
{ id: val },
{ name: val },
{ nickname: { like: '%' + val + '%' } },
{ code: { like: `${val}%` } },
],
});
const exprBuilder = (param, value) => {
return {
and: [{ active: { neq: false } }, handleSalesModelValue(value)],
};
};
</script> </script>
<template> <template>
<VnFilterPanel :data-key="dataKey" :search-button="true" search-url="table"> <VnFilterPanel :data-key="dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>
@ -52,14 +66,18 @@ defineProps({
<QItem class="q-mb-sm"> <QItem class="q-mb-sm">
<QItemSection> <QItemSection>
<VnSelect <VnSelect
url="Workers/activeWithInheritedRole" url="Workers/search"
:where="{ role: 'salesPerson' }" :params="{
departmentCodes: ['VT'],
}"
auto-load auto-load
:label="t('Salesperson')" :label="t('Salesperson')"
:expr-builder="exprBuilder"
v-model="params.salesPersonFk" v-model="params.salesPersonFk"
@update:model-value="searchFn()" @update:model-value="searchFn()"
option-value="id" option-value="id"
option-label="name" option-label="name"
sort-by="nickname ASC"
emit-value emit-value
map-options map-options
use-input use-input
@ -67,7 +85,19 @@ defineProps({
dense dense
outlined outlined
rounded rounded
/> :input-debounce="0"
>
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
<QItemSection>
<QItemLabel>{{ opt.name }}</QItemLabel>
<QItemLabel caption>
{{ opt.nickname }},{{ opt.code }}
</QItemLabel>
</QItemSection>
</QItem>
</template></VnSelect
>
</QItemSection> </QItemSection>
</QItem> </QItem>
<QItem class="q-mb-sm"> <QItem class="q-mb-sm">

View File

@ -394,16 +394,16 @@ function handleLocation(data, location) {
<VnSearchbar <VnSearchbar
:info="t('You can search by customer id or name')" :info="t('You can search by customer id or name')"
:label="t('Search customer')" :label="t('Search customer')"
data-key="Customer" data-key="CustomerList"
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<CustomerFilter data-key="Customer" /> <CustomerFilter data-key="CustomerList" />
</template> </template>
</RightMenu> </RightMenu>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="Customer" data-key="CustomerList"
url="Clients/filter" url="Clients/filter"
:create="{ :create="{
urlCreate: 'Clients/createWithUser', urlCreate: 'Clients/createWithUser',

View File

@ -23,6 +23,7 @@ const incoterms = ref([]);
const customsAgents = ref([]); const customsAgents = ref([]);
const observationTypes = ref([]); const observationTypes = ref([]);
const notes = ref([]); const notes = ref([]);
let originalNotes = [];
const deletes = ref([]); const deletes = ref([]);
onBeforeMount(() => { onBeforeMount(() => {
@ -42,7 +43,8 @@ const getData = async (observations) => {
}); });
if (data.length) { if (data.length) {
notes.value = data originalNotes = data;
notes.value = originalNotes
.map((observation) => { .map((observation) => {
const type = observationTypes.value.find( const type = observationTypes.value.find(
(type) => type.id === observation.observationTypeFk (type) => type.id === observation.observationTypeFk
@ -81,14 +83,24 @@ const deleteNote = (id, index) => {
}; };
const onDataSaved = async () => { const onDataSaved = async () => {
let payload = {}; let payload = {
const creates = notes.value.filter((note) => note.$isNew); creates: notes.value.filter((note) => note.$isNew),
if (creates.length) { deletes: deletes.value,
payload.creates = creates; updates: notes.value
} .filter((note) =>
if (deletes.value.length) { originalNotes.some(
payload.deletes = deletes.value; (oNote) =>
} oNote.id === note.id &&
(note.description !== oNote.description ||
note.observationTypeFk !== oNote.observationTypeFk)
)
)
.map((note) => ({
data: note,
where: { id: note.id },
})),
};
await axios.post('AddressObservations/crud', payload); await axios.post('AddressObservations/crud', payload);
notes.value = []; notes.value = [];
deletes.value = []; deletes.value = [];

View File

@ -122,7 +122,7 @@ const cols = computed(() => [
:columns="cols" :columns="cols"
:right-search="false" :right-search="false"
:disable-option="{ card: true }" :disable-option="{ card: true }"
:auto-load="!!$route.query.params" :auto-load="!!$route.query.table"
> >
<template #column-supplierFk="{ row }"> <template #column-supplierFk="{ row }">
<span class="link" @click.stop> <span class="link" @click.stop>

View File

@ -183,7 +183,7 @@ onMounted(async () => {
<i18n> <i18n>
en: en:
invoiceDate: Invoice date invoiceDate: Invoice date
maxShipped: Max date maxShipped: Max date ticket
allClients: All clients allClients: All clients
oneClient: One client oneClient: One client
company: Company company: Company
@ -195,7 +195,7 @@ en:
es: es:
invoiceDate: Fecha de factura invoiceDate: Fecha de factura
maxShipped: Fecha límite maxShipped: Fecha límite ticket
allClients: Todos los clientes allClients: Todos los clientes
oneClient: Un solo cliente oneClient: Un solo cliente
company: Empresa company: Empresa

View File

@ -6,15 +6,19 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue'; import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue'; import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import { usePrintService } from 'composables/usePrintService'; import { usePrintService } from 'src/composables/usePrintService';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import InvoiceOutSummary from './Card/InvoiceOutSummary.vue'; import InvoiceOutSummary from './Card/InvoiceOutSummary.vue';
import { toCurrency, toDate } from 'src/filters/index'; import { toCurrency, toDate } from 'src/filters/index';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { QBtn } from 'quasar'; import { QBtn } from 'quasar';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue'; import axios from 'axios';
import RightMenu from 'src/components/common/RightMenu.vue'; import RightMenu from 'src/components/common/RightMenu.vue';
import InvoiceOutFilter from './InvoiceOutFilter.vue'; import InvoiceOutFilter from './InvoiceOutFilter.vue';
import VnRow from 'src/components/ui/VnRow.vue';
import VnRadio from 'src/components/common/VnRadio.vue';
import VnInput from 'src/components/common/VnInput.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
const { t } = useI18n(); const { t } = useI18n();
const stateStore = useStateStore(); const stateStore = useStateStore();
@ -26,99 +30,86 @@ const selectedRows = ref([]);
const hasSelectedCards = computed(() => selectedRows.value.length > 0); const hasSelectedCards = computed(() => selectedRows.value.length > 0);
const MODEL = 'InvoiceOuts'; const MODEL = 'InvoiceOuts';
const { openReport } = usePrintService(); const { openReport } = usePrintService();
const addressOptions = ref([]);
const selectedOption = ref('ticket');
async function fetchClientAddress(id) {
const { data } = await axios.get(
`Clients/${id}/addresses?filter[order]=isActive DESC`
);
addressOptions.value = data;
}
const exprBuilder = (_, value) => {
return {
or: [{ code: value }, { description: { like: `%${value}%` } }],
};
};
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'center', align: 'center',
name: 'id', name: 'id',
label: t('invoiceOutList.tableVisibleColumns.id'), label: t('invoiceOutList.tableVisibleColumns.id'),
chip: { chip: { condition: () => true },
condition: () => true,
},
isId: true, isId: true,
columnFilter: { columnFilter: { name: 'search' },
name: 'search',
},
}, },
{ {
align: 'left', align: 'left',
name: 'ref', name: 'ref',
label: t('invoiceOutList.tableVisibleColumns.ref'), label: t('globals.reference'),
isTitle: true, isTitle: true,
component: 'select', component: 'select',
attrs: { attrs: { url: MODEL, optionLabel: 'ref', optionValue: 'id' },
url: MODEL, columnField: { component: null },
optionLabel: 'ref',
optionValue: 'id',
},
columnField: {
component: null,
},
}, },
{ {
align: 'left', align: 'left',
name: 'Issued', name: 'issued',
label: t('invoiceOutList.tableVisibleColumns.issued'), label: t('invoiceOut.summary.issued'),
component: 'date', component: 'date',
format: (row) => toDate(row.issued), format: (row) => toDate(row.issued),
columnField: { columnField: { component: null },
component: null,
},
}, },
{ {
align: 'left', align: 'left',
name: 'clientFk', name: 'clientFk',
label: t('invoiceOutModule.customer'), label: t('globals.client'),
cardVisible: true, cardVisible: true,
component: 'select', component: 'select',
attrs: { attrs: { url: 'Clients', fields: ['id', 'name'] },
url: 'Clients', columnField: { component: null },
fields: ['id', 'name'],
},
columnField: {
component: null,
},
}, },
{ {
align: 'left', align: 'left',
name: 'companyCode', name: 'companyCode',
label: t('invoiceOutModule.company'), label: t('globals.company'),
cardVisible: true, cardVisible: true,
component: 'select', component: 'select',
attrs: { attrs: { url: 'Companies', optionLabel: 'code', optionValue: 'id' },
url: 'Companies', columnField: { component: null },
optionLabel: 'code',
optionValue: 'id',
},
columnField: {
component: null,
},
}, },
{ {
align: 'left', align: 'left',
name: 'amount', name: 'amount',
label: t('invoiceOutModule.amount'), label: t('globals.amount'),
cardVisible: true, cardVisible: true,
format: (row) => toCurrency(row.amount), format: (row) => toCurrency(row.amount),
}, },
{ {
align: 'left', align: 'left',
name: 'created', name: 'created',
label: t('invoiceOutList.tableVisibleColumns.created'), label: t('globals.created'),
component: 'date', component: 'date',
columnField: { columnField: { component: null },
component: null,
},
format: (row) => toDate(row.created), format: (row) => toDate(row.created),
}, },
{ {
align: 'left', align: 'left',
name: 'dued', name: 'dued',
label: t('invoiceOutList.tableVisibleColumns.dueDate'), label: t('invoiceOut.summary.dued'),
component: 'date', component: 'date',
columnField: { columnField: { component: null },
component: null,
},
format: (row) => toDate(row.dued), format: (row) => toDate(row.dued),
}, },
{ {
@ -128,11 +119,12 @@ const columns = computed(() => [
{ {
title: t('components.smartCard.viewSummary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
isPrimary: true,
action: (row) => viewSummary(row.id, InvoiceOutSummary), action: (row) => viewSummary(row.id, InvoiceOutSummary),
}, },
{ {
title: t('DownloadPdf'), title: t('globals.downloadPdf'),
icon: 'vn:ticket', icon: 'cloud_download',
isPrimary: true, isPrimary: true,
action: (row) => openPdf(row.id), action: (row) => openPdf(row.id),
}, },
@ -181,12 +173,12 @@ watchEffect(selectedRows);
<template> <template>
<VnSearchbar <VnSearchbar
:info="t('youCanSearchByInvoiceReference')" :info="t('youCanSearchByInvoiceReference')"
:label="t('searchInvoice')" :label="t('Search invoice')"
data-key="invoiceOut" data-key="invoiceOutList"
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<InvoiceOutFilter data-key="invoiceOut" /> <InvoiceOutFilter data-key="invoiceOutList" />
</template> </template>
</RightMenu> </RightMenu>
<VnSubToolbar> <VnSubToolbar>
@ -197,21 +189,19 @@ watchEffect(selectedRows);
@click="downloadPdf()" @click="downloadPdf()"
:disable="!hasSelectedCards" :disable="!hasSelectedCards"
> >
<QTooltip>{{ t('globals.downloadPdf') }}</QTooltip> <QTooltip>{{ t('downloadPdf') }}</QTooltip>
</QBtn> </QBtn>
</template> </template>
</VnSubToolbar> </VnSubToolbar>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="invoiceOut" data-key="invoiceOutList"
:url="`${MODEL}/filter`" :url="`${MODEL}/filter`"
:create="{ :create="{
urlCreate: 'InvoiceOuts/createManualInvoice', urlCreate: 'InvoiceOuts/createManualInvoice',
title: t('Create manual invoice'), title: t('createManualInvoice'),
onDataSaved: ({ id }) => tableRef.redirect(id), onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: { formInitialData: { active: true },
active: true,
},
}" }"
:right-search="false" :right-search="false"
v-model:selected="selectedRows" v-model:selected="selectedRows"
@ -231,74 +221,203 @@ watchEffect(selectedRows);
</span> </span>
</template> </template>
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<div class="flex no-wrap flex-center"> <div class="row q-col-gutter-xs">
<VnSelect <div class="col-12">
url="Tickets" <div class="q-col-gutter-xs">
v-model="data.ticketFk" <VnRow fixed>
:label="t('invoiceOutList.tableVisibleColumns.ticket')" <VnRadio
option-label="id" v-model="selectedOption"
option-value="id" val="ticket"
> :label="t('globals.ticket')"
<template #option="scope"> class="q-my-none q-mr-md"
<QItem v-bind="scope.itemProps"> />
<QItemSection>
<QItemLabel> #{{ scope.opt?.id }} </QItemLabel> <VnInput
<QItemLabel caption>{{ scope.opt?.nickname }}</QItemLabel> v-show="selectedOption === 'ticket'"
</QItemSection> v-model="data.ticketFk"
</QItem> :label="t('globals.ticket')"
</template> style="flex: 1"
</VnSelect> />
<span class="q-ml-md">O</span>
<div
class="row q-col-gutter-xs q-ml-none"
v-show="selectedOption !== 'ticket'"
>
<div class="col">
<VnSelect
v-model="data.clientFk"
:label="t('globals.client')"
url="Clients"
:options="customerOptions"
option-label="name"
option-value="id"
@update:model-value="fetchClientAddress"
>
<template #option="scope">
<QItem
v-bind="scope.itemProps"
@click="selectedClient(scope.opt)"
>
<QItemSection>
<QItemLabel>
#{{ scope.opt?.id }} -
{{ scope.opt?.name }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</div>
<div class="col">
<VnSelect
v-model="data.addressFk"
:label="t('ticket.summary.consignee')"
:options="addressOptions"
option-label="nickname"
option-value="id"
v-if="
data.clientFk &&
selectedOption === 'consignatario'
"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel
:class="{
'color-vn-label':
!scope.opt?.isActive,
}"
>
{{
`${
!scope.opt?.isActive
? t('inactive')
: ''
} `
}}
<span>
{{
scope.opt?.nickname
}}</span
>
<span
v-if="
scope.opt?.province ||
scope.opt?.city ||
scope.opt?.street
"
>, {{ scope.opt?.street }},
{{ scope.opt?.city }},
{{
scope.opt?.province?.name
}}
-
{{
scope.opt?.agencyMode
?.name
}}</span
>
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</div>
</div>
</VnRow>
<VnRow fixed>
<VnRadio
v-model="selectedOption"
val="cliente"
:label="t('globals.client')"
class="q-my-none q-mr-md"
/>
</VnRow>
<VnRow fixed>
<VnRadio
v-model="selectedOption"
val="consignatario"
:label="t('ticket.summary.consignee')"
class="q-my-none q-mr-md"
/>
</VnRow>
</div>
</div>
<div class="full-width">
<VnRow class="row q-col-gutter-xs">
<VnSelect
url="InvoiceOutSerials"
v-model="data.serial"
:label="t('invoiceIn.serial')"
:options="invoiceOutSerialsOptions"
option-label="description"
option-value="code"
option-filter
:expr-builder="exprBuilder"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.code }} -
{{ scope.opt?.description }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnInputDate
:label="t('invoiceOut.summary.dued')"
v-model="data.maxShipped"
/>
</VnRow>
<VnRow class="row q-col-gutter-xs">
<VnSelect
url="TaxAreas"
v-model="data.taxArea"
:label="t('invoiceOutList.tableVisibleColumns.taxArea')"
:options="taxAreasOptions"
option-label="code"
option-value="code"
/>
<VnInput
v-model="data.reference"
:label="t('globals.reference')"
/>
</VnRow>
</div>
</div> </div>
<VnSelect
url="Clients"
v-model="data.clientFk"
:label="t('invoiceOutModule.customer')"
:options="customerOptions"
option-label="name"
option-value="id"
/>
<VnSelect
url="InvoiceOutSerials"
v-model="data.serial"
:label="t('invoiceOutList.tableVisibleColumns.invoiceOutSerial')"
:options="invoiceOutSerialsOptions"
option-label="description"
option-value="code"
/>
<VnInputDate
:label="t('invoiceOutList.tableVisibleColumns.dueDate')"
v-model="data.maxShipped"
/>
<VnSelect
url="TaxAreas"
v-model="data.taxArea"
:label="t('invoiceOutList.tableVisibleColumns.taxArea')"
:options="taxAreasOptions"
option-label="code"
option-value="code"
/>
<QInput
v-model="data.reference"
:label="t('invoiceOutList.tableVisibleColumns.ref')"
/>
</template> </template>
</VnTable> </VnTable>
</template> </template>
<style lang="scss" scoped>
#formModel .vn-row {
min-height: 45px;
.q-radio {
align-self: flex-end;
flex: 0.3;
}
> .q-input,
> .q-select {
flex: 0.75;
}
}
</style>
<i18n> <i18n>
en: en:
searchInvoice: Search issued invoice invoiceId: Invoice ID
fileDenied: Browser denied file download... youCanSearchByInvoiceReference: You can search by invoice reference
fileAllowed: Successful download of CSV file createManualInvoice: Create Manual Invoice
youCanSearchByInvoiceReference: You can search by invoice reference inactive: (Inactive)
createInvoice: Make invoice
Create manual invoice: Create manual invoice es:
es: invoiceId: ID de factura
searchInvoice: Buscar factura emitida youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura
fileDenied: El navegador denegó la descarga de archivos... createManualInvoice: Crear factura manual
fileAllowed: Descarga exitosa de archivo CSV inactive: (Inactivo)
youCanSearchByInvoiceReference: Puedes buscar por referencia de la factura
createInvoice: Crear factura
Create manual invoice: Crear factura manual
</i18n> </i18n>

View File

@ -2,6 +2,7 @@ invoiceOutModule:
customer: Client customer: Client
amount: Amount amount: Amount
company: Company company: Company
address: Address
invoiceOutList: invoiceOutList:
tableVisibleColumns: tableVisibleColumns:
id: ID id: ID
@ -15,11 +16,11 @@ invoiceOutList:
DownloadPdf: Download PDF DownloadPdf: Download PDF
InvoiceOutSummary: Summary InvoiceOutSummary: Summary
negativeBases: negativeBases:
country: Country country: Country
clientId: Client ID clientId: Client ID
base: Base base: Base
ticketId: Ticket ticketId: Ticket
active: Active active: Active
hasToInvoice: Has to invoice hasToInvoice: Has to invoice
verifiedData: Verified data verifiedData: Verified data
commercial: Commercial commercial: Commercial

View File

@ -4,6 +4,7 @@ invoiceOutModule:
customer: Cliente customer: Cliente
amount: Importe amount: Importe
company: Empresa company: Empresa
address: Consignatario
invoiceOutList: invoiceOutList:
tableVisibleColumns: tableVisibleColumns:
id: ID id: ID

View File

@ -64,8 +64,7 @@ const columns = computed(() => [
}, },
{ {
label: t('globals.name'), label: t('globals.name'),
field: 'name', name: 'name',
name: 'description',
...defaultColumnAttrs, ...defaultColumnAttrs,
create: true, create: true,
cardVisible: true, cardVisible: true,
@ -426,7 +425,7 @@ function handleOnDataSave({ CrudModelRef }) {
:default-save="false" :default-save="false"
data-key="ItemFixedPrices" data-key="ItemFixedPrices"
url="FixedPrices/filter" url="FixedPrices/filter"
:order="['description DESC']" :order="['itemFk DESC', 'name DESC']"
save-url="FixedPrices/crud" save-url="FixedPrices/crud"
:user-params="{ warehouseFk: user.warehouseFk }" :user-params="{ warehouseFk: user.warehouseFk }"
ref="tableRef" ref="tableRef"
@ -480,7 +479,7 @@ function handleOnDataSave({ CrudModelRef }) {
</template> </template>
</VnSelect> </VnSelect>
</template> </template>
<template #column-description="{ row }"> <template #column-name="{ row }">
<span class="link"> <span class="link">
{{ row.name }} {{ row.name }}
</span> </span>

View File

@ -17,21 +17,6 @@ const props = defineProps({
}); });
const itemTypeWorkersOptions = ref([]); const itemTypeWorkersOptions = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return { 'i.name': { like: `%${value}%` } };
case 'itemFk':
case 'warehouseFk':
case 'rate2':
case 'rate3':
param = `fp.${param}`;
return { [param]: value };
case 'minPrice':
param = `i.${param}`;
return { [param]: value };
}
};
</script> </script>
<template> <template>
@ -66,7 +51,7 @@ const exprBuilder = (param, value) => {
url="Warehouses" url="Warehouses"
auto-load auto-load
:filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }" :filter="{ fields: ['id', 'name'], order: 'name ASC', limit: 30 }"
:label="t('components.itemsFilterPanel.warehouseFk')" :label="t('globals.warehouse')"
v-model="params.warehouseFk" v-model="params.warehouseFk"
option-label="name" option-label="name"
option-value="id" option-value="id"

View File

@ -166,6 +166,7 @@ onMounted(() => {
:expr-builder="exprBuilder" :expr-builder="exprBuilder"
:custom-tags="['tagGroups', 'categoryFk']" :custom-tags="['tagGroups', 'categoryFk']"
:redirect="false" :redirect="false"
search-url="params"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<strong v-if="tag.label === 'typeFk'"> <strong v-if="tag.label === 'typeFk'">

View File

@ -1,6 +1,6 @@
<script setup> <script setup>
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { onMounted, ref } from 'vue'; import { reactive, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import { useState } from 'composables/useState'; import { useState } from 'composables/useState';
@ -9,7 +9,6 @@ import VnRow from 'components/ui/VnRow.vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'components/common/VnInputDate.vue'; import VnInputDate from 'components/common/VnInputDate.vue';
import { useDialogPluginComponent } from 'quasar'; import { useDialogPluginComponent } from 'quasar';
import { reactive } from 'vue';
const { t } = useI18n(); const { t } = useI18n();
const state = useState(); const state = useState();
@ -58,10 +57,6 @@ const fetchAgencyList = async (landed, addressFk) => {
} }
}; };
// const fetchOrderDetails = (order) => {
// fetchAddressList(order?.addressFk);
// fetchAgencyList(order?.landed, order?.addressFk);
// };
const $props = defineProps({ const $props = defineProps({
clientFk: { clientFk: {
type: Number, type: Number,
@ -73,39 +68,6 @@ const initialFormState = reactive({
addressId: null, addressId: null,
clientFk: $props.clientFk, clientFk: $props.clientFk,
}); });
// const orderMapper = (order) => {
// return {
// addressId: order.addressFk,
// agencyModeId: order.agencyModeFk,
// landed: new Date(order.landed).toISOString(),
// };
// };
// const orderFilter = {
// 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 onClientChange = async (clientId = $props.clientFk) => { const onClientChange = async (clientId = $props.clientFk) => {
try { try {

View File

@ -111,6 +111,7 @@ const columns = computed(() => [
component: 'select', component: 'select',
attrs: { attrs: {
url: 'Items', url: 'Items',
sortBy: 'name ASC ',
fields: ['id', 'name', 'subName'], fields: ['id', 'name', 'subName'],
}, },
columnField: { columnField: {

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { computed, ref } from 'vue'; import { computed, onMounted, ref } from 'vue';
import { dashIfEmpty, toCurrency, toDate } from 'src/filters'; import { dashIfEmpty, toCurrency, toDate } from 'src/filters';
import OrderSummary from 'pages/Order/Card/OrderSummary.vue'; import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import { useSummaryDialog } from 'src/composables/useSummaryDialog';
@ -14,7 +14,6 @@ import OrderFilter from './Card/OrderFilter.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue'; import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import { toDateTimeFormat } from 'src/filters/date'; import { toDateTimeFormat } from 'src/filters/date';
import { onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
const { t } = useI18n(); const { t } = useI18n();
@ -142,8 +141,13 @@ const columns = computed(() => [
], ],
}, },
]); ]);
onMounted(() => {
async function fetchClientAddress(id, formData) { if (!route.query.createForm) return;
const clientId = route.query.createForm;
const id = JSON.parse(clientId);
fetchClientAddress(id.clientFk);
});
async function fetchClientAddress(id, formData = {}) {
const { data } = await axios.get(`Clients/${id}`, { const { data } = await axios.get(`Clients/${id}`, {
params: { filter: { include: { relation: 'addresses' } } }, params: { filter: { include: { relation: 'addresses' } } },
}); });
@ -170,13 +174,6 @@ const getDateColor = (date) => {
if (comparation == 0) return 'bg-warning'; if (comparation == 0) return 'bg-warning';
if (comparation < 0) return 'bg-success'; if (comparation < 0) return 'bg-success';
}; };
onMounted(() => {
if (!route.query.createForm) return;
const clientId = route.query.createForm;
const id = JSON.parse(clientId);
fetchClientAddress(id.clientFk, id);
});
</script> </script>
<template> <template>
<OrderSearchbar /> <OrderSearchbar />
@ -194,7 +191,7 @@ onMounted(() => {
urlCreate: 'Orders/new', urlCreate: 'Orders/new',
title: t('module.cerateOrder'), title: t('module.cerateOrder'),
onDataSaved: (url) => { onDataSaved: (url) => {
tableRef.redirect(url); tableRef.redirect(`${url}/catalog`);
}, },
formInitialData: { formInitialData: {
active: true, active: true,

View File

@ -16,12 +16,9 @@ import { useAcl } from 'src/composables/useAcl';
import { useValidator } from 'src/composables/useValidator'; import { useValidator } from 'src/composables/useValidator';
import { toTimeFormat } from 'filters/date.js'; import { toTimeFormat } from 'filters/date.js';
const $props = defineProps({ const formData = defineModel({
formData: { type: Object,
type: Object, required: true,
required: true,
default: () => ({}),
},
}); });
const emit = defineEmits(['updateForm']); const emit = defineEmits(['updateForm']);
@ -40,7 +37,6 @@ const agenciesOptions = ref([]);
const zonesOptions = ref([]); const zonesOptions = ref([]);
const addresses = ref([]); const addresses = ref([]);
const zoneSelectRef = ref(); const zoneSelectRef = ref();
const formData = ref($props.formData);
watch( watch(
() => formData.value, () => formData.value,
@ -69,47 +65,28 @@ const zoneWhere = computed(() => {
: {}; : {};
}); });
const getLanded = async (params) => { async function getLanded(params) {
try { getDate(`Agencies/getLanded`, params);
const validParams = }
shipped.value && addressId.value && agencyModeId.value && warehouseId.value;
if (!validParams) return;
formData.value.zoneFk = null; async function getShipped(params) {
zonesOptions.value = []; getDate(`Agencies/getShipped`, params);
const { data } = await axios.get(`Agencies/getLanded`, { params }); }
if (data) {
formData.value.zoneFk = data.zoneFk; async function getDate(query, params) {
formData.value.landed = data.landed; for (const param in params) {
formData.value.shipped = params.shipped; if (!params[param]) return;
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
} }
};
const getShipped = async (params) => { formData.value.zoneFk = null;
try { zonesOptions.value = [];
const validParams = const { data } = await axios.get(query, { params });
landed.value && addressId.value && agencyModeId.value && warehouseId.value; if (!data) return notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
if (!validParams) return;
formData.value.zoneFk = null; formData.value.zoneFk = data.zoneFk;
zonesOptions.value = []; if (data.landed) formData.value.landed = data.landed;
const { data } = await axios.get(`Agencies/getShipped`, { params }); if (data.shipped) formData.value.shipped = data.shipped;
if (data) { }
formData.value.zoneFk = data.zoneFk;
formData.value.landed = params.landed;
formData.value.shipped = data.shipped;
} else {
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
} catch (error) {
console.error(error);
notify(t('basicData.noDeliveryZoneAvailable'), 'negative');
}
};
const onChangeZone = async (zoneId) => { const onChangeZone = async (zoneId) => {
formData.value.agencyModeFk = null; formData.value.agencyModeFk = null;
@ -177,18 +154,26 @@ const clientId = computed({
}, },
}); });
const landed = computed({ function addDateParams(obj) {
get: () => formData.value?.landed, return {
set: (val) => { ...obj,
formData.value.landed = val; ...{
getShipped({
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,
}); },
}, };
}); }
async function setLanded(landed) {
if (!landed) return;
getShipped(addDateParams({ landed }));
}
async function setShipped(shipped) {
if (!shipped) return;
getLanded(addDateParams({ shipped }));
}
const agencyModeId = computed({ const agencyModeId = computed({
get: () => formData.value.agencyModeFk, get: () => formData.value.agencyModeFk,
@ -236,21 +221,6 @@ const warehouseId = computed({
}, },
}); });
const shipped = computed({
get: () => formData.value?.shipped,
set: (val) => {
if (new Date(formData.value?.shipped).toDateString() != val.toDateString())
val.setHours(0, 0, 0, 0);
formData.value.shipped = val;
getLanded({
shipped: val,
addressFk: formData.value?.addressFk,
agencyModeFk: formData.value?.agencyModeFk,
warehouseFk: formData.value?.warehouseFk,
});
},
});
const onFormModelInit = () => { const onFormModelInit = () => {
if (formData.value?.clientFk) clientAddressesList(formData.value?.clientFk); if (formData.value?.clientFk) clientAddressesList(formData.value?.clientFk);
}; };
@ -451,18 +421,21 @@ async function getZone(options) {
v-model="formData.shipped" v-model="formData.shipped"
:required="true" :required="true"
:rules="validate('ticketList.shipped')" :rules="validate('ticketList.shipped')"
@update:model-value="setShipped"
/> />
<VnInputTime <VnInputTime
:label="t('basicData.shippedHour')" :label="t('basicData.shippedHour')"
v-model="formData.shipped" v-model="formData.shipped"
:required="true" :required="true"
:rules="validate('basicData.shippedHour')" :rules="validate('basicData.shippedHour')"
@update:model-value="setShipped"
/> />
<VnInputDate <VnInputDate
:label="t('basicData.landed')" :label="t('basicData.landed')"
v-model="formData.landed" v-model="formData.landed"
:required="true" :required="true"
:rules="validate('basicData.landed')" :rules="validate('basicData.landed')"
@update:model-value="setLanded"
/> />
</VnRow> </VnRow>
</QForm> </QForm>

View File

@ -158,7 +158,7 @@ onBeforeMount(async () => await getTicketData());
<TicketBasicDataForm <TicketBasicDataForm
v-if="initialDataLoaded" v-if="initialDataLoaded"
@update-form="($event) => (formData = $event)" @update-form="($event) => (formData = $event)"
:form-data="formData" v-model="formData"
/> />
</QStep> </QStep>
<QStep :name="2" :title="t('basicData.priceDifference')"> <QStep :name="2" :title="t('basicData.priceDifference')">

View File

@ -1,9 +1,9 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { ref, toRefs } from 'vue'; import { computed, ref, toRefs } from 'vue';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute, useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { usePrintService } from 'composables/usePrintService'; import { usePrintService } from 'composables/usePrintService';
import SendEmailDialog from 'components/common/SendEmailDialog.vue'; import SendEmailDialog from 'components/common/SendEmailDialog.vue';
import VnConfirm from 'components/ui/VnConfirm.vue'; import VnConfirm from 'components/ui/VnConfirm.vue';
@ -23,7 +23,6 @@ const props = defineProps({
required: true, required: true,
}, },
}); });
const route = useRoute();
const { push, currentRoute } = useRouter(); const { push, currentRoute } = useRouter();
const { dialog, notify } = useQuasar(); const { dialog, notify } = useQuasar();
@ -31,7 +30,7 @@ const { t } = useI18n();
const { openReport, sendEmail } = usePrintService(); const { openReport, sendEmail } = usePrintService();
const ticketSummary = useArrayData('TicketSummary'); const ticketSummary = useArrayData('TicketSummary');
const { ticket } = toRefs(props); const { ticket } = toRefs(props);
const ticketId = currentRoute.value.params.id; const ticketId = computed(() => props.ticket.id ?? currentRoute.value.params.id);
const client = ref(); const client = ref();
const showTransferDialog = ref(false); const showTransferDialog = ref(false);
const showTurnDialog = ref(false); const showTurnDialog = ref(false);
@ -68,7 +67,7 @@ const actions = {
setWeight: async () => { setWeight: async () => {
try { try {
const invoiceIds = ( const invoiceIds = (
await axios.post(`Tickets/${ticketId}/setWeight`, { await axios.post(`Tickets/${ticketId.value}/setWeight`, {
weight: weight.value, weight: weight.value,
}) })
).data; ).data;
@ -86,7 +85,7 @@ const actions = {
}, },
remove: async () => { remove: async () => {
try { try {
await axios.post(`Tickets/${ticketId}/setDeleted`); await axios.post(`Tickets/${ticketId.value}/setDeleted`);
notify({ message: t('Ticket deleted'), type: 'positive' }); notify({ message: t('Ticket deleted'), type: 'positive' });
notify({ notify({
@ -176,14 +175,14 @@ function showSmsDialog(template, customData) {
} }
async function showSmsDialogWithChanges() { async function showSmsDialogWithChanges() {
const query = `TicketLogs/${ticketId}/getChanges`; const query = `TicketLogs/${ticketId.value}/getChanges`;
const response = await axios.get(query); const response = await axios.get(query);
showSmsDialog('orderChanges', { changes: response.data }); showSmsDialog('orderChanges', { changes: response.data });
} }
async function sendSms(body) { async function sendSms(body) {
await axios.post(`Tickets/${ticketId}/sendSms`, body); await axios.post(`Tickets/${ticketId.value}/sendSms`, body);
notify({ notify({
message: 'Notification sent', message: 'Notification sent',
type: 'positive', type: 'positive',
@ -256,7 +255,10 @@ async function transferClient(client) {
clientFk: client, clientFk: client,
}; };
const { data } = await axios.patch(`Tickets/${ticketId}/transferClient`, params); const { data } = await axios.patch(
`Tickets/${ticketId.value}/transferClient`,
params
);
if (data) window.location.reload(); if (data) window.location.reload();
} }
@ -296,7 +298,10 @@ async function changeShippedHour(time) {
shipped: time, shipped: time,
}; };
const { data } = await axios.post(`Tickets/${ticketId}/updateEditableTicket`, params); const { data } = await axios.post(
`Tickets/${ticketId.value}/updateEditableTicket`,
params
);
if (data) window.location.reload(); if (data) window.location.reload();
} }
@ -313,7 +318,7 @@ function openRecalculateDialog() {
} }
async function recalculateComponents() { async function recalculateComponents() {
await axios.post(`Tickets/${ticketId}/recalculateComponents`); await axios.post(`Tickets/${ticketId.value}/recalculateComponents`);
notify({ notify({
message: t('Data saved'), message: t('Data saved'),
type: 'positive', type: 'positive',
@ -336,11 +341,11 @@ async function handleInvoiceOutData() {
} }
async function docuwareDownload() { async function docuwareDownload() {
await axios.get(`Tickets/${ticketId}/docuwareDownload`); await axios.get(`Tickets/${ticketId.value}/docuwareDownload`);
} }
async function hasDocuware() { async function hasDocuware() {
const { data } = await axios.post(`Docuwares/${ticketId}/checkFile`, { const { data } = await axios.post(`Docuwares/${ticketId.value}/checkFile`, {
fileCabinet: 'deliveryNote', fileCabinet: 'deliveryNote',
signed: true, signed: true,
}); });
@ -371,11 +376,7 @@ async function uploadDocuware(force) {
</script> </script>
<template> <template>
<FetchData <FetchData
:url=" :url="`Tickets/${ticketId}/isEditable`"
route.path.startsWith('/ticket')
? `Tickets/${ticketId}/isEditable`
: `Tickets/${ticket}/isEditable`
"
auto-load auto-load
@on-fetch="handleFetchData" @on-fetch="handleFetchData"
/> />
@ -396,8 +397,6 @@ async function uploadDocuware(force) {
<VnSelect <VnSelect
url="Clients" url="Clients"
:fields="['id', 'name']" :fields="['id', 'name']"
option-label="name"
option-value="id"
v-model="client" v-model="client"
:label="t('Client')" :label="t('Client')"
auto-load auto-load

View File

@ -94,25 +94,32 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
label: t('ticketList.id'), label: t('globals.id'),
name: 'itemFk', name: 'itemFk',
}, },
{ {
align: 'left', align: 'left',
label: t('basicData.quantity'), label: t('globals.quantity'),
name: 'quantity', name: 'quantity',
format: (row) => toCurrency(row.quantity), format: (row) => toCurrency(row.quantity),
}, },
{ {
align: 'left', align: 'left',
label: t('basicData.item'), label: t('globals.item'),
name: 'item', name: 'item',
format: (row) => row?.item?.name, format: (row) => row?.item?.name,
columnClass: 'expand', columnClass: 'expand',
}, },
{ {
align: 'left', align: 'left',
label: t('basicData.price'), label: t('globals.size'),
name: 'size',
format: (row) => row?.item?.size,
columnClass: 'expand',
},
{
align: 'left',
label: t('globals.price'),
name: 'price', name: 'price',
format: (row) => toCurrency(row.price), format: (row) => toCurrency(row.price),
}, },
@ -124,7 +131,7 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
label: t('ticketList.amount'), label: t('globals.amount'),
name: 'amount', name: 'amount',
format: (row) => parseInt(row.amount * row.quantity), format: (row) => parseInt(row.amount * row.quantity),
}, },

View File

@ -20,6 +20,7 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnToSummary from 'src/components/ui/VnToSummary.vue'; import VnToSummary from 'src/components/ui/VnToSummary.vue';
import TicketDescriptorMenu from './TicketDescriptorMenu.vue';
const route = useRoute(); const route = useRoute();
const { notify } = useNotify(); const { notify } = useNotify();
@ -116,24 +117,36 @@ function toTicketUrl(section) {
{{ entity.nickname }} {{ entity.nickname }}
</div> </div>
</template> </template>
<template #header-right> <template #header-right="{ entity }">
<QBtnDropdown <div>
ref="stateBtnDropdownRef" <QBtnDropdown
color="black" ref="stateBtnDropdownRef"
text-color="white" color="black"
:label="t('globals.changeState')" text-color="white"
:disable="!isEditable()" :label="t('globals.changeState')"
> :disable="!isEditable()"
<VnSelect >
:options="editableStates" <VnSelect
hide-selected :options="editableStates"
option-label="name" hide-selected
option-value="code" option-label="name"
hide-dropdown-icon option-value="code"
focus-on-mount hide-dropdown-icon
@update:model-value="changeState" focus-on-mount
/> @update:model-value="changeState"
</QBtnDropdown> />
</QBtnDropdown>
<QBtn color="white" dense flat icon="more_vert" round size="md">
<QTooltip>
{{ t('components.cardDescriptor.moreOptions') }}
</QTooltip>
<QMenu>
<QList>
<TicketDescriptorMenu :ticket="entity" />
</QList>
</QMenu>
</QBtn>
</div>
</template> </template>
<template #body="{ entity }"> <template #body="{ entity }">
<QCard class="vn-one"> <QCard class="vn-one">

View File

@ -47,7 +47,7 @@ const getGroupedStates = (data) => {
/> />
<FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load /> <FetchData url="AgencyModes" @on-fetch="(data) => (agencies = data)" auto-load />
<FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load /> <FetchData url="Warehouses" @on-fetch="(data) => (warehouses = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table"> <VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { computed, ref, onMounted } from 'vue'; import { computed, ref, onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
@ -18,12 +18,13 @@ import RightMenu from 'src/components/common/RightMenu.vue';
import TicketFilter from './TicketFilter.vue'; import TicketFilter from './TicketFilter.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'src/components/FetchData.vue'; import FetchData from 'src/components/FetchData.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue'; import CustomerDescriptorProxy from 'src/pages/Customer/Card/CustomerDescriptorProxy.vue';
import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from 'src/pages/Zone/Card/ZoneDescriptorProxy.vue';
import { toTimeFormat } from 'src/filters/date'; import { toTimeFormat } from 'src/filters/date';
import InvoiceOutDescriptorProxy from '../InvoiceOut/Card/InvoiceOutDescriptorProxy.vue'; import InvoiceOutDescriptorProxy from 'src/pages/InvoiceOut/Card/InvoiceOutDescriptorProxy.vue';
const route = useRoute(); const route = useRoute();
const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const tableRef = ref(); const tableRef = ref();
@ -40,23 +41,18 @@ from.setDate(from.getDate() - 7);
const to = Date.vnNew(); const to = Date.vnNew();
to.setHours(23, 59, 0, 0); to.setHours(23, 59, 0, 0);
to.setDate(to.getDate() + 1); to.setDate(to.getDate() + 1);
const userParams = { const userParams = {
from: null, from: null,
to: null, to: null,
}; };
onMounted(() => { onMounted(() => {
initializeFromQuery(); initializeFromQuery();
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
if (!route.query.createForm) return; if (!route.query.createForm) return;
onClientSelected(JSON.parse(route.query.createForm)); onClientSelected(JSON.parse(route.query.createForm));
}); });
// Método para inicializar las variables desde la query string
const initializeFromQuery = () => { const initializeFromQuery = () => {
const query = route.query.table ? JSON.parse(route.query.table) : {}; const query = route.query.table ? JSON.parse(route.query.table) : {};
// Asigna los valores a las variables correspondientes
from.value = query.from || from.toISOString(); from.value = query.from || from.toISOString();
to.value = query.to || to.toISOString(); to.value = query.to || to.toISOString();
Object.assign(userParams, { from, to }); Object.assign(userParams, { from, to });
@ -213,13 +209,19 @@ const columns = computed(() => [
{ {
title: t('components.smartCard.viewSummary'), title: t('components.smartCard.viewSummary'),
icon: 'preview', icon: 'preview',
isPrimary: true, action: (row, evt) => {
action: (row) => viewSummary(row.id, TicketSummary), if (evt && evt.ctrlKey) {
const url = router.resolve({
params: { id: row.id },
name: 'TicketCard',
}).href;
window.open(url, '_blank');
} else viewSummary(row.id, TicketSummary);
},
}, },
], ],
}, },
]); ]);
function redirectToLines(id) { function redirectToLines(id) {
const url = `#/ticket/${id}/sale`; const url = `#/ticket/${id}/sale`;
window.open(url, '_blank'); window.open(url, '_blank');
@ -456,24 +458,24 @@ function setReference(data) {
auto-load auto-load
/> />
<VnSearchbar <VnSearchbar
data-key="Ticket" data-key="TicketList"
:label="t('Search ticket')" :label="t('Search ticket')"
:info="t('You can search by ticket id or alias')" :info="t('You can search by ticket id or alias')"
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<TicketFilter data-key="Ticket" /> <TicketFilter data-key="TicketList" />
</template> </template>
</RightMenu> </RightMenu>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="Ticket" data-key="TicketList"
url="Tickets/filter" url="Tickets/filter"
:create="{ :create="{
urlCreate: 'Tickets/new', urlCreate: 'Tickets/new',
title: t('ticketList.createTicket'), title: t('ticketList.createTicket'),
onDataSaved: ({ id }) => tableRef.redirect(id), onDataSaved: ({ id }) => tableRef.redirect(id),
formInitialData: {}, formInitialData: { clientId: null },
}" }"
default-mode="table" default-mode="table"
:order="['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id']" :order="['shippedDate DESC', 'shippedHour ASC', 'zoneLanding ASC', 'id']"
@ -575,17 +577,17 @@ function setReference(data) {
</span> </span>
</template> </template>
<template #column-stateFk="{ row }"> <template #column-stateFk="{ row }">
<span v-if="getColor(row)"> <span v-if="row.refFk">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else-if="row.state === 'Entregado'">
<span class="link" @click.stop> <span class="link" @click.stop>
{{ row.refFk }} {{ row.refFk }}
<InvoiceOutDescriptorProxy :id="row.invoiceOutId" /> <InvoiceOutDescriptorProxy :id="row.invoiceOutId" />
</span> </span>
</span> </span>
<span v-else-if="getColor(row)">
<QChip :class="getColor(row)" dense square>
{{ row.state }}
</QChip>
</span>
<span v-else> <span v-else>
{{ row.state }} {{ row.state }}
</span> </span>
@ -617,6 +619,7 @@ function setReference(data) {
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected
required
@update:model-value="(client) => onClientSelected(data)" @update:model-value="(client) => onClientSelected(data)"
:sort-by="'id ASC'" :sort-by="'id ASC'"
> >
@ -643,6 +646,7 @@ function setReference(data) {
option-label="nickname" option-label="nickname"
hide-selected hide-selected
map-options map-options
required
:disable="!data.clientId" :disable="!data.clientId"
:sort-by="'isActive DESC'" :sort-by="'isActive DESC'"
@update:model-value="() => fetchAvailableAgencies(data)" @update:model-value="() => fetchAvailableAgencies(data)"
@ -693,6 +697,7 @@ function setReference(data) {
option-value="id" option-value="id"
option-label="name" option-label="name"
hide-selected hide-selected
required
@update:model-value="() => fetchAvailableAgencies(data)" @update:model-value="() => fetchAvailableAgencies(data)"
/> />
</div> </div>
@ -706,7 +711,6 @@ function setReference(data) {
option-value="agencyModeFk" option-value="agencyModeFk"
option-label="agencyMode" option-label="agencyMode"
hide-selected hide-selected
:disable="!data.clientId || !data.landed || !data.warehouseId"
/> />
</div> </div>
</VnRow> </VnRow>
@ -842,7 +846,14 @@ function setReference(data) {
</QTooltip> </QTooltip>
</QPageSticky> </QPageSticky>
</template> </template>
<style scoped>
.disabled,
.disabled *,
[disabled],
[disabled] * {
cursor: pointer !important;
}
</style>
<i18n> <i18n>
es: es:
Search ticket: Buscar ticket Search ticket: Buscar ticket

View File

@ -138,6 +138,7 @@ ticketSale:
ok: Ok ok: Ok
more: Más more: Más
address: Consignatario address: Consignatario
size: Medida
ticketComponents: ticketComponents:
serie: Serie serie: Serie
components: Componentes components: Componentes

View File

@ -205,6 +205,7 @@ const onThermographCreated = async (data) => {
}" }"
sort-by="thermographFk ASC" sort-by="thermographFk ASC"
option-label="thermographFk" option-label="thermographFk"
option-filter-value="thermographFk"
:disable="viewAction === 'edit'" :disable="viewAction === 'edit'"
:tooltip="t('New thermograph')" :tooltip="t('New thermograph')"
:roles-allowed-to-create="['logistic']" :roles-allowed-to-create="['logistic']"

View File

@ -24,7 +24,7 @@ defineExpose({ states });
<template> <template>
<FetchData url="warehouses" @on-fetch="(data) => (states = data)" auto-load /> <FetchData url="warehouses" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true" search-url="table"> <VnFilterPanel :data-key="props.dataKey" :search-button="true">
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">
<strong>{{ t(`params.${tag.label}`) }}: </strong> <strong>{{ t(`params.${tag.label}`) }}: </strong>

View File

@ -14,6 +14,7 @@ import WorkerFilter from '../WorkerFilter.vue';
url: 'Workers/filter', url: 'Workers/filter',
label: 'Search worker', label: 'Search worker',
info: 'You can search by worker id or name', info: 'You can search by worker id or name',
order: 'id DESC',
}" }"
:redirect-on-error="true" :redirect-on-error="true"
/> />

View File

@ -70,7 +70,7 @@ function setNotifications(data) {
:default-reset="false" :default-reset="false"
:default-remove="false" :default-remove="false"
:default-save="false" :default-save="false"
@on-fetch="setNotifications" @on-fetch="(data) => data && setNotifications(data)"
search-url="notifications" search-url="notifications"
> >
<template #body> <template #body>

View File

@ -20,12 +20,13 @@ function notIsLocations(ifIsFalse, ifIsTrue) {
<template> <template>
<VnCard <VnCard
data-key="zone" data-key="zone"
base-url="Zones" :base-url="notIsLocations('Zones', undefined)"
:descriptor="ZoneDescriptor" :descriptor="ZoneDescriptor"
:filter-panel="ZoneFilterPanel" :filter-panel="notIsLocations(ZoneFilterPanel, undefined)"
:search-data-key="notIsLocations('ZoneList', 'ZoneLocations')" :search-data-key="notIsLocations('ZoneList', undefined)"
:custom-url="`Zones/${route.params?.id}/getLeaves`"
:searchbar-props="{ :searchbar-props="{
url: 'Zones', url: notIsLocations('Zones', 'ZoneLocations'),
label: notIsLocations(t('list.searchZone'), t('list.searchLocation')), label: notIsLocations(t('list.searchZone'), t('list.searchLocation')),
info: t('list.searchInfo'), info: t('list.searchInfo'),
whereFilter: notIsLocations((value) => { whereFilter: notIsLocations((value) => {

View File

@ -5,6 +5,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import { useState } from 'src/composables/useState'; import { useState } from 'src/composables/useState';
import axios from 'axios'; import axios from 'axios';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
const props = defineProps({ const props = defineProps({
rootLabel: { rootLabel: {
@ -33,22 +34,23 @@ const state = useState();
const treeRef = ref(); const treeRef = ref();
const expanded = ref([]); const expanded = ref([]);
const arrayData = useArrayData('ZoneLocations', { const datakey = 'ZoneLocations';
url: `Zones/${route.params.id}/getLeaves`, const url = computed(() => `Zones/${route.params.id}/getLeaves`);
const arrayData = useArrayData(datakey, {
url: url.value,
}); });
const { store } = arrayData; const { store } = arrayData;
const storeData = computed(() => store.data); const storeData = computed(() => store.data);
const nodes = ref([ const defaultNode = {
{ id: null,
id: null, name: props.rootLabel,
name: props.rootLabel, sons: true,
sons: true, tickable: false,
tickable: false, noTick: true,
noTick: true, children: [{}],
children: [{}], };
}, const nodes = ref([defaultNode]);
]);
const _tickedNodes = computed({ const _tickedNodes = computed({
get: () => props.tickedNodes, get: () => props.tickedNodes,
@ -128,6 +130,7 @@ function getNodeIds(node) {
watch(storeData, async (val) => { watch(storeData, async (val) => {
// Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar // Se triggerea cuando se actualiza el store.data, el cual es el resultado del fetch de la searchbar
if (!nodes.value[0]) nodes.value = [defaultNode];
nodes.value[0].childs = [...val]; nodes.value[0].childs = [...val];
const fetchedNodeKeys = val.flatMap(getNodeIds); const fetchedNodeKeys = val.flatMap(getNodeIds);
state.set('Tree', [...fetchedNodeKeys]); state.set('Tree', [...fetchedNodeKeys]);
@ -193,6 +196,7 @@ onUnmounted(() => {
<QBtn color="primary" icon="search" dense flat @click="reFetch()" /> <QBtn color="primary" icon="search" dense flat @click="reFetch()" />
</template> </template>
</VnInput> </VnInput>
<VnSearchbar :data-key="datakey" :url="url" :redirect="false" />
<QTree <QTree
ref="treeRef" ref="treeRef"
:nodes="nodes" :nodes="nodes"

View File

@ -26,7 +26,7 @@ const exprBuilder = (param, value) => {
<template> <template>
<VnSearchbar <VnSearchbar
data-key="Zones" data-key="ZonesList"
url="Zones" url="Zones"
:filter="{ :filter="{
include: { relation: 'agencyMode', scope: { fields: ['name'] } }, include: { relation: 'agencyMode', scope: { fields: ['name'] } },

View File

@ -32,7 +32,6 @@ const agencies = ref([]);
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
:hidden-tags="['search']" :hidden-tags="['search']"
search-url="table"
> >
<template #tags="{ tag }"> <template #tags="{ tag }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">

View File

@ -139,12 +139,12 @@ onMounted(() => (stateStore.rightDrawer = true));
<ZoneSearchbar /> <ZoneSearchbar />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<ZoneFilterPanel data-key="Zones" /> <ZoneFilterPanel data-key="ZonesList" />
</template> </template>
</RightMenu> </RightMenu>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="Zones" data-key="ZonesList"
url="Zones" url="Zones"
:create="{ :create="{
urlCreate: 'Zones', urlCreate: 'Zones',

View File

@ -113,7 +113,7 @@ export default {
name: 'SupplierAccounts', name: 'SupplierAccounts',
meta: { meta: {
title: 'accounts', title: 'accounts',
icon: 'vn:account', icon: 'vn:credit',
}, },
component: () => component: () =>
import('src/pages/Supplier/Card/SupplierAccounts.vue'), import('src/pages/Supplier/Card/SupplierAccounts.vue'),

View File

@ -162,6 +162,15 @@ export const useInvoiceOutGlobalStore = defineStore({
); );
throw new Error('Invalid Serial Type'); throw new Error('Invalid Serial Type');
} }
if (clientsToInvoice === 'all' && params.serialType !== 'global') {
notify(
'invoiceOut.globalInvoices.errors.invalidSerialTypeForAll',
'negative'
);
throw new Error('For "all" clients, the serialType must be "global"');
}
if (!params.companyFk) { if (!params.companyFk) {
notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative'); notify('invoiceOut.globalInvoices.errors.chooseValidCompany', 'negative');
throw new Error('Invalid company'); throw new Error('Invalid company');

View File

@ -8,7 +8,7 @@ export const useArrayDataStore = defineStore('arrayDataStore', () => {
userFilter: {}, userFilter: {},
userParams: {}, userParams: {},
url: '', url: '',
limit: 10, limit: 20,
skip: 0, skip: 0,
order: '', order: '',
isLoading: false, isLoading: false,

View File

@ -5,7 +5,7 @@ import { useRouter } from 'vue-router';
import * as vueRouter from 'vue-router'; import * as vueRouter from 'vue-router';
describe('useArrayData', () => { describe('useArrayData', () => {
const filter = '{"limit":10,"skip":0}'; const filter = '{"limit":20,"skip":0}';
const params = { supplierFk: 2 }; const params = { supplierFk: 2 };
beforeEach(() => { beforeEach(() => {
vi.spyOn(useRouter(), 'replace'); vi.spyOn(useRouter(), 'replace');