forked from verdnatura/salix-front
Merge branch 'dev' into feature/ItemFamily
This commit is contained in:
commit
9a840c9cee
|
@ -1 +1,94 @@
|
|||
<template>Item barcode</template>
|
||||
<script setup>
|
||||
import { ref, onMounted, nextTick } from 'vue';
|
||||
import { useRoute } from 'vue-router';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
|
||||
const route = useRoute();
|
||||
const { t } = useI18n();
|
||||
|
||||
const itemBarcodeRef = ref(null);
|
||||
|
||||
const insertRow = () => {
|
||||
itemBarcodeRef.value.insert();
|
||||
focusLastInput();
|
||||
};
|
||||
|
||||
const focusLastInput = () => {
|
||||
nextTick(() => {
|
||||
const inputs = document.querySelectorAll('[focusable-input]');
|
||||
const lastInput = inputs[inputs.length - 1];
|
||||
if (lastInput) lastInput.focus();
|
||||
});
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
if (itemBarcodeRef.value) itemBarcodeRef.value.reload();
|
||||
});
|
||||
</script>
|
||||
<template>
|
||||
<div class="full-width flex justify-center">
|
||||
<QPage class="card-width q-pa-lg">
|
||||
<CrudModel
|
||||
:data-required="{ itemFk: route.params.id }"
|
||||
:default-remove="false"
|
||||
:filter="{
|
||||
fields: ['id', 'itemFk', 'code'],
|
||||
where: { itemFk: route.params.id },
|
||||
}"
|
||||
data-key="ItemBarcodes"
|
||||
model="ItemBarcodes"
|
||||
ref="itemBarcodeRef"
|
||||
url="ItemBarcodes"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
<QCard class="q-px-lg q-py-md">
|
||||
<div
|
||||
v-for="(row, index) in rows"
|
||||
:key="index"
|
||||
class="q-mb-md full-width row items-center no-wrap"
|
||||
>
|
||||
<VnInput
|
||||
:label="t('Code')"
|
||||
v-model="row.code"
|
||||
class="full-width"
|
||||
focusable-input
|
||||
/>
|
||||
<QIcon
|
||||
@click="itemBarcodeRef.remove([row])"
|
||||
class="cursor-pointer q-ml-md"
|
||||
color="primary"
|
||||
name="delete"
|
||||
size="sm"
|
||||
>
|
||||
<QTooltip class="text-no-wrap">
|
||||
{{ t('Remove barcode') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</div>
|
||||
<QIcon
|
||||
@click="insertRow()"
|
||||
class="cursor-pointer fill-icon-on-hover"
|
||||
color="primary"
|
||||
name="add_circle"
|
||||
size="sm"
|
||||
>
|
||||
<QTooltip>
|
||||
{{ t('Add barcode') }}
|
||||
</QTooltip>
|
||||
</QIcon>
|
||||
</QCard>
|
||||
</template>
|
||||
</CrudModel>
|
||||
</QPage>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
es:
|
||||
Code: Código
|
||||
Remove barcode: Quitar código de barras
|
||||
Add barcode: Añadir código de barras
|
||||
</i18n>
|
||||
|
|
|
@ -177,14 +177,27 @@ const openCloneDialog = async () => {
|
|||
<VnLv :label="t('item.descriptor.buyer')">
|
||||
<template #value>
|
||||
<span class="link">
|
||||
{{ t('item.descriptor.buyer') }}
|
||||
{{ entity.itemType?.worker?.user?.name }}
|
||||
<WorkerDescriptorProxy :id="entity.itemType?.worker?.id" />
|
||||
</span>
|
||||
</template>
|
||||
</VnLv>
|
||||
<VnLv :label="t('item.descriptor.color')" :value="entity.value5"> </VnLv>
|
||||
<VnLv :label="t('item.descriptor.color')" :value="entity.value6" />
|
||||
<VnLv :label="t('item.descriptor.stems')" :value="entity.value7" />
|
||||
<VnLv
|
||||
v-if="entity.value5"
|
||||
:label="t('item.descriptor.color')"
|
||||
:value="entity.value5"
|
||||
>
|
||||
</VnLv>
|
||||
<VnLv
|
||||
v-if="entity.value6"
|
||||
:label="t('item.descriptor.category')"
|
||||
:value="entity.value6"
|
||||
/>
|
||||
<VnLv
|
||||
v-if="entity.value7"
|
||||
:label="t('item.descriptor.stems')"
|
||||
:value="entity.value7"
|
||||
/>
|
||||
</template>
|
||||
<template #actions="{}">
|
||||
<QCardActions class="row justify-center">
|
||||
|
|
|
@ -12,6 +12,7 @@ import ItemDescriptorProxy from '../Item/Card/ItemDescriptorProxy.vue';
|
|||
import WorkerDescriptorProxy from 'src/pages/Worker/Card/WorkerDescriptorProxy.vue';
|
||||
import ItemSummary from '../Item/Card/ItemSummary.vue';
|
||||
import VnPaginate from 'components/ui/VnPaginate.vue';
|
||||
import ItemListFilter from './ItemListFilter.vue';
|
||||
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
import { toDateFormat } from 'src/filters/date.js';
|
||||
|
@ -69,7 +70,7 @@ const exprBuilder = (param, value) => {
|
|||
}
|
||||
};
|
||||
|
||||
const params = reactive({});
|
||||
const params = reactive({ isFloramondo: false, isActive: true });
|
||||
|
||||
const applyColumnFilter = async (col) => {
|
||||
try {
|
||||
|
@ -442,6 +443,11 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
|||
<QSpace />
|
||||
<div id="st-actions"></div>
|
||||
</QToolbar>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="256" show-if-above>
|
||||
<QScrollArea class="fit text-grey-8">
|
||||
<ItemListFilter data-key="ItemList" />
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<QPage class="column items-center q-pa-md">
|
||||
<VnPaginate
|
||||
ref="paginateRef"
|
||||
|
|
|
@ -0,0 +1,460 @@
|
|||
<script setup>
|
||||
import { ref } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { onMounted } from 'vue';
|
||||
import { useStateStore } from 'stores/useStateStore';
|
||||
|
||||
import FetchData from 'components/FetchData.vue';
|
||||
import VnFilterPanel from 'src/components/ui/VnFilterPanel.vue';
|
||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||
import VnInput from 'src/components/common/VnInput.vue';
|
||||
import { QCheckbox } from 'quasar';
|
||||
|
||||
import { useArrayData } from 'composables/useArrayData';
|
||||
import { useValidator } from 'src/composables/useValidator';
|
||||
import axios from 'axios';
|
||||
|
||||
const { t } = useI18n();
|
||||
|
||||
const props = defineProps({
|
||||
dataKey: {
|
||||
type: String,
|
||||
required: true,
|
||||
},
|
||||
});
|
||||
|
||||
const stateStore = useStateStore();
|
||||
const validationsStore = useValidator();
|
||||
|
||||
const itemTypesRef = ref(null);
|
||||
const categoriesOptions = ref([]);
|
||||
const itemTypesOptions = ref([]);
|
||||
const buyersOptions = ref([]);
|
||||
const suppliersOptions = ref([]);
|
||||
const tagValues = ref([]);
|
||||
const fieldFiltersValues = ref([]);
|
||||
const moreFields = ref([]);
|
||||
|
||||
const arrayData = useArrayData(props.dataKey);
|
||||
const itemTypesFilter = {
|
||||
fields: ['id', 'name', 'categoryFk'],
|
||||
include: 'category',
|
||||
order: 'name ASC',
|
||||
where: {},
|
||||
};
|
||||
|
||||
const onCategoryChange = async (categoryFk, search) => {
|
||||
if (!categoryFk) {
|
||||
itemTypesFilter.where.categoryFk = null;
|
||||
delete itemTypesFilter.where.categoryFk;
|
||||
} else {
|
||||
itemTypesFilter.where.categoryFk = categoryFk;
|
||||
}
|
||||
search();
|
||||
await itemTypesRef.value.fetch();
|
||||
};
|
||||
|
||||
const getSelectedTagValues = async (tag) => {
|
||||
try {
|
||||
tag.value = null;
|
||||
const filter = {
|
||||
fields: ['value'],
|
||||
order: 'value ASC',
|
||||
};
|
||||
|
||||
const params = { filter: JSON.stringify(filter) };
|
||||
const { data } = await axios.get(`Tags/${tag.selectedTag.id}/filterValue`, {
|
||||
params,
|
||||
});
|
||||
tag.valueOptions = data;
|
||||
} catch (err) {
|
||||
console.error('Error getting selected tag values');
|
||||
}
|
||||
};
|
||||
|
||||
const applyTags = (params, search) => {
|
||||
params.tags = tagValues.value
|
||||
.filter((tag) => tag.selectedTag && tag.value)
|
||||
.map((tag) => ({
|
||||
tagFk: tag.selectedTag.id,
|
||||
tagName: tag.selectedTag.name,
|
||||
value: tag.value,
|
||||
}));
|
||||
search();
|
||||
};
|
||||
|
||||
const removeTag = (index, params, search) => {
|
||||
(tagValues.value || []).splice(index, 1);
|
||||
applyTags(params, search);
|
||||
};
|
||||
|
||||
const applyFieldFilters = (params) => {
|
||||
fieldFiltersValues.value.forEach((fieldFilter) => {
|
||||
if (
|
||||
fieldFilter.selectedField &&
|
||||
(fieldFilter.value !== null ||
|
||||
fieldFilter.value !== '' ||
|
||||
fieldFilter.value !== undefined)
|
||||
) {
|
||||
params[fieldFilter.name] = fieldFilter.value;
|
||||
}
|
||||
});
|
||||
arrayData.applyFilter({ params });
|
||||
};
|
||||
|
||||
const removeFieldFilter = (index, params, search) => {
|
||||
delete params[fieldFiltersValues.value[index].name];
|
||||
(fieldFiltersValues.value || []).splice(index, 1);
|
||||
applyFieldFilters(params, search);
|
||||
};
|
||||
|
||||
onMounted(async () => {
|
||||
stateStore.rightDrawer = true;
|
||||
if (arrayData.store?.userParams?.categoryFk)
|
||||
itemTypesFilter.where.categoryFk = arrayData.store?.userParams?.categoryFk;
|
||||
await itemTypesRef.value.fetch();
|
||||
const { models } = validationsStore;
|
||||
const properties = models.Item?.properties || {};
|
||||
|
||||
const _moreFields = ['id', 'description', 'name', 'isActive'];
|
||||
|
||||
_moreFields.forEach((field) => {
|
||||
let prop = properties[field];
|
||||
const label = t(`params.${field}`);
|
||||
moreFields.value.push({
|
||||
name: field,
|
||||
label,
|
||||
type: prop ? prop.type : null,
|
||||
});
|
||||
});
|
||||
|
||||
// Fill fieldFiltersValues with existent userParams
|
||||
if (arrayData.store?.userParams) {
|
||||
fieldFiltersValues.value = Object.entries(arrayData.store?.userParams)
|
||||
.filter(([key, value]) => value && _moreFields.includes(key))
|
||||
.map(([key, value]) => ({
|
||||
name: key,
|
||||
value,
|
||||
selectedField: moreFields.value.find((field) => field.name === key),
|
||||
}));
|
||||
}
|
||||
});
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<FetchData
|
||||
url="ItemCategories"
|
||||
:filter="{ fields: ['id', 'name'], order: 'name ASC' }"
|
||||
@on-fetch="(data) => (categoriesOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
ref="itemTypesRef"
|
||||
url="ItemTypes"
|
||||
:filter="itemTypesFilter"
|
||||
@on-fetch="(data) => (itemTypesOptions = data)"
|
||||
/>
|
||||
<FetchData
|
||||
url="TicketRequests/getItemTypeWorker"
|
||||
:filter="{ fields: ['id', 'nickname'], order: 'nickname ASC' }"
|
||||
@on-fetch="(data) => (buyersOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="Suppliers"
|
||||
:filter="{ fields: ['id', 'name', 'nickname'], order: 'name ASC' }"
|
||||
@on-fetch="(data) => (suppliersOptions = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="Tags"
|
||||
:filter="{ fields: ['id', 'name', 'isFree'] }"
|
||||
auto-load
|
||||
@on-fetch="(data) => (tagOptions = data)"
|
||||
/>
|
||||
<VnFilterPanel
|
||||
:data-key="props.dataKey"
|
||||
:search-button="true"
|
||||
:hidden-tags="tagValues.length === 0 ? ['tags'] : []"
|
||||
>
|
||||
<template #tags="{ tag, formatFn }">
|
||||
<div>
|
||||
<strong>{{ t(`params.${tag.label}`) }}</strong>
|
||||
<span v-if="tag.label !== 'tags'">: {{ formatFn(tag.value) }}</span>
|
||||
</div>
|
||||
</template>
|
||||
<template #body="{ params, searchFn }">
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnInput
|
||||
v-model="params.search"
|
||||
:label="t('params.search')"
|
||||
is-outlined
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('params.categoryFk')"
|
||||
v-model="params.categoryFk"
|
||||
@update:model-value="
|
||||
($event) => onCategoryChange($event, searchFn)
|
||||
"
|
||||
:options="categoriesOptions"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('params.typeFk')"
|
||||
v-model="params.typeFk"
|
||||
@update:model-value="searchFn()"
|
||||
:options="itemTypesOptions"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
|
||||
<QItemLabel caption>{{
|
||||
scope.opt?.category?.name
|
||||
}}</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('params.buyerFk')"
|
||||
v-model="params.buyerFk"
|
||||
@update:model-value="searchFn()"
|
||||
:options="buyersOptions"
|
||||
option-value="id"
|
||||
option-label="nickname"
|
||||
hide-selected
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<VnSelect
|
||||
:label="t('params.supplierFk')"
|
||||
v-model="params.supplierFk"
|
||||
@update:model-value="searchFn()"
|
||||
:options="suppliersOptions"
|
||||
option-value="id"
|
||||
option-label="name"
|
||||
hide-selected
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
<QItemSection>
|
||||
<QItemLabel>{{
|
||||
scope.opt?.name + ': ' + scope.opt?.nickname
|
||||
}}</QItemLabel>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnSelect>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
<!-- Tags filter -->
|
||||
<QItem class="row items-center">
|
||||
<QItemLabel>
|
||||
{{ t('params.tags') }}
|
||||
</QItemLabel>
|
||||
<QIcon
|
||||
name="add_circle"
|
||||
class="fill-icon-on-hover q-ml-md"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="tagValues.push({})"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-for="(tag, index) in tagValues"
|
||||
:key="index"
|
||||
class="row items-center"
|
||||
>
|
||||
<QItemSection class="col">
|
||||
<VnSelect
|
||||
:label="t('params.tag')"
|
||||
v-model="tag.selectedTag"
|
||||
:options="tagOptions"
|
||||
option-label="name"
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
:emit-value="false"
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
@update:model-value="getSelectedTagValues(tag)"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection class="col">
|
||||
<VnSelect
|
||||
v-if="!tag?.selectedTag?.isFree && tag.valueOptions"
|
||||
:label="t('params.tag')"
|
||||
v-model="tag.value"
|
||||
:options="tag.valueOptions || []"
|
||||
option-value="value"
|
||||
option-label="value"
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
emit-value
|
||||
use-input
|
||||
:disable="!tag"
|
||||
:is-clearable="false"
|
||||
@update:model-value="applyTags(params, searchFn)"
|
||||
/>
|
||||
<VnInput
|
||||
v-else
|
||||
v-model="tag.value"
|
||||
:label="t('params.value')"
|
||||
:disable="!tag"
|
||||
is-outlined
|
||||
:is-clearable="false"
|
||||
@keydown.enter.prevent="applyTags(params, searchFn)"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QIcon
|
||||
name="delete"
|
||||
class="fill-icon-on-hover q-ml-xs"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="removeTag(index, params, searchFn)"
|
||||
/>
|
||||
</QItem>
|
||||
<!-- Filter fields -->
|
||||
<QItem class="row items-center">
|
||||
<QItemLabel>
|
||||
{{ t('More fields') }}
|
||||
</QItemLabel>
|
||||
<QIcon
|
||||
name="add_circle"
|
||||
class="fill-icon-on-hover q-ml-md"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="fieldFiltersValues.push({})"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem
|
||||
v-for="(fieldFilter, index) in fieldFiltersValues"
|
||||
:key="index"
|
||||
class="row items-center"
|
||||
>
|
||||
<QItemSection class="col">
|
||||
<VnSelect
|
||||
:label="t('params.tag')"
|
||||
:model-value="fieldFilter.selectedField"
|
||||
:options="moreFields"
|
||||
option-label="label"
|
||||
dense
|
||||
outlined
|
||||
rounded
|
||||
:emit-value="false"
|
||||
use-input
|
||||
:is-clearable="false"
|
||||
@update:model-value="
|
||||
($event) => {
|
||||
fieldFilter.name = $event.name;
|
||||
fieldFilter.value = null;
|
||||
fieldFilter.selectedField = $event;
|
||||
}
|
||||
"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QItemSection class="col">
|
||||
<QCheckbox
|
||||
v-if="fieldFilter.selectedField?.type === 'boolean'"
|
||||
v-model="fieldFilter.value"
|
||||
:label="t('params.value')"
|
||||
@update:model-value="applyFieldFilters(params, searchFn)"
|
||||
/>
|
||||
<VnInput
|
||||
v-else
|
||||
v-model="fieldFilter.value"
|
||||
:label="t('params.value')"
|
||||
:disable="!fieldFilter.selectedField"
|
||||
is-outlined
|
||||
@keydown.enter="applyFieldFilters(params, searchFn)"
|
||||
/>
|
||||
</QItemSection>
|
||||
<QIcon
|
||||
name="delete"
|
||||
class="fill-icon-on-hover q-ml-xs"
|
||||
size="sm"
|
||||
color="primary"
|
||||
@click="removeFieldFilter(index, params, searchFn)"
|
||||
/>
|
||||
</QItem>
|
||||
<QItem>
|
||||
<QItemSection>
|
||||
<QCheckbox
|
||||
:label="t('params.isFloramondo')"
|
||||
v-model="params.isFloramondo"
|
||||
toggle-indeterminate
|
||||
@update:model-value="searchFn()"
|
||||
/>
|
||||
</QItemSection>
|
||||
</QItem>
|
||||
</template>
|
||||
</VnFilterPanel>
|
||||
</template>
|
||||
|
||||
<i18n>
|
||||
en:
|
||||
params:
|
||||
search: General search
|
||||
categoryFk: Category
|
||||
typeFk: Type
|
||||
buyerFk: Buyer
|
||||
supplierFk: Supplier
|
||||
tags: Tags
|
||||
tag: Tag
|
||||
value: Value
|
||||
isFloramondo: Floramondo
|
||||
isActive: Active
|
||||
description: Description
|
||||
name: Name
|
||||
id: Id
|
||||
es:
|
||||
More fields: Más campos
|
||||
params:
|
||||
search: Búsqueda general
|
||||
categoryFk: Reino
|
||||
typeFk: Tipo
|
||||
buyerFk: Comprador
|
||||
supplierFk: Proveedor
|
||||
tags: Etiquetas
|
||||
tag: Etiqueta
|
||||
value: Valor
|
||||
isFloramondo: Floramondo
|
||||
isActive: Activo
|
||||
description: Descripción
|
||||
name: Nombre
|
||||
id: Id
|
||||
</i18n>
|
Loading…
Reference in New Issue