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

This commit is contained in:
PAU ROVIRA ROSALENY 2025-01-16 06:15:51 +00:00
commit a0f7905983
17 changed files with 403 additions and 342 deletions

View File

@ -1,29 +1,17 @@
<script setup>
import { ref, onMounted, useSlots } from 'vue';
import { onMounted, useSlots } from 'vue';
import { useI18n } from 'vue-i18n';
import { useStateStore } from 'stores/useStateStore';
import { useQuasar } from 'quasar';
import { useHasContent } from 'src/composables/useHasContent';
const { t } = useI18n();
const quasar = useQuasar();
const stateStore = useStateStore();
const slots = useSlots();
const hasContent = ref(false);
const rightPanel = ref(null);
const hasContent = useHasContent('#right-panel');
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)
stateStore.rightDrawer = false;
});

View File

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

View File

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

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
companyFk: Company
changePass: Change password
setPass: Set password
deleteConfirmTitle: Delete selected elements
changeState: Change state
raid: 'Raid {daysInForward} days'
@ -578,27 +579,6 @@ parking:
searchBar:
info: You can search by parking code
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:
chat: Chat
bossDepartment: Boss Department

View File

@ -348,6 +348,7 @@ globals:
countryFk: País
companyFk: Empresa
changePass: Cambiar contraseña
setPass: Establecer contraseña
deleteConfirmTitle: Eliminar los elementos seleccionados
changeState: Cambiar estado
raid: 'Redada {daysInForward} días'
@ -562,30 +563,6 @@ invoiceOut:
comercial: Comercial
errors:
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:
list:
parking: Parking

View File

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

View File

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

View File

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

View File

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

View File

@ -1,38 +1,12 @@
<script setup>
import { computed } from 'vue';
import { useRoute } from 'vue-router';
import VnCard from 'components/common/VnCard.vue';
import VnCardBeta from 'components/common/VnCardBeta.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>
<template>
<VnCard
<VnCardBeta
data-key="Order"
base-url="Orders"
:descriptor="OrderDescriptor"
:filter-panel="customFilterPanel"
:search-data-key="customRouteRedirectName"
>
<template #searchbar>
<OrderSearchbar />
</template>
</VnCard>
/>
</template>

View File

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

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 OrderSummary from 'pages/Order/Card/OrderSummary.vue';
import OrderSearchbar from './Card/OrderSearchbar.vue';
import OrderFilter from './Card/OrderFilter.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import CustomerDescriptorProxy from '../Customer/Card/CustomerDescriptorProxy.vue';
import WorkerDescriptorProxy from '../Worker/Card/WorkerDescriptorProxy.vue';
import VnTable from 'src/components/VnTable/VnTable.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import VnSection from 'src/components/common/VnSection.vue';
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
@ -24,6 +23,8 @@ const tableRef = ref();
const agencyList = ref([]);
const route = useRoute();
const addressOptions = ref([]);
const dataKey = 'OrderList';
const columns = computed(() => [
{
align: 'left',
@ -178,18 +179,24 @@ const getDateColor = (date) => {
if (difference < 0) return 'bg-success';
};
</script>
<template>
<OrderSearchbar />
<RightMenu>
<template #right-panel>
<VnSection
:data-key="dataKey"
:columns="columns"
prefix="order"
:array-data-props="{
url: 'Orders/filter',
order: ['landed DESC', 'clientFk ASC', 'id DESC'],
}"
>
<template #rightMenu>
<OrderFilter data-key="OrderList" />
</template>
</RightMenu>
<template #body>
<VnTable
ref="tableRef"
data-key="OrderList"
url="Orders/filter"
:order="['landed DESC', 'clientFk ASC', 'id DESC']"
:data-key="dataKey"
:create="{
urlCreate: 'Orders/new',
title: t('module.cerateOrder'),
@ -270,7 +277,8 @@ const getDateColor = (date) => {
: ''
} `
}}
{{ scope.opt?.nickname }}: {{ scope.opt?.street }},
{{ scope.opt?.nickname }}:
{{ scope.opt?.street }},
{{ scope.opt?.city }}
</QItemLabel>
</QItemSection>
@ -292,3 +300,5 @@ const getDateColor = (date) => {
</template>
</VnTable>
</template>
</VnSection>
</template>

View File

@ -21,3 +21,26 @@ lines:
image: Image
params:
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
params:
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';
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 {
path: '/order',
name: 'Order',
path: '/order',
meta: {
title: 'order',
icon: 'vn:basket',
moduleName: 'Order',
keyBinding: 'o',
menu: ['OrderList'],
},
component: RouterView,
redirect: { name: 'OrderMain' },
menus: {
main: ['OrderList'],
card: ['OrderBasicData', 'OrderCatalog', 'OrderVolume', 'OrderLines'],
},
children: [
{
name: 'OrderMain',
path: '',
component: () => import('src/components/common/VnModule.vue'),
redirect: { name: 'OrderIndexMain' },
children: [
{
path: '',
name: 'OrderMain',
component: () => import('src/components/common/VnModule.vue'),
name: 'OrderIndexMain',
redirect: { name: 'OrderList' },
component: () => import('src/pages/Order/OrderList.vue'),
children: [
{
path: 'list',
name: 'OrderList',
path: 'list',
meta: {
title: 'orderList',
icon: 'view_list',
},
component: () => import('src/pages/Order/OrderList.vue'),
},
orderCard,
],
},
{
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'),
},
],
},
],
};