Merge branch '7396-addBasicDataWorker' of https://gitea.verdnatura.es/verdnatura/salix-front into 7396-addBasicDataWorker
gitea/salix-front/pipeline/pr-dev This commit looks good Details

This commit is contained in:
Carlos Satorres 2024-05-17 14:23:02 +02:00
commit 488c6b3f94
8 changed files with 169 additions and 31 deletions

View File

@ -29,7 +29,16 @@ module.exports = configure(function (/* ctx */) {
// app boot file (/src/boot) // app boot file (/src/boot)
// --> boot files are part of "main.js" // --> boot files are part of "main.js"
// https://v2.quasar.dev/quasar-cli/boot-files // https://v2.quasar.dev/quasar-cli/boot-files
boot: ['i18n', 'axios', 'vnDate', 'validations', 'quasar', 'quasar.defaults'], boot: [
'i18n',
'axios',
'vnDate',
'validations',
'quasar',
'quasar.defaults',
'customQTh',
'customQInput',
],
// https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css // https://v2.quasar.dev/quasar-cli-vite/quasar-config-js#css
css: ['app.scss'], css: ['app.scss'],

77
src/boot/customQInput.js Normal file
View File

@ -0,0 +1,77 @@
// src/boot/customQTh.js
import { boot } from 'quasar/wrappers';
import { QInput } from 'quasar';
import i18n from 'src/i18n';
const TR_HEADER = 'tr-header';
export default boot((b) => {
const { app } = b;
app.use(i18n);
app.mixin({
// mounted() {
// this.applyMixinLogic();
// },
mounted() {
this.applyMixinLogic();
// if (this.$options.name === QInput.name) {
// console.table([this.$options.name]);
// if (this.label) this.label = this.$t(this.label);
// // this.addClassToQTh(this);
// }
},
methods: {
applyMixinLogic() {
if (this.$options.name === 'QInput') {
// Traducción de la etiqueta
if (this.label) {
const el = this.$el;
// Recorrer los elementos hijos
const children = el.children || [];
for (let i = 0; i < children.length; i++) {
const child = children[i];
if (
child.tagName === 'DIV' &&
child.classList.contains('q-field__inner')
) {
const input = child.querySelector('input');
const filterAvailableText = (element) =>
element.__vueParentComponent.type.name === 'QInput' &&
element.__vueParentComponent?.attrs?.class !==
'vn-input-date';
if (
input &&
input.__vueParentComponent.type.name === 'QInput'
) {
// Añadir clase CSS
input.classList.add('input-default');
// Traducción de la etiqueta
const labelElement =
child.querySelector('.q-field__label');
if (labelElement) {
const labelKey = labelElement.textContent.trim();
labelElement.textContent = this.$t(labelKey);
}
}
}
}
// Traducción de la etiqueta
// const label = this.$el.getAttribute('label');
// if (label) {
// this.$el = this.$el.setAttribute('label', 'sasd');
// }
// this.$props.label = this.$t(`*${this.$props.label}`);
// this.label = this.$t(`*${this.$props.label}`);
// this.getNativeElement().ariaLabel = '++++';
}
// // Añadir clase CSS
// if (!this.$el.classList.contains('input-default')) {
// this.$el.classList.add('input-default');
// }
}
},
},
});
});

34
src/boot/customQTh.js Normal file
View File

@ -0,0 +1,34 @@
// src/boot/customQTh.js
import { QTable } from 'quasar';
import { boot } from 'quasar/wrappers';
import i18n from 'src/i18n';
const TR_HEADER = 'tr-header';
export default boot((b) => {
const { app } = b;
app.use(i18n);
app.mixin({
mounted() {
if (this.$options.name === QTable.name) {
console.table([this.$options.name]);
this.addClassToQTh(this.columns ?? []);
}
},
methods: {
addClassToQTh(columns) {
for (const column of columns) {
let { headerClasses, label, sortable } = column ?? [];
if (!headerClasses) headerClasses = TR_HEADER;
if (!Array.isArray(headerClasses)) headerClasses = [headerClasses];
else headerClasses.push(TR_HEADER);
column.headerClasses = headerClasses;
if (sortable === undefined) column.sortable = true;
column.label = this.$t(label);
console.table([headerClasses, column.headerClasses]);
}
},
},
});
});

View File

@ -1,5 +1,51 @@
import { QTable } from 'quasar'; import { QTable } from 'quasar';
import { QInput } from 'quasar';
import setDefault from './setDefault'; import setDefault from './setDefault';
import { QSelect } from 'quasar';
setDefault(QTable, 'pagination', { rowsPerPage: 0 }); setDefault(QTable, 'pagination', { rowsPerPage: 0 });
setDefault(QTable, 'hidePagination', true); setDefault(QTable, 'hidePagination', true);
QInput.props.outlined = {
type: QInput.props.outlined,
default: false,
};
QInput.props.dense = {
type: QInput.props.dense,
default: false,
};
QInput.props.stackLabel = {
type: QInput.props.stackLabel,
default: true,
};
QSelect.props.optionLabel = {
type: QSelect.props.optionLabel,
default: 'name',
};
QSelect.props.optionValue = {
type: QSelect.props.optionValue,
default: 'id',
};
QInput.props.hideBottomSpace = {
type: QInput.props.hideBottomSpace,
default: true,
};
QTable.props.columns = {
type: QTable.props.columns,
align: 'right',
format: (value) => `${value}*`,
};
QTable.props.noDataLabel = {
default: 'asd',
};
setDefault(QInput, 'outlined', false);
// setDefault(QTable, "noDataLabel", t('globalfs.noResults'));
setDefault(QTable, 'gridHeader', true);
setDefault(QTable, 'color', 'red-8');
setDefault(QTable, 'pagination', { rowsPerPage: 25 });
setDefault(QTable, 'rowKey', 'id');
// setDefault(QTable, 'columns', (data) => {
// console.log(this);
// });
// setDefault(QSelect, 'optionValue', 'id');
// setDefault(QSelect, 'optionLabel', 'name');

View File

@ -69,7 +69,6 @@ const inputRules = [
:clearable="false" :clearable="false"
:rules="inputRules" :rules="inputRules"
:lazy-rules="true" :lazy-rules="true"
hide-bottom-space
> >
<template v-if="$slots.prepend" #prepend> <template v-if="$slots.prepend" #prepend>
<slot name="prepend" /> <slot name="prepend" />

View File

@ -52,51 +52,45 @@ const detailsColumns = ref([
name: 'item', name: 'item',
label: 'claim.summary.item', label: 'claim.summary.item',
field: (row) => row.sale.itemFk, field: (row) => row.sale.itemFk,
sortable: true,
}, },
{ {
name: 'landed', name: 'landed',
label: 'claim.summary.landed', label: 'claim.summary.landed',
field: (row) => row.sale.ticket.landed, field: (row) => row.sale.ticket.landed,
format: (value) => toDate(value), format: (value) => toDate(value),
sortable: true,
}, },
{ {
name: 'quantity', name: 'quantity',
label: 'claim.summary.quantity', label: 'claim.summary.quantity',
field: (row) => row.sale.quantity, field: (row) => row.sale.quantity,
sortable: true,
}, },
{ {
name: 'claimed', name: 'claimed',
label: 'claim.summary.claimed', label: 'claim.summary.claimed',
field: (row) => row.quantity, field: (row) => row.quantity,
sortable: true,
}, },
{ {
name: 'description', name: 'description',
label: 'globals.description', label: 'globals.description',
field: (row) => row.sale.concept, field: (row) => row.sale.concept,
sortable: false,
}, },
{ {
name: 'price', name: 'price',
label: 'claim.summary.price', label: 'claim.summary.price',
field: (row) => row.sale.price, field: (row) => row.sale.price,
sortable: true,
}, },
{ {
name: 'discount', name: 'discount',
label: 'claim.summary.discount', label: 'claim.summary.discount',
field: (row) => row.sale.discount, field: (row) => row.sale.discount,
format: (value) => `${value} %`, format: (value) => `${value} %`,
sortable: true,
}, },
{ {
name: 'total', name: 'total',
label: 'claim.summary.total', label: 'claim.summary.total',
field: ({ sale }) => field: ({ sale }) =>
toCurrency(sale.quantity * sale.price * ((100 - sale.discount) / 100)), toCurrency(sale.quantity * sale.price * ((100 - sale.discount) / 100)),
sortable: true,
}, },
]); ]);
@ -115,31 +109,26 @@ const developmentColumns = ref([
name: 'claimReason', name: 'claimReason',
label: 'claim.summary.reason', label: 'claim.summary.reason',
field: (row) => row.claimReason.description, field: (row) => row.claimReason.description,
sortable: true,
}, },
{ {
name: 'claimResult', name: 'claimResult',
label: 'claim.summary.result', label: 'claim.summary.result',
field: (row) => row.claimResult.description, field: (row) => row.claimResult.description,
sortable: true,
}, },
{ {
name: 'claimResponsible', name: 'claimResponsible',
label: 'claim.summary.responsible', label: 'claim.summary.responsible',
field: (row) => row.claimResponsible.description, field: (row) => row.claimResponsible.description,
sortable: true,
}, },
{ {
name: 'worker', name: 'worker',
label: 'claim.summary.worker', label: 'claim.summary.worker',
field: (row) => row.worker?.user.nickname, field: (row) => row.worker?.user.nickname,
sortable: true,
}, },
{ {
name: 'claimRedelivery', name: 'claimRedelivery',
label: 'claim.summary.redelivery', label: 'claim.summary.redelivery',
field: (row) => row.claimRedelivery.description, field: (row) => row.claimRedelivery.description,
sortable: true,
}, },
]); ]);
const claimDms = ref([]); const claimDms = ref([]);
@ -290,13 +279,6 @@ async function changeState(value) {
:rows-per-page-options="[0]" :rows-per-page-options="[0]"
hide-bottom hide-bottom
> >
<template #header="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
{{ t(col.label) }}
</QTh>
</QTr>
</template>
<template #body="props"> <template #body="props">
<QTr :props="props"> <QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props"> <QTh v-for="col in props.cols" :key="col.name" :props="props">
@ -374,13 +356,6 @@ async function changeState(value) {
:rows-per-page-options="[0]" :rows-per-page-options="[0]"
hide-bottom hide-bottom
> >
<template #header="props">
<QTr :props="props">
<QTh v-for="col in props.cols" :key="col.name" :props="props">
{{ t(col.label) }}
</QTh>
</QTr>
</template>
</QTable> </QTable>
</QCard> </QCard>
<QCard class="vn-max"> <QCard class="vn-max">

View File

@ -49,7 +49,7 @@ const zones = ref();
<QItem class="q-mb-sm"> <QItem class="q-mb-sm">
<QItemSection> <QItemSection>
<VnInput <VnInput
:label="t('customerFilter.filter.name')" label="customerFilter.filter.name"
v-model="params.name" v-model="params.name"
is-outlined is-outlined
/> />

View File

@ -89,8 +89,6 @@ const warehouses = ref();
:label="t('Salesperson')" :label="t('Salesperson')"
v-model="params.salesPersonFk" v-model="params.salesPersonFk"
:options="workers" :options="workers"
option-value="id"
option-label="name"
emit-value emit-value
map-options map-options
use-input use-input