forked from verdnatura/salix-front
Merge pull request '7155-travel_daysOnward_2' (!759) from 7155-travel_daysOnward_2 into test
Reviewed-on: verdnatura/salix-front#759 Reviewed-by: Jorge Penadés <jorgep@verdnatura.es>
This commit is contained in:
commit
5f4df6eb96
|
@ -10,8 +10,6 @@ import VnInputDate from 'components/common/VnInputDate.vue';
|
||||||
import VnInputTime from 'components/common/VnInputTime.vue';
|
import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
import VnTableColumn from 'components/VnTable/VnColumn.vue';
|
||||||
|
|
||||||
defineExpose({ addFilter });
|
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
column: {
|
column: {
|
||||||
type: Object,
|
type: Object,
|
||||||
|
@ -30,6 +28,9 @@ const $props = defineProps({
|
||||||
default: 'params',
|
default: 'params',
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
defineExpose({ addFilter, props: $props });
|
||||||
|
|
||||||
const model = defineModel(undefined, { required: true });
|
const model = defineModel(undefined, { required: true });
|
||||||
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
const arrayData = useArrayData($props.dataKey, { searchUrl: $props.searchUrl });
|
||||||
const columnFilter = computed(() => $props.column?.columnFilter);
|
const columnFilter = computed(() => $props.column?.columnFilter);
|
||||||
|
@ -115,11 +116,11 @@ const components = {
|
||||||
rawSelect: selectComponent,
|
rawSelect: selectComponent,
|
||||||
};
|
};
|
||||||
|
|
||||||
async function addFilter(value) {
|
async function addFilter(value, name) {
|
||||||
value ??= undefined;
|
value ??= undefined;
|
||||||
if (value && typeof value === 'object') value = model.value;
|
if (value && typeof value === 'object') value = model.value;
|
||||||
value = value === '' ? undefined : value;
|
value = value === '' ? undefined : value;
|
||||||
let field = columnFilter.value?.name ?? $props.column.name;
|
let field = columnFilter.value?.name ?? $props.column.name ?? name;
|
||||||
|
|
||||||
if (columnFilter.value?.inWhere) {
|
if (columnFilter.value?.inWhere) {
|
||||||
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
if (columnFilter.value.alias) field = columnFilter.value.alias + '.' + field;
|
||||||
|
|
|
@ -98,6 +98,10 @@ const $props = defineProps({
|
||||||
type: String,
|
type: String,
|
||||||
default: '90vh',
|
default: '90vh',
|
||||||
},
|
},
|
||||||
|
chipLocale: {
|
||||||
|
type: String,
|
||||||
|
default: null,
|
||||||
|
},
|
||||||
footer: {
|
footer: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false,
|
default: false,
|
||||||
|
@ -122,6 +126,7 @@ const showForm = ref(false);
|
||||||
const splittedColumns = ref({ columns: [] });
|
const splittedColumns = ref({ columns: [] });
|
||||||
const columnsVisibilitySkipped = ref();
|
const columnsVisibilitySkipped = ref();
|
||||||
const createForm = ref();
|
const createForm = ref();
|
||||||
|
const tableFilterRef = ref([]);
|
||||||
|
|
||||||
const tableModes = [
|
const tableModes = [
|
||||||
{
|
{
|
||||||
|
@ -224,7 +229,7 @@ function splitColumns(columns) {
|
||||||
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
if (col.cardVisible) splittedColumns.value.cardVisible.push(col);
|
||||||
if ($props.isEditable && col.disable == null) col.disable = false;
|
if ($props.isEditable && col.disable == null) col.disable = false;
|
||||||
if ($props.useModel && col.columnFilter != false)
|
if ($props.useModel && col.columnFilter != false)
|
||||||
col.columnFilter = { ...col.columnFilter, inWhere: true };
|
col.columnFilter = { inWhere: true, ...col.columnFilter };
|
||||||
splittedColumns.value.columns.push(col);
|
splittedColumns.value.columns.push(col);
|
||||||
}
|
}
|
||||||
// Status column
|
// Status column
|
||||||
|
@ -326,6 +331,13 @@ function handleOnDataSaved(_) {
|
||||||
:search-url="searchUrl"
|
:search-url="searchUrl"
|
||||||
:redirect="!!redirect"
|
:redirect="!!redirect"
|
||||||
@set-user-params="setUserParams"
|
@set-user-params="setUserParams"
|
||||||
|
:disable-submit-event="true"
|
||||||
|
@remove="
|
||||||
|
(key) =>
|
||||||
|
tableFilterRef
|
||||||
|
.find((f) => f.props?.column.name == key)
|
||||||
|
?.addFilter()
|
||||||
|
"
|
||||||
>
|
>
|
||||||
<template #body>
|
<template #body>
|
||||||
<div
|
<div
|
||||||
|
@ -336,6 +348,7 @@ function handleOnDataSaved(_) {
|
||||||
:key="col.id"
|
:key="col.id"
|
||||||
>
|
>
|
||||||
<VnTableFilter
|
<VnTableFilter
|
||||||
|
ref="tableFilterRef"
|
||||||
:column="col"
|
:column="col"
|
||||||
:data-key="$attrs['data-key']"
|
:data-key="$attrs['data-key']"
|
||||||
v-model="params[columnName(col)]"
|
v-model="params[columnName(col)]"
|
||||||
|
@ -359,10 +372,15 @@ function handleOnDataSaved(_) {
|
||||||
:columns="splittedColumns.columns"
|
:columns="splittedColumns.columns"
|
||||||
/>
|
/>
|
||||||
</template>
|
</template>
|
||||||
|
<template #tags="{ tag, formatFn }" v-if="chipLocale">
|
||||||
|
<div class="q-gutter-x-xs">
|
||||||
|
<strong>{{ t(`${chipLocale}.${tag.label}`) }}: </strong>
|
||||||
|
<span>{{ formatFn(tag.value) }}</span>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</VnFilterPanel>
|
</VnFilterPanel>
|
||||||
</QScrollArea>
|
</QScrollArea>
|
||||||
</QDrawer>
|
</QDrawer>
|
||||||
<!-- class in div to fix warn-->
|
|
||||||
<CrudModel
|
<CrudModel
|
||||||
v-bind="$attrs"
|
v-bind="$attrs"
|
||||||
:class="$attrs['class'] ?? 'q-px-md'"
|
:class="$attrs['class'] ?? 'q-px-md'"
|
||||||
|
|
|
@ -114,9 +114,9 @@ watch(
|
||||||
);
|
);
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
async function search(evt) {
|
async function search() {
|
||||||
try {
|
try {
|
||||||
if (evt && $props.disableSubmitEvent) return;
|
if ($props.disableSubmitEvent) return;
|
||||||
|
|
||||||
store.filter.where = {};
|
store.filter.where = {};
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
@ -167,7 +167,7 @@ const tagsList = computed(() => {
|
||||||
for (const key of Object.keys(userParams.value)) {
|
for (const key of Object.keys(userParams.value)) {
|
||||||
const value = userParams.value[key];
|
const value = userParams.value[key];
|
||||||
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
if (value == null || ($props.hiddenTags || []).includes(key)) continue;
|
||||||
tagList.push({ label: key, value });
|
tagList.push({ label: aliasField(key), value });
|
||||||
}
|
}
|
||||||
return tagList;
|
return tagList;
|
||||||
});
|
});
|
||||||
|
@ -203,6 +203,11 @@ function sanitizer(params) {
|
||||||
}
|
}
|
||||||
return params;
|
return params;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function aliasField(field) {
|
||||||
|
const split = field.split('.');
|
||||||
|
return split[1] ?? split[0];
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -119,10 +119,9 @@ watch(
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => [props.url, props.filter, props.userParams],
|
() => [props.url, props.filter],
|
||||||
([url, filter, userParams]) => mounted.value && fetch({ url, filter, userParams })
|
([url, filter]) => mounted.value && fetch({ url, filter })
|
||||||
);
|
);
|
||||||
|
|
||||||
const addFilter = async (filter, params) => {
|
const addFilter = async (filter, params) => {
|
||||||
await arrayData.addFilter({ filter, params });
|
await arrayData.addFilter({ filter, params });
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,7 +26,8 @@ export function useArrayData(key = useRoute().meta.moduleName, userOptions) {
|
||||||
const params = JSON.parse(query[searchUrl]);
|
const params = JSON.parse(query[searchUrl]);
|
||||||
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
|
const filter = params?.filter && JSON.parse(params?.filter ?? '{}');
|
||||||
delete params.filter;
|
delete params.filter;
|
||||||
store.userParams = { ...params, ...store.userParams };
|
|
||||||
|
store.userParams = { ...store.userParams, ...params };
|
||||||
store.userFilter = { ...filter, ...store.userFilter };
|
store.userFilter = { ...filter, ...store.userFilter };
|
||||||
if (filter?.order) store.order = filter.order;
|
if (filter?.order) store.order = filter.order;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1000,6 +1000,7 @@ travel:
|
||||||
warehouseOut: Warehouse out
|
warehouseOut: Warehouse out
|
||||||
totalEntries: Total entries
|
totalEntries: Total entries
|
||||||
totalEntriesTooltip: Total entries
|
totalEntriesTooltip: Total entries
|
||||||
|
daysOnward: Landed days onwards
|
||||||
summary:
|
summary:
|
||||||
confirmed: Confirmed
|
confirmed: Confirmed
|
||||||
entryId: Entry Id
|
entryId: Entry Id
|
||||||
|
|
|
@ -985,6 +985,7 @@ travel:
|
||||||
warehouseOut: Alm.entrada
|
warehouseOut: Alm.entrada
|
||||||
totalEntries: ∑
|
totalEntries: ∑
|
||||||
totalEntriesTooltip: Entradas totales
|
totalEntriesTooltip: Entradas totales
|
||||||
|
daysOnward: Días de llegada en adelante
|
||||||
summary:
|
summary:
|
||||||
confirmed: Confirmado
|
confirmed: Confirmado
|
||||||
entryId: Id entrada
|
entryId: Id entrada
|
||||||
|
|
|
@ -1,18 +1,14 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref } from 'vue';
|
import { onMounted, ref, computed } from 'vue';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { useRouter } from 'vue-router';
|
import { useRouter, useRoute } from 'vue-router';
|
||||||
import { useRoute } from 'vue-router';
|
|
||||||
import { useStateStore } from 'stores/useStateStore';
|
import { useStateStore } from 'stores/useStateStore';
|
||||||
import VnTable from 'components/VnTable/VnTable.vue';
|
import VnTable from 'components/VnTable/VnTable.vue';
|
||||||
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
|
||||||
import { computed } from 'vue';
|
|
||||||
import TravelSummary from './Card/TravelSummary.vue';
|
import TravelSummary from './Card/TravelSummary.vue';
|
||||||
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
import VnSearchbar from 'components/ui/VnSearchbar.vue';
|
||||||
import { toDate } from 'src/filters';
|
import { toDate } from 'src/filters';
|
||||||
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
|
import { getDateQBadgeColor } from 'src/composables/getDateQBadgeColor.js';
|
||||||
import { dateRange } from 'src/filters';
|
|
||||||
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
|
|
||||||
|
|
||||||
const { viewSummary } = useSummaryDialog();
|
const { viewSummary } = useSummaryDialog();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
@ -30,7 +26,6 @@ const entityId = computed(() => $props.id || route.params.id);
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
stateStore.rightDrawer = true;
|
stateStore.rightDrawer = true;
|
||||||
handleScopeDays();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
const cloneTravel = (travelData) => {
|
const cloneTravel = (travelData) => {
|
||||||
|
@ -38,16 +33,6 @@ const cloneTravel = (travelData) => {
|
||||||
redirectToCreateView(stringifiedTravelData);
|
redirectToCreateView(stringifiedTravelData);
|
||||||
};
|
};
|
||||||
|
|
||||||
function handleScopeDays(days = 7) {
|
|
||||||
days = +days;
|
|
||||||
tableRef.value.params.scopeDays = days;
|
|
||||||
const [landedFrom, landedTo] = dateRange(Date.vnNew());
|
|
||||||
landedTo.setDate(landedTo.getDate() + days);
|
|
||||||
|
|
||||||
tableRef.value.params.landedFrom = landedFrom;
|
|
||||||
tableRef.value.params.landedTo = landedTo;
|
|
||||||
}
|
|
||||||
|
|
||||||
const redirectToCreateView = (queryParams) => {
|
const redirectToCreateView = (queryParams) => {
|
||||||
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
router.push({ name: 'TravelCreate', query: { travelData: queryParams } });
|
||||||
};
|
};
|
||||||
|
@ -173,6 +158,15 @@ const columns = computed(() => [
|
||||||
cardVisible: true,
|
cardVisible: true,
|
||||||
create: true,
|
create: true,
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
align: 'left',
|
||||||
|
name: 'daysOnward',
|
||||||
|
label: t('travel.travelList.tableVisibleColumns.daysOnward'),
|
||||||
|
visible: false,
|
||||||
|
columnFilter: {
|
||||||
|
inWhere: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
{
|
{
|
||||||
align: 'right',
|
align: 'right',
|
||||||
label: '',
|
label: '',
|
||||||
|
@ -219,12 +213,14 @@ const columns = computed(() => [
|
||||||
editorFk: entityId,
|
editorFk: entityId,
|
||||||
},
|
},
|
||||||
}"
|
}"
|
||||||
|
:user-params="{ daysOnward: 7 }"
|
||||||
order="landed DESC"
|
order="landed DESC"
|
||||||
:columns="columns"
|
:columns="columns"
|
||||||
auto-load
|
auto-load
|
||||||
redirect="travel"
|
redirect="travel"
|
||||||
:is-editable="false"
|
:is-editable="false"
|
||||||
:use-model="true"
|
:use-model="true"
|
||||||
|
chip-locale="travel.travelList.tableVisibleColumns"
|
||||||
>
|
>
|
||||||
<template #column-shipped="{ row }">
|
<template #column-shipped="{ row }">
|
||||||
<QBadge
|
<QBadge
|
||||||
|
|
Loading…
Reference in New Issue