0
0
Fork 0

fix(VnTable): refs #6825 VnInputDate

This commit is contained in:
Alex Moreno 2024-05-27 14:36:50 +02:00
parent 88c2af555c
commit a4baa88cb4
5 changed files with 53 additions and 10 deletions

View File

@ -53,7 +53,9 @@ const defaultComponents = {
date: { date: {
component: markRaw(VnInputDate), component: markRaw(VnInputDate),
attrs: { attrs: {
readonly: true,
disable: !$props.isEditable, disable: !$props.isEditable,
style: 'min-width: 125px',
}, },
}, },
checkbox: { checkbox: {

View File

@ -40,6 +40,7 @@ const components = {
class: 'q-px-sm q-pb-xs q-pt-none', class: 'q-px-sm q-pb-xs q-pt-none',
dense: true, dense: true,
filled: !$props.showTitle, filled: !$props.showTitle,
clearable: true,
}, },
forceAttrs: { forceAttrs: {
label: $props.showTitle ? '' : $props.column.label, label: $props.showTitle ? '' : $props.column.label,
@ -50,7 +51,12 @@ const components = {
event: enterEvent, event: enterEvent,
attrs: { attrs: {
dense: true, dense: true,
class: 'q-px-md q-pb-xs q-pt-none', class: 'q-px-sm q-pb-xs q-pt-none',
clearable: true,
filled: !$props.showTitle,
},
forceAttrs: {
label: $props.showTitle ? '' : $props.column.label,
}, },
}, },
date: { date: {
@ -58,7 +64,12 @@ const components = {
event: updateEvent, event: updateEvent,
attrs: { attrs: {
dense: true, dense: true,
class: 'q-px-md q-pb-xs q-pt-none', class: 'q-px-sm q-pb-xs q-pt-none',
filled: !$props.showTitle,
style: 'min-width: 150px',
},
forceAttrs: {
label: $props.showTitle ? '' : $props.column.label,
}, },
}, },
checkbox: { checkbox: {
@ -94,8 +105,8 @@ async function addFilter(value) {
let params = { [field]: value }; let params = { [field]: value };
if (columnFilter.value?.inWhere) { if (columnFilter.value?.inWhere) {
if (columnFilter.value.prefix) field = columnFilter.value.prefix + '.' + field; if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
params = { filter: { where: params } }; params = { filter: { where: { [field]: value } } };
} }
await arrayData.addFilter({ params }); await arrayData.addFilter({ params });
} }

View File

@ -130,6 +130,13 @@ function reload() {
VnPaginateRef.value.fetch(); VnPaginateRef.value.fetch();
} }
function columnName(col) {
const column = Object.assign({}, col, col.columnFilter);
let name = column.name;
if (column.alias) name = column.alias + '.' + name;
return name;
}
defineExpose({ defineExpose({
reload, reload,
redirect: redirectFn, redirect: redirectFn,
@ -156,7 +163,7 @@ defineExpose({
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"
v-for="col of splittedColumns.columns" v-for="col of splittedColumns.columns"
:key="col.id" :key="col.id"
v-model="params[col.columnFilter?.name ?? col.name]" v-model="params[columnName(col)]"
/> />
</template> </template>
<slot <slot
@ -225,7 +232,7 @@ defineExpose({
:column="col" :column="col"
:show-title="true" :show-title="true"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"
v-model="params[col.columnFilter?.name ?? col.name]" v-model="params[columnName(col)]"
/> />
</QTh> </QTh>
</template> </template>
@ -243,7 +250,11 @@ defineExpose({
</template> </template>
<template #body-cell="{ col, row }"> <template #body-cell="{ col, row }">
<!-- Columns --> <!-- Columns -->
<QTd class="no-margin" :class="`text-${col.align ?? 'left'}`"> <QTd
auto-width
class="no-margin q-px-xs"
:class="`text-${col.align ?? 'left'}`"
>
<VnTableColumn <VnTableColumn
:column="col" :column="col"
:row="row" :row="row"
@ -328,7 +339,11 @@ defineExpose({
<span <span
@click="stopEventPropagation($event)" @click="stopEventPropagation($event)"
> >
<VnTableColumn :column="col" :row /> <VnTableColumn
:column="col"
:row
component-prop="columnField"
/>
</span> </span>
</template> </template>
</VnLv> </VnLv>

View File

@ -97,7 +97,7 @@ const styleAttrs = computed(() => {
<QIcon <QIcon
name="close" name="close"
size="xs" size="xs"
v-if="hover && value" v-if="hover && value && !readonly"
@click="onDateUpdate(null)" @click="onDateUpdate(null)"
></QIcon> ></QIcon>
<QIcon name="event" class="cursor-pointer"> <QIcon name="event" class="cursor-pointer">

View File

@ -75,6 +75,7 @@ const columns = computed(() => [
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.credit'), label: t('customer.extendedList.tableVisibleColumns.credit'),
name: 'credit', name: 'credit',
component: 'number',
columnFilter: { columnFilter: {
inWhere: true, inWhere: true,
}, },
@ -83,6 +84,7 @@ const columns = computed(() => [
align: 'left', align: 'left',
label: t('customer.extendedList.tableVisibleColumns.creditInsurance'), label: t('customer.extendedList.tableVisibleColumns.creditInsurance'),
name: 'creditInsurance', name: 'creditInsurance',
component: 'number',
columnFilter: { columnFilter: {
inWhere: true, inWhere: true,
}, },
@ -98,6 +100,10 @@ const columns = computed(() => [
'phone-number': prop.phone, 'phone-number': prop.phone,
}), }),
}, },
component: 'number',
columnField: {
component: null,
},
}, },
{ {
align: 'left', align: 'left',
@ -105,6 +111,7 @@ const columns = computed(() => [
name: 'mobile', name: 'mobile',
cardVisible: true, cardVisible: true,
columnFilter: { columnFilter: {
component: 'number',
inWhere: true, inWhere: true,
}, },
}, },
@ -113,6 +120,9 @@ const columns = computed(() => [
label: t('customer.extendedList.tableVisibleColumns.street'), label: t('customer.extendedList.tableVisibleColumns.street'),
name: 'street', name: 'street',
create: true, create: true,
columnFilter: {
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',
@ -121,7 +131,7 @@ const columns = computed(() => [
columnFilter: { columnFilter: {
component: 'select', component: 'select',
inWhere: true, inWhere: true,
prefix: 'c', alias: 'c',
attrs: { attrs: {
url: 'Countries', url: 'Countries',
}, },
@ -162,6 +172,11 @@ const columns = computed(() => [
label: t('customer.extendedList.tableVisibleColumns.created'), label: t('customer.extendedList.tableVisibleColumns.created'),
name: 'created', name: 'created',
format: ({ created }) => toDate(created), format: ({ created }) => toDate(created),
component: 'date',
columnFilter: {
alias: 'c',
inWhere: true,
},
}, },
{ {
align: 'left', align: 'left',