From f2147311d3f774b2cdc332b3d22783287b3818d6 Mon Sep 17 00:00:00 2001 From: alexm Date: Mon, 21 Oct 2024 08:41:19 +0200 Subject: [PATCH] fix(TicketBasicData_zone): refs #6233 add acls and fix get zones --- src/components/common/VnSelect.vue | 1 + .../Card/BasicData/TicketBasicDataForm.vue | 52 ++++++++++++------- 2 files changed, 34 insertions(+), 19 deletions(-) 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/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); +}