This commit is contained in:
parent
abb1b3f7c1
commit
ef177c01e5
|
@ -31,82 +31,6 @@ const $props = defineProps({
|
|||
},
|
||||
});
|
||||
|
||||
// watch(
|
||||
// () => $props,
|
||||
// (props) => {
|
||||
// fetch(props.url);
|
||||
// },
|
||||
// { deep: true }
|
||||
// );
|
||||
|
||||
// const emit = defineEmits(['onFetch']);
|
||||
// const arrayData = computed(() => {
|
||||
// const currentArrayData = useArrayData($props.dataKey);
|
||||
// const newArrayData = useArrayData($props.dataKey, {
|
||||
// url: $props.url,
|
||||
// filter: $props.filter,
|
||||
// });
|
||||
// console.log(currentArrayData.store.url, currentArrayData?.store?.url != $props.url);
|
||||
// if (currentArrayData?.store?.url != $props.url) newArrayData.fetch({ append: false });
|
||||
// return newArrayData;
|
||||
// });
|
||||
|
||||
// watch(
|
||||
// () => arrayData,
|
||||
// (arrayData) => {
|
||||
// console.log('watch CHANGE??', arrayData.value.store.data);
|
||||
// entity.value = arrayData.value.store.data;
|
||||
// emit('onFetch', arrayData.value.store.data);
|
||||
// },
|
||||
// { deep: true }
|
||||
// );
|
||||
|
||||
// const slots = useSlots();
|
||||
// const { t } = useI18n();
|
||||
// let lastUrl = ref(null);
|
||||
// const entity = ref();
|
||||
|
||||
// async function fetch(url) {
|
||||
// console.log('FETCH??', arrayData.value.store.url, url);
|
||||
// if (arrayData.value.store.url == url) return;
|
||||
// useArrayData($props.dataKey, {
|
||||
// url: url ?? $props.url,
|
||||
// filter: $props.filter,
|
||||
// });
|
||||
// await arrayData.value.fetch({ append: false });
|
||||
// console.log('FETCH?? 2', url, $props.url);
|
||||
// // if (arrayData.value.store.data) emit('onFetch', arrayData.value.store.data);
|
||||
// }
|
||||
|
||||
// watch($props, async () => {
|
||||
// if (lastUrl.value == $props.url) return;
|
||||
// entity.value = arrayData.value.store.data;
|
||||
// // await fetch();
|
||||
// });
|
||||
|
||||
// onMounted(async () => {
|
||||
// console.log('onMounted');
|
||||
// fetch($props.url);
|
||||
// });
|
||||
|
||||
/*
|
||||
|
||||
ArrayData es null. la url tb
|
||||
|
||||
Watch → arrayData
|
||||
url diferent a la nostra fetch
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
*/
|
||||
|
||||
// onMounted(async () => {
|
||||
// console.log('onMounted');
|
||||
// fetch($props.url);
|
||||
// });
|
||||
const slots = useSlots();
|
||||
const { t } = useI18n();
|
||||
const emit = defineEmits(['onFetch']);
|
||||
|
@ -119,26 +43,11 @@ const arrayData = computed(() => {
|
|||
url: $props.url,
|
||||
filter: $props.filter,
|
||||
});
|
||||
console.log(
|
||||
'URLS ',
|
||||
currentArrayData.store.url,
|
||||
$props.dataKey,
|
||||
$props.url,
|
||||
current?.url
|
||||
);
|
||||
if (current?.url != $props.url) newArrayData.fetch({ append: false });
|
||||
if (newArrayData.store.data) emit('onFetch', newArrayData.store.data);
|
||||
|
||||
return newArrayData;
|
||||
});
|
||||
|
||||
watch(
|
||||
() => arrayData,
|
||||
(arrayData) => {
|
||||
console.log('watch CHANGE??', arrayDataStore.get($props.dataKey));
|
||||
},
|
||||
{ deep: true }
|
||||
);
|
||||
</script>
|
||||
<template>
|
||||
<div class="descriptor">
|
||||
|
|
|
@ -7,7 +7,6 @@ const arrayDataStore = useArrayDataStore();
|
|||
|
||||
export function useArrayData(key, userOptions) {
|
||||
if (!key) throw new Error('ArrayData: A key is required to use this composable');
|
||||
console.log('CALLED WITH KEY → ', key, userOptions);
|
||||
if (!arrayDataStore.get(key)) {
|
||||
arrayDataStore.set(key);
|
||||
}
|
||||
|
@ -74,7 +73,6 @@ export function useArrayData(key, userOptions) {
|
|||
Object.assign(params, store.userParams);
|
||||
|
||||
store.isLoading = true;
|
||||
console.log('ARRAY FETCH', store.url);
|
||||
const response = await axios.get(store.url, {
|
||||
signal: canceller.signal,
|
||||
params,
|
||||
|
|
|
@ -1,23 +1,25 @@
|
|||
<script setup>
|
||||
import { ref, computed, watchEffect, onMounted, onUnmounted } from 'vue';
|
||||
import { ref, computed, watchEffect } from 'vue';
|
||||
import { useQuasar } from 'quasar';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { useRoute } from 'vue-router';
|
||||
import axios from 'axios';
|
||||
import { useStateStore } from 'src/stores/useStateStore';
|
||||
import { toDate, toPercentage, toCurrency } from 'filters/index';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import CrudModel from 'src/components/CrudModel.vue';
|
||||
import FetchData from 'src/components/FetchData.vue';
|
||||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
import VnSelectFilter from 'src/components/common/VnSelectFilter.vue';
|
||||
import { useArrayData } from 'src/composables/useArrayData';
|
||||
import { tMobile } from 'src/composables/tMobile';
|
||||
import TicketDescriptorProxy from 'src/pages/Ticket/Card/TicketDescriptorProxy.vue';
|
||||
|
||||
const { t } = useI18n();
|
||||
const quasar = useQuasar();
|
||||
const route = useRoute();
|
||||
const stateStore = computed(() => useStateStore());
|
||||
const claim = ref(null);
|
||||
const claimId = route.params.id;
|
||||
const dialog = ref(false);
|
||||
const dialogOption = ref(null);
|
||||
const dialogDestination = ref(false);
|
||||
const claimDestinationFk = ref(null);
|
||||
const resolvedStateId = ref(null);
|
||||
const claimActionsForm = ref();
|
||||
const rows = ref([]);
|
||||
|
@ -25,14 +27,8 @@ const selectedRows = ref([]);
|
|||
const destinationTypes = ref([]);
|
||||
const destinations = ref([]);
|
||||
const totalClaimed = ref(null);
|
||||
const responsibility = ref(5); // pending to get from ClaimDescriptor
|
||||
const manaCharger = ref(false); // pending to get from ClaimDescriptor
|
||||
const claimData = useArrayData('claimData');
|
||||
// ClaimEnds/filter?filter={ claimFk: route.param.id}
|
||||
// for update responsability and mana /Claims/id/updateClaimAction
|
||||
|
||||
// onMounted(() => (stateStore.value.rightDrawer = true));
|
||||
// onUnmounted(() => (stateStore.value.rightDrawer = false));
|
||||
const maxResponsibility = computed(() => 5);
|
||||
const dialogGreuge = ref(false);
|
||||
|
||||
const columns = computed(() => [
|
||||
{
|
||||
|
@ -107,14 +103,6 @@ function getDestination(destinationId) {
|
|||
return destinationTypes.value.find((type) => type.id == destinationId);
|
||||
}
|
||||
|
||||
async function updateDestination(claimDestinationFk, row) {
|
||||
if (claimDestinationFk) {
|
||||
await axios.post('Claims/updateClaimDestination', {
|
||||
claimDestinationFk,
|
||||
rows: [row],
|
||||
});
|
||||
}
|
||||
}
|
||||
async function deleteSale(sale) {
|
||||
await axios.post(`ClaimEnds/deleteClamedSales`, { sales: [sale] });
|
||||
claimActionsForm.value.reload();
|
||||
|
@ -129,8 +117,103 @@ async function updateDestinations(claimDestinationFk) {
|
|||
claimActionsForm.value.reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function updateDestination(claimDestinationFk, row) {
|
||||
if (claimDestinationFk) {
|
||||
await axios.post('Claims/updateClaimDestination', {
|
||||
claimDestinationFk,
|
||||
rows: [row],
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function regularizeClaim() {
|
||||
const query = `Claims/${claimId}/regularizeClaim`;
|
||||
|
||||
await axios.post(query);
|
||||
if (claim.value.responsibility >= Math.ceil(maxResponsibility.value) / 2) {
|
||||
dialogGreuge.value = true;
|
||||
} else {
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
|
||||
claimActionsForm.value.reload();
|
||||
}
|
||||
}
|
||||
|
||||
async function updateGreuge(greuges) {
|
||||
const { data } = await axios.post(`Greuges`, greuges);
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
return data;
|
||||
}
|
||||
|
||||
async function onUpdateGreugeAccept() {
|
||||
const greugeTypeFreightId = await getGreugeTypeId();
|
||||
const freightPickUpPrice = await getGreugeConfig();
|
||||
|
||||
await updateGreuge({
|
||||
clientFk: claim.value.clientFk,
|
||||
description: `${t('ClaimGreugeDescription')} ${claimId}`.toUpperCase(),
|
||||
amount: freightPickUpPrice,
|
||||
greugeTypeFk: greugeTypeFreightId,
|
||||
ticketFk: claim.value.ticketFk,
|
||||
});
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
}
|
||||
|
||||
async function getGreugeTypeId() {
|
||||
const params = { filter: { where: { code: 'freightPickUp' } } };
|
||||
const query = `GreugeTypes/findOne`;
|
||||
const { data } = await axios.get(query, { params });
|
||||
return data.id;
|
||||
}
|
||||
|
||||
async function getGreugeConfig() {
|
||||
const query = `GreugeConfigs/findOne`;
|
||||
const { data } = await axios.get(query);
|
||||
return data.freightPickUpPrice;
|
||||
}
|
||||
|
||||
async function save(data) {
|
||||
const query = `Claims/${claimId}/updateClaimAction`;
|
||||
await axios.patch(query, data);
|
||||
}
|
||||
|
||||
async function importToNewRefundTicket() {
|
||||
const query = `ClaimBeginnings/${claimId}/importToNewRefundTicket`;
|
||||
await axios.post(query);
|
||||
claimActionsForm.value.reload();
|
||||
quasar.notify({
|
||||
message: t('globals.dataSaved'),
|
||||
type: 'positive',
|
||||
});
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
:url="`Claims/${claimId}`"
|
||||
@on-fetch="(data) => (claim = data)"
|
||||
auto-load
|
||||
/>
|
||||
<FetchData
|
||||
url="ClaimStates/findOne"
|
||||
@on-fetch="(data) => (resolvedStateId = data.id)"
|
||||
auto-load
|
||||
:where="{ code: 'resolved' }"
|
||||
/>
|
||||
<FetchData
|
||||
url="ClaimDestinations"
|
||||
auto-load
|
||||
@on-fetch="(data) => (destinationTypes = data)"
|
||||
/>
|
||||
<template v-if="stateStore.isHeaderMounted()">
|
||||
<Teleport to="#actions-append">
|
||||
<div class="row q-gutter-x-sm">
|
||||
|
@ -148,7 +231,13 @@ async function updateDestinations(claimDestinationFk) {
|
|||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
<QDrawer v-model="stateStore.rightDrawer" side="right" :width="300" show-if-above>
|
||||
<QDrawer
|
||||
v-model="stateStore.rightDrawer"
|
||||
side="right"
|
||||
:width="300"
|
||||
show-if-above
|
||||
v-if="claim"
|
||||
>
|
||||
<QScrollArea class="fit text-grey-8 q-mt-lg">
|
||||
<div class="totalClaim q-mb-md">
|
||||
{{ `${t('Total claimed')}: ${toCurrency(totalClaimed)}` }}
|
||||
|
@ -160,10 +249,12 @@ async function updateDestinations(claimDestinationFk) {
|
|||
{{ t('claim.summary.actions') }}
|
||||
</p>
|
||||
<QSlider
|
||||
class="responsability { 'background-color:primary': quasar.platform.is.mobile }"
|
||||
v-model="responsibility"
|
||||
label
|
||||
class="responsibility { 'background-color:primary': quasar.platform.is.mobile }"
|
||||
v-model="claim.responsibility"
|
||||
:label-value="t('claim.summary.responsibility')"
|
||||
@update:model-value="
|
||||
(value) => save({ responsibility: value })
|
||||
"
|
||||
label-always
|
||||
color="primary"
|
||||
markers
|
||||
|
@ -178,26 +269,18 @@ async function updateDestinations(claimDestinationFk) {
|
|||
</QItem>
|
||||
</QCard>
|
||||
<QItemLabel class="mana q-mb-md">
|
||||
<QCheckbox v-model="manaCharger" />
|
||||
<QCheckbox
|
||||
v-model="claim.isChargedToMana"
|
||||
@update:model-value="(value) => save({ isChargedToMana: value })"
|
||||
/>
|
||||
<span>{{ t('mana') }}</span>
|
||||
</QItemLabel>
|
||||
</QScrollArea>
|
||||
</QDrawer>
|
||||
<FetchData
|
||||
url="ClaimDestinations"
|
||||
auto-load
|
||||
@on-fetch="(data) => (destinationTypes = data)"
|
||||
/>
|
||||
<FetchData
|
||||
:url="`ClaimStates/findOne`"
|
||||
:where="{ code: 'resolved' }"
|
||||
auto-load
|
||||
@on-fetch="(data) => (resolvedStateId = data)"
|
||||
/>
|
||||
<Teleport to="#st-data" v-if="stateStore.isSubToolbarShown()"> </Teleport>
|
||||
|
||||
<div class="claim-action">
|
||||
<CrudModel
|
||||
v-if="claim"
|
||||
data-key="ClaimEnds"
|
||||
url="ClaimEnds/filter"
|
||||
save-url="ClaimEnds/crud"
|
||||
|
@ -314,8 +397,10 @@ async function updateDestinations(claimDestinationFk) {
|
|||
:label="tMobile('Regularize')"
|
||||
:title="t('Regularize')"
|
||||
icon="check"
|
||||
@click="regularizeClaim"
|
||||
:disable="claim.claimStateFk == resolvedStateId"
|
||||
/>
|
||||
<!--disabled="(ClaimDescriptor)claimStateFk == resolvedStateId"-->
|
||||
|
||||
<QBtn
|
||||
color="primary"
|
||||
text-color="white"
|
||||
|
@ -324,7 +409,7 @@ async function updateDestinations(claimDestinationFk) {
|
|||
:label="tMobile('Change destination')"
|
||||
:title="t('Change destination')"
|
||||
icon="swap_horiz"
|
||||
@click="dialog = !dialog"
|
||||
@click="dialogDestination = !dialogDestination"
|
||||
/>
|
||||
<QBtn
|
||||
color="primary"
|
||||
|
@ -333,11 +418,12 @@ async function updateDestinations(claimDestinationFk) {
|
|||
:label="tMobile('Import claim')"
|
||||
:title="t('Import claim')"
|
||||
icon="Upload"
|
||||
@click="importToNewRefundTicket"
|
||||
:disable="claim.claimStateFk == resolvedStateId"
|
||||
/>
|
||||
<!--disabled="(ClaimDescriptor)claimStateFk == resolvedStateId"-->
|
||||
</template>
|
||||
</CrudModel>
|
||||
<QDialog v-model="dialog">
|
||||
<QDialog v-model="dialogDestination">
|
||||
<QCard>
|
||||
<QCardSection>
|
||||
<QItem class="q-pa-none">
|
||||
|
@ -349,7 +435,7 @@ async function updateDestinations(claimDestinationFk) {
|
|||
</QCardSection>
|
||||
<QCardSection>
|
||||
<VnSelectFilter
|
||||
v-model="dialogOption"
|
||||
v-model="claimDestinationFk"
|
||||
:options="destinationTypes"
|
||||
option-label="description"
|
||||
option-value="id"
|
||||
|
@ -363,15 +449,39 @@ async function updateDestinations(claimDestinationFk) {
|
|||
v-close-popup
|
||||
/>
|
||||
<QBtn
|
||||
:disable="!dialogOption"
|
||||
:disable="!claimDestinationFk"
|
||||
:label="t('globals.save')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
@click="updateDestinations(dialogOption)"
|
||||
@click="updateDestinations(claimDestinationFk)"
|
||||
/>
|
||||
</QCardActions>
|
||||
</QCard>
|
||||
</QDialog>
|
||||
<QDialog v-model="dialogGreuge">
|
||||
<QCardSection>
|
||||
<QItem class="q-pa-none">
|
||||
<span class="q-dialog__title text-white">
|
||||
{{ t('dialogGreuge title') }}
|
||||
</span>
|
||||
<QBtn icon="close" flat round dense v-close-popup />
|
||||
</QItem>
|
||||
<QCardActions class="justify-end q-mr-sm">
|
||||
<QBtn
|
||||
flat
|
||||
:label="t('globals.close')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
/>
|
||||
<QBtn
|
||||
:label="t('globals.save')"
|
||||
color="primary"
|
||||
v-close-popup
|
||||
@click="onUpdateGreugeAccept"
|
||||
/>
|
||||
</QCardActions>
|
||||
</QCardSection>
|
||||
</QDialog>
|
||||
</div>
|
||||
</template>
|
||||
<style lang="scss">
|
||||
|
@ -409,7 +519,7 @@ async function updateDestinations(claimDestinationFk) {
|
|||
padding: 10px;
|
||||
margin: 5px;
|
||||
}
|
||||
.responsability {
|
||||
.responsibility {
|
||||
max-width: 100%;
|
||||
margin-left: 40px;
|
||||
}
|
||||
|
@ -418,14 +528,14 @@ async function updateDestinations(claimDestinationFk) {
|
|||
color: white;
|
||||
float: inline-start;
|
||||
}
|
||||
|
||||
.qdrawer {
|
||||
}
|
||||
</style>
|
||||
<i18n>
|
||||
en:
|
||||
mana: Is paid with mana
|
||||
dialog title: Change destination to all selected rows
|
||||
dialogGreuge title: Insert greuges on client card
|
||||
ClaimGreugeDescription: Claim Id
|
||||
|
||||
es:
|
||||
mana: Cargado al maná
|
||||
Delivered: Descripción
|
||||
|
@ -443,4 +553,6 @@ es:
|
|||
Import claim: Importar reclamación
|
||||
dialog title: Cambiar destino en todas las filas seleccionadas
|
||||
Remove: Eliminar
|
||||
dialogGreuge title: Insertar greuges en la ficha del cliente
|
||||
ClaimGreugeDescription: Id reclamación
|
||||
</i18n>
|
||||
|
|
|
@ -69,7 +69,6 @@ function stateColor(code) {
|
|||
}
|
||||
const data = ref(useCardDescription());
|
||||
const setData = (entity) => {
|
||||
console.log('SET ENTITY SETDATA', entity);
|
||||
if (!entity) return;
|
||||
data.value = useCardDescription(entity.client.name, entity.id);
|
||||
state.set('ClaimDescriptor', entity);
|
||||
|
|
|
@ -7,6 +7,7 @@ import FetchData from 'components/FetchData.vue';
|
|||
import VnSelectFilter from 'components/common/VnSelectFilter.vue';
|
||||
import { getUrl } from 'composables/getUrl';
|
||||
import { tMobile } from 'composables/tMobile';
|
||||
import router from 'src/router';
|
||||
|
||||
const route = useRoute();
|
||||
|
||||
|
@ -102,10 +103,6 @@ const columns = computed(() => [
|
|||
tabIndex: 5,
|
||||
},
|
||||
]);
|
||||
|
||||
function goToAction() {
|
||||
location.href = `${salixUrl}/action`;
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -148,7 +145,7 @@ function goToAction() {
|
|||
:data-required="{ claimFk: route.params.id }"
|
||||
v-model:selected="selected"
|
||||
auto-load
|
||||
@save-changes="goToAction"
|
||||
@save-changes="$router.push(`/claim/${route.params.id}/action`)"
|
||||
:default-save="false"
|
||||
>
|
||||
<template #body="{ rows }">
|
||||
|
|
Loading…
Reference in New Issue