fix: poc
This commit is contained in:
parent
0d50944c2d
commit
a03049a721
|
@ -78,11 +78,23 @@ watch(
|
||||||
);
|
);
|
||||||
|
|
||||||
const isLoading = ref(false);
|
const isLoading = ref(false);
|
||||||
|
function eliminarPropiedadesNull(objeto) {
|
||||||
|
for (let clave in objeto) {
|
||||||
|
if (objeto[clave] === null) {
|
||||||
|
delete objeto[clave];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return objeto;
|
||||||
|
}
|
||||||
|
|
||||||
async function search() {
|
async function search() {
|
||||||
isLoading.value = true;
|
isLoading.value = true;
|
||||||
|
const objetoSinNull = eliminarPropiedadesNull(userParams.value);
|
||||||
|
userParams.value = objetoSinNull;
|
||||||
const params = { ...userParams.value };
|
const params = { ...userParams.value };
|
||||||
if (Object.entries(params).length > 0) store.exprBuilder = props.exprBuilder;
|
if (Object.entries(params).length > 0) store.exprBuilder = props.exprBuilder;
|
||||||
|
else delete store.filter.where;
|
||||||
|
store.userParams = userParams.value;
|
||||||
store.userParamsChanged = true;
|
store.userParamsChanged = true;
|
||||||
store.filter.skip = 0;
|
store.filter.skip = 0;
|
||||||
store.skip = 0;
|
store.skip = 0;
|
||||||
|
@ -146,25 +158,26 @@ const customTags = computed(() =>
|
||||||
tagsList.value.filter((tag) => (props.customTags || []).includes(tag.label))
|
tagsList.value.filter((tag) => (props.customTags || []).includes(tag.label))
|
||||||
);
|
);
|
||||||
|
|
||||||
watch(tags, (now, before) => {
|
// watch(tags, (now, before) => {
|
||||||
if (now.length < before.length) {
|
// if (now.length < before.length) {
|
||||||
const beforeMap = before.map(({ label }) => label);
|
// const beforeMap = before.map(({ label }) => label);
|
||||||
const nowMap = now.map(({ label }) => label);
|
// const nowMap = now.map(({ label }) => label);
|
||||||
const key = beforeMap.filter((elemento) => !nowMap.includes(elemento))[0];
|
// const key = beforeMap.filter((elemento) => !nowMap.includes(elemento))[0];
|
||||||
remove(key ?? beforeMap[0]);
|
// remove(key ?? beforeMap[0]);
|
||||||
}
|
// }
|
||||||
console.error('');
|
// console.error('');
|
||||||
});
|
// });
|
||||||
|
|
||||||
async function remove(key) {
|
async function remove(key) {
|
||||||
// userParams.value[key] = null;
|
// userParams.value[key] = null;
|
||||||
delete userParams.value[key];
|
if (userParams.value[key]) delete userParams.value[key];
|
||||||
if (Object.entries(userParams.value).length === 0) {
|
// if (Object.entries(userParams.value).length === 0) {
|
||||||
store.exprBuilder = null;
|
// store.exprBuilder = null;
|
||||||
delete store.filter.where;
|
// delete store.filter.where;
|
||||||
} else {
|
// }
|
||||||
store.exprBuilder = props.exprBuilder;
|
// else {
|
||||||
}
|
// store.exprBuilder = props.exprBuilder;
|
||||||
|
// }
|
||||||
await search();
|
await search();
|
||||||
emit('remove', key);
|
emit('remove', key);
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,17 +24,10 @@ const redirectToItemTypeSummary = (id) => {
|
||||||
const redirectToCreateView = () => {
|
const redirectToCreateView = () => {
|
||||||
router.push({ name: 'ItemTypeCreate' });
|
router.push({ name: 'ItemTypeCreate' });
|
||||||
};
|
};
|
||||||
const exprBuilder = (param, value) => {
|
const exprBuilder = (param, value) => ({
|
||||||
switch (param) {
|
name: { like: `%${value}%` },
|
||||||
case 'name':
|
code: { like: `%${value}%` },
|
||||||
case 'code':
|
});
|
||||||
case 'search':
|
|
||||||
return {
|
|
||||||
name: { like: `%${value}%` },
|
|
||||||
code: { like: `%${value}%` },
|
|
||||||
};
|
|
||||||
}
|
|
||||||
};
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -29,22 +29,12 @@ const emit = defineEmits(['search']);
|
||||||
<template #body="{ params }">
|
<template #body="{ params }">
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput
|
<VnInput :label="t('Name')" v-model="params.name" is-outlined />
|
||||||
@update:model-value="emit('search')"
|
|
||||||
:label="t('Name')"
|
|
||||||
v-model="params.name"
|
|
||||||
is-outlined
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
<QItem>
|
<QItem>
|
||||||
<QItemSection>
|
<QItemSection>
|
||||||
<VnInput
|
<VnInput v-model="params.code" :label="t('Code')" is-outlined />
|
||||||
@update:model-value="emit('search')"
|
|
||||||
v-model="params.code"
|
|
||||||
:label="t('Code')"
|
|
||||||
is-outlined
|
|
||||||
/>
|
|
||||||
</QItemSection>
|
</QItemSection>
|
||||||
</QItem>
|
</QItem>
|
||||||
</template>
|
</template>
|
||||||
|
|
Loading…
Reference in New Issue