forked from verdnatura/salix-front
Add change state dropdown action
This commit is contained in:
parent
531f4bb8cd
commit
8c3262bcdf
|
@ -1,6 +1,5 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { ref, toRefs, computed, watch } from 'vue';
|
import { ref, toRefs, computed, watch, onMounted } from 'vue';
|
||||||
import { onMounted } from 'vue';
|
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import FetchData from 'src/components/FetchData.vue';
|
import FetchData from 'src/components/FetchData.vue';
|
||||||
const emit = defineEmits(['update:modelValue', 'update:options']);
|
const emit = defineEmits(['update:modelValue', 'update:options']);
|
||||||
|
@ -58,6 +57,10 @@ const $props = defineProps({
|
||||||
type: [Number, String],
|
type: [Number, String],
|
||||||
default: '30',
|
default: '30',
|
||||||
},
|
},
|
||||||
|
focusOnMount: {
|
||||||
|
type: Boolean,
|
||||||
|
default: false,
|
||||||
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
@ -146,6 +149,10 @@ watch(modelValue, (newValue) => {
|
||||||
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
if (!myOptions.value.some((option) => option[optionValue.value] == newValue))
|
||||||
fetchFilter(newValue);
|
fetchFilter(newValue);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
onMounted(async () => {
|
||||||
|
if ($props.focusOnMount) setTimeout(() => vnSelectRef.value.showPopup(), 300);
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
|
|
|
@ -31,6 +31,7 @@ const { notify } = useNotify();
|
||||||
const { openConfirmationModal } = useVnConfirm();
|
const { openConfirmationModal } = useVnConfirm();
|
||||||
const salesDataRef = ref(null);
|
const salesDataRef = ref(null);
|
||||||
const editPriceProxyRef = ref(null);
|
const editPriceProxyRef = ref(null);
|
||||||
|
const stateBtnDropdownRef = ref(null);
|
||||||
|
|
||||||
const arrayData = useArrayData('ticketData');
|
const arrayData = useArrayData('ticketData');
|
||||||
const { store } = arrayData;
|
const { store } = arrayData;
|
||||||
|
@ -40,6 +41,7 @@ const isLocked = ref(false);
|
||||||
const isTicketEditable = ref(false);
|
const isTicketEditable = ref(false);
|
||||||
const sales = ref([]);
|
const sales = ref([]);
|
||||||
const itemsWithNameOptions = ref([]);
|
const itemsWithNameOptions = ref([]);
|
||||||
|
const editableStatesOptions = ref([]);
|
||||||
const selectedSales = ref([]);
|
const selectedSales = ref([]);
|
||||||
const mana = ref(null);
|
const mana = ref(null);
|
||||||
const manaCode = ref('mana');
|
const manaCode = ref('mana');
|
||||||
|
@ -336,6 +338,7 @@ const goToLog = (saleId) => {
|
||||||
|
|
||||||
const changeTicketState = async (val) => {
|
const changeTicketState = async (val) => {
|
||||||
try {
|
try {
|
||||||
|
stateBtnDropdownRef.value.hide();
|
||||||
const params = { ticketFk: route.params.id, code: val };
|
const params = { ticketFk: route.params.id, code: val };
|
||||||
await axios.post('Tickets/state', params);
|
await axios.post('Tickets/state', params);
|
||||||
notify('globals.dataSaved', 'positive');
|
notify('globals.dataSaved', 'positive');
|
||||||
|
@ -397,9 +400,38 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (itemsWithNameOptions = data)"
|
@on-fetch="(data) => (itemsWithNameOptions = data)"
|
||||||
/>
|
/>
|
||||||
|
<FetchData
|
||||||
|
url="States/editableStates"
|
||||||
|
:filter="{ fields: ['code', 'name', 'id', 'alertLevel'], order: 'name ASC' }"
|
||||||
|
auto-load
|
||||||
|
@on-fetch="(data) => (editableStatesOptions = data)"
|
||||||
|
/>
|
||||||
<VnSubToolbar>
|
<VnSubToolbar>
|
||||||
<template #st-actions>
|
<template #st-actions>
|
||||||
<QBtnGroup push class="q-gutter-x-sm" flat>
|
<QBtnGroup push class="q-gutter-x-sm" flat>
|
||||||
|
<QBtn
|
||||||
|
:label="t('ticketSale.ok')"
|
||||||
|
color="primary"
|
||||||
|
:disable="!isTicketEditable || ticketState === 'OK'"
|
||||||
|
@click="changeTicketState('OK')"
|
||||||
|
>
|
||||||
|
<QTooltip>{{ t(`Change ticket state to 'Ok'`) }}</QTooltip>
|
||||||
|
</QBtn>
|
||||||
|
<QBtnDropdown
|
||||||
|
ref="stateBtnDropdownRef"
|
||||||
|
color="primary"
|
||||||
|
:label="t('ticketSale.state')"
|
||||||
|
>
|
||||||
|
<VnSelect
|
||||||
|
:options="editableStatesOptions"
|
||||||
|
hide-selected
|
||||||
|
option-label="name"
|
||||||
|
option-value="code"
|
||||||
|
hide-dropdown-icon
|
||||||
|
focus-on-mount
|
||||||
|
@update:model-value="changeTicketState"
|
||||||
|
/>
|
||||||
|
</QBtnDropdown>
|
||||||
<QBtn
|
<QBtn
|
||||||
color="primary"
|
color="primary"
|
||||||
icon="delete"
|
icon="delete"
|
||||||
|
@ -414,14 +446,6 @@ onUnmounted(() => (stateStore.rightDrawer = false));
|
||||||
>
|
>
|
||||||
<QTooltip>{{ t('Remove lines') }}</QTooltip>
|
<QTooltip>{{ t('Remove lines') }}</QTooltip>
|
||||||
</QBtn>
|
</QBtn>
|
||||||
<QBtn
|
|
||||||
:label="t('ticketSale.ok')"
|
|
||||||
color="primary"
|
|
||||||
:disable="!isTicketEditable || ticketState === 'OK'"
|
|
||||||
@click="changeTicketState('OK')"
|
|
||||||
>
|
|
||||||
<QTooltip>{{ t(`Change ticket state to 'Ok'`) }}</QTooltip>
|
|
||||||
</QBtn>
|
|
||||||
</QBtnGroup>
|
</QBtnGroup>
|
||||||
</template>
|
</template>
|
||||||
</VnSubToolbar>
|
</VnSubToolbar>
|
||||||
|
|
|
@ -17,3 +17,4 @@ ticketSale:
|
||||||
noVisible: Not visible
|
noVisible: Not visible
|
||||||
hasComponentLack: Component lack
|
hasComponentLack: Component lack
|
||||||
ok: Ok
|
ok: Ok
|
||||||
|
state: State
|
||||||
|
|
|
@ -19,3 +19,4 @@ ticketSale:
|
||||||
noVisible: No visible
|
noVisible: No visible
|
||||||
hasComponentLack: Faltan componentes
|
hasComponentLack: Faltan componentes
|
||||||
ok: Ok
|
ok: Ok
|
||||||
|
state: Estado
|
||||||
|
|
Loading…
Reference in New Issue