ref #5417 params fixed
gitea/salix-front/pipeline/head This commit looks good Details

This commit is contained in:
Jorge Penadés 2023-10-11 12:32:33 +02:00
parent 6d116b9798
commit e5ffd2faad
1 changed files with 7 additions and 7 deletions

View File

@ -33,16 +33,15 @@ const store = arrayData.store;
const userParams = ref({}); const userParams = ref({});
onMounted(() => { onMounted(() => {
if (props.params) userParams.value = props.params; if (props.params) userParams.value = JSON.parse(JSON.stringify(props.params));
const params = store.userParams; if (Object.keys(store.userParams).length > 0) {
if (Object.keys(params).length > 0) { userParams.value = JSON.parse(JSON.stringify(store.userParams));
userParams.value = Object.assign({}, params);
} }
}); });
const isLoading = ref(false); const isLoading = ref(false);
async function search() { async function search() {
const params = userParams.value; const params = JSON.parse(JSON.stringify(userParams.value));
for (const param in params) { for (const param in params) {
if (params[param] === '' || params[param] === null) { if (params[param] === '' || params[param] === null) {
delete userParams.value[param]; delete userParams.value[param];
@ -51,16 +50,17 @@ async function search() {
} }
isLoading.value = true; isLoading.value = true;
await arrayData.addFilter({ params }); await arrayData.addFilter({ params });
if (!props.showAll && !Object.values(store.userParams).length) store.data = []; if (!props.showAll && !Object.values(params).length) store.data = [];
isLoading.value = false; isLoading.value = false;
} }
async function reload() { async function reload() {
isLoading.value = true; isLoading.value = true;
const params = Object.values(userParams.value).filter((param) => param);
await arrayData.fetch({ append: false }); await arrayData.fetch({ append: false });
if (!props.showAll && !Object.values(store.userParams).length) store.data = []; if (!props.showAll && !params.length) store.data = [];
isLoading.value = false; isLoading.value = false;
emit('refresh'); emit('refresh');
} }