feat: refs #8246 use new addressFk field
gitea/salix-front/pipeline/pr-test There was a failure building this commit Details

This commit is contained in:
Jon Elias 2025-02-10 10:25:49 +01:00
parent 676ce400ac
commit 66559a1c9e
3 changed files with 61 additions and 32 deletions

View File

@ -1,16 +1,13 @@
<script setup>
import { useRoute } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { ref } from 'vue';
import { computed, ref } from 'vue';
import FetchData from 'components/FetchData.vue';
import FormModel from 'src/components/FormModel.vue';
import VnRow from 'components/ui/VnRow.vue';
import VnInput from 'src/components/common/VnInput.vue';
import { QCheckbox } from 'quasar';
import VnInputTime from 'src/components/common/VnInputTime.vue';
import VnSelect from 'src/components/common/VnSelect.vue';
const route = useRoute();
const { t } = useI18n();
const agencyFilter = {
@ -19,6 +16,11 @@ const agencyFilter = {
limit: 30,
};
const agencyOptions = ref([]);
const validAddresses = ref([]);
const filterWhere = computed(() => ({
id: { inq: validAddresses.value.map((item) => item.addressFk) },
}));
</script>
<template>
@ -28,7 +30,11 @@ const agencyOptions = ref([]);
auto-load
url="AgencyModes/isActive"
/>
<FetchData
url="RoadmapAddresses"
auto-load
@on-fetch="(data) => (validAddresses = data)"
/>
<FormModel :url="`Zones/${route.params.id}`" auto-load model="zone">
<template #form="{ data, validate }">
<VnRow>
@ -42,16 +48,16 @@ const agencyOptions = ref([]);
<VnRow>
<VnSelect
option-label="name"
option-value="id"
v-model="data.agencyModeFk"
:rules="validate('zone.agencyModeFk')"
:options="agencyOptions"
url="AgencyModes/isActive"
:fields="['id', 'name']"
:label="t('Agency')"
emit-value
map-options
use-input
hide-bottom-space
sort-by="name"
/>
<VnInput
class="mw-10"
@ -128,6 +134,8 @@ const agencyOptions = ref([]);
hide-selected
map-options
:rules="validate('data.addressFk')"
:filter-options="['id']"
:where="filterWhere"
/>
</VnRow>
<VnRow>

View File

@ -22,15 +22,50 @@ const exprBuilder = (param, value) => {
return /^\d+$/.test(value) ? { id: value } : { name: { like: `%${value}%` } };
}
};
const tableFilter = {
include: [
{
relation: 'agencyMode',
scope: {
fields: ['id', 'name'],
},
},
{
relation: 'address',
scope: {
fields: ['id', 'nickname', 'provinceFk', 'postalCode'],
include: [
{
relation: 'province',
scope: {
fields: ['id', 'name'],
},
},
{
relation: 'postcode',
scope: {
fields: ['code', 'townFk'],
include: {
relation: 'town',
scope: {
fields: ['id', 'name'],
},
},
},
},
],
},
},
],
};
</script>
<template>
<VnSearchbar
data-key="ZonesList"
url="Zones"
:filter="{
include: { relation: 'agencyMode', scope: { fields: ['name'] } },
}"
:filter="tableFilter"
:expr-builder="exprBuilder"
:label="t('list.searchZone')"
:info="t('list.searchInfo')"

View File

@ -4,7 +4,7 @@ import { useRouter } from 'vue-router';
import { computed, ref } from 'vue';
import axios from 'axios';
import { toCurrency } from 'src/filters';
import { dashIfEmpty, toCurrency } from 'src/filters';
import { toTimeFormat } from 'src/filters/date';
import { useVnConfirm } from 'composables/useVnConfirm';
import useNotify from 'src/composables/useNotify.js';
@ -17,7 +17,6 @@ import VnInputTime from 'src/components/common/VnInputTime.vue';
import RightMenu from 'src/components/common/RightMenu.vue';
import ZoneFilterPanel from './ZoneFilterPanel.vue';
import ZoneSearchbar from './Card/ZoneSearchbar.vue';
import FetchData from 'src/components/FetchData.vue';
const { t } = useI18n();
const router = useRouter();
@ -26,7 +25,6 @@ const { viewSummary } = useSummaryDialog();
const { openConfirmationModal } = useVnConfirm();
const tableRef = ref();
const warehouseOptions = ref([]);
const validAddresses = ref([]);
const tableFilter = {
include: [
@ -161,30 +159,18 @@ const handleClone = (id) => {
openConfirmationModal(
t('list.confirmCloneTitle'),
t('list.confirmCloneSubtitle'),
() => clone(id)
() => clone(id),
);
};
function showValidAddresses(row) {
if (row.addressFk) {
const isValid = validAddresses.value.some(
(address) => address.addressFk === row.addressFk
);
if (isValid)
return `${row.address?.nickname},
${row.address?.postcode?.town?.name} (${row.address?.province?.name})`;
else return '-';
}
return '-';
function formatRow(row) {
if (!row?.address) return '-';
return dashIfEmpty(`${row?.address?.nickname},
${row?.address?.postcode?.town?.name} (${row?.address?.province?.name})`);
}
</script>
<template>
<FetchData
url="RoadmapAddresses"
auto-load
@on-fetch="(data) => (validAddresses = data)"
/>
<ZoneSearchbar />
<RightMenu>
<template #right-panel>
@ -207,7 +193,7 @@ function showValidAddresses(row) {
:right-search="false"
>
<template #column-addressFk="{ row }">
{{ showValidAddresses(row) }}
{{ dashIfEmpty(formatRow(row)) }}
</template>
<template #more-create-dialog="{ data }">
<VnSelect