Merge pull request '#8409: Added VnSelectSupplier' (!1274) from 8409-VnSelectSupplier into dev
gitea/salix-front/pipeline/head This commit looks good Details

Reviewed-on: #1274
Reviewed-by: Javier Segarra <jsegarra@verdnatura.es>
This commit is contained in:
Jon Elias 2025-01-30 14:20:06 +00:00
commit 22ae08863b
15 changed files with 91 additions and 296 deletions

View File

@ -31,7 +31,6 @@ const props = defineProps({
const route = useRoute();
const itemTypesOptions = ref([]);
const suppliersOptions = ref([]);
const tagOptions = ref([]);
const tagValues = ref([]);
const categoryList = ref(null);
@ -40,13 +39,13 @@ const selectedTypeFk = ref(getParamWhere(route.query.table, 'typeFk', false));
const selectedCategory = computed(() => {
return (categoryList.value || []).find(
(category) => category?.id === selectedCategoryFk.value
(category) => category?.id === selectedCategoryFk.value,
);
});
const selectedType = computed(() => {
return (itemTypesOptions.value || []).find(
(type) => type?.id === selectedTypeFk.value
(type) => type?.id === selectedTypeFk.value,
);
});
@ -134,13 +133,6 @@ const setCategoryList = (data) => {
<template>
<FetchData url="ItemCategories" limit="30" auto-load @on-fetch="setCategoryList" />
<FetchData
url="Suppliers"
limit="30"
auto-load
:filter="{ fields: ['id', 'name', 'nickname'], order: 'name ASC', limit: 30 }"
@on-fetch="(data) => (suppliersOptions = data)"
/>
<FetchData
url="Tags"
:filter="{ fields: ['id', 'name', 'isFree'] }"

View File

@ -0,0 +1,35 @@
<script setup>
import { computed } from 'vue';
import VnSelect from 'components/common/VnSelect.vue';
const model = defineModel({ type: [String, Number, Object] });
const url = 'Suppliers';
</script>
<template>
<VnSelect
:label="$t('globals.supplier')"
v-bind="$attrs"
v-model="model"
:url="url"
option-value="id"
option-label="nickname"
:fields="['id', 'name', 'nickname', 'nif']"
sort-by="name ASC"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name }}
</QItemLabel>
<QItemLabel caption>
{{
`#${scope.opt?.id} , ${scope.opt?.nickname} (${scope.opt?.nif})`
}}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
</template>

View File

@ -12,6 +12,7 @@ import VnSelectDialog from 'src/components/common/VnSelectDialog.vue';
import FilterTravelForm from 'src/components/FilterTravelForm.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import { toDate } from 'src/filters';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const route = useRoute();
const { t } = useI18n();
@ -51,28 +52,12 @@ const onFilterTravelSelected = (formData, id) => {
>
<template #form="{ data }">
<VnRow>
<VnSelect
:label="t('globals.supplier')"
<VnSelectSupplier
v-model="data.supplierFk"
url="Suppliers"
option-value="id"
option-label="nickname"
:fields="['id', 'nickname']"
hide-selected
:required="true"
map-options
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.name }}</QItemLabel>
<QItemLabel caption>
{{ scope.opt?.nickname }}, {{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
<VnSelectDialog
:label="t('entry.basicData.travel')"
v-model="data.travelFk"

View File

@ -13,6 +13,7 @@ import VnSearchbar from 'src/components/ui/VnSearchbar.vue';
import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState';
import { toDate } from 'src/filters';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const state = useState();
const { t } = useI18n();
@ -26,7 +27,6 @@ const newEntryForm = reactive({
travelFk: Number(route.query?.travelFk) || null,
companyFk: user.value.companyFk || null,
});
const suppliersOptions = ref([]);
const travelsOptions = ref([]);
const companiesOptions = ref([]);
@ -36,13 +36,6 @@ const redirectToEntryBasicData = (_, { id }) => {
</script>
<template>
<FetchData
url="Suppliers"
:filter="{ fields: ['id', 'nickname'] }"
order="nickname"
@on-fetch="(data) => (suppliersOptions = data)"
auto-load
/>
<FetchData
url="Travels/filter"
:filter="{ fields: ['id', 'warehouseInName'] }"
@ -79,28 +72,13 @@ const redirectToEntryBasicData = (_, { id }) => {
>
<template #form="{ data, validate }">
<VnRow>
<VnSelect
:label="t('Supplier')"
<VnSelectSupplier
class="full-width"
v-model="data.supplierFk"
:options="suppliersOptions"
option-value="id"
option-label="nickname"
hide-selected
:required="true"
:rules="validate('entry.supplierFk')"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.nickname }}</QItemLabel>
<QItemLabel caption>
#{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</VnRow>
<VnRow>
<VnSelect
@ -152,7 +130,6 @@ const redirectToEntryBasicData = (_, { id }) => {
<i18n>
es:
Supplier: Proveedor
Travel: Envío
Company: Empresa
</i18n>

View File

@ -7,6 +7,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import FetchData from 'components/FetchData.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
const props = defineProps({
@ -115,34 +116,14 @@ const companiesOptions = ref([]);
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('entryFilter.params.supplierFk')"
<VnSelectSupplier
v-model="params.supplierFk"
@update:model-value="searchFn()"
url="Suppliers"
option-value="id"
option-label="name"
:fields="['id', 'name', 'nickname']"
:filter-options="['id', 'name', 'nickname']"
sort-by="nickname"
hide-selected
dense
outlined
rounded
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name}}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<QItem>
@ -202,4 +183,4 @@ const companiesOptions = ref([]);
</QItem>
</template>
</VnFilterPanel>
</template>
</template>

View File

@ -7,6 +7,7 @@ import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue';
import VnSelect from 'components/common/VnSelect.vue';
import ItemsFilterPanel from 'src/components/ItemsFilterPanel.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
@ -18,7 +19,6 @@ defineProps({
});
const itemTypeWorkersOptions = ref([]);
const suppliersOptions = ref([]);
const tagValues = ref([]);
</script>
@ -30,13 +30,6 @@ const tagValues = ref([]);
:filter="{ fields: ['id', 'nickname'], order: 'nickname ASC', limit: 30 }"
@on-fetch="(data) => (itemTypeWorkersOptions = data)"
/>
<FetchData
url="Suppliers"
limit="30"
auto-load
:filter="{ fields: ['id', 'name', 'nickname'], order: 'name ASC', limit: 30 }"
@on-fetch="(data) => (suppliersOptions = data)"
/>
<ItemsFilterPanel :data-key="dataKey" :custom-tags="['tags']">
<template #body="{ params, searchFn }">
<QItem class="q-my-md">
@ -57,31 +50,14 @@ const tagValues = ref([]);
</QItem>
<QItem class="q-my-md">
<QItemSection>
<VnSelect
:label="t('globals.params.supplierFk')"
<VnSelectSupplier
v-model="params.supplierFk"
:options="suppliersOptions"
option-value="id"
option-label="name"
@update:model-value="searchFn()"
hide-selected
dense
outlined
rounded
use-input
@update:model-value="searchFn()"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name}}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<QItem class="q-my-md">

View File

@ -13,6 +13,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import VnDms from 'src/components/common/VnDms.vue';
import VnConfirm from 'src/components/ui/VnConfirm.vue';
import axios from 'axios';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
@ -115,27 +116,12 @@ function deleteFile(dmsFk) {
>
<template #form="{ data }">
<VnRow>
<VnSelect
:required="true"
:label="t('supplierFk')"
<VnSelectSupplier
v-model="data.supplierFk"
option-value="id"
option-label="nickname"
url="Suppliers"
:fields="['id', 'nickname']"
sort-by="nickname"
hide-selected
:is-clearable="false"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{
`${scope.opt.id} - ${scope.opt.nickname}`
}}</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
:required="true"
/>
<VnInput
clearable
clear-icon="close"

View File

@ -12,6 +12,7 @@ import { useStateStore } from 'stores/useStateStore';
import { useState } from 'src/composables/useState';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const state = useState();
const { t } = useI18n();
@ -60,28 +61,12 @@ const redirectToInvoiceInBasicData = (__, { id }) => {
>
<template #form="{ data, validate }">
<VnRow>
<VnSelect
url="Suppliers"
:fields="['id', 'nickname']"
:label="t('Supplier')"
<VnSelectSupplier
v-model="data.supplierFk"
option-value="id"
option-label="nickname"
hide-selected
:required="true"
:rules="validate('entry.supplierFk')"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.nickname }}</QItemLabel>
<QItemLabel caption>
#{{ scope.opt?.id }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
<VnInput
:label="t('invoiceIn.list.supplierRef')"
v-model="data.supplierRef"
@ -111,7 +96,6 @@ const redirectToInvoiceInBasicData = (__, { id }) => {
<i18n>
es:
Supplier: Proveedor
Travel: Envío
Company: Empresa
</i18n>

View File

@ -6,6 +6,7 @@ import VnInputDate from 'components/common/VnInputDate.vue';
import VnInputNumber from 'src/components/common/VnInputNumber.vue';
import { dateRange } from 'src/filters';
import { date } from 'quasar';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
defineProps({ dataKey: { type: String, required: true } });
const dateFormat = 'YYYY-MM-DDTHH:mm:ss.SSSZ';
@ -65,29 +66,12 @@ function handleDaysAgo(params, daysAgo) {
</QItem>
<QItem>
<QItemSection>
<VnSelect
<VnSelectSupplier
v-model="params.supplierFk"
url="Suppliers"
:fields="['id', 'nickname', 'name']"
:label="getLocale('supplierFk')"
option-label="nickname"
dense
outlined
rounded
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name}}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<QItem>

View File

@ -14,6 +14,7 @@ import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'src/components/common/VnInputDate.vue';
import FetchData from 'src/components/FetchData.vue';
import VnSection from 'src/components/common/VnSection.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const user = useState().getUser();
const { viewSummary } = useSummaryDialog();
@ -148,7 +149,9 @@ const cols = computed(() => [
<template #body>
<VnTable
ref="tableRef"
:data-key
data-key="InvoiceInList"
url="InvoiceIns/filter"
:order="['issued DESC', 'id DESC']"
:create="{
urlCreate: 'InvoiceIns',
title: t('globals.createInvoiceIn'),
@ -168,29 +171,13 @@ const cols = computed(() => [
</span>
</template>
<template #more-create-dialog="{ data }">
<VnSelect
<VnSelectSupplier
v-model="data.supplierFk"
url="Suppliers"
:fields="['id', 'name', 'nickname']"
:label="t('globals.supplier')"
option-value="id"
option-label="nickname"
:filter-options="['id', 'name', 'nickname']"
hide-selected
:required="true"
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>{{ scope.opt?.nickname }}</QItemLabel>
<QItemLabel caption>
#{{ scope.opt?.id }}, {{ scope.opt?.name }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
<VnInput
:label="t('invoiceIn.list.supplierRef')"
:label="t('invoicein.list.supplierRef')"
v-model="data.supplierRef"
/>
<VnSelect
@ -203,7 +190,7 @@ const cols = computed(() => [
:required="true"
/>
<VnInputDate
:label="t('invoiceIn.summary.issued')"
:label="t('invoicein.summary.issued')"
v-model="data.issued"
/>
</template>

View File

@ -12,6 +12,7 @@ import { QCheckbox } from 'quasar';
import { useArrayData } from 'composables/useArrayData';
import { useValidator } from 'src/composables/useValidator';
import axios from 'axios';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
@ -246,34 +247,14 @@ onMounted(async () => {
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('params.supplierFk')"
<VnSelectSupplier
v-model="params.supplierFk"
@update:model-value="searchFn()"
url="Suppliers"
option-value="id"
option-label="name"
:fields="['id', 'name', 'nickname']"
:filter-options="['id', 'name', 'nickname']"
sort-by="name ASC"
hide-selected
dense
outlined
rounded
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name }}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id} , ${scope.opt?.nickname}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<!-- Tags filter -->

View File

@ -6,6 +6,7 @@ import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
const props = defineProps({
@ -19,7 +20,6 @@ const emit = defineEmits(['search']);
const agencyList = ref([]);
const agencyAgreementList = ref([]);
const supplierList = ref([]);
const exprBuilder = (param, value) => {
switch (param) {
@ -58,14 +58,6 @@ const exprBuilder = (param, value) => {
@on-fetch="(data) => (agencyAgreementList = data)"
auto-load
/>
<FetchData
url="Suppliers"
:filter="{ fields: ['name'] }"
sort-by="name ASC"
limit="30"
@on-fetch="(data) => (supplierList = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:expr-builder="exprBuilder"
@ -123,14 +115,12 @@ const exprBuilder = (param, value) => {
/>
</QItemSection>
</QItem>
<QItem class="q-my-sm" v-if="supplierList">
<QItem class="q-my-sm">
<QItemSection>
<VnSelect
<VnSelectSupplier
:label="t('Autonomous')"
v-model="params.supplierFk"
:options="supplierList"
option-value="name"
option-label="name"
hide-selected
dense
outlined
rounded

View File

@ -6,29 +6,18 @@ import FormModel from 'components/FormModel.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue';
import VnInputTime from 'components/common/VnInputTime.vue';
import VnSelect from 'components/common/VnSelect.vue';
import FetchData from 'components/FetchData.vue';
import { ref } from 'vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
const router = useRouter();
const route = useRoute();
const supplierList = ref([]);
const filter = { include: [{ relation: 'supplier' }] };
const onSave = (data, response) => {
router.push({ name: 'RoadmapSummary', params: { id: response?.id } });
};
</script>
<template>
<FetchData
url="Suppliers"
auto-load
:filter="{ fields: ['id', 'nickname'] }"
sort-by="nickname"
limit="30"
@on-fetch="(data) => (supplierList = data)"
/>
<FormModel
:url="`Roadmaps/${route.params?.id}`"
observe-form-changes
@ -56,27 +45,14 @@ const onSave = (data, response) => {
/>
</VnRow>
<VnRow>
<VnSelect
<VnSelectSupplier
:label="t('Carrier')"
v-model="data.supplierFk"
:options="supplierList"
option-value="id"
option-label="nickname"
emit-value
map-options
use-input
:input-debounce="0"
>
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
<QItemSection>
<QItemLabel
>{{ opt.id }} - {{ opt.nickname }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
<VnInput
v-model="data.price"
:label="t('Price')"

View File

@ -3,9 +3,9 @@ import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import FetchData from 'components/FetchData.vue';
import VnFilterPanel from 'components/ui/VnFilterPanel.vue';
import VnSelect from 'components/common/VnSelect.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import VnInput from 'components/common/VnInput.vue';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
const props = defineProps({
@ -16,19 +16,9 @@ const props = defineProps({
});
const emit = defineEmits(['search']);
const supplierList = ref([]);
</script>
<template>
<FetchData
url="Suppliers"
:filter="{ fields: ['id', 'nickname'] }"
sort-by="nickname"
limit="30"
@on-fetch="(data) => (supplierList = data)"
auto-load
/>
<VnFilterPanel
:data-key="props.dataKey"
:search-button="true"
@ -71,14 +61,11 @@ const supplierList = ref([]);
/>
</QItemSection>
</QItem>
<QItem v-if="supplierList" class="q-my-sm">
<QItem class="q-my-sm">
<QItemSection>
<VnSelect
<VnSelectSupplier
:label="t('Carrier')"
v-model="params.supplierFk"
:options="supplierList"
option-value="id"
option-label="nickname"
dense
outlined
rounded
@ -86,17 +73,7 @@ const supplierList = ref([]);
map-options
use-input
:input-debounce="0"
>
<template #option="{ itemProps, opt }">
<QItem v-bind="itemProps">
<QItemSection>
<QItemLabel
>{{ opt.id }} - {{ opt.nickname }}</QItemLabel
>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<QItem class="q-my-sm">

View File

@ -8,6 +8,7 @@ import VnSelect from 'src/components/common/VnSelect.vue';
import VnInput from 'src/components/common/VnInput.vue';
import VnInputDate from 'components/common/VnInputDate.vue';
import axios from 'axios';
import VnSelectSupplier from 'src/components/common/VnSelectSupplier.vue';
const { t } = useI18n();
const props = defineProps({
@ -48,11 +49,11 @@ const warehouses = async () => {
continentsResponse.data.forEach((continent) => {
const countriesInContinent = Object.keys(countryContinentMap).filter(
(countryId) => countryContinentMap[countryId] === continent.id.toString()
(countryId) => countryContinentMap[countryId] === continent.id.toString(),
);
warehousesByContinent.value[continent.code] = warehousesResponse.data.filter(
(warehouse) => countriesInContinent.includes(warehouse.countryFk.toString())
(warehouse) => countriesInContinent.includes(warehouse.countryFk.toString()),
);
});
};
@ -211,30 +212,13 @@ warehouses();
</QItem>
<QItem>
<QItemSection>
<VnSelect
:label="t('globals.pageTitles.supplier')"
<VnSelectSupplier
v-model="params.cargoSupplierFk"
url="Suppliers"
option-value="id"
option-label="name"
hide-selected
dense
outlined
rounded
>
<template #option="scope">
<QItem v-bind="scope.itemProps">
<QItemSection>
<QItemLabel>
{{ scope.opt?.name}}
</QItemLabel>
<QItemLabel caption>
{{ `#${scope.opt?.id } , ${ scope.opt?.nickname}` }}
</QItemLabel>
</QItemSection>
</QItem>
</template>
</VnSelect>
/>
</QItemSection>
</QItem>
<QItem>