diff --git a/src/boot/axios.js b/src/boot/axios.js index 99a163cca..3bd80f487 100644 --- a/src/boot/axios.js +++ b/src/boot/axios.js @@ -2,9 +2,11 @@ import axios from 'axios'; import { useSession } from 'src/composables/useSession'; import { Router } from 'src/router'; import useNotify from 'src/composables/useNotify.js'; +import { useStateQueryStore } from 'src/stores/useStateQueryStore'; const session = useSession(); const { notify } = useNotify(); +const stateQuery = useStateQueryStore(); const baseUrl = '/api/'; axios.defaults.baseURL = baseUrl; @@ -15,7 +17,7 @@ const onRequest = (config) => { if (token.length && !config.headers.Authorization) { config.headers.Authorization = token; } - + stateQuery.add(config); return config; }; @@ -24,10 +26,10 @@ const onRequestError = (error) => { }; const onResponse = (response) => { - const { method } = response.config; + const config = response.config; + stateQuery.remove(config); - const isSaveRequest = method === 'patch'; - if (isSaveRequest) { + if (config.method === 'patch') { notify('globals.dataSaved', 'positive'); } @@ -35,6 +37,8 @@ const onResponse = (response) => { }; const onResponseError = (error) => { + stateQuery.remove(error.config); + let message = ''; const response = error.response; diff --git a/src/components/CreateNewPostcodeForm.vue b/src/components/CreateNewPostcodeForm.vue index 99cba5360..030ca1388 100644 --- a/src/components/CreateNewPostcodeForm.vue +++ b/src/components/CreateNewPostcodeForm.vue @@ -79,14 +79,20 @@ async function onProvinceCreated(data) { watch( () => [postcodeFormData.countryFk], async (newCountryFk, oldValueFk) => { - if (!!oldValueFk[0] && newCountryFk[0] !== oldValueFk[0]) { + if (Array.isArray(newCountryFk)) { + newCountryFk = newCountryFk[0]; + } + if (Array.isArray(oldValueFk)) { + oldValueFk = oldValueFk[0]; + } + if (!!oldValueFk && newCountryFk !== oldValueFk) { postcodeFormData.provinceFk = null; postcodeFormData.townFk = null; } - if ((newCountryFk, newCountryFk !== postcodeFormData.countryFk)) { + if (oldValueFk !== newCountryFk) { await provincesFetchDataRef.value.fetch({ where: { - countryFk: newCountryFk[0], + countryFk: newCountryFk, }, }); await townsFetchDataRef.value.fetch({ @@ -103,9 +109,12 @@ watch( watch( () => postcodeFormData.provinceFk, async (newProvinceFk) => { - if (newProvinceFk[0] && newProvinceFk[0] !== postcodeFormData.provinceFk) { + if (Array.isArray(newProvinceFk)) { + newProvinceFk = newProvinceFk[0]; + } + if (newProvinceFk !== postcodeFormData.provinceFk) { await townsFetchDataRef.value.fetch({ - where: { provinceFk: newProvinceFk[0] }, + where: { provinceFk: newProvinceFk }, }); } } @@ -125,16 +134,26 @@ async function handleCountries(data) { - + { }, }" url="Autonomies/location" + :sort-by="['name ASC']" + :limit="30" /> + diff --git a/src/components/common/VnSelect.vue b/src/components/common/VnSelect.vue index 952b7dd8c..b0aa648c1 100644 --- a/src/components/common/VnSelect.vue +++ b/src/components/common/VnSelect.vue @@ -141,6 +141,7 @@ function findKeyInOptions() { function setOptions(data) { myOptions.value = JSON.parse(JSON.stringify(data)); myOptionsOriginal.value = JSON.parse(JSON.stringify(data)); + emit('update:options', data); } function filter(val, options) { diff --git a/src/css/app.scss b/src/css/app.scss index 905934d4c..d4c76ad6b 100644 --- a/src/css/app.scss +++ b/src/css/app.scss @@ -288,3 +288,7 @@ input::-webkit-inner-spin-button { color: $info; } } + +.no-visible { + visibility: hidden; +} diff --git a/src/pages/Item/ItemRequest.vue b/src/pages/Item/ItemRequest.vue index 8a41bbe04..82c3b48e0 100644 --- a/src/pages/Item/ItemRequest.vue +++ b/src/pages/Item/ItemRequest.vue @@ -229,7 +229,7 @@ onBeforeMount(() => { > @@ -251,7 +251,7 @@ onBeforeMount(() => { @@ -292,7 +292,7 @@ onBeforeMount(() => { diff --git a/src/pages/Item/ItemRequestFilter.vue b/src/pages/Item/ItemRequestFilter.vue index 0e81ff5a5..64bc0e575 100644 --- a/src/pages/Item/ItemRequestFilter.vue +++ b/src/pages/Item/ItemRequestFilter.vue @@ -174,6 +174,16 @@ const decrement = (paramsObj, key) => { + + + + + @@ -274,11 +284,11 @@ en: to: To mine: For me state: State + myTeam: My team dateFiltersTooltip: Cannot choose a range of dates and days onward at the same time denied: Denied accepted: Accepted pending: Pending - es: params: search: Búsqueda general @@ -291,6 +301,7 @@ es: to: Hasta mine: Para mi state: Estado + myTeam: Mi equipo dateFiltersTooltip: No se puede seleccionar un rango de fechas y días en adelante a la vez denied: Denegada accepted: Aceptada diff --git a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue index fdc75abda..f5ce8a0f3 100644 --- a/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue +++ b/src/pages/Ticket/Card/BasicData/TicketBasicDataForm.vue @@ -12,6 +12,7 @@ import VnInputTime from 'components/common/VnInputTime.vue'; import axios from 'axios'; import useNotify from 'src/composables/useNotify.js'; +import { useAcl } from 'src/composables/useAcl'; import { useValidator } from 'src/composables/useValidator'; import { toTimeFormat } from 'filters/date.js'; @@ -28,14 +29,17 @@ const { validate } = useValidator(); const { notify } = useNotify(); const router = useRouter(); const { t } = useI18n(); -const agencyFetchRef = ref(null); -const zonesFetchRef = ref(null); +const canEditZone = useAcl().hasAny([ + { model: 'Ticket', props: 'editZone', accessType: 'WRITE' }, +]); +const agencyFetchRef = ref(); const warehousesOptions = ref([]); const companiesOptions = ref([]); const agenciesOptions = ref([]); const zonesOptions = ref([]); const addresses = ref([]); +const zoneSelectRef = ref(); const formData = ref($props.formData); watch( @@ -44,6 +48,8 @@ watch( { deep: true } ); +onMounted(() => onFormModelInit()); + const agencyByWarehouseFilter = computed(() => ({ fields: ['id', 'name'], order: 'name ASC', @@ -52,18 +58,16 @@ const agencyByWarehouseFilter = computed(() => ({ }, })); -function zoneWhere() { - if (formData?.value?.agencyModeFk) { - return formData.value?.agencyModeFk - ? { - shipped: formData.value?.shipped, - addressFk: formData.value?.addressFk, - agencyModeFk: formData.value?.agencyModeFk, - warehouseFk: formData.value?.warehouseFk, - } - : {}; - } -} +const zoneWhere = computed(() => { + return formData.value?.agencyModeFk + ? { + shipped: formData.value?.shipped, + addressFk: formData.value?.addressFk, + agencyModeFk: formData.value?.agencyModeFk, + warehouseFk: formData.value?.warehouseFk, + } + : {}; +}); const getLanded = async (params) => { try { @@ -270,7 +274,17 @@ const redirectToCustomerAddress = () => { }); }; -onMounted(() => onFormModelInit()); +async function getZone(options) { + if (!zoneId.value) return; + + const zone = options.find((z) => z.id == zoneId.value); + if (zone) return; + + const { data } = await axios.get('Zones/' + zoneId.value, { + params: { filter: JSON.stringify({ fields: ['id', 'name'] }) }, + }); + zoneSelectRef.value.opts.push(data); +}