0
0
Fork 0

fix: itemType redirection and fix filters

This commit is contained in:
Alex Moreno 2024-10-28 09:57:25 +01:00
parent 0537213a58
commit cca255507a
16 changed files with 93 additions and 125 deletions

View File

@ -1,5 +1,5 @@
<script setup> <script setup>
import { computed, defineModel } from 'vue'; import { computed } from 'vue';
const model = defineModel(undefined, { required: true }); const model = defineModel(undefined, { required: true });
const $props = defineProps({ const $props = defineProps({

View File

@ -37,7 +37,7 @@ const $props = defineProps({
}, },
hiddenTags: { hiddenTags: {
type: Array, type: Array,
default: () => ['filter', 'search', 'or', 'and'], default: () => ['filter', 'or', 'and'],
}, },
customTags: { customTags: {
type: Array, type: Array,

View File

@ -1,7 +1,7 @@
<script setup> <script setup>
import VnCard from 'components/common/VnCard.vue'; import VnCard from 'components/common/VnCard.vue';
import ItemTypeDescriptor from 'src/pages/ItemType/Card/ItemTypeDescriptor.vue'; import ItemTypeDescriptor from 'src/pages/Item/ItemType/Card/ItemTypeDescriptor.vue';
import ItemTypeFilter from 'src/pages/ItemType/ItemTypeFilter.vue'; import ItemTypeFilter from 'src/pages/Item/ItemType/ItemTypeFilter.vue';
import ItemTypeSearchbar from '../ItemTypeSearchbar.vue'; import ItemTypeSearchbar from '../ItemTypeSearchbar.vue';
</script> </script>
<template> <template>

View File

@ -12,6 +12,39 @@ const props = defineProps({
}); });
const emit = defineEmits(['search']); const emit = defineEmits(['search']);
const exprBuilder = (param, value) => {
switch (param) {
case 'name':
return {
name: { like: `%${value}%` },
};
case 'code':
return {
code: { like: `%${value}%` },
};
case 'search':
if (value) {
if (!isNaN(value)) {
return { id: value };
} else {
return {
or: [
{
name: {
like: `%${value}%`,
},
},
{
code: {
like: `%${value}%`,
},
},
],
};
}
}
}
};
</script> </script>
<template> <template>
@ -19,6 +52,8 @@ const emit = defineEmits(['search']);
:data-key="props.dataKey" :data-key="props.dataKey"
:search-button="true" :search-button="true"
@search="emit('search')" @search="emit('search')"
search-url="table"
:expr-builder="exprBuilder"
> >
<template #tags="{ tag, formatFn }"> <template #tags="{ tag, formatFn }">
<div class="q-gutter-x-xs"> <div class="q-gutter-x-xs">

View File

@ -10,6 +10,7 @@ const { t } = useI18n();
url="ItemTypes" url="ItemTypes"
:label="t('Search item type')" :label="t('Search item type')"
:info="t('Search itemType by id, name or code')" :info="t('Search itemType by id, name or code')"
search-url="table"
/> />
</template> </template>
<i18n> <i18n>

View File

@ -1,98 +0,0 @@
<script setup>
import { reactive, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { useRouter } from 'vue-router';
import FetchData from 'components/FetchData.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
import FormModel from 'components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSubToolbar from 'src/components/ui/VnSubToolbar.vue';
const { t } = useI18n();
const router = useRouter();
const newItemTypeForm = reactive({});
const categoriesOptions = ref([]);
const temperaturesOptions = ref([]);
const redirectToItemTypeBasicData = (_, { id }) => {
router.push({ name: 'ItemTypeBasicData', params: { id } });
};
</script>
<template>
<FetchData
url="ItemCategories"
@on-fetch="(data) => (categoriesOptions = data)"
:filter="{ order: 'name ASC', fields: ['id', 'name'] }"
auto-load
/>
<FetchData
url="Temperatures"
@on-fetch="(data) => (temperaturesOptions = data)"
:filter="{ order: 'name ASC', fields: ['code', 'name'] }"
auto-load
/>
<QPage>
<VnSubToolbar />
<FormModel
url-create="ItemTypes"
model="itemTypeCreate"
:form-initial-data="newItemTypeForm"
observe-form-changes
@on-data-saved="redirectToItemTypeBasicData"
>
<template #form="{ data }">
<VnRow>
<VnInput v-model="data.code" :label="t('itemType.shared.code')" />
<VnInput v-model="data.name" :label="t('itemType.shared.name')" />
</VnRow>
<VnRow>
<VnSelect
url="Workers/search"
v-model="data.workerFk"
:label="t('shared.worker')"
sort-by="nickname ASC"
:fields="['id', 'nickname']"
:params="{ departmentCodes: ['shopping'] }"
option-label="nickname"
option-value="id"
hide-selected
><template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption
>{{ scope.opt?.nickname }},
{{ scope.opt?.code }}</QItemLabel
>
</QItemSection>
</QItem>
</template>
</VnSelect>
<VnSelect
v-model="data.categoryFk"
:label="t('itemType.shared.category')"
:options="categoriesOptions"
option-value="id"
option-label="name"
hide-selected
/>
</VnRow>
<VnRow>
<VnSelect
v-model="data.temperatureFk"
:label="t('itemType.shared.temperature')"
:options="temperaturesOptions"
option-value="code"
option-label="name"
hide-selected
/>
</VnRow>
</template>
</FormModel>
</QPage>
</template>

View File

@ -1,13 +1,16 @@
<script setup> <script setup>
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { ref, computed } from 'vue'; import { ref, computed } from 'vue';
import ItemTypeSearchbar from '../ItemType/ItemTypeSearchbar.vue'; import ItemTypeSearchbar from 'src/pages/Item/ItemType/ItemTypeSearchbar.vue';
import VnTable from 'components/VnTable/VnTable.vue'; import VnTable from 'components/VnTable/VnTable.vue';
import FetchData from 'components/FetchData.vue'; import FetchData from 'components/FetchData.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import ItemTypeFilter from './ItemType/ItemTypeFilter.vue';
const { t } = useI18n(); const { t } = useI18n();
const tableRef = ref(); const tableRef = ref();
const ItemCategoriesOptions = ref([]); const itemCategoriesOptions = ref([]);
const temperatureOptions = ref([]);
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -34,7 +37,6 @@ const columns = computed(() => [
}, },
{ {
align: 'left', align: 'left',
name: 'workerFk',
label: t('worker'), label: t('worker'),
create: true, create: true,
component: 'select', component: 'select',
@ -45,6 +47,19 @@ const columns = computed(() => [
}, },
cardVisible: true, cardVisible: true,
visible: true, visible: true,
columnField: {
component: 'userLink',
attrs: ({ row }) => {
return {
workerId: row?.worker?.id,
name: row.worker?.user?.name,
defaultName: true,
};
},
},
columnFilter: {
name: 'workerFk',
},
}, },
{ {
align: 'left', align: 'left',
@ -53,9 +68,7 @@ const columns = computed(() => [
create: true, create: true,
component: 'select', component: 'select',
attrs: { attrs: {
options: ItemCategoriesOptions.value, options: itemCategoriesOptions.value,
fields: ['id', 'name'],
order: 'name ASC',
}, },
cardVisible: false, cardVisible: false,
visible: false, visible: false,
@ -67,8 +80,7 @@ const columns = computed(() => [
create: true, create: true,
component: 'select', component: 'select',
attrs: { attrs: {
url: 'Temperatures', options: temperatureOptions.value,
fields: ['id', 'name'],
}, },
cardVisible: false, cardVisible: false,
visible: false, visible: false,
@ -80,26 +92,52 @@ const columns = computed(() => [
<FetchData <FetchData
url="ItemCategories" url="ItemCategories"
:filter="{ fields: ['id', 'name'], order: ['name ASC'] }" :filter="{ fields: ['id', 'name'], order: ['name ASC'] }"
@on-fetch="(data) => (ItemCategoriesOptions = data)" @on-fetch="(data) => (itemCategoriesOptions = data)"
auto-load auto-load
/> />
<FetchData
url="Temperatures"
:filter="{ fields: ['id', 'name'], order: ['name ASC'] }"
@on-fetch="(data) => (temperatureOptions = data)"
auto-load
/>
<RightMenu>
<template #right-panel>
<ItemTypeFilter data-key="ItemTypeList" />
</template>
</RightMenu>
<ItemTypeSearchbar /> <ItemTypeSearchbar />
<VnTable <VnTable
ref="tableRef" ref="tableRef"
data-key="ItemTypeList" data-key="ItemTypeList"
:url="`ItemTypes`" url="ItemTypes"
:create="{ :create="{
urlCreate: 'ItemTypes', urlCreate: 'ItemTypes',
title: t('Create ItemTypes'), title: t('Create ItemTypes'),
onDataSaved: () => tableRef.reload(), onDataSaved: () => tableRef.reload(),
formInitialData: {}, formInitialData: {},
}" }"
:user-filter="{
include: {
relation: 'worker',
scope: {
fields: ['id'],
include: {
relation: 'user',
scope: {
fields: ['id', 'name'],
},
},
},
},
}"
order="name ASC" order="name ASC"
:columns="columns" :columns="columns"
auto-load auto-load
:right-search="false" :right-search="false"
:is-editable="false" :is-editable="false"
:use-model="true" :use-model="true"
redirect="item/item-type"
/> />
</template> </template>

View File

@ -348,7 +348,6 @@ async function hasDocuware() {
} }
async function uploadDocuware(force) { async function uploadDocuware(force) {
console.log('force: ', force);
if (!force) if (!force)
return quasar return quasar
.dialog({ .dialog({

View File

@ -97,14 +97,6 @@ export default {
}, },
component: () => import('src/pages/Item/ItemTypeList.vue'), component: () => import('src/pages/Item/ItemTypeList.vue'),
}, },
{
path: 'item-type-list/create',
name: 'ItemTypeCreate',
meta: {
title: 'itemTypeCreate',
},
component: () => import('src/pages/Item/ItemTypeCreate.vue'),
},
], ],
}, },
{ {

View File

@ -18,7 +18,7 @@ export default {
{ {
name: 'ItemTypeCard', name: 'ItemTypeCard',
path: ':id', path: ':id',
component: () => import('src/pages/ItemType/Card/ItemTypeCard.vue'), component: () => import('src/pages/Item/ItemType/Card/ItemTypeCard.vue'),
redirect: { name: 'ItemTypeSummary' }, redirect: { name: 'ItemTypeSummary' },
children: [ children: [
{ {
@ -28,7 +28,7 @@ export default {
title: 'summary', title: 'summary',
}, },
component: () => component: () =>
import('src/pages/ItemType/Card/ItemTypeSummary.vue'), import('src/pages/Item/ItemType/Card/ItemTypeSummary.vue'),
}, },
{ {
name: 'ItemTypeBasicData', name: 'ItemTypeBasicData',
@ -38,7 +38,7 @@ export default {
icon: 'vn:settings', icon: 'vn:settings',
}, },
component: () => component: () =>
import('src/pages/ItemType/Card/ItemTypeBasicData.vue'), import('src/pages/Item/ItemType/Card/ItemTypeBasicData.vue'),
}, },
{ {
path: 'log', path: 'log',
@ -47,7 +47,8 @@ export default {
title: 'log', title: 'log',
icon: 'vn:History', icon: 'vn:History',
}, },
component: () => import('src/pages/ItemType/Card/ItemTypeLog.vue'), component: () =>
import('src/pages/Item/ItemType/Card/ItemTypeLog.vue'),
}, },
], ],
}, },