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

This commit is contained in:
Jose Antonio Tubau 2025-01-17 10:33:08 +00:00
commit 3305bb4222
25 changed files with 643 additions and 402 deletions

View File

@ -1,29 +1,17 @@
<script setup> <script setup>
import { ref, onMounted, useSlots } from 'vue'; import { onMounted, useSlots } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useHasContent } from 'src/composables/useHasContent';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const stateStore = useStateStore(); const stateStore = useStateStore();
const slots = useSlots(); const slots = useSlots();
const hasContent = ref(false); const hasContent = useHasContent('#right-panel');
const rightPanel = ref(null);
onMounted(() => { onMounted(() => {
rightPanel.value = document.querySelector('#right-panel');
if (!rightPanel.value) return;
const observer = new MutationObserver(() => {
hasContent.value = rightPanel.value.childNodes.length;
});
observer.observe(rightPanel.value, {
subtree: true,
childList: true,
attributes: true,
});
if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile) if ((!slots['right-panel'] && !hasContent.value) || quasar.platform.is.mobile)
stateStore.rightDrawer = false; stateStore.rightDrawer = false;
}); });

View File

@ -2,7 +2,7 @@
import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue'; import CreateNewPostcode from 'src/components/CreateNewPostcodeForm.vue';
import VnSelectDialog from 'components/common/VnSelectDialog.vue'; import VnSelectDialog from 'components/common/VnSelectDialog.vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { computed } from 'vue'; import { ref, watch } from 'vue';
import { useAttrs } from 'vue'; import { useAttrs } from 'vue';
import { useRequired } from 'src/composables/useRequired'; import { useRequired } from 'src/composables/useRequired';
const { t } = useI18n(); const { t } = useI18n();
@ -16,6 +16,14 @@ const props = defineProps({
}, },
}); });
watch(
() => props.location,
(newValue) => {
if (!modelValue.value) return;
modelValue.value = formatLocation(newValue) ?? null;
}
);
const mixinRules = [requiredFieldRule]; const mixinRules = [requiredFieldRule];
const locationProperties = [ const locationProperties = [
'postcode', 'postcode',
@ -43,9 +51,7 @@ const formatLocation = (obj, properties = locationProperties) => {
return filteredParts.join(', '); return filteredParts.join(', ');
}; };
const modelValue = computed(() => const modelValue = ref(props.location ? formatLocation(props.location) : null);
props.location ? formatLocation(props.location, locationProperties) : null
);
function showLabel(data) { function showLabel(data) {
const dataProperties = [ const dataProperties = [

View File

@ -2,9 +2,10 @@
import RightMenu from './RightMenu.vue'; import RightMenu from './RightMenu.vue';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
import VnTableFilter from '../VnTable/VnTableFilter.vue'; import VnTableFilter from '../VnTable/VnTableFilter.vue';
import { onBeforeMount, computed } from 'vue'; import { onBeforeMount, computed, ref } from 'vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useHasContent } from 'src/composables/useHasContent';
const $props = defineProps({ const $props = defineProps({
section: { section: {
@ -55,6 +56,8 @@ const isMainSection = computed(() => {
} }
return isSame; return isSame;
}); });
const searchbarId = 'section-searchbar';
const hasContent = useHasContent(`#${searchbarId}`);
onBeforeMount(() => { onBeforeMount(() => {
if ($props.dataKey) if ($props.dataKey)
@ -69,14 +72,14 @@ onBeforeMount(() => {
<template> <template>
<slot name="searchbar"> <slot name="searchbar">
<VnSearchbar <VnSearchbar
v-if="searchBar" v-if="searchBar && !hasContent"
v-bind="arrayDataProps" v-bind="arrayDataProps"
:data-key="dataKey" :data-key="dataKey"
:label="$t(`${prefix}.search`)" :label="$t(`${prefix}.search`)"
:info="$t(`${prefix}.searchInfo`)" :info="$t(`${prefix}.searchInfo`)"
/> />
<div :id="searchbarId"></div>
</slot> </slot>
<RightMenu> <RightMenu>
<template #right-panel v-if="$slots['rightMenu'] || rightFilter"> <template #right-panel v-if="$slots['rightMenu'] || rightFilter">
<slot name="rightMenu"> <slot name="rightMenu">

View File

@ -0,0 +1,63 @@
import { vi, describe, expect, it, beforeAll, afterEach } from 'vitest';
import { createWrapper } from 'app/test/vitest/helper';
import VnInputTime from 'components/common/VnInputTime.vue';
describe('VnInputTime', () => {
let wrapper;
let vm;
beforeAll(() => {
wrapper = createWrapper(VnInputTime, {
props: {
isOutlined: true,
timeOnly: false,
},
});
vm = wrapper.vm;
wrapper = wrapper.wrapper;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should return the correct data if isOutlined is true', () => {
expect(vm.isOutlined).toBe(true);
expect(vm.styleAttrs).toEqual({ dense: true, outlined: true, rounded: true });
});
it('should return the formatted data', () => {
expect(vm.dateToTime('2022-01-01T03:23:43')).toBe('03:23');
});
describe('formattedTime', () => {
it('should return the formatted time for a valid ISO date', () => {
vm.model = '2025-01-02T15:45:00';
expect(vm.formattedTime).toBe('15:45');
});
it('should handle null model value gracefully', () => {
vm.model = null;
expect(vm.formattedTime).toBe(null);
});
it('should handle time-only input correctly', async () => {
await wrapper.setProps({ timeOnly: true });
vm.formattedTime = '14:30';
expect(vm.model).toBe('14:30');
});
it('should pad short time values correctly', async () => {
await wrapper.setProps({ timeOnly: true });
vm.formattedTime = '9';
expect(vm.model).toBe('09:00');
});
it('should not update the model if the value is unchanged', () => {
vm.model = '14:30';
const previousModel = vm.model;
vm.formattedTime = '14:30';
expect(vm.model).toBe(previousModel);
});
});
});

View File

@ -2,7 +2,6 @@
import { ref, computed, watch, onBeforeMount } from 'vue'; import { ref, computed, watch, onBeforeMount } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import SkeletonSummary from 'components/ui/SkeletonSummary.vue'; import SkeletonSummary from 'components/ui/SkeletonSummary.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { isDialogOpened } from 'src/filters'; import { isDialogOpened } from 'src/filters';
import VnMoreOptions from './VnMoreOptions.vue'; import VnMoreOptions from './VnMoreOptions.vue';

View File

@ -18,8 +18,7 @@ const $props = defineProps({
}, },
columns: { columns: {
type: Number, type: Number,
required: false, default: 3,
default: null,
}, },
}); });

View File

@ -1,38 +1,49 @@
<template> <template>
<div class="header bg-primary q-pa-sm q-mb-md"> <div class="header bg-primary q-pa-sm q-mb-md">
<QSkeleton type="rect" square /> <QSkeleton type="rect" square />
<QSkeleton type="rect" square />
</div> </div>
<div class="row q-pa-md q-col-gutter-md q-mb-md"> <div class="row q-pa-md q-col-gutter-md q-mb-md">
<QSkeleton type="rect" class="q-mb-md" square /> <div class="col">
<QSkeleton type="text" square /> <QSkeleton type="rect" class="q-mb-md" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="rect" class="q-mb-md" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> </div>
<QSkeleton type="text" square /> <div class="col">
<QSkeleton type="text" square /> <QSkeleton type="rect" class="q-mb-md" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="rect" class="q-mb-md" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> </div>
<QSkeleton type="text" square /> <div class="col">
<QSkeleton type="text" square /> <QSkeleton type="rect" class="q-mb-md" square />
<QSkeleton type="rect" class="q-mb-md" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> </div>
<QSkeleton type="rect" class="q-mb-md" square /> <div class="col">
<QSkeleton type="text" square /> <QSkeleton type="rect" class="q-mb-md" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square /> <QSkeleton type="text" square />
<QSkeleton type="text" square />
</div>
<div class="col">
<QSkeleton type="rect" class="q-mb-md" square />
<QSkeleton type="text" square />
<QSkeleton type="text" square />
<QSkeleton type="text" square />
<QSkeleton type="text" square />
<QSkeleton type="text" square />
</div>
</div> </div>
</template> </template>

View File

@ -0,0 +1,78 @@
import { vi, describe, expect, it, beforeAll, afterEach, beforeEach } from 'vitest';
import { createWrapper, axios } from 'app/test/vitest/helper';
import CardSummary from 'src/components/ui/CardSummary.vue';
import * as vueRouter from 'vue-router';
describe('CardSummary', () => {
let vm;
let wrapper;
beforeAll(() => {
vi.spyOn(axios, 'get').mockResolvedValue({ data: [] });
});
vi.spyOn(vueRouter, 'useRoute').mockReturnValue({
query: {},
params: {},
meta: { moduleName: 'mockName' },
path: 'mockName/1/summary',
name: 'CardSummary',
});
beforeEach(() => {
wrapper = createWrapper(CardSummary, {
propsData: {
dataKey: 'cardSummaryKey',
url: 'cardSummaryUrl',
filter: 'cardFilter',
},
});
vm = wrapper.vm;
wrapper = wrapper.wrapper;
});
afterEach(() => {
vi.clearAllMocks();
});
it('should fetch data correctly', async () => {
const fetchSpy = vi
.spyOn(vm.arrayData, 'fetch')
.mockResolvedValue({ data: [{ id: 1, name: 'Test Entity' }] });
await vm.fetch();
expect(fetchSpy).toHaveBeenCalledWith({ append: false, updateRouter: false });
expect(wrapper.emitted('onFetch')).toBeTruthy();
expect(vm.isLoading).toBe(false);
});
it('should set correct props to the store', () => {
expect(vm.store.url).toEqual('cardSummaryUrl');
expect(vm.store.filter).toEqual('cardFilter');
});
it('should compute entity correctly from store data', () => {
vm.store.data = [{ id: 1, name: 'Entity 1' }];
expect(vm.entity).toEqual({ id: 1, name: 'Entity 1' });
});
it('should handle empty data gracefully', () => {
vm.store.data = [];
expect(vm.entity).toBeUndefined();
});
it('should respond to prop changes and refetch data', async () => {
const newUrl = 'CardSummary/35';
const newKey = 'cardSummaryKey/35';
const fetchSpy = vi.spyOn(vm.arrayData, 'fetch');
await wrapper.setProps({ url: newUrl, filter: { key: newKey } });
expect(fetchSpy).toHaveBeenCalled();
expect(vm.store.url).toBe(newUrl);
expect(vm.store.filter).toEqual({ key: newKey });
});
it('should return true if route path ends with /summary' , () => {
expect(vm.isSummary).toBe(true);
});
});

View File

@ -0,0 +1,24 @@
import { onMounted, ref } from 'vue';
export function useHasContent(selector) {
const container = ref({});
const hasContent = ref();
onMounted(() => {
container.value = document.querySelector(selector);
if (!container.value) return;
const observer = new MutationObserver(() => {
if (document.querySelector(selector))
hasContent.value = !!container.value.childNodes.length;
});
observer.observe(container.value, {
subtree: true,
childList: true,
attributes: true,
});
});
return hasContent;
}

View File

@ -346,6 +346,7 @@ globals:
countryFk: Country countryFk: Country
companyFk: Company companyFk: Company
changePass: Change password changePass: Change password
setPass: Set password
deleteConfirmTitle: Delete selected elements deleteConfirmTitle: Delete selected elements
changeState: Change state changeState: Change state
raid: 'Raid {daysInForward} days' raid: 'Raid {daysInForward} days'
@ -578,27 +579,6 @@ parking:
searchBar: searchBar:
info: You can search by parking code info: You can search by parking code
label: Search parking... label: Search parking...
order:
field:
salesPersonFk: Sales Person
form:
clientFk: Client
addressFk: Address
agencyModeFk: Agency
list:
newOrder: New Order
summary:
basket: Basket
notConfirmed: Not confirmed
created: Created
createdFrom: Created From
address: Address
total: Total
items: Items
orderTicketList: Order Ticket List
amount: Amount
confirm: Confirm
confirmLines: Confirm lines
department: department:
chat: Chat chat: Chat
bossDepartment: Boss Department bossDepartment: Boss Department

View File

@ -348,6 +348,7 @@ globals:
countryFk: País countryFk: País
companyFk: Empresa companyFk: Empresa
changePass: Cambiar contraseña changePass: Cambiar contraseña
setPass: Establecer contraseña
deleteConfirmTitle: Eliminar los elementos seleccionados deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado changeState: Cambiar estado
raid: 'Redada {daysInForward} días' raid: 'Redada {daysInForward} días'
@ -562,30 +563,6 @@ invoiceOut:
comercial: Comercial comercial: Comercial
errors: errors:
downloadCsvFailed: Error al descargar CSV downloadCsvFailed: Error al descargar CSV
order:
field:
salesPersonFk: Comercial
form:
clientFk: Cliente
addressFk: Dirección
agencyModeFk: Agencia
list:
newOrder: Nuevo Pedido
summary:
basket: Cesta
notConfirmed: No confirmada
created: Creado
createdFrom: Creado desde
address: Dirección
total: Total
vat: IVA
state: Estado
alias: Alias
items: Artículos
orderTicketList: Tickets del pedido
amount: Monto
confirm: Confirmar
confirmLines: Confirmar lineas
shelving: shelving:
list: list:
parking: Parking parking: Parking

View File

@ -1,48 +1,56 @@
<script setup> <script setup>
import axios from 'axios'; import axios from 'axios';
import { computed, onMounted, ref } from 'vue'; import { computed, onMounted, ref, toRefs } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useVnConfirm } from 'composables/useVnConfirm'; import { useVnConfirm } from 'composables/useVnConfirm';
import { useRoute } from 'vue-router';
import { useAcl } from 'src/composables/useAcl'; import { useAcl } from 'src/composables/useAcl';
import { useArrayData } from 'src/composables/useArrayData'; import { useArrayData } from 'src/composables/useArrayData';
import { useState } from 'src/composables/useState';
import VnConfirm from 'src/components/ui/VnConfirm.vue'; import VnConfirm from 'src/components/ui/VnConfirm.vue';
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
import useNotify from 'src/composables/useNotify.js';
import useHasAccount from 'src/composables/useHasAccount.js';
import VnInputPassword from 'src/components/common/VnInputPassword.vue'; import VnInputPassword from 'src/components/common/VnInputPassword.vue';
import VnChangePassword from 'src/components/common/VnChangePassword.vue';
import { useQuasar } from 'quasar';
import { useRouter } from 'vue-router';
const $props = defineProps({ const $props = defineProps({
entityId: { hasAccount: {
type: Number, type: Boolean,
default: false,
required: true, required: true,
}, },
}); });
const { t } = useI18n(); const { t } = useI18n();
const { hasAccount } = toRefs($props);
const { openConfirmationModal } = useVnConfirm(); const { openConfirmationModal } = useVnConfirm();
const { notify } = useNotify(); const route = useRoute();
const router = useRouter();
const state = useState();
const user = state.getUser();
const { notify } = useQuasar();
const account = computed(() => useArrayData('AccountId').store.data[0]); const account = computed(() => useArrayData('AccountId').store.data[0]);
account.value.hasAccount = hasAccount.value;
onMounted(async () => { const entityId = computed(() => +route.params.id);
account.value.hasAccount = await useHasAccount($props.entityId); const hasitManagementAccess = ref();
}); const hasSysadminAccess = ref();
async function updateStatusAccount(active) { async function updateStatusAccount(active) {
if (active) { if (active) {
await axios.post(`Accounts`, { id: $props.entityId }); await axios.post(`Accounts`, { id: entityId.value });
} else { } else {
await axios.delete(`Accounts/${$props.entityId}`); await axios.delete(`Accounts/${entityId.value}`);
} }
account.value.hasAccount = active; account.value.hasAccount = active;
const status = active ? 'enable' : 'disable'; const status = active ? 'enable' : 'disable';
notify({ notify({
message: t(`account.card.${status}Account.success`), message: t(`account.card.actions.${status}Account.success`),
type: 'positive', type: 'positive',
}); });
} }
async function updateStatusUser(active) { async function updateStatusUser(active) {
await axios.patch(`VnUsers/${$props.entityId}`, { active }); await axios.patch(`VnUsers/${entityId.value}`, { active });
account.value.active = active; account.value.active = active;
const status = active ? 'activate' : 'deactivate'; const status = active ? 'activate' : 'deactivate';
notify({ notify({
@ -50,6 +58,17 @@ async function updateStatusUser(active) {
type: 'positive', type: 'positive',
}); });
} }
async function deleteAccount() {
const { data } = await axios.delete(`VnUsers/${entityId.value}`);
if (data) {
notify({
message: t('account.card.actions.delete.success'),
type: 'positive',
});
router.push({ name: 'AccountList' });
}
}
const showSyncDialog = ref(false); const showSyncDialog = ref(false);
const syncPassword = ref(null); const syncPassword = ref(null);
const shouldSyncPassword = ref(false); const shouldSyncPassword = ref(false);
@ -64,11 +83,27 @@ async function sync() {
type: 'positive', type: 'positive',
}); });
} }
const askOldPass = ref(false);
const changePassRef = ref();
const onChangePass = (oldPass) => {
askOldPass.value = oldPass;
changePassRef.value.show();
};
onMounted(() => {
hasitManagementAccess.value = useAcl().hasAny([
{ model: 'VnUser', props: 'higherPrivileges', accessType: 'WRITE' },
]);
hasSysadminAccess.value = useAcl().hasAny([
{ model: 'VnUser', props: 'adminUser', accessType: 'WRITE' },
]);
});
</script> </script>
<template> <template>
<VnChangePassword <VnChangePassword
ref="changePassRef" ref="changePassRef"
:ask-old-pass="true" :ask-old-pass="askOldPass"
:submit-fn=" :submit-fn="
async (newPassword, oldPassword) => { async (newPassword, oldPassword) => {
await axios.patch(`Accounts/change-password`, { await axios.patch(`Accounts/change-password`, {
@ -110,18 +145,46 @@ async function sync() {
</template> </template>
</VnConfirm> </VnConfirm>
<QItem <QItem
v-if=" v-if="hasitManagementAccess"
entityId == account.id &&
useAcl().hasAny([{ model: 'Account', props: '*', accessType: 'WRITE' }])
"
v-ripple v-ripple
clickable clickable
@click="$refs.changePassRef.show()" @click="
openConfirmationModal(
t('account.card.actions.disableAccount.title'),
t('account.card.actions.disableAccount.subtitle'),
() => deleteAccount()
)
"
> >
<QItemSection>{{ t('globals.changePass') }}</QItemSection> <QItemSection>{{ t('globals.delete') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem
v-if="account.hasAccount" v-if="hasSysadminAccess"
v-ripple
clickable
@click="user.id === account.id ? onChangePass(true) : onChangePass(false)"
>
<QItemSection v-if="user.id === account.id">
{{ t('globals.changePass') }}
</QItemSection>
<QItemSection v-else>{{ t('globals.setPass') }}</QItemSection>
</QItem>
<QItem
v-if="!account.hasAccount && hasSysadminAccess"
v-ripple
clickable
@click="
openConfirmationModal(
t('account.card.actions.enableAccount.title'),
t('account.card.actions.enableAccount.subtitle'),
() => updateStatusAccount(true)
)
"
>
<QItemSection>{{ t('account.card.actions.enableAccount.name') }}</QItemSection>
</QItem>
<QItem
v-if="account.hasAccount && hasSysadminAccess"
v-ripple v-ripple
clickable clickable
@click=" @click="
@ -136,7 +199,7 @@ async function sync() {
</QItem> </QItem>
<QItem <QItem
v-if="!account.active" v-if="!account.active && hasitManagementAccess"
v-ripple v-ripple
clickable clickable
@click=" @click="
@ -150,7 +213,7 @@ async function sync() {
<QItemSection>{{ t('account.card.actions.activateUser.name') }}</QItemSection> <QItemSection>{{ t('account.card.actions.activateUser.name') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem
v-if="account.active" v-if="account.active && hasitManagementAccess"
v-ripple v-ripple
clickable clickable
@click=" @click="
@ -163,7 +226,12 @@ async function sync() {
> >
<QItemSection>{{ t('account.card.actions.deactivateUser.name') }}</QItemSection> <QItemSection>{{ t('account.card.actions.deactivateUser.name') }}</QItemSection>
</QItem> </QItem>
<QItem v-ripple clickable @click="showSyncDialog = true"> <QItem
v-if="useAcl().hasAny([{ model: 'VnRole', props: '*', accessType: 'WRITE' }])"
v-ripple
clickable
@click="showSyncDialog = true"
>
<QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection> <QItemSection>{{ t('account.card.actions.sync.name') }}</QItemSection>
</QItem> </QItem>
<QSeparator /> <QSeparator />

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed, onMounted } from 'vue'; import { ref, computed } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
@ -11,16 +11,9 @@ import CardDescriptor from 'components/ui/CardDescriptor.vue';
import VnLv from 'src/components/ui/VnLv.vue'; import VnLv from 'src/components/ui/VnLv.vue';
import VnUserLink from 'src/components/ui/VnUserLink.vue'; import VnUserLink from 'src/components/ui/VnUserLink.vue';
import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue'; import CustomerDescriptorMenu from './CustomerDescriptorMenu.vue';
import { useState } from 'src/composables/useState';
const state = useState();
const customer = ref();
onMounted(async () => {
customer.value = state.get('customer');
if (customer.value) customer.value.webAccess = data.value?.account?.isActive;
});
const customerDebt = ref();
const customerCredit = ref();
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: Number,
@ -42,10 +35,12 @@ const entityId = computed(() => {
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => { const setData = (entity) => {
customerDebt.value = entity?.debt;
customerCredit.value = entity?.credit;
data.value = useCardDescription(entity?.name, entity?.id); data.value = useCardDescription(entity?.name, entity?.id);
}; };
const debtWarning = computed(() => { const debtWarning = computed(() => {
return customer.value?.debt > customer.value?.credit ? 'negative' : 'primary'; return customerDebt.value > customerCredit.value ? 'negative' : 'primary';
}); });
</script> </script>
@ -97,26 +92,21 @@ const debtWarning = computed(() => {
:value="entity.businessType.description" :value="entity.businessType.description"
/> />
</template> </template>
<template #icons> <template #icons="{ entity }">
<QCardActions v-if="customer" class="q-gutter-x-md"> <QCardActions class="q-gutter-x-md">
<QIcon <QIcon
v-if="!customer.isActive" v-if="!entity.isActive"
name="vn:disabled" name="vn:disabled"
size="xs" size="xs"
color="primary" color="primary"
> >
<QTooltip>{{ t('customer.card.isDisabled') }}</QTooltip> <QTooltip>{{ t('customer.card.isDisabled') }}</QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon v-if="entity.isFreezed" name="vn:frozen" size="xs" color="primary">
v-if="customer.isFreezed"
name="vn:frozen"
size="xs"
color="primary"
>
<QTooltip>{{ t('customer.card.isFrozen') }}</QTooltip> <QTooltip>{{ t('customer.card.isFrozen') }}</QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="!customer.account?.active" v-if="!entity.account?.active"
color="primary" color="primary"
name="vn:noweb" name="vn:noweb"
size="xs" size="xs"
@ -124,7 +114,7 @@ const debtWarning = computed(() => {
<QTooltip>{{ t('customer.card.webAccountInactive') }}</QTooltip> <QTooltip>{{ t('customer.card.webAccountInactive') }}</QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="customer.debt > customer.credit" v-if="entity.debt > entity.credit"
name="vn:risk" name="vn:risk"
size="xs" size="xs"
:color="debtWarning" :color="debtWarning"
@ -132,7 +122,7 @@ const debtWarning = computed(() => {
<QTooltip>{{ t('customer.card.hasDebt') }}</QTooltip> <QTooltip>{{ t('customer.card.hasDebt') }}</QTooltip>
</QIcon> </QIcon>
<QIcon <QIcon
v-if="!customer.isTaxDataChecked" v-if="!entity.isTaxDataChecked"
name="vn:no036" name="vn:no036"
size="xs" size="xs"
color="primary" color="primary"
@ -140,7 +130,7 @@ const debtWarning = computed(() => {
<QTooltip>{{ t('customer.card.notChecked') }}</QTooltip> <QTooltip>{{ t('customer.card.notChecked') }}</QTooltip>
</QIcon> </QIcon>
<QBtn <QBtn
v-if="customer.unpaid" v-if="entity.unpaid"
flat flat
size="sm" size="sm"
icon="vn:Client_unpaid" icon="vn:Client_unpaid"

View File

@ -11,6 +11,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue'; import CustomerNewCustomsAgent from 'src/pages/Customer/components/CustomerNewCustomsAgent.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -150,6 +151,22 @@ function onAgentCreated({ id, fiscalName }, data) {
</template> </template>
</VnSelectDialog> </VnSelectDialog>
</VnRow> </VnRow>
<VnRow>
<VnInputNumber
:label="t('Longitude')"
clearable
v-model="data.longitude"
:decimal-places="7"
:positive="false"
/>
<VnInputNumber
:label="t('Latitude')"
clearable
v-model="data.latitude"
:decimal-places="7"
:positive="false"
/>
</VnRow>
</template> </template>
</FormModel> </FormModel>
</template> </template>
@ -175,4 +192,6 @@ es:
Mobile: Movíl Mobile: Movíl
Incoterms: Incoterms Incoterms: Incoterms
Customs agent: Agente de aduanas Customs agent: Agente de aduanas
Longitude: Longitud
Latitude: Latitud
</i18n> </i18n>

View File

@ -391,7 +391,7 @@ onBeforeMount(async () => {
{{ row?.subName.toUpperCase() }} {{ row?.subName.toUpperCase() }}
</div> </div>
</div> </div>
<FetchedTags :item="row" :columns="3" /> <FetchedTags :item="row" />
</template> </template>
<template #more-create-dialog="{ data }"> <template #more-create-dialog="{ data }">
<VnInput <VnInput

View File

@ -58,6 +58,7 @@ lastEntries:
pvp: PVP pvp: PVP
label: Label label: Label
grouping: Grouping grouping: Grouping
packing: Packing
quantity: Quantity quantity: Quantity
cost: Cost cost: Cost
kg: Kg. kg: Kg.

View File

@ -58,6 +58,7 @@ lastEntries:
pvp: PVP pvp: PVP
label: Eti. label: Eti.
grouping: Grouping grouping: Grouping
packing: Packing
quantity: Cantidad quantity: Cantidad
cost: Coste cost: Coste
kg: Kg. kg: Kg.

View File

@ -1,38 +1,12 @@
<script setup> <script setup>
import { computed } from 'vue'; import VnCardBeta from 'components/common/VnCardBeta.vue';
import { useRoute } from 'vue-router';
import VnCard from 'components/common/VnCard.vue';
import OrderDescriptor from 'pages/Order/Card/OrderDescriptor.vue'; import OrderDescriptor from 'pages/Order/Card/OrderDescriptor.vue';
import OrderFilter from './OrderFilter.vue';
import OrderSearchbar from './OrderSearchbar.vue';
import OrderCatalogFilter from './OrderCatalogFilter.vue';
const config = {
OrderCatalog: OrderCatalogFilter,
};
const route = useRoute();
const routeName = computed(() => route.name);
const customRouteRedirectName = computed(() => {
const route = config[routeName.value];
if (route) return null;
return 'OrderList';
});
const customFilterPanel = computed(() => {
const filterPanel = config[routeName.value] ?? OrderFilter;
return filterPanel;
});
</script> </script>
<template> <template>
<VnCard <VnCardBeta
data-key="Order" data-key="Order"
base-url="Orders" base-url="Orders"
:descriptor="OrderDescriptor" :descriptor="OrderDescriptor"
:filter-panel="customFilterPanel" />
:search-data-key="customRouteRedirectName"
>
<template #searchbar>
<OrderSearchbar />
</template>
</VnCard>
</template> </template>

View File

@ -15,15 +15,18 @@ const router = useRouter();
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
const dataKey = 'OrderCatalogList'; const dataKey = 'OrderCatalogList';
const arrayData = useArrayData(dataKey); const catalogParams = {
const store = arrayData.store;
const tags = ref([]);
const itemRefs = ref({});
let catalogParams = {
orderFk: route.params.id, orderFk: route.params.id,
orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }), orderBy: JSON.stringify({ field: 'relevancy DESC, name', way: 'ASC', isTag: false }),
}; };
const arrayData = useArrayData(dataKey, {
url: 'Orders/CatalogFilter',
limit: 50,
userParams: catalogParams,
});
const store = arrayData.store;
const tags = ref([]);
const itemRefs = ref({});
onMounted(() => { onMounted(() => {
stateStore.rightDrawer = true; stateStore.rightDrawer = true;
@ -66,7 +69,6 @@ function extractValueTags(items) {
); );
tagValue.value = resultValueTags; tagValue.value = resultValueTags;
} }
const autoLoad = computed(() => !!JSON.parse(route?.query.table ?? '{}')?.categoryFk);
watch( watch(
() => store.data, () => store.data,
@ -78,16 +80,15 @@ watch(
</script> </script>
<template> <template>
<VnSearchbar <Teleport to="#section-searchbar" v-if="stateStore.isHeaderMounted()">
:data-key="dataKey" <VnSearchbar
:user-params="catalogParams" :data-key="dataKey"
:static-params="['orderFk', 'orderBy']" :redirect="false"
:redirect="false" :label="t('Search items')"
url="Orders/CatalogFilter" :info="t('You can search items by name or id')"
:label="t('Search items')" :search-remove-params="false"
:info="t('You can search items by name or id')" />
:search-remove-params="false" </Teleport>
/>
<Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()"> <Teleport to="#right-panel" v-if="stateStore.isHeaderMounted()">
<OrderCatalogFilter <OrderCatalogFilter
:data-key="dataKey" :data-key="dataKey"
@ -98,13 +99,7 @@ watch(
</Teleport> </Teleport>
<QPage class="column items-center q-pa-md" data-cy="orderCatalogPage"> <QPage class="column items-center q-pa-md" data-cy="orderCatalogPage">
<div class="full-width"> <div class="full-width">
<VnPaginate <VnPaginate :data-key="dataKey">
:data-key="dataKey"
url="Orders/CatalogFilter"
:limit="50"
:user-params="catalogParams"
:auto-load="autoLoad"
>
<template #body="{ rows }"> <template #body="{ rows }">
<div class="catalog-list"> <div class="catalog-list">
<div v-if="rows && !rows?.length" class="no-result"> <div v-if="rows && !rows?.length" class="no-result">

View File

@ -208,6 +208,20 @@ async function remove(item) {
async function handleConfirm() { async function handleConfirm() {
const result = await confirm(route.params.id); const result = await confirm(route.params.id);
if (result) { if (result) {
const sale = await axios.get(`OrderRows`, {
params: {
filter: JSON.stringify({
where: { orderFk: route.params.id },
}),
},
});
const ticket = await axios.get(`Sales`, {
params: {
filter: JSON.stringify({
where: { id: sale.data[0].saleFk },
}),
},
});
quasar.notify({ quasar.notify({
message: t('globals.dataSaved'), message: t('globals.dataSaved'),
type: 'positive', type: 'positive',
@ -215,7 +229,7 @@ async function handleConfirm() {
router.push({ router.push({
name: 'TicketSale', name: 'TicketSale',
query: { query: {
table: JSON.stringify({ id: route.params.id }), table: JSON.stringify({ id: ticket.data[0].ticketFk }),
}, },
}); });
} }

View File

@ -1,22 +0,0 @@
<script setup>
import { useI18n } from 'vue-i18n';
import VnSearchbar from 'components/ui/VnSearchbar.vue';
const { t } = useI18n();
</script>
<template>
<VnSearchbar
data-key="OrderList"
url="Orders/filter"
:label="t('Search order')"
:info="t('Search orders by ticket id')"
/>
</template>
<style scoped lang="scss"></style>
<i18n>
es:
Search order: Buscar orden
Search orders by ticket id: Buscar pedido por id ticket
</i18n>

View File

@ -8,15 +8,14 @@ import { useRoute } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import OrderSummary from 'pages/Order/Card/OrderSummary.vue'; import OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import OrderSearchbar from './Card/OrderSearchbar.vue';
import OrderFilter from './Card/OrderFilter.vue'; import OrderFilter from './Card/OrderFilter.vue';
import RightMenu from 'src/components/common/RightMenu.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 VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue'; import VnSelect from 'src/components/common/VnSelect.vue';
import VnSection from 'src/components/common/VnSection.vue';
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
@ -24,6 +23,8 @@ const tableRef = ref();
const agencyList = ref([]); const agencyList = ref([]);
const route = useRoute(); const route = useRoute();
const addressOptions = ref([]); const addressOptions = ref([]);
const dataKey = 'OrderList';
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -178,117 +179,126 @@ const getDateColor = (date) => {
if (difference < 0) return 'bg-success'; if (difference < 0) return 'bg-success';
}; };
</script> </script>
<template> <template>
<OrderSearchbar /> <VnSection
<RightMenu> :data-key="dataKey"
<template #right-panel> :columns="columns"
prefix="order"
:array-data-props="{
url: 'Orders/filter',
order: ['landed DESC', 'clientFk ASC', 'id DESC'],
}"
>
<template #rightMenu>
<OrderFilter data-key="OrderList" /> <OrderFilter data-key="OrderList" />
</template> </template>
</RightMenu> <template #body>
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="OrderList" :data-key="dataKey"
url="Orders/filter" :create="{
:order="['landed DESC', 'clientFk ASC', 'id DESC']" urlCreate: 'Orders/new',
:create="{ title: t('module.cerateOrder'),
urlCreate: 'Orders/new', onDataSaved: (url) => {
title: t('module.cerateOrder'), tableRef.redirect(`${url}/catalog`);
onDataSaved: (url) => { },
tableRef.redirect(`${url}/catalog`); formInitialData: {
}, active: true,
formInitialData: { addressId: null,
active: true, clientFk: null,
addressId: null, },
clientFk: null, }"
}, :user-params="{ showEmpty: false }"
}" :columns="columns"
:user-params="{ showEmpty: false }" :right-search="false"
:columns="columns" redirect="order"
:right-search="false"
redirect="order"
>
<template #column-clientFk="{ row }">
<span class="link" @click.stop>
{{ row?.clientName }}
<CustomerDescriptorProxy :id="row?.clientFk" />
</span>
</template>
<template #column-salesPersonFk="{ row }">
<span class="link" @click.stop>
{{ row?.name }}
<WorkerDescriptorProxy :id="row?.salesPersonFk" />
</span>
</template>
<template #column-landed="{ row }">
<span v-if="getDateColor(row.landed)">
<QChip :class="getDateColor(row.landed)" dense square>
{{ toDate(row?.landed) }}
</QChip>
</span>
</template>
<template #more-create-dialog="{ data }">
<VnSelect
url="Clients"
:include="{ relation: 'addresses' }"
v-model="data.clientFk"
:label="t('module.customer')"
@update:model-value="(id) => fetchClientAddress(id, data)"
> >
<template #option="scope"> <template #column-clientFk="{ row }">
<QItem v-bind="scope.itemProps"> <span class="link" @click.stop>
<QItemSection> {{ row?.clientName }}
<QItemLabel> <CustomerDescriptorProxy :id="row?.clientFk" />
{{ scope.opt.name }} </span>
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt.id}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template> </template>
</VnSelect> <template #column-salesPersonFk="{ row }">
<VnSelect <span class="link" @click.stop>
v-model="data.addressId" {{ row?.name }}
:options="addressOptions" <WorkerDescriptorProxy :id="row?.salesPersonFk" />
:label="t('module.address')" </span>
option-value="id"
option-label="nickname"
@update:model-value="() => fetchAgencies(data)"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel
:class="{
'color-vn-label': !scope.opt?.isActive,
}"
>
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
{{ scope.opt?.city }}
</QItemLabel>
</QItemSection>
</QItem>
</template> </template>
</VnSelect> <template #column-landed="{ row }">
<VnInputDate <span v-if="getDateColor(row.landed)">
v-model="data.landed" <QChip :class="getDateColor(row.landed)" dense square>
:label="t('module.landed')" {{ toDate(row?.landed) }}
@update:model-value="() => fetchAgencies(data)" </QChip>
/> </span>
<VnSelect </template>
v-model="data.agencyModeId" <template #more-create-dialog="{ data }">
:label="t('module.agency')" <VnSelect
:options="agencyList" url="Clients"
option-value="agencyModeFk" :include="{ relation: 'addresses' }"
option-label="agencyMode" v-model="data.clientFk"
/> :label="t('module.customer')"
@update:model-value="(id) => fetchClientAddress(id, data)"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt.name }}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt.id}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
v-model="data.addressId"
:options="addressOptions"
:label="t('module.address')"
option-value="id"
option-label="nickname"
@update:model-value="() => fetchAgencies(data)"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel
:class="{
'color-vn-label': !scope.opt?.isActive,
}"
>
{{
`${
!scope.opt?.isActive
? t('basicData.inactive')
: ''
} `
}}
{{ scope.opt?.nickname }}:
{{ scope.opt?.street }},
{{ scope.opt?.city }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnInputDate
v-model="data.landed"
:label="t('module.landed')"
@update:model-value="() => fetchAgencies(data)"
/>
<VnSelect
v-model="data.agencyModeId"
:label="t('module.agency')"
:options="agencyList"
option-value="agencyModeFk"
option-label="agencyMode"
/>
</template>
</VnTable>
</template> </template>
</VnTable> </VnSection>
</template> </template>

View File

@ -21,3 +21,26 @@ lines:
image: Image image: Image
params: params:
tagGroups: Tags tagGroups: Tags
order:
field:
salesPersonFk: Sales Person
form:
clientFk: Client
addressFk: Address
agencyModeFk: Agency
list:
newOrder: New Order
summary:
basket: Basket
notConfirmed: Not confirmed
created: Created
createdFrom: Created From
address: Address
total: Total
items: Items
orderTicketList: Order Ticket List
amount: Amount
confirm: Confirm
confirmLines: Confirm lines
search: Search orders
searchInfo: You can search orders by ticket id

View File

@ -21,3 +21,29 @@ lines:
image: Imagen image: Imagen
params: params:
tagGroups: Tags tagGroups: Tags
order:
field:
salesPersonFk: Comercial
form:
clientFk: Cliente
addressFk: Dirección
agencyModeFk: Agencia
list:
newOrder: Nuevo Pedido
summary:
basket: Cesta
notConfirmed: No confirmada
created: Creado
createdFrom: Creado desde
address: Dirección
total: Total
vat: IVA
state: Estado
alias: Alias
items: Artículos
orderTicketList: Tickets del pedido
amount: Monto
confirm: Confirmar
confirmLines: Confirmar lineas
search: Buscar pedido
searchInfo: Buscar pedidos por el número de ticket

View File

@ -1,35 +1,102 @@
import { RouterView } from 'vue-router'; import { RouterView } from 'vue-router';
const orderCard = {
name: 'OrderCard',
path: ':id',
component: () => import('src/pages/Order/Card/OrderCard.vue'),
redirect: { name: 'OrderSummary' },
meta: {
menu: [
'OrderBasicData',
'OrderCatalog',
'OrderVolume',
'OrderLines',
],
},
children: [
{
path: 'summary',
name: 'OrderSummary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Order/Card/OrderSummary.vue'),
},
{
path: 'basic-data',
name: 'OrderBasicData',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () => import('src/pages/Order/Card/OrderBasicData.vue'),
},
{
path: 'catalog',
name: 'OrderCatalog',
meta: {
title: 'catalog',
icon: 'vn:basket',
},
component: () => import('src/pages/Order/Card/OrderCatalog.vue'),
},
{
path: 'volume',
name: 'OrderVolume',
meta: {
title: 'volume',
icon: 'vn:volume',
},
component: () => import('src/pages/Order/Card/OrderVolume.vue'),
},
{
path: 'line',
name: 'OrderLines',
meta: {
title: 'lines',
icon: 'vn:lines',
},
component: () => import('src/pages/Order/Card/OrderLines.vue'),
},
],
};
export default { export default {
path: '/order',
name: 'Order', name: 'Order',
path: '/order',
meta: { meta: {
title: 'order', title: 'order',
icon: 'vn:basket', icon: 'vn:basket',
moduleName: 'Order', moduleName: 'Order',
keyBinding: 'o', keyBinding: 'o',
menu: ['OrderList'],
}, },
component: RouterView, component: RouterView,
redirect: { name: 'OrderMain' }, redirect: { name: 'OrderMain' },
menus: {
main: ['OrderList'],
card: ['OrderBasicData', 'OrderCatalog', 'OrderVolume', 'OrderLines'],
},
children: [ children: [
{ {
path: '',
name: 'OrderMain', name: 'OrderMain',
path: '',
component: () => import('src/components/common/VnModule.vue'), component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'OrderList' }, redirect: { name: 'OrderIndexMain' },
children: [ children: [
{ {
path: 'list', path: '',
name: 'OrderList', name: 'OrderIndexMain',
meta: { redirect: { name: 'OrderList' },
title: 'orderList',
icon: 'view_list',
},
component: () => import('src/pages/Order/OrderList.vue'), component: () => import('src/pages/Order/OrderList.vue'),
children: [
{
name: 'OrderList',
path: 'list',
meta: {
title: 'orderList',
icon: 'view_list',
},
},
orderCard,
],
}, },
{ {
path: 'create', path: 'create',
@ -42,58 +109,5 @@ export default {
}, },
], ],
}, },
{
name: 'OrderCard',
path: ':id',
component: () => import('src/pages/Order/Card/OrderCard.vue'),
redirect: { name: 'OrderSummary' },
children: [
{
name: 'OrderSummary',
path: 'summary',
meta: {
title: 'summary',
icon: 'launch',
},
component: () => import('src/pages/Order/Card/OrderSummary.vue'),
},
{
name: 'OrderBasicData',
path: 'basic-data',
meta: {
title: 'basicData',
icon: 'vn:settings',
},
component: () => import('src/pages/Order/Card/OrderBasicData.vue'),
},
{
name: 'OrderCatalog',
path: 'catalog',
meta: {
title: 'catalog',
icon: 'vn:basket',
},
component: () => import('src/pages/Order/Card/OrderCatalog.vue'),
},
{
name: 'OrderVolume',
path: 'volume',
meta: {
title: 'volume',
icon: 'vn:volume',
},
component: () => import('src/pages/Order/Card/OrderVolume.vue'),
},
{
name: 'OrderLines',
path: 'line',
meta: {
title: 'lines',
icon: 'vn:lines',
},
component: () => import('src/pages/Order/Card/OrderLines.vue'),
},
],
},
], ],
}; };