refactor: refs #8246 fetch options efficiently and deleted unused data
gitea/salix-front/pipeline/pr-test This commit looks good
Details
gitea/salix-front/pipeline/pr-test This commit looks good
Details
This commit is contained in:
parent
f2335d7bda
commit
3e111d144e
|
@ -1,6 +1,6 @@
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useI18n } from 'vue-i18n';
|
import { useI18n } from 'vue-i18n';
|
||||||
import { computed, ref } from 'vue';
|
import { ref } from 'vue';
|
||||||
import FetchData from 'components/FetchData.vue';
|
import FetchData from 'components/FetchData.vue';
|
||||||
import FormModel from 'src/components/FormModel.vue';
|
import FormModel from 'src/components/FormModel.vue';
|
||||||
import VnRow from 'components/ui/VnRow.vue';
|
import VnRow from 'components/ui/VnRow.vue';
|
||||||
|
@ -9,33 +9,23 @@ import VnInputTime from 'src/components/common/VnInputTime.vue';
|
||||||
import VnSelect from 'src/components/common/VnSelect.vue';
|
import VnSelect from 'src/components/common/VnSelect.vue';
|
||||||
|
|
||||||
const { t } = useI18n();
|
const { t } = useI18n();
|
||||||
|
|
||||||
const agencyFilter = {
|
|
||||||
fields: ['id', 'name'],
|
|
||||||
order: 'name ASC',
|
|
||||||
limit: 30,
|
|
||||||
};
|
|
||||||
const agencyOptions = ref([]);
|
|
||||||
const validAddresses = ref([]);
|
const validAddresses = ref([]);
|
||||||
|
const addresses = ref([]);
|
||||||
|
|
||||||
const filterWhere = computed(() => ({
|
const setFilteredAddresses = (data) => {
|
||||||
id: { inq: validAddresses.value.map((item) => item.addressFk) },
|
const validIds = new Set(validAddresses.value.map((item) => item.addressFk));
|
||||||
}));
|
addresses.value = data.filter((address) => validIds.has(address.id));
|
||||||
|
};
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<FetchData
|
|
||||||
:filter="agencyFilter"
|
|
||||||
@on-fetch="(data) => (agencyOptions = data)"
|
|
||||||
auto-load
|
|
||||||
url="AgencyModes/isActive"
|
|
||||||
/>
|
|
||||||
<FetchData
|
<FetchData
|
||||||
url="RoadmapAddresses"
|
url="RoadmapAddresses"
|
||||||
auto-load
|
auto-load
|
||||||
@on-fetch="(data) => (validAddresses = data)"
|
@on-fetch="(data) => (validAddresses = data)"
|
||||||
/>
|
/>
|
||||||
<FormModel :url="`Zones/${route.params.id}`" auto-load model="zone">
|
<FetchData url="Addresses" auto-load @on-fetch="setFilteredAddresses" />
|
||||||
|
<FormModel auto-load model="zone">
|
||||||
<template #form="{ data, validate }">
|
<template #form="{ data, validate }">
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnInput
|
<VnInput
|
||||||
|
@ -45,7 +35,6 @@ const filterWhere = computed(() => ({
|
||||||
v-model="data.name"
|
v-model="data.name"
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
|
|
||||||
<VnRow>
|
<VnRow>
|
||||||
<VnSelect
|
<VnSelect
|
||||||
v-model="data.agencyModeFk"
|
v-model="data.agencyModeFk"
|
||||||
|
@ -128,14 +117,12 @@ const filterWhere = computed(() => ({
|
||||||
v-model="data.addressFk"
|
v-model="data.addressFk"
|
||||||
option-value="id"
|
option-value="id"
|
||||||
option-label="nickname"
|
option-label="nickname"
|
||||||
url="Addresses"
|
:options="addresses"
|
||||||
:fields="['id', 'nickname']"
|
:fields="['id', 'nickname']"
|
||||||
sort-by="id"
|
sort-by="id"
|
||||||
hide-selected
|
hide-selected
|
||||||
map-options
|
map-options
|
||||||
:rules="validate('data.addressFk')"
|
:rules="validate('data.addressFk')"
|
||||||
:filter-options="['id']"
|
|
||||||
:where="filterWhere"
|
|
||||||
/>
|
/>
|
||||||
</VnRow>
|
</VnRow>
|
||||||
<VnRow>
|
<VnRow>
|
||||||
|
|
Loading…
Reference in New Issue