From bd908e5e93be8feb9285a96d21a251a528f9a4a9 Mon Sep 17 00:00:00 2001 From: joan Date: Mon, 31 Oct 2022 09:34:01 +0100 Subject: [PATCH] RMA refactor --- src/App.vue | 2 +- src/components/FetchData.vue | 9 +- src/components/FormModel.vue | 57 ++- src/components/SmartCard.vue | 27 +- src/i18n/en/index.js | 1 + src/i18n/es/index.js | 1 + src/pages/Claim/Card/ClaimBasicData.vue | 395 +++++++++--------- src/pages/Claim/Card/ClaimCard.vue | 2 +- src/pages/Claim/Card/ClaimRma.vue | 79 ++-- src/pages/Claim/ClaimCreate.vue | 52 --- src/pages/Customer/Card/CustomerBasicData.vue | 82 ++-- src/router/modules/claim.js | 12 +- 12 files changed, 340 insertions(+), 379 deletions(-) delete mode 100644 src/pages/Claim/ClaimCreate.vue diff --git a/src/App.vue b/src/App.vue index 8eae0d1a6..f381d2576 100644 --- a/src/App.vue +++ b/src/App.vue @@ -61,7 +61,7 @@ function responseError(error) { router.push({ path: '/login' }); } - return Promise.resolve(error); + return Promise.reject(error); } axios.interceptors.response.use((response) => { diff --git a/src/components/FetchData.vue b/src/components/FetchData.vue index 3da3a8e5f..0eee59f90 100644 --- a/src/components/FetchData.vue +++ b/src/components/FetchData.vue @@ -15,13 +15,10 @@ const $props = defineProps({ type: Object, default: null, }, - limit: { - type: String, - default: '20', - }, }); -const emit = defineEmits(['fetch-data']); +defineExpose({ fetch }); +const emit = defineEmits(['onFetch']); onMounted(async () => { if ($props.autoLoad) { @@ -34,7 +31,7 @@ async function fetch() { params: { filter: $props.filter }, }); - return emit('fetch-data', data); + emit('onFetch', data); } const render = () => { diff --git a/src/components/FormModel.vue b/src/components/FormModel.vue index ebb8f57cf..d36f8c4ea 100644 --- a/src/components/FormModel.vue +++ b/src/components/FormModel.vue @@ -5,11 +5,13 @@ import { useQuasar } from 'quasar'; import axios from 'axios'; import { useState } from 'src/composables/useState'; +import { useValidator } from 'src/composables/useValidator'; import SkeletonForm from 'src/components/SkeletonForm.vue'; const quasar = useQuasar(); const { t } = useI18n(); const state = useState(); +const { validate } = useValidator(); const $props = defineProps({ url: { @@ -26,7 +28,7 @@ const $props = defineProps({ }, }); -const emit = defineEmits(['fetch-data']); +const emit = defineEmits(['onFetch']); defineExpose({ save, @@ -53,7 +55,7 @@ async function fetch() { watch(formData.value, () => (hasChanges.value = true)); - return emit('fetch-data', state.get($props.model)); + emit('onFetch', state.get($props.model)); } async function save() { @@ -64,10 +66,10 @@ async function save() { }); } isLoading.value = true; - await new Promise((resolve) => { - setTimeout(resolve, 5000); - }); await axios.patch($props.url, formData.value); + + originalData.value = formData.value; + hasChanges.value = false; isLoading.value = false; } @@ -75,22 +77,41 @@ function reset() { state.set($props.model, originalData.value); hasChanges.value = false; } + +function filter(value, update, filterOptions) { + update( + () => { + const { options, filterFn } = filterOptions; + + options.value = filterFn(options, value); + }, + (ref) => { + ref.setOptionIndex(-1); + ref.moveOptionSelection(1, true); + } + ); +}