forked from verdnatura/salix-front
Merge pull request 'fix(TicketBasicData_zone): refs #6233 add acls and fix get zones' (!847) from 6233-fix_ticketBasicData_zone into dev
Reviewed-on: verdnatura/salix-front#847 Reviewed-by: Javi Gallego <jgallego@verdnatura.es>
This commit is contained in:
commit
fbd6633bdb
|
@ -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) {
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
</script>
|
||||
<template>
|
||||
<FetchData
|
||||
|
@ -416,6 +430,7 @@ onMounted(() => onFormModelInit());
|
|||
:rules="validate('basicData.agency')"
|
||||
/>
|
||||
<VnSelect
|
||||
ref="zoneSelectRef"
|
||||
:label="t('basicData.zone')"
|
||||
v-model="zoneId"
|
||||
option-value="id"
|
||||
|
@ -424,11 +439,10 @@ onMounted(() => onFormModelInit());
|
|||
:fields="['id', 'name']"
|
||||
sort-by="id"
|
||||
:where="zoneWhere"
|
||||
hide-selected
|
||||
map-options
|
||||
:required="true"
|
||||
@focus="zonesFetchRef.fetch()"
|
||||
:rules="validate('basicData.zone')"
|
||||
:required="true"
|
||||
:disable="!canEditZone"
|
||||
@update:options="getZone"
|
||||
>
|
||||
<template #option="scope">
|
||||
<QItem v-bind="scope.itemProps">
|
||||
|
|
Loading…
Reference in New Issue