0
0
Fork 0

perf: updates

This commit is contained in:
Javier Segarra 2024-05-02 13:53:40 +02:00
parent 1907301852
commit 6323f165a0
1 changed files with 40 additions and 21 deletions

View File

@ -1,9 +1,9 @@
<script setup> <script setup>
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import { ref, reactive, computed, watch } from 'vue'; import { ref, reactive, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useDialogPluginComponent } from 'quasar'; // import { useDialogPluginComponent } from 'quasar';
import VnInput from 'src/components/common/VnInput.vue'; import VnInput from 'src/components/common/VnInput.vue';
import { useArrayData } from 'composables/useArrayData'; import { useArrayData } from 'composables/useArrayData';
@ -18,10 +18,10 @@ const $props = defineProps({
}); });
const itemsProposal = ref([]); const itemsProposal = ref([]);
const showProposalDialog = ref(false); const showProposalDialog = ref(false);
const { dialogRef, onDialogHide } = useDialogPluginComponent(); // const { dialogRef, onDialogHide } = useDialogPluginComponent();
watch($props.item, (newX, oldX) => { // watch($props.item, (newX, oldX) => {
showProposalDialog.value = !newX; // showProposalDialog.value = !newX;
}); // });
const exprBuilder = (param, value) => { const exprBuilder = (param, value) => {
switch (param) { switch (param) {
default: default:
@ -34,7 +34,7 @@ const arrayData = useArrayData('ItemProposal', {
order: ['itemFk'], order: ['itemFk'],
exprBuilder: exprBuilder, exprBuilder: exprBuilder,
}); });
const store = arrayData.store; // const store = arrayData.store;
const defaultColumnAttrs = { const defaultColumnAttrs = {
align: 'left', align: 'left',
sortable: true, sortable: true,
@ -55,24 +55,43 @@ const applyColumnFilter = async (col) => {
console.error('Error applying column filter', err); console.error('Error applying column filter', err);
} }
}; };
const defaultColumnFilter = { // const defaultColumnFilter = {
component: VnInput, // component: VnInput,
type: 'text', // type: 'text',
filterValue: null, // filterValue: null,
event: getColumnInputEvents, // event: getColumnInputEvents,
attrs: { // attrs: {
dense: true, // dense: true,
}, // },
// };
const statusConditionalValue = (row) => {
const total = [5, 6, 7, 8].reduce((acc, i) => acc + row[`match${i}`], 0);
const STATUS_VALUES = { 2: '$secondary', 3: 'positive', 4: 'warning' };
const status = STATUS_VALUES[total - 2];
if (!status) return 'not-match';
return status;
}; };
const conditionalValue = (tag) => (tag === 1 ? 'match' : 'not-match');
const conditionalValue = (tag) => (tag === 1 ? 'redd' : 'blackd');
const columns = computed(() => [ const columns = computed(() => [
{
...defaultColumnAttrs,
label: t('proposal.counter'),
name: 'counter',
field: 'counter',
},
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
label: t('proposal.itemFk'), label: t('proposal.itemFk'),
name: 'id', name: 'id',
field: 'id', field: 'id',
}, },
{
...defaultColumnAttrs,
label: t('proposal.status'),
name: 'status',
field: 'status',
classes: statusConditionalValue,
},
{ {
...defaultColumnAttrs, ...defaultColumnAttrs,
label: t('proposal.longName'), label: t('proposal.longName'),
@ -201,11 +220,11 @@ const columns = computed(() => [
</QDialog> </QDialog>
</template> </template>
<style lang="scss"> <style lang="scss">
.redd { .match {
background-color: red; color: $negative;
} }
.blackd { .not-match {
color: black; color: inherit;
} }
</style> </style>