0
0
Fork 0

feat: claimList better support vnTable, claimSummary redesign.

BREAKING CHANGE: VnTable default-mode table
This commit is contained in:
Alex Moreno 2024-07-11 15:03:39 +02:00
parent 3a2b27484a
commit 5232df2595
22 changed files with 84 additions and 34 deletions

View File

@ -5,7 +5,7 @@ const model = defineModel({ type: Object, required: true });
const $props = defineProps({ const $props = defineProps({
name: { name: {
type: String, type: String,
required: true, default: '',
}, },
label: { label: {
type: String, type: String,
@ -28,6 +28,7 @@ const hover = ref();
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl }); const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
async function orderBy(name, direction) { async function orderBy(name, direction) {
if (!name) return;
switch (direction) { switch (direction) {
case 'DESC': case 'DESC':
direction = undefined; direction = undefined;
@ -54,7 +55,7 @@ defineExpose({ orderBy });
> >
<span>{{ label }}</span> <span>{{ label }}</span>
<QChip <QChip
v-if="name != 'tableStatus'" v-if="name"
:label="!vertical && model?.index" :label="!vertical && model?.index"
:icon=" :icon="
(model?.index || hover) && !vertical (model?.index || hover) && !vertical

View File

@ -23,7 +23,7 @@ const $props = defineProps({
}, },
defaultMode: { defaultMode: {
type: String, type: String,
default: 'card', // 'table', 'card' default: 'table', // 'table', 'card'
}, },
columnSearch: { columnSearch: {
type: Boolean, type: Boolean,
@ -137,6 +137,10 @@ const rowClickFunction = computed(() => {
}); });
const isTableMode = computed(() => mode.value == TABLE_MODE); const isTableMode = computed(() => mode.value == TABLE_MODE);
const columnsVisibilitySkiped = computed(() => [
...splittedColumns.value.columns.filter((c) => c.visible == false).map((c) => c.name),
...['tableActions'],
]);
function setUserParams(watchedParams) { function setUserParams(watchedParams) {
if (!watchedParams) return; if (!watchedParams) return;
@ -182,6 +186,7 @@ function splitColumns(columns) {
label: t('status'), label: t('status'),
name: 'tableStatus', name: 'tableStatus',
columnFilter: false, columnFilter: false,
orderBy: false,
}); });
} }
} }
@ -259,7 +264,7 @@ defineExpose({
/> />
<VnTableOrder <VnTableOrder
v-model="orders[col.name]" v-model="orders[col.name]"
:name="col.name" :name="col.orderBy ?? col.name"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"
:search-url="searchUrl" :search-url="searchUrl"
:vertical="true" :vertical="true"
@ -321,6 +326,7 @@ defineExpose({
v-if="isTableMode" v-if="isTableMode"
v-model="splittedColumns.columns" v-model="splittedColumns.columns"
:table-code="tableCode ?? route.name" :table-code="tableCode ?? route.name"
:skip="columnsVisibilitySkiped"
/> />
<QBtnToggle <QBtnToggle
v-model="mode" v-model="mode"
@ -355,7 +361,7 @@ defineExpose({
> >
<VnTableOrder <VnTableOrder
v-model="orders[col.name]" v-model="orders[col.name]"
:name="col.name" :name="col.orderBy ?? col.name"
:label="col?.label" :label="col?.label"
:data-key="$attrs['data-key']" :data-key="$attrs['data-key']"
:search-url="searchUrl" :search-url="searchUrl"

View File

@ -12,6 +12,10 @@ const $props = defineProps({
type: String, type: String,
default: '', default: '',
}, },
skip: {
type: Array,
default: () => [],
},
}); });
const { notify } = useNotify(); const { notify } = useNotify();
@ -30,8 +34,12 @@ function setUserConfigViewData(data, isLocal) {
if (!data) return; if (!data) return;
// Importante: El name de las columnas de la tabla debe conincidir con el name de las variables que devuelve la view config // Importante: El name de las columnas de la tabla debe conincidir con el name de las variables que devuelve la view config
if (!isLocal) localColumns.value = []; if (!isLocal) localColumns.value = [];
// Array to Object
const skippeds = $props.skip.reduce((a, v) => ({ ...a, [v]: v }), {});
for (let column of columns.value) { for (let column of columns.value) {
const { label, name } = column; const { label, name } = column;
if (skippeds[name]) continue;
column.visible = data[name] ?? true; column.visible = data[name] ?? true;
if (!isLocal) localColumns.value.push({ name, label, visible: column.visible }); if (!isLocal) localColumns.value.push({ name, label, visible: column.visible });
} }

View File

@ -149,7 +149,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
store.filter = {}; store.filter = {};
if (params) store.userParams = { ...params }; if (params) store.userParams = { ...params };
const response = await fetch({ append: false }); const response = await fetch({});
return response; return response;
} }
@ -162,7 +162,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
store.userParams = userParams; store.userParams = userParams;
arrayDataStore.reset(['skip', 'filter.skip', 'page']); arrayDataStore.reset(['skip', 'filter.skip', 'page']);
await fetch({ append: false }); await fetch({});
return { filter, params }; return { filter, params };
} }
@ -187,7 +187,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
} }
store.order = order; store.order = order;
fetch({ append: false, updateRouter: true }); fetch({});
index++; index++;
return { index, order }; return { index, order };
@ -201,7 +201,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
if (index > -1) order.splice(index, 1); if (index > -1) order.splice(index, 1);
store.order = order; store.order = order;
fetch({ append: false, updateRouter: true }); fetch({});
} }
function sanitizerParams(params, exprBuilder) { function sanitizerParams(params, exprBuilder) {
@ -231,7 +231,7 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
} }
async function refresh() { async function refresh() {
if (Object.values(store.userParams).length) await fetch({ append: false }); if (Object.values(store.userParams).length) await fetch({});
} }
function updateStateParams() { function updateStateParams() {

View File

@ -211,7 +211,7 @@ async function changeState(value) {
> >
<QList> <QList>
<QVirtualScroll <QVirtualScroll
style="max-height: 300px" class="max-container-height"
:items="ClaimStates" :items="ClaimStates"
separator separator
v-slot="{ item, index }" v-slot="{ item, index }"
@ -279,13 +279,13 @@ async function changeState(value) {
<ClaimNotes <ClaimNotes
:id="entityId" :id="entityId"
:add-note="false" :add-note="false"
style="max-height: 300px" class="max-container-height"
order="created ASC" order="created ASC"
/> />
</QCard> </QCard>
<QCard class="vn-two" v-if="claimDms.length > 0"> <QCard class="vn-two" v-if="claimDms?.length">
<VnTitle :url="`#/claim/${entityId}/photos`" :text="t('claim.photos')" /> <VnTitle :url="`#/claim/${entityId}/photos`" :text="t('claim.photos')" />
<div class="container"> <div class="container max-container-height" style="overflow: auto">
<div <div
class="multimedia-container" class="multimedia-container"
v-for="(media, index) of claimDms" v-for="(media, index) of claimDms"
@ -302,7 +302,10 @@ async function changeState(value) {
> >
<QTooltip>Video</QTooltip> <QTooltip>Video</QTooltip>
</QIcon> </QIcon>
<QCard class="multimedia relative-position"> <QCard
class="multimedia relative-position"
style="max-height: 128px"
>
<QImg <QImg
:src="media.url" :src="media.url"
class="rounded-borders cursor-pointer fit" class="rounded-borders cursor-pointer fit"
@ -322,7 +325,7 @@ async function changeState(value) {
</div> </div>
</div> </div>
</QCard> </QCard>
<QCard class="vn-two" v-if="salesClaimed.length > 0"> <QCard class="vn-max" v-if="salesClaimed.length > 0">
<VnTitle :url="`#/claim/${entityId}/lines`" :text="t('claim.details')" /> <VnTitle :url="`#/claim/${entityId}/lines`" :text="t('claim.details')" />
<QTable <QTable
:columns="detailsColumns" :columns="detailsColumns"
@ -361,7 +364,7 @@ async function changeState(value) {
</template> </template>
</QTable> </QTable>
</QCard> </QCard>
<QCard class="vn-two" v-if="developments.length > 0"> <QCard class="vn-max" v-if="developments.length > 0">
<VnTitle :url="claimUrl + 'development'" :text="t('claim.development')" /> <VnTitle :url="claimUrl + 'development'" :text="t('claim.development')" />
<QTable <QTable
:columns="developmentColumns" :columns="developmentColumns"
@ -458,7 +461,7 @@ async function changeState(value) {
gap: 15px; gap: 15px;
} }
.multimedia-container { .multimedia-container {
flex: 1 0 21%; flex: 0 0 128px;
} }
.multimedia { .multimedia {
transition: all 0.5s; transition: all 0.5s;
@ -491,4 +494,8 @@ async function changeState(value) {
.change-state { .change-state {
width: 10%; width: 10%;
} }
.max-container-height {
max-height: 300px;
}
</style> </style>

View File

@ -71,7 +71,6 @@ const columns = [
<VnTable <VnTable
data-key="ClaimEndsTable" data-key="ClaimEndsTable"
url="ClaimEnds/filter" url="ClaimEnds/filter"
default-mode="table"
:right-search="false" :right-search="false"
:column-search="false" :column-search="false"
:disable-option="{ card: true, table: true }" :disable-option="{ card: true, table: true }"

View File

@ -17,6 +17,8 @@ const props = defineProps({
}); });
const states = ref([]); const states = ref([]);
defineExpose({ states });
</script> </script>
<template> <template>

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed } from 'vue'; import { ref, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { toDate } from 'filters/index'; import { toDate } from 'filters/index';
import VnSearchbar from 'components/ui/VnSearchbar.vue'; import VnSearchbar from 'components/ui/VnSearchbar.vue';
@ -14,6 +14,7 @@ import VnTable from 'src/components/VnTable/VnTable.vue';
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const { viewSummary } = useSummaryDialog();
const claimFilterRef = ref();
const columns = computed(() => [ const columns = computed(() => [
{ {
align: 'left', align: 'left',
@ -29,18 +30,38 @@ const columns = computed(() => [
label: t('customer.extendedList.tableVisibleColumns.name'), label: t('customer.extendedList.tableVisibleColumns.name'),
name: 'clientName', name: 'clientName',
isTitle: true, isTitle: true,
visible: false,
}, },
{ {
align: 'left', align: 'left',
label: t('claim.customer'), label: t('claim.customer'),
name: 'clientFk', name: 'clientFk',
cardVisible: true, cardVisible: true,
columnFilter: {
component: 'select',
attrs: {
url: 'Clients',
fields: ['id', 'name'],
},
},
}, },
{ {
align: 'left', align: 'left',
label: t('claim.attendedBy'), label: t('claim.attendedBy'),
name: 'attendedBy', name: 'attendedBy',
cardVisible: true, cardVisible: true,
columnFilter: {
component: 'select',
attrs: {
url: 'Workers/activeWithInheritedRole',
fields: ['id', 'name'],
where: { role: 'salesPerson' },
useLike: false,
optionValue: 'id',
optionLabel: 'name',
optionFilter: 'firstName',
},
},
}, },
{ {
align: 'left', align: 'left',
@ -48,6 +69,9 @@ const columns = computed(() => [
name: 'created', name: 'created',
format: ({ created }) => toDate(created), format: ({ created }) => toDate(created),
cardVisible: true, cardVisible: true,
columnFilter: {
component: 'date',
},
}, },
{ {
align: 'left', align: 'left',
@ -57,6 +81,14 @@ const columns = computed(() => [
condition: () => true, condition: () => true,
color: ({ stateCode }) => STATE_COLOR[stateCode] ?? 'bg-grey', color: ({ stateCode }) => STATE_COLOR[stateCode] ?? 'bg-grey',
}, },
columnFilter: {
name: 'claimStateFk',
component: 'select',
attrs: {
options: claimFilterRef.value?.states,
optionLabel: 'description',
},
},
}, },
{ {
align: 'right', align: 'right',
@ -86,7 +118,7 @@ const STATE_COLOR = {
/> />
<RightMenu> <RightMenu>
<template #right-panel> <template #right-panel>
<ClaimFilter data-key="ClaimList" /> <ClaimFilter data-key="ClaimList" ref="claimFilterRef" />
</template> </template>
</RightMenu> </RightMenu>
<VnTable <VnTable
@ -116,4 +148,9 @@ const STATE_COLOR = {
es: es:
Search claim: Buscar reclamación Search claim: Buscar reclamación
You can search by claim id or customer name: Puedes buscar por id de la reclamación o nombre del cliente You can search by claim id or customer name: Puedes buscar por id de la reclamación o nombre del cliente
params:
stateCode: Estado
en:
params:
stateCode: State
</i18n> </i18n>

View File

@ -405,7 +405,6 @@ function handleLocation(data, location) {
}" }"
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
default-mode="table"
redirect="customer" redirect="customer"
auto-load auto-load
> >

View File

@ -191,7 +191,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
redirect="entry" redirect="entry"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
/> />

View File

@ -199,7 +199,6 @@ onMounted(async () => {
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
redirect="entry" redirect="entry"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
/> />

View File

@ -207,7 +207,6 @@ watchEffect(selectedRows);
v-model:selected="selectedRows" v-model:selected="selectedRows"
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
default-mode="table"
redirect="invoice-out" redirect="invoice-out"
auto-load auto-load
:table="{ :table="{

View File

@ -164,7 +164,6 @@ const downloadCSV = async () => {
" "
:limit="0" :limit="0"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
:is-editable="false" :is-editable="false"
:use-model="true" :use-model="true"

View File

@ -249,7 +249,6 @@ async function confirmOrder() {
data-key="OrderLines" data-key="OrderLines"
url="OrderRows" url="OrderRows"
:columns="columns" :columns="columns"
default-mode="table"
:right-search="false" :right-search="false"
:use-model="true" :use-model="true"
auto-load auto-load

View File

@ -154,7 +154,6 @@ async function fetchClientAddress(id, data) {
}, },
}" }"
:columns="columns" :columns="columns"
default-mode="table"
redirect="order" redirect="order"
auto-load auto-load
> >

View File

@ -78,6 +78,7 @@ const columns = computed(() => [
:columns="columns" :columns="columns"
:right-search="false" :right-search="false"
:use-model="true" :use-model="true"
default-mode="card"
/> />
</template> </template>
<i18n> <i18n>

View File

@ -117,6 +117,7 @@ function downloadPdfs() {
:columns="columns" :columns="columns"
:right-search="true" :right-search="true"
:use-model="true" :use-model="true"
default-mode="card"
/> />
</template> </template>
<style lang="scss" scoped> <style lang="scss" scoped>

View File

@ -237,7 +237,6 @@ const openTicketsDialog = (id) => {
url="Routes/filter" url="Routes/filter"
:columns="columns" :columns="columns"
:right-search="true" :right-search="true"
default-mode="table"
:is-editable="true" :is-editable="true"
:create="{ :create="{
urlCreate: 'Routes', urlCreate: 'Routes',

View File

@ -99,7 +99,6 @@ const columns = computed(() => [
}" }"
order="id ASC" order="id ASC"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
:use-model="true" :use-model="true"

View File

@ -198,7 +198,6 @@ const columns = computed(() => [
}" }"
order="landed DESC" order="landed DESC"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
redirect="travel" redirect="travel"
:is-editable="false" :is-editable="false"

View File

@ -77,7 +77,6 @@ const columns = computed(() => [
}" }"
order="paymentDate DESC" order="paymentDate DESC"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
:is-editable="true" :is-editable="true"

View File

@ -116,7 +116,6 @@ const columns = computed(() => [
}" }"
order="id DESC" order="id DESC"
:columns="columns" :columns="columns"
default-mode="table"
auto-load auto-load
:right-search="false" :right-search="false"
:is-editable="true" :is-editable="true"