diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index a0f6bf479..22ef1622c 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -87,6 +87,10 @@ const $props = defineProps({ type: Boolean, default: false, }, + defaultTrim: { + type: Boolean, + default: true, + }, }); const emit = defineEmits(['onFetch', 'onDataSaved']); const modelValue = computed( @@ -195,6 +199,7 @@ async function save() { isLoading.value = true; try { + formData.value = trimData(formData.value); const body = $props.mapper ? $props.mapper(formData.value) : formData.value; const method = $props.urlCreate ? 'post' : 'patch'; const url = @@ -253,6 +258,14 @@ function updateAndEmit(evt, val, res) { emit(evt, state.get(modelValue), res); } +function trimData(data) { + if (!$props.defaultTrim) return data; + for (const key in data) { + if (typeof data[key] == 'string') data[key] = data[key].trim(); + } + return data; +} + defineExpose({ save, isLoading, diff --git a/src/components/VnTable/VnTable.vue b/src/components/VnTable/VnTable.vue index d6b35d4da..6c77d44df 100644 --- a/src/components/VnTable/VnTable.vue +++ b/src/components/VnTable/VnTable.vue @@ -315,7 +315,7 @@ defineExpose({ col?.columnFilter !== false && col?.name !== 'tableActions' " - v-model="orders[col.name]" + v-model="orders[col.orderBy ?? col.name]" :name="col.orderBy ?? col.name" :data-key="$attrs['data-key']" :search-url="searchUrl" @@ -409,7 +409,7 @@ defineExpose({ style="height: 30px" > { if (props.baseUrl) return `${props.baseUrl}/${route.params.id}`; return props.customUrl; }); - +const searchRightDataKey = computed(() => { + if (!props.searchDataKey) return route.name; + return props.searchDataKey; +}); const arrayData = useArrayData(props.dataKey, { url: url.value, filter: props.filter, @@ -62,10 +65,9 @@ if (props.baseUrl) { - diff --git a/src/components/ui/VnFilterPanel.vue b/src/components/ui/VnFilterPanel.vue index b12a9f7b8..3598f96a5 100644 --- a/src/components/ui/VnFilterPanel.vue +++ b/src/components/ui/VnFilterPanel.vue @@ -37,7 +37,7 @@ const $props = defineProps({ }, hiddenTags: { type: Array, - default: () => ['filter'], + default: () => ['filter', 'search', 'or', 'and'], }, customTags: { type: Array, @@ -111,24 +111,23 @@ watch( const isLoading = ref(false); async function search(evt) { - if (evt && $props.disableSubmitEvent) return; - - store.filter.where = {}; - isLoading.value = true; - const filter = { ...userParams.value, ...$props.modelValue }; - store.userParamsChanged = true; try { + if (evt && $props.disableSubmitEvent) return; + + store.filter.where = {}; + isLoading.value = true; + const filter = { ...userParams.value, ...$props.modelValue }; + store.userParamsChanged = true; const { params: newParams } = await arrayData.addFilter({ params: filter, }); userParams.value = newParams; if (!$props.showAll && !Object.values(filter).length) store.data = []; + emit('search'); } finally { isLoading.value = false; } - - emit('search'); } async function reload() { @@ -143,29 +142,31 @@ async function reload() { } async function clearFilters() { - isLoading.value = true; - store.userParamsChanged = true; - arrayData.reset(['skip', 'filter.skip', 'page']); - // Filtrar los params no removibles - const removableFilters = Object.keys(userParams.value).filter((param) => - $props.unRemovableParams.includes(param) - ); - const newParams = {}; - // Conservar solo los params que no son removibles - for (const key of removableFilters) { - newParams[key] = userParams.value[key]; - } - userParams.value = {}; - userParams.value = { ...newParams }; // Actualizar los params con los removibles - await arrayData.applyFilter({ params: userParams.value }); + try { + isLoading.value = true; + store.userParamsChanged = true; + arrayData.reset(['skip', 'filter.skip', 'page']); + // Filtrar los params no removibles + const removableFilters = Object.keys(userParams.value).filter((param) => + $props.unRemovableParams.includes(param) + ); + const newParams = {}; + // Conservar solo los params que no son removibles + for (const key of removableFilters) { + newParams[key] = userParams.value[key]; + } + userParams.value = {}; + userParams.value = { ...newParams }; // Actualizar los params con los removibles + await arrayData.applyFilter({ params: userParams.value }); - if (!$props.showAll) { - store.data = []; + if (!$props.showAll) { + store.data = []; + } + emit('clear'); + emit('update:modelValue', userParams.value); + } finally { + isLoading.value = false; } - - isLoading.value = false; - emit('clear'); - emit('update:modelValue', userParams.value); } const tagsList = computed(() => { @@ -201,8 +202,10 @@ function formatValue(value) { function sanitizer(params) { for (const [key, value] of Object.entries(params)) { - if (typeof value == 'object') - params[key] = Object.values(value)?.[0]?.replaceAll('%', ''); + if (value && typeof value === 'object') { + const param = Object.values(value)[0]; + if (typeof param == 'string') params[key] = param.replaceAll('%', ''); + } } return params; } diff --git a/src/components/ui/VnOutForm.vue b/src/components/ui/VnOutForm.vue new file mode 100644 index 000000000..e7ad441d0 --- /dev/null +++ b/src/components/ui/VnOutForm.vue @@ -0,0 +1,32 @@ + + + diff --git a/src/components/ui/VnSearchbar.vue b/src/components/ui/VnSearchbar.vue index a34eba6af..a4375f36c 100644 --- a/src/components/ui/VnSearchbar.vue +++ b/src/components/ui/VnSearchbar.vue @@ -104,9 +104,7 @@ onMounted(() => { }); async function search() { - const staticParams = Object.entries(store.userParams).filter( - ([key, value]) => value && (props.staticParams || []).includes(key) - ); + const staticParams = Object.entries(store.userParams); arrayData.reset(['skip', 'page']); if (props.makeFetch) diff --git a/src/components/ui/VnSms.vue b/src/components/ui/VnSms.vue index 81058a6cb..bf6e0695e 100644 --- a/src/components/ui/VnSms.vue +++ b/src/components/ui/VnSms.vue @@ -1,5 +1,5 @@ diff --git a/src/pages/Account/Role/Card/RoleCard.vue b/src/pages/Account/Role/Card/RoleCard.vue index 622bfb1c6..35f9a1f27 100644 --- a/src/pages/Account/Role/Card/RoleCard.vue +++ b/src/pages/Account/Role/Card/RoleCard.vue @@ -1,33 +1,20 @@ diff --git a/src/pages/Claim/ClaimList.vue b/src/pages/Claim/ClaimList.vue index 6fd607da0..b03dfb226 100644 --- a/src/pages/Claim/ClaimList.vue +++ b/src/pages/Claim/ClaimList.vue @@ -50,7 +50,7 @@ const columns = computed(() => [ align: 'left', label: t('claim.attendedBy'), name: 'attendedBy', - cardVisible: true, + orderBy: 'workerFk', columnFilter: { component: 'select', attrs: { @@ -63,6 +63,7 @@ const columns = computed(() => [ optionFilter: 'firstName', }, }, + cardVisible: true, }, { align: 'left', @@ -77,6 +78,9 @@ const columns = computed(() => [ { align: 'left', label: t('claim.state'), + format: ({ stateCode }) => + claimFilterRef.value?.states.find(({code}) => code === stateCode) + ?.description, name: 'stateCode', chip: { condition: () => true, diff --git a/src/pages/Claim/locale/es.yml b/src/pages/Claim/locale/es.yml index 90bef8e66..052416aa7 100644 --- a/src/pages/Claim/locale/es.yml +++ b/src/pages/Claim/locale/es.yml @@ -42,7 +42,7 @@ claim: pickup: Recoger null: No agency: Agencia - delivery: Entrega + delivery: Reparto fileDescription: 'ID de reclamación {claimId} del cliente {clientName} con ID {clientId}' noData: 'No hay imágenes/videos, haz clic aquí o arrastra y suelta el archivo' dragDrop: Arrastra y suelta aquí diff --git a/src/pages/Customer/Card/CustomerConsumption.vue b/src/pages/Customer/Card/CustomerConsumption.vue index 98a3115da..4d3da1116 100644 --- a/src/pages/Customer/Card/CustomerConsumption.vue +++ b/src/pages/Customer/Card/CustomerConsumption.vue @@ -1,8 +1,6 @@