forked from verdnatura/salix-front
fix: fixed change state function
This commit is contained in:
parent
26f34619c0
commit
6b0a0f71ce
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { onMounted, ref, computed } from 'vue';
|
import { onMounted, ref, computed } from 'vue';
|
||||||
import { useRoute, useRouter } from 'vue-router';
|
import { useRoute } from 'vue-router';
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import { dashIfEmpty, toDate, toCurrency } from 'src/filters';
|
import { dashIfEmpty, toDate, toCurrency } from 'src/filters';
|
||||||
|
@ -11,13 +11,15 @@ import InvoiceOutDescriptorProxy from 'pages/InvoiceOut/Card/InvoiceOutDescripto
|
||||||
import VnLv from 'src/components/ui/VnLv.vue';
|
import VnLv from 'src/components/ui/VnLv.vue';
|
||||||
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
import VnLinkPhone from 'src/components/ui/VnLinkPhone.vue';
|
||||||
import { getUrl } from 'src/composables/getUrl';
|
import { getUrl } from 'src/composables/getUrl';
|
||||||
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
import { useArrayData } from 'composables/useArrayData';
|
||||||
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
import VnUserLink from 'src/components/ui/VnUserLink.vue';
|
||||||
import VnTitle from 'src/components/common/VnTitle.vue';
|
import VnTitle from 'src/components/common/VnTitle.vue';
|
||||||
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue';
|
||||||
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
|
||||||
const route = useRoute();
|
const route = useRoute();
|
||||||
const router = useRouter();
|
const { notify } = useNotify();
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const $props = defineProps({
|
const $props = defineProps({
|
||||||
|
@ -36,6 +38,8 @@ const salesLines = ref(null);
|
||||||
const editableStates = ref([]);
|
const editableStates = ref([]);
|
||||||
const ticketUrl = ref();
|
const ticketUrl = ref();
|
||||||
const grafanaUrl = 'https://grafana.verdnatura.es';
|
const grafanaUrl = 'https://grafana.verdnatura.es';
|
||||||
|
const stateBtnDropdownRef = ref();
|
||||||
|
const descriptorData = useArrayData('ticketData');
|
||||||
|
|
||||||
onMounted(async () => {
|
onMounted(async () => {
|
||||||
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
|
ticketUrl.value = (await getUrl('ticket/')) + entityId.value + '/';
|
||||||
|
@ -68,15 +72,19 @@ function isEditable() {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function changeState(value) {
|
async function changeState(value) {
|
||||||
if (!ticket.value.id) return;
|
try {
|
||||||
|
stateBtnDropdownRef.value.hide();
|
||||||
const formData = {
|
const formData = {
|
||||||
ticketFk: ticket.value.id,
|
ticketFk: entityId.value,
|
||||||
code: value,
|
code: value,
|
||||||
};
|
};
|
||||||
|
await axios.post(`Tickets/state`, formData);
|
||||||
await axios.post(`Tickets/state`, formData);
|
notify('globals.dataSaved', 'positive');
|
||||||
router.go(route.fullPath);
|
summaryRef.value?.fetch();
|
||||||
|
descriptorData.fetch({});
|
||||||
|
} catch (err) {
|
||||||
|
console.error('Error changing ticket state', err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
@ -102,33 +110,21 @@ async function changeState(value) {
|
||||||
</template>
|
</template>
|
||||||
<template #header-right>
|
<template #header-right>
|
||||||
<QBtnDropdown
|
<QBtnDropdown
|
||||||
side
|
ref="stateBtnDropdownRef"
|
||||||
top
|
|
||||||
color="black"
|
color="black"
|
||||||
text-color="white"
|
text-color="white"
|
||||||
:label="t('ticket.summary.changeState')"
|
:label="t('ticket.summary.changeState')"
|
||||||
:disable="!isEditable()"
|
:disable="!isEditable()"
|
||||||
>
|
>
|
||||||
<QList>
|
<VnSelect
|
||||||
<QVirtualScroll
|
:options="editableStates"
|
||||||
style="max-height: 300px"
|
hide-selected
|
||||||
:items="editableStates"
|
option-label="name"
|
||||||
separator
|
option-value="code"
|
||||||
v-slot="{ item, index }"
|
hide-dropdown-icon
|
||||||
>
|
focus-on-mount
|
||||||
<QItem
|
@update:model-value="changeState"
|
||||||
:key="index"
|
/>
|
||||||
dense
|
|
||||||
clickable
|
|
||||||
v-close-popup
|
|
||||||
@click="changeState(item.code)"
|
|
||||||
>
|
|
||||||
<QItemSection>
|
|
||||||
<QItemLabel>{{ item.name }}</QItemLabel>
|
|
||||||
</QItemSection>
|
|
||||||
</QItem>
|
|
||||||
</QVirtualScroll>
|
|
||||||
</QList>
|
|
||||||
</QBtnDropdown>
|
</QBtnDropdown>
|
||||||
</template>
|
</template>
|
||||||
<template #body>
|
<template #body>
|
||||||
|
|
Loading…
Reference in New Issue