6157-actionClaim #106

Merged
carlossa merged 22 commits from 6157-actionClaim into dev 2023-11-24 07:46:30 +00:00
4 changed files with 41 additions and 28 deletions
Showing only changes of commit d03092f41d - Show all commits

View File

@ -1,8 +1,9 @@
<script setup> <script setup>
import { onMounted, useSlots, ref, watch } from 'vue'; import { onMounted, useSlots, ref, watch, computed } from 'vue';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import axios from 'axios'; import axios from 'axios';
import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue'; import SkeletonDescriptor from 'components/ui/SkeletonDescriptor.vue';
import { useArrayData } from 'composables/useArrayData';
const $props = defineProps({ const $props = defineProps({
url: { url: {
@ -25,33 +26,40 @@ const $props = defineProps({
type: Number, type: Number,
default: 0, default: 0,
}, },
dataKey: {
type: String,
default: '',
},
}); });
const slots = useSlots(); const slots = useSlots();
const { t } = useI18n(); const { t } = useI18n();
const entity = ref(); defineExpose({ fetch });
carlossa marked this conversation as resolved
Review

Esta tb borrala

Esta tb borrala
const entity = computed(() => useArrayData($props.dataKey).store.data);
onMounted(async () => { onMounted(async () => {
await fetch(); await getData();
watch(
() => $props.url,
async (newUrl, lastUrl) => {
if (newUrl == lastUrl) return;
entity.value = null;
await getData();
}
);
}); });
const emit = defineEmits(['onFetch']); async function getData() {
const arrayData = useArrayData($props.dataKey, {
async function fetch() { url: $props.url,
const params = {}; filter: $props.filter,
skip: 0,
if ($props.filter) params.filter = JSON.stringify($props.filter); });
const { data } = await arrayData.fetch({ append: false });
const { data } = await axios.get($props.url, { params });
entity.value = data;
emit('onFetch', data); emit('onFetch', data);
} }
const emit = defineEmits(['onFetch']);
watch($props, async () => { async function fetch() {}
entity.value = null;
await fetch();
});
</script> </script>
<template> <template>

View File

@ -29,6 +29,10 @@ export function useArrayData(key, userOptions) {
} }
}); });
if (key && userOptions) {
setOptions();
}
function setOptions() { function setOptions() {
const allowedOptions = [ const allowedOptions = [
'url', 'url',
@ -97,6 +101,7 @@ export function useArrayData(key, userOptions) {
store.isLoading = false; store.isLoading = false;
canceller = null; canceller = null;
return response;
} }
function destroy() { function destroy() {
@ -147,10 +152,11 @@ export function useArrayData(key, userOptions) {
if (store.userParams && Object.keys(store.userParams).length !== 0) if (store.userParams && Object.keys(store.userParams).length !== 0)
query.params = JSON.stringify(store.userParams); query.params = JSON.stringify(store.userParams);
router.replace({ if (router)
path: route.path, router.replace({
query: query, path: route.path,
}); query: query,
});
} }
const totalRows = computed(() => (store.data && store.data.length) || 0); const totalRows = computed(() => (store.data && store.data.length) || 0);

View File

@ -2,7 +2,7 @@
import { ref, computed, onMounted } from 'vue'; import { ref, computed, onMounted } from 'vue';
import { useQuasar } from 'quasar'; import { useQuasar } from 'quasar';
import { useI18n } from 'vue-i18n'; import { useI18n } from 'vue-i18n';
import { useRoute } from 'vue-router'; import { useRoute, useRouter } from 'vue-router';
import axios from 'axios'; import axios from 'axios';
import { useStateStore } from 'src/stores/useStateStore'; import { useStateStore } from 'src/stores/useStateStore';
import { toDate, toPercentage, toCurrency } from 'filters/index'; import { toDate, toPercentage, toCurrency } from 'filters/index';
@ -17,6 +17,7 @@ import { useArrayData } from 'composables/useArrayData';
const { t } = useI18n(); const { t } = useI18n();
const quasar = useQuasar(); const quasar = useQuasar();
const route = useRoute(); const route = useRoute();
const router = useRouter();
const stateStore = computed(() => useStateStore()); const stateStore = computed(() => useStateStore());
const claim = ref(null); const claim = ref(null);
const claimRef = ref(); const claimRef = ref();
@ -30,6 +31,7 @@ const selectedRows = ref([]);
const destinationTypes = ref([]); const destinationTypes = ref([]);
const totalClaimed = ref(null); const totalClaimed = ref(null);
const DEFAULT_MAX_RESPONSABILITY = 5; const DEFAULT_MAX_RESPONSABILITY = 5;
const arrayData = useArrayData('claimData');
const columns = computed(() => [ const columns = computed(() => [
{ {
@ -140,9 +142,7 @@ async function regularizeClaim() {
type: 'positive', type: 'positive',
}); });
} }
claimActionsForm.value.reload(); await arrayData.fetch({ append: false });
const arrayData = useArrayData('Claim');
await arrayData.refresh();
} }
async function updateGreuge(greuges) { async function updateGreuge(greuges) {

View File

@ -64,11 +64,10 @@ const filter = {
const STATE_COLOR = { const STATE_COLOR = {
pending: 'positive', pending: 'positive',
managed: 'warning', managed: 'warning',
resolved: 'negative', resolved: 'negative',
}; };
function stateColor(code) { function stateColor(code) {
return STATE_COLOR[code]; return STATE_COLOR[code];
} }