0
0
Fork 0

feat: refs #7404 style dynamic text color

This commit is contained in:
Pablo Natek 2024-09-23 13:14:25 +02:00
parent 17bb144bce
commit e700f6f4a8
8 changed files with 83 additions and 38 deletions

View File

@ -639,18 +639,10 @@ function handleOnDataSaved(_) {
:key="col?.id" :key="col?.id"
class="text-center" class="text-center"
> >
<div <slot
v-if="col?.summation" :name="`column-footer-${col.name}`"
:class="`text-${col?.align ?? 'left'}`" :class="getColAlign(col)"
class="text-bold q-pa-sm" />
>
{{
rows.reduce(
(sum, currentRow) => sum + currentRow[col.name],
0
)
}}
</div>
</QTh> </QTh>
</QTr> </QTr>
</template> </template>

View File

@ -131,9 +131,8 @@ async function fetch(params) {
useArrayData(props.dataKey, params); useArrayData(props.dataKey, params);
arrayData.reset(['filter.skip', 'skip']); arrayData.reset(['filter.skip', 'skip']);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!store.hasMoreData) { if (!store.hasMoreData) isLoading.value = false;
isLoading.value = false;
}
emit('onFetch', store.data); emit('onFetch', store.data);
return store.data; return store.data;
} }

View File

@ -36,7 +36,6 @@ $color-font-secondary: #777;
.bg-success { .bg-success {
background-color: $positive; background-color: $positive;
} }
.bg-notice { .bg-notice {
background-color: $info; background-color: $info;
} }

View File

@ -10,6 +10,7 @@ import TravelDescriptorProxy from 'src/pages/Travel/Card/TravelDescriptorProxy.v
import { toDate, toCurrency } from 'src/filters'; import { toDate, toCurrency } from 'src/filters';
import { getUrl } from 'src/composables/getUrl'; import { getUrl } from 'src/composables/getUrl';
import axios from 'axios'; import axios from 'axios';
import FetchedTags from 'src/components/ui/FetchedTags.vue';
const route = useRoute(); const route = useRoute();
const { t } = useI18n(); const { t } = useI18n();
@ -163,7 +164,7 @@ const fetchEntryBuys = async () => {
> >
<template #header-left> <template #header-left>
<router-link <router-link
v-if="route.name !== 'EntrySummary'" v-if="route?.name !== 'EntrySummary'"
:to="{ name: 'EntrySummary', params: { id: entityId } }" :to="{ name: 'EntrySummary', params: { id: entityId } }"
class="header link" class="header link"
:href="entryUrl" :href="entryUrl"
@ -184,7 +185,10 @@ const fetchEntryBuys = async () => {
<QIcon name="open_in_new" /> <QIcon name="open_in_new" />
</router-link> </router-link>
<VnLv :label="t('entry.summary.commission')" :value="entry.commission" /> <VnLv :label="t('entry.summary.commission')" :value="entry.commission" />
<VnLv :label="t('entry.summary.currency')" :value="entry.currency.name" /> <VnLv
:label="t('entry.summary.currency')"
:value="entry.currency?.name"
/>
<VnLv :label="t('entry.summary.company')" :value="entry.company.code" /> <VnLv :label="t('entry.summary.company')" :value="entry.company.code" />
<VnLv :label="t('entry.summary.reference')" :value="entry.reference" /> <VnLv :label="t('entry.summary.reference')" :value="entry.reference" />
<VnLv <VnLv
@ -210,12 +214,12 @@ const fetchEntryBuys = async () => {
</VnLv> </VnLv>
<VnLv <VnLv
:label="t('entry.summary.travelAgency')" :label="t('entry.summary.travelAgency')"
:value="entry.travel.agency.name" :value="entry.travel.agency?.name"
/> />
<VnLv :label="t('shipped')" :value="toDate(entry.travel.shipped)" /> <VnLv :label="t('shipped')" :value="toDate(entry.travel.shipped)" />
<VnLv <VnLv
:label="t('entry.summary.travelWarehouseOut')" :label="t('entry.summary.travelWarehouseOut')"
:value="entry.travel.warehouseOut.name" :value="entry.travel.warehouseOut?.name"
/> />
<QCheckbox <QCheckbox
:label="t('entry.summary.travelDelivered')" :label="t('entry.summary.travelDelivered')"
@ -225,7 +229,7 @@ const fetchEntryBuys = async () => {
<VnLv :label="t('landed')" :value="toDate(entry.travel.landed)" /> <VnLv :label="t('landed')" :value="toDate(entry.travel.landed)" />
<VnLv <VnLv
:label="t('entry.summary.travelWarehouseIn')" :label="t('entry.summary.travelWarehouseIn')"
:value="entry.travel.warehouseIn.name" :value="entry.travel.warehouseIn?.name"
/> />
<QCheckbox <QCheckbox
:label="t('entry.summary.travelReceived')" :label="t('entry.summary.travelReceived')"
@ -281,17 +285,17 @@ const fetchEntryBuys = async () => {
> >
<template #body="{ cols, row, rowIndex }"> <template #body="{ cols, row, rowIndex }">
<QTr no-hover> <QTr no-hover>
<QTd v-for="col in cols" :key="col.name"> <QTd v-for="col in cols" :key="col?.name">
<component <component
:is="tableColumnComponents[col.name].component(props)" :is="tableColumnComponents[col?.name].component()"
v-bind="tableColumnComponents[col.name].props(props)" v-bind="tableColumnComponents[col?.name].props()"
@click="tableColumnComponents[col.name].event(props)" @click="tableColumnComponents[col?.name].event()"
class="col-content" class="col-content"
> >
<template <template
v-if=" v-if="
col.name !== 'observation' && col?.name !== 'observation' &&
col.name !== 'isConfirmed' col?.name !== 'isConfirmed'
" "
>{{ col.value }}</template >{{ col.value }}</template
> >

View File

@ -1,16 +1,17 @@
<script setup> <script setup>
import { onMounted, onUnmounted, ref } from 'vue'; import { onMounted, onUnmounted, ref } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import EntryLatestBuysFilter from './EntryLatestBuysFilter.vue';
import { useStateStore } from 'stores/useStateStore'; import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import EntryLatestBuysFilter from './EntryLatestBuysFilter.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import VnImg from 'src/components/ui/VnImg.vue';
const stateStore = useStateStore(); const stateStore = useStateStore();
const { t } = useI18n(); const { t } = useI18n();
import { toDate } from 'src/filters';
import VnImg from 'src/components/ui/VnImg.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
const columns = [ const columns = [
{ {
align: 'center', align: 'center',

View File

@ -4,6 +4,7 @@ import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue'; import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue';
import VnSelect from 'components/common/VnSelect.vue'; import VnSelect from 'components/common/VnSelect.vue';
import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue'; import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue';
@ -18,6 +19,7 @@ defineProps({
const itemTypeWorkersOptions = ref([]); const itemTypeWorkersOptions = ref([]);
const suppliersOptions = ref([]); const suppliersOptions = ref([]);
const tagValues = ref([]);
</script> </script>
<template> <template>

View File

@ -56,7 +56,7 @@ const columns = [
summation: true, summation: true,
}, },
{ {
align: 'left', align: 'center',
label: t('Bought'), label: t('Bought'),
name: 'bought', name: 'bought',
summation: true, summation: true,
@ -129,6 +129,18 @@ const setUserParams = async ({ dated }) => {
function openDialog() { function openDialog() {
travelDialogRef.value = true; travelDialogRef.value = true;
} }
function setFooter(data) {
const footer = {
bought: 0,
reserve: 0,
};
data.forEach((row) => {
footer.bought += row?.bought;
footer.reserve += row?.reserve;
});
tableRef.value.footer = footer;
}
</script> </script>
<template> <template>
<VnSubToolbar> <VnSubToolbar>
@ -203,6 +215,7 @@ function openDialog() {
order="reserve DESC" order="reserve DESC"
:right-search="false" :right-search="false"
:is-editable="true" :is-editable="true"
@on-fetch="(data) => setFooter(data)"
:create="{ :create="{
urlCreate: 'StockBoughts', urlCreate: 'StockBoughts',
title: t('Reserve some space'), title: t('Reserve some space'),
@ -223,11 +236,31 @@ function openDialog() {
<WorkerDescriptorProxy :id="row?.workerFk" /> <WorkerDescriptorProxy :id="row?.workerFk" />
</span> </span>
</template> </template>
<template #column-bought="{ row }">
<span :class="{ 'text-negative': row.reserve < row.bought }">
{{ row?.bought }}
</span>
</template>
<template #column-footer-reserve>
<span>
{{ tableRef.footer.reserve }}
</span>
</template>
<template #column-footer-bought>
<span
:class="{
'text-negative':
tableRef.footer.reserve < tableRef.footer.bought,
}"
>
{{ tableRef.footer.bought }}
</span>
</template>
</VnTable> </VnTable>
</QPage> </QPage>
</div> </div>
</template> </template>
<style lang="css" scoped> <style lang="scss" scoped>
.travel { .travel {
margin-bottom: 0px; margin-bottom: 0px;
} }
@ -241,6 +274,15 @@ function openDialog() {
align-items: center; align-items: center;
width: 40%; width: 40%;
} }
.text-negative {
color: $negative !important;
}
.input-container {
display: flex;
justify-content: center;
align-items: center;
height: 100%;
}
</style> </style>
<i18n> <i18n>
es: es:

View File

@ -81,7 +81,13 @@ const columns = [
auto-load auto-load
> >
<template #top-left> <template #top-left>
<QBtn flat icon="Close" v-close-popup /> <QBtn
flat
icon="Close"
color="primary"
class="bg-vn-section-color q-pa-xs"
v-close-popup
/>
</template> </template>
<template #column-entryFk="{ row }"> <template #column-entryFk="{ row }">
<span class="link"> <span class="link">
@ -103,10 +109,10 @@ const columns = [
.container { .container {
max-width: 50vw; max-width: 50vw;
overflow: auto; overflow: auto;
display: flex;
justify-content: center; justify-content: center;
align-items: center; align-items: center;
margin: auto; margin: auto;
background-color: var(--vn-section-color);
} }
</style> </style>
<i18n> <i18n>