0
0
Fork 0

refs #7283 item filters

This commit is contained in:
Carlos Satorres 2024-07-15 14:31:33 +02:00
parent 16b5b5d9a1
commit afbcd2ebda
2 changed files with 91 additions and 63 deletions

View File

@ -7,9 +7,7 @@ import VnImg from 'src/components/ui/VnImg.vue';
import VnTable from 'components/VnTable/VnTable.vue';
import { useStateStore } from 'stores/useStateStore';
import { toDate } from 'src/filters';
import { dashIfEmpty } from 'src/filters';
import axios from 'axios';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
const entityId = computed(() => route.params.id);
const router = useRouter();
@ -104,7 +102,7 @@ const columns = computed(() => [
align: 'left',
component: 'select',
attrs: {
url: 'ItemType',
url: 'ItemTypes',
fields: ['id', 'name'],
},
columnField: {
@ -112,7 +110,6 @@ const columns = computed(() => [
},
create: true,
},
{
label: t('item.list.category'),
field: 'category',
@ -120,14 +117,13 @@ const columns = computed(() => [
align: 'left',
component: 'select',
attrs: {
url: 'ItemCategory',
url: 'ItemCategories',
fields: ['id', 'name'],
},
columnField: {
component: null,
},
},
{
label: t('item.list.intrastat'),
field: 'intrastat',
@ -135,7 +131,7 @@ const columns = computed(() => [
align: 'left',
component: 'select',
attrs: {
url: 'Intrastat',
url: 'Intrastats',
fields: ['id', 'description'],
},
columnField: {
@ -150,7 +146,7 @@ const columns = computed(() => [
align: 'left',
component: 'select',
attrs: {
url: 'Origin',
url: 'Origins',
fields: ['id', 'name'],
},
columnField: {
@ -198,7 +194,7 @@ const columns = computed(() => [
align: 'left',
component: 'select',
attrs: {
url: 'Producer',
url: 'Producers',
fields: ['id', 'name'],
},
columnField: {

View File

@ -1,20 +1,13 @@
<script setup>
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import VnPaginate from 'src/components/ui/VnPaginate.vue';
import VnLv from 'src/components/ui/VnLv.vue';
import CardList from 'src/components/ui/CardList.vue';
import ItemTypeSummary from 'src/pages/ItemType/Card/ItemTypeSummary.vue';
import ItemTypeFilter from 'src/pages/ItemType/ItemTypeFilter.vue';
import { ref, computed } from 'vue';
import ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog';
import RightMenu from 'src/components/common/RightMenu.vue';
import VnTable from 'components/VnTable/VnTable.vue';
const router = useRouter();
const { t } = useI18n();
const { viewSummary } = useSummaryDialog();
const tableRef = ref();
const redirectToItemTypeSummary = (id) => {
router.push({ name: 'ItemTypeSummary', params: { id } });
};
@ -56,52 +49,91 @@ const exprBuilder = (param, value) => {
}
}
};
const columns = computed(() => [
{
align: 'left',
name: 'id',
label: t('id'),
isId: true,
cardVisible: true,
},
{
align: 'left',
name: 'code',
label: t('code'),
isTitle: true,
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'name',
label: t('name'),
cardVisible: true,
create: true,
},
{
align: 'left',
name: 'worker',
label: t('worker'),
create: true,
component: 'select',
attrs: {
url: 'Workers',
fields: ['id', 'firstName'],
},
cardVisible: true,
},
{
align: 'left',
name: 'ItemCategory',
label: t('ItemCategory'),
create: true,
component: 'select',
attrs: {
url: 'ItemCategories',
fields: ['id', 'name'],
},
cardVisible: true,
},
{
align: 'left',
name: 'Temperature',
label: t('Temperature'),
create: true,
component: 'select',
attrs: {
url: 'Temperatures',
fields: ['id', 'name'],
},
cardVisible: true,
},
]);
</script>
<template>
<ItemTypeSearchbar />
<RightMenu>
<template #right-panel>
<ItemTypeFilter data-key="ItemTypeList" />
</template>
</RightMenu>
<QPage class="column items-center q-pa-md">
<div class="vn-card-list">
<VnPaginate
data-key="ItemTypeList"
url="ItemTypes"
:order="['name']"
auto-load
:expr-builder="exprBuilder"
>
<template #body="{ rows }">
<CardList
v-for="row of rows"
:key="row.id"
:title="row.code"
@click="redirectToItemTypeSummary(row.id)"
:id="row.id"
>
<template #list-items>
<VnLv :label="t('Name')" :value="row.name" />
</template>
<template #actions>
<QBtn
:label="t('components.smartCard.openSummary')"
@click.stop="viewSummary(row.id, ItemTypeSummary)"
color="primary"
type="submit"
/>
</template>
</CardList>
</template>
</VnPaginate>
</div>
</QPage>
<QPageSticky :offset="[20, 20]">
<QBtn fab icon="add" color="primary" @click="redirectToCreateView()" />
<QTooltip>
{{ t('New item type') }}
</QTooltip>
</QPageSticky>
<VnTable
ref="tableRef"
data-key="ItemTypeList"
:url="`ItemTypes`"
:url-create="`ItemTypes`"
save-url="ItemTypes/crud"
:filter="courseFilter"
:create="{
urlCreate: 'ItemTypes',
title: 'Create ItemTypes',
onDataSaved: () => tableRef.reload(),
formInitialData: {
workerFk: entityId,
},
}"
order="id DESC"
:columns="columns"
auto-load
:right-search="false"
:is-editable="false"
:use-model="true"
/>
</template>