Warmfix: show descriptors when click on it #1394

Merged
jsegarra merged 2 commits from warmfix_vnTable_card_descriptor into test 2025-02-14 11:39:59 +00:00
13 changed files with 76 additions and 58 deletions
Showing only changes of commit 60bbf4f8ad - Show all commits

View File

@ -11,6 +11,7 @@ export async function useCau(res, message) {
const { config, headers, request, status, statusText, data } = res || {}; const { config, headers, request, status, statusText, data } = res || {};
const { params, url, method, signal, headers: confHeaders } = config || {}; const { params, url, method, signal, headers: confHeaders } = config || {};
const { message: resMessage, code, name } = data?.error || {}; const { message: resMessage, code, name } = data?.error || {};
delete confHeaders.Authorization;
const additionalData = { const additionalData = {
path: location.hash, path: location.hash,
@ -40,7 +41,7 @@ export async function useCau(res, message) {
handler: async () => { handler: async () => {
const locale = i18n.global.t; const locale = i18n.global.t;
const reason = ref( const reason = ref(
code == 'ACCESS_DENIED' ? locale('cau.askPrivileges') : '' code == 'ACCESS_DENIED' ? locale('cau.askPrivileges') : '',
); );
openConfirmationModal( openConfirmationModal(
locale('cau.title'), locale('cau.title'),
@ -59,10 +60,9 @@ export async function useCau(res, message) {
'onUpdate:modelValue': (val) => (reason.value = val), 'onUpdate:modelValue': (val) => (reason.value = val),
label: locale('cau.inputLabel'), label: locale('cau.inputLabel'),
class: 'full-width', class: 'full-width',
required: true,
autofocus: true, autofocus: true,
}, },
} },
); );
}, },
}, },

View File

@ -34,6 +34,12 @@ account.value.hasAccount = hasAccount.value;
const entityId = computed(() => +route.params.id); const entityId = computed(() => +route.params.id);
const hasitManagementAccess = ref(); const hasitManagementAccess = ref();
const hasSysadminAccess = ref(); const hasSysadminAccess = ref();
const isHimself = computed(() => user.value.id === account.value.id);
const url = computed(() =>
isHimself.value
? 'Accounts/change-password'
: `Accounts/${entityId.value}/setPassword`
);
async function updateStatusAccount(active) { async function updateStatusAccount(active) {
if (active) { if (active) {
@ -106,11 +112,8 @@ onMounted(() => {
:ask-old-pass="askOldPass" :ask-old-pass="askOldPass"
:submit-fn=" :submit-fn="
async (newPassword, oldPassword) => { async (newPassword, oldPassword) => {
await axios.patch(`Accounts/change-password`, { const body = isHimself ? { userId: entityId, oldPassword } : {};
userId: entityId, await axios.patch(url, { ...body, newPassword });
newPassword,
oldPassword,
});
} }
" "
/> />
@ -158,16 +161,10 @@ onMounted(() => {
> >
<QItemSection>{{ t('globals.delete') }}</QItemSection> <QItemSection>{{ t('globals.delete') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem v-if="hasSysadminAccess" v-ripple clickable>
v-if="hasSysadminAccess" <QItemSection @click="onChangePass(isHimself)">
v-ripple {{ isHimself ? t('globals.changePass') : t('globals.setPass') }}
clickable
@click="user.id === account.id ? onChangePass(true) : onChangePass(false)"
>
<QItemSection v-if="user.id === account.id">
{{ t('globals.changePass') }}
</QItemSection> </QItemSection>
<QItemSection v-else>{{ t('globals.setPass') }}</QItemSection>
</QItem> </QItem>
<QItem <QItem
v-if="!account.hasAccount && hasSysadminAccess" v-if="!account.hasAccount && hasSysadminAccess"

View File

@ -57,7 +57,6 @@ function onFetch(rows, newRows) {
const price = row.quantity * sale.price; const price = row.quantity * sale.price;
const discount = (sale.discount * price) / 100; const discount = (sale.discount * price) / 100;
amountClaimed.value = amountClaimed.value + (price - discount); amountClaimed.value = amountClaimed.value + (price - discount);
} }
} }
@ -191,7 +190,7 @@ async function saveWhenHasChanges() {
ref="claimLinesForm" ref="claimLinesForm"
:url="`Claims/${route.params.id}/lines`" :url="`Claims/${route.params.id}/lines`"
save-url="ClaimBeginnings/crud" save-url="ClaimBeginnings/crud"
:filter="linesFilter" :user-filter="linesFilter"
@on-fetch="onFetch" @on-fetch="onFetch"
v-model:selected="selected" v-model:selected="selected"
:default-save="false" :default-save="false"
@ -208,7 +207,6 @@ async function saveWhenHasChanges() {
selection="multiple" selection="multiple"
v-model:selected="selected" v-model:selected="selected"
:grid="$q.screen.lt.md" :grid="$q.screen.lt.md"
> >
<template #body-cell-claimed="{ row }"> <template #body-cell-claimed="{ row }">
<QTd auto-width align="right" class="text-primary shrink"> <QTd auto-width align="right" class="text-primary shrink">
@ -330,9 +328,10 @@ async function saveWhenHasChanges() {
width: 100%; width: 100%;
} }
.grid-style-transition { .grid-style-transition {
transition: transform 0.28s, background-color 0.28s; transition:
transform 0.28s,
background-color 0.28s;
} }
</style> </style>
<i18n> <i18n>

View File

@ -1,8 +1,6 @@
<script setup> <script setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue'; import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
@ -14,15 +12,14 @@ const props = defineProps({
type: String, type: String,
required: true, required: true,
}, },
states: {
type: Array,
default: () => [],
},
}); });
const states = ref([]);
defineExpose({ states });
</script> </script>
<template> <template>
<FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
<VnFilterPanel :data-key="props.dataKey" :search-button="true"> <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">

View File

@ -10,12 +10,13 @@ import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import VnTable from 'src/components/VnTable/VnTable.vue'; import VnTable from 'src/components/VnTable/VnTable.vue';
import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue'; import ZoneDescriptorProxy from '../Zone/Card/ZoneDescriptorProxy.vue';
import VnSection from 'src/components/common/VnSection.vue'; import VnSection from 'src/components/common/VnSection.vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const dataKey = 'ClaimList'; const dataKey = 'ClaimList';
const claimFilterRef = ref(); const states = ref([]);
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -81,8 +82,7 @@ const columns = computed(() => [
align: 'left', align: 'left',
label: t('claim.state'), label: t('claim.state'),
format: ({ stateCode }) => format: ({ stateCode }) =>
claimFilterRef.value?.states.find(({ code }) => code === stateCode) states.value?.find(({ code }) => code === stateCode)?.description,
?.description,
name: 'stateCode', name: 'stateCode',
chip: { chip: {
condition: () => true, condition: () => true,
@ -92,7 +92,7 @@ const columns = computed(() => [
name: 'claimStateFk', name: 'claimStateFk',
component: 'select', component: 'select',
attrs: { attrs: {
options: claimFilterRef.value?.states, options: states.value,
optionLabel: 'description', optionLabel: 'description',
}, },
}, },
@ -125,6 +125,7 @@ const STATE_COLOR = {
</script> </script>
<template> <template>
<FetchData url="ClaimStates" @on-fetch="(data) => (states = data)" auto-load />
<VnSection <VnSection
:data-key="dataKey" :data-key="dataKey"
:columns="columns" :columns="columns"
@ -135,7 +136,7 @@ const STATE_COLOR = {
}" }"
> >
<template #advanced-menu> <template #advanced-menu>
<ClaimFilter data-key="ClaimList" ref="claimFilterRef" /> <ClaimFilter :data-key ref="claimFilterRef" :states />
</template> </template>
<template #body> <template #body>
<VnTable <VnTable

View File

@ -9,6 +9,7 @@ import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue'; 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 VnLocation from 'src/components/common/VnLocation.vue'; import VnLocation from 'src/components/common/VnLocation.vue';
import { getDifferences, getUpdatedValues } from 'src/filters';
const { t } = useI18n(); const { t } = useI18n();
const route = useRoute(); const route = useRoute();
@ -23,6 +24,12 @@ function handleLocation(data, location) {
data.provinceFk = provinceFk; data.provinceFk = provinceFk;
data.countryFk = countryFk; data.countryFk = countryFk;
} }
function onBeforeSave(formData, originalData) {
return getUpdatedValues(
Object.keys(getDifferences(formData, originalData)),
formData,
);
}
</script> </script>
<template> <template>
@ -36,6 +43,7 @@ function handleLocation(data, location) {
:url-update="`Clients/${route.params.id}/updateFiscalData`" :url-update="`Clients/${route.params.id}/updateFiscalData`"
auto-load auto-load
model="customer" model="customer"
:mapper="onBeforeSave"
> >
<template #form="{ data, validate }"> <template #form="{ data, validate }">
<VnRow> <VnRow>

View File

@ -31,20 +31,18 @@ onMounted(async () => {
ref="summary" ref="summary"
:url="`Departments/${entityId}`" :url="`Departments/${entityId}`"
class="full-width" class="full-width"
style="max-width: 900px"
module-name="Department"
> >
<template #header="{ entity }"> <template #header="{ entity }">
<div>{{ entity.name }}</div> <div>{{ entity.name }}</div>
</template> </template>
<template #body="{ entity: department }"> <template #body="{ entity: department }">
<QCard class="column"> <QCard class="vn-one">
<VnTitle <VnTitle
:url="`#/worker/department/${entityId}/basic-data`" :url="`#/worker/department/${entityId}/basic-data`"
:text="t('Basic data')" :text="t('Basic data')"
/> />
<div class="full-width row wrap justify-between content-between"> <div class="full-width row wrap justify-between content-between">
<div class="column" style="min-width: 50%"> <div class="column">
<VnLv :label="t('globals.name')" :value="department.name" dash /> <VnLv :label="t('globals.name')" :value="department.name" dash />
<VnLv :label="t('globals.code')" :value="department.code" dash /> <VnLv :label="t('globals.code')" :value="department.code" dash />
<VnLv <VnLv

View File

@ -43,10 +43,9 @@ const addToOrder = async () => {
); );
state.set('orderTotal', orderTotal); state.set('orderTotal', orderTotal);
const rows = orderData.value.rows.push(...items) || [];
state.set('orderData', { state.set('orderData', {
...orderData.value, ...orderData.value,
rows, items,
}); });
notify(t('globals.dataSaved'), 'positive'); notify(t('globals.dataSaved'), 'positive');
emit('added', -totalQuantity(items)); emit('added', -totalQuantity(items));

View File

@ -15,7 +15,7 @@ const sectors = ref([]);
const sectorFilter = { fields: ['id', 'description'] }; const sectorFilter = { fields: ['id', 'description'] };
const filter = { const filter = {
fields: ['sectorFk', 'code', 'pickingOrder', 'row', 'column'], fields: ['sectorFk', 'code', 'pickingOrder'],
include: [{ relation: 'sector', scope: sectorFilter }], include: [{ relation: 'sector', scope: sectorFilter }],
}; };
</script> </script>
@ -33,10 +33,6 @@ const filter = {
<VnInput v-model="data.code" :label="t('globals.code')" /> <VnInput v-model="data.code" :label="t('globals.code')" />
<VnInput v-model="data.pickingOrder" :label="t('parking.pickingOrder')" /> <VnInput v-model="data.pickingOrder" :label="t('parking.pickingOrder')" />
</VnRow> </VnRow>
<VnRow>
<VnInput v-model="data.row" :label="t('parking.row')" />
<VnInput v-model="data.column" :label="t('parking.column')" />
</VnRow>
<VnRow> <VnRow>
<VnSelect <VnSelect
v-model="data.sectorFk" v-model="data.sectorFk"

View File

@ -1,7 +1,5 @@
parking: parking:
pickingOrder: Picking order pickingOrder: Picking order
sector: Sector sector: Sector
row: Row
column: Column
search: Search parking search: Search parking
searchInfo: You can search by parking code searchInfo: You can search by parking code

View File

@ -1,7 +1,5 @@
parking: parking:
pickingOrder: Orden de recogida pickingOrder: Orden de recogida
row: Fila
sector: Sector sector: Sector
column: Columna
search: Buscar parking search: Buscar parking
searchInfo: Puedes buscar por código de parking searchInfo: Puedes buscar por código de parking

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { ref, computed } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useRoute } from 'vue-router'; import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import CardDescriptor from 'components/ui/CardDescriptor.vue'; import CardDescriptor from 'components/ui/CardDescriptor.vue';
@ -7,7 +7,7 @@ import VnLv from 'components/ui/VnLv.vue';
import useCardDescription from 'composables/useCardDescription'; import useCardDescription from 'composables/useCardDescription';
import { dashIfEmpty, toDate } from 'src/filters'; import { dashIfEmpty, toDate } from 'src/filters';
import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue'; import RouteDescriptorMenu from 'pages/Route/Card/RouteDescriptorMenu.vue';
import axios from 'axios';
const $props = defineProps({ const $props = defineProps({
id: { id: {
type: Number, type: Number,
@ -18,10 +18,24 @@ const $props = defineProps({
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
const zone = ref();
const zoneId = ref();
const entityId = computed(() => { const entityId = computed(() => {
return $props.id || route.params.id; return $props.id || route.params.id;
}); });
const getZone = async () => {
const filter = {
where: { routeFk: $props.id ? $props.id : route.params.id },
};
const { data } = await axios.get('Tickets/findOne', {
params: {
filter: JSON.stringify(filter),
},
});
zoneId.value = data.zoneFk;
const { data: zoneData } = await axios.get(`Zones/${zoneId.value}`);
zone.value = zoneData.name;
};
const filter = { const filter = {
fields: [ fields: [
@ -38,7 +52,6 @@ const filter = {
'started', 'started',
'finished', 'finished',
'cost', 'cost',
'zoneFk',
'isOk', 'isOk',
], ],
include: [ include: [
@ -47,7 +60,13 @@ const filter = {
relation: 'vehicle', relation: 'vehicle',
scope: { fields: ['id', 'm3'] }, scope: { fields: ['id', 'm3'] },
}, },
{ relation: 'zone', scope: { fields: ['id', 'name'] } }, {
relation: 'ticket',
scope: {
fields: ['id', 'name', 'zoneFk'],
include: { relation: 'zone', scope: { fields: ['id', 'name'] } },
},
},
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {
@ -65,6 +84,9 @@ const filter = {
}; };
const data = ref(useCardDescription()); const data = ref(useCardDescription());
const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id)); const setData = (entity) => (data.value = useCardDescription(entity.code, entity.id));
onMounted(async () => {
getZone();
});
</script> </script>
<template> <template>
@ -81,11 +103,11 @@ const setData = (entity) => (data.value = useCardDescription(entity.code, entity
<template #body="{ entity }"> <template #body="{ entity }">
<VnLv :label="t('Date')" :value="toDate(entity?.dated)" /> <VnLv :label="t('Date')" :value="toDate(entity?.dated)" />
<VnLv :label="t('Agency')" :value="entity?.agencyMode?.name" /> <VnLv :label="t('Agency')" :value="entity?.agencyMode?.name" />
<VnLv :label="t('Zone')" :value="entity?.zone?.name" /> <VnLv :label="t('Zone')" :value="zone" />
<VnLv <VnLv
:label="t('Volume')" :label="t('Volume')"
:value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty( :value="`${dashIfEmpty(entity?.m3)} / ${dashIfEmpty(
entity?.vehicle?.m3 entity?.vehicle?.m3,
)} `" )} `"
/> />
<VnLv :label="t('Description')" :value="entity?.description" /> <VnLv :label="t('Description')" :value="entity?.description" />

View File

@ -43,7 +43,6 @@ const routeFilter = {
'started', 'started',
'finished', 'finished',
'cost', 'cost',
'zoneFk',
'isOk', 'isOk',
], ],
include: [ include: [
@ -52,7 +51,13 @@ const routeFilter = {
relation: 'vehicle', relation: 'vehicle',
scope: { fields: ['id', 'm3'] }, scope: { fields: ['id', 'm3'] },
}, },
{ relation: 'zone', scope: { fields: ['id', 'name'] } }, {
relation: 'ticket',
scope: {
fields: ['id', 'name', 'zoneFk'],
include: { relation: 'zone', scope: { fields: ['id', 'name'] } },
},
},
{ {
relation: 'worker', relation: 'worker',
scope: { scope: {