forked from verdnatura/salix-front
fix(TicketBasicData_zone): refs #6233 add acls and fix get zones
This commit is contained in:
parent
55f8b78eba
commit
f2147311d3
|
@ -141,6 +141,7 @@ function findKeyInOptions() {
|
||||||
function setOptions(data) {
|
function setOptions(data) {
|
||||||
myOptions.value = JSON.parse(JSON.stringify(data));
|
myOptions.value = JSON.parse(JSON.stringify(data));
|
||||||
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
myOptionsOriginal.value = JSON.parse(JSON.stringify(data));
|
||||||
|
emit('update:options', data);
|
||||||
}
|
}
|
||||||
|
|
||||||
function filter(val, options) {
|
function filter(val, options) {
|
||||||
|
|
|
@ -12,6 +12,7 @@ import VnInputTime from 'components/common/VnInputTime.vue';
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import useNotify from 'src/composables/useNotify.js';
|
import useNotify from 'src/composables/useNotify.js';
|
||||||
|
import { useAcl } from 'src/composables/useAcl';
|
||||||
import { useValidator } from 'src/composables/useValidator';
|
import { useValidator } from 'src/composables/useValidator';
|
||||||
import { toTimeFormat } from 'filters/date.js';
|
import { toTimeFormat } from 'filters/date.js';
|
||||||
|
|
||||||
|
@ -28,14 +29,17 @@ const { validate } = useValidator();
|
||||||
const { notify } = useNotify();
|
const { notify } = useNotify();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
const agencyFetchRef = ref(null);
|
const canEditZone = useAcl().hasAny([
|
||||||
const zonesFetchRef = ref(null);
|
{ model: 'Ticket', props: 'editZone', accessType: 'WRITE' },
|
||||||
|
]);
|
||||||
|
|
||||||
|
const agencyFetchRef = ref();
|
||||||
const warehousesOptions = ref([]);
|
const warehousesOptions = ref([]);
|
||||||
const companiesOptions = ref([]);
|
const companiesOptions = ref([]);
|
||||||
const agenciesOptions = ref([]);
|
const agenciesOptions = ref([]);
|
||||||
const zonesOptions = ref([]);
|
const zonesOptions = ref([]);
|
||||||
const addresses = ref([]);
|
const addresses = ref([]);
|
||||||
|
const zoneSelectRef = ref();
|
||||||
const formData = ref($props.formData);
|
const formData = ref($props.formData);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
|
@ -44,6 +48,8 @@ watch(
|
||||||
{ deep: true }
|
{ deep: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
|
onMounted(() => onFormModelInit());
|
||||||
|
|
||||||
const agencyByWarehouseFilter = computed(() => ({
|
const agencyByWarehouseFilter = computed(() => ({
|
||||||
fields: ['id', 'name'],
|
fields: ['id', 'name'],
|
||||||
order: 'name ASC',
|
order: 'name ASC',
|
||||||
|
@ -52,8 +58,7 @@ const agencyByWarehouseFilter = computed(() => ({
|
||||||
},
|
},
|
||||||
}));
|
}));
|
||||||
|
|
||||||
function zoneWhere() {
|
const zoneWhere = computed(() => {
|
||||||
if (formData?.value?.agencyModeFk) {
|
|
||||||
return formData.value?.agencyModeFk
|
return formData.value?.agencyModeFk
|
||||||
? {
|
? {
|
||||||
shipped: formData.value?.shipped,
|
shipped: formData.value?.shipped,
|
||||||
|
@ -62,8 +67,7 @@ function zoneWhere() {
|
||||||
warehouseFk: formData.value?.warehouseFk,
|
warehouseFk: formData.value?.warehouseFk,
|
||||||
}
|
}
|
||||||
: {};
|
: {};
|
||||||
}
|
});
|
||||||
}
|
|
||||||
|
|
||||||
const getLanded = async (params) => {
|
const getLanded = async (params) => {
|
||||||
try {
|
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>
|
</script>
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
<FetchData
|
||||||
|
@ -416,6 +430,7 @@ onMounted(() => onFormModelInit());
|
||||||
:rules="validate('basicData.agency')"
|
:rules="validate('basicData.agency')"
|
||||||
/>
|
/>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
|
ref="zoneSelectRef"
|
||||||
:label="t('basicData.zone')"
|
:label="t('basicData.zone')"
|
||||||
v-model="zoneId"
|
v-model="zoneId"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
|
@ -424,11 +439,10 @@ onMounted(() => onFormModelInit());
|
||||||
:fields="['id', 'name']"
|
:fields="['id', 'name']"
|
||||||
sort-by="id"
|
sort-by="id"
|
||||||
:where="zoneWhere"
|
:where="zoneWhere"
|
||||||
hide-selected
|
|
||||||
map-options
|
|
||||||
:required="true"
|
|
||||||
@focus="zonesFetchRef.fetch()"
|
|
||||||
:rules="validate('basicData.zone')"
|
:rules="validate('basicData.zone')"
|
||||||
|
:required="true"
|
||||||
|
:disable="!canEditZone"
|
||||||
|
@update:options="getZone"
|
||||||
>
|
>
|
||||||
<template #option="scope">
|
<template #option="scope">
|
||||||
<QItem v-bind="scope.itemProps">
|
<QItem v-bind="scope.itemProps">
|
||||||
|
|
Loading…
Reference in New Issue