refs #7283 item filters
gitea/salix-front/pipeline/pr-dev This commit looks good Details

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

View File

@ -1,20 +1,13 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router'; import { useRouter } from 'vue-router';
import { ref, computed } from 'vue';
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 ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue'; import ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue';
import { useSummaryDialog } from 'src/composables/useSummaryDialog'; import VnTable from 'components/VnTable/VnTable.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
const router = useRouter(); const router = useRouter();
const { t } = useI18n(); const { t } = useI18n();
const { viewSummary } = useSummaryDialog(); const tableRef = ref();
const redirectToItemTypeSummary = (id) => { const redirectToItemTypeSummary = (id) => {
router.push({ name: 'ItemTypeSummary', params: { 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> </script>
<template> <template>
<ItemTypeSearchbar /> <ItemTypeSearchbar />
<RightMenu> <VnTable
<template #right-panel> ref="tableRef"
<ItemTypeFilter data-key="ItemTypeList" /> data-key="ItemTypeList"
</template> :url="`ItemTypes`"
</RightMenu> :url-create="`ItemTypes`"
<QPage class="column items-center q-pa-md"> save-url="ItemTypes/crud"
<div class="vn-card-list"> :filter="courseFilter"
<VnPaginate :create="{
data-key="ItemTypeList" urlCreate: 'ItemTypes',
url="ItemTypes" title: 'Create ItemTypes',
:order="['name']" onDataSaved: () => tableRef.reload(),
auto-load formInitialData: {
:expr-builder="exprBuilder" workerFk: entityId,
> },
<template #body="{ rows }"> }"
<CardList order="id DESC"
v-for="row of rows" :columns="columns"
:key="row.id" auto-load
:title="row.code" :right-search="false"
@click="redirectToItemTypeSummary(row.id)" :is-editable="false"
:id="row.id" :use-model="true"
> />
<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>
</template> </template>