From 554b9e814b9af83e65c091cf1d0a30c61d6ead3e Mon Sep 17 00:00:00 2001 From: wbuezas <wbuezas@verdnatura.es> Date: Thu, 2 May 2024 09:08:03 -0300 Subject: [PATCH] WIP --- src/components/FilterItemForm.vue | 11 +- src/pages/Entry/Card/EntryBuysImport.vue | 1 + src/pages/Item/Card/CreateIntrastatForm.vue | 52 +++++ src/pages/Item/Card/ItemBasicData.vue | 240 +++++++++++++++++++- src/pages/Item/locale/en.yml | 17 ++ src/pages/Item/locale/es.yml | 17 ++ 6 files changed, 334 insertions(+), 4 deletions(-) create mode 100644 src/pages/Item/Card/CreateIntrastatForm.vue diff --git a/src/components/FilterItemForm.vue b/src/components/FilterItemForm.vue index e031999e2d..00659f8fd2 100644 --- a/src/components/FilterItemForm.vue +++ b/src/components/FilterItemForm.vue @@ -1,7 +1,6 @@ <script setup> import { ref, reactive, computed } from 'vue'; import { useI18n } from 'vue-i18n'; -import { useRoute } from 'vue-router'; import VnRow from 'components/ui/VnRow.vue'; import FetchData from 'components/FetchData.vue'; @@ -12,10 +11,16 @@ import ItemDescriptorProxy from 'src/pages/Item/Card/ItemDescriptorProxy.vue'; import axios from 'axios'; import { dashIfEmpty } from 'src/filters'; +const props = defineProps({ + url: { + type: String, + required: true, + }, +}); + const emit = defineEmits(['itemSelected']); const { t } = useI18n(); -const route = useRoute(); const itemFilter = { include: [ @@ -100,7 +105,7 @@ const fetchResults = async () => { } filter.where = where; - const { data } = await axios.get(`Entries/${route.params.id}/lastItemBuys`, { + const { data } = await axios.get(props.url, { params: { filter: JSON.stringify(filter) }, }); tableRows.value = data; diff --git a/src/pages/Entry/Card/EntryBuysImport.vue b/src/pages/Entry/Card/EntryBuysImport.vue index 705f56b682..6d856f0689 100644 --- a/src/pages/Entry/Card/EntryBuysImport.vue +++ b/src/pages/Entry/Card/EntryBuysImport.vue @@ -251,6 +251,7 @@ const redirectToBuysView = () => { > <template #form> <FilterItemForm + :url="`Entries/${route.params.id}/lastItemBuys`" @item-selected="row[col.field] = $event" /> </template> diff --git a/src/pages/Item/Card/CreateIntrastatForm.vue b/src/pages/Item/Card/CreateIntrastatForm.vue new file mode 100644 index 0000000000..3fd1ffe22c --- /dev/null +++ b/src/pages/Item/Card/CreateIntrastatForm.vue @@ -0,0 +1,52 @@ +<script setup> +import { reactive, ref, onMounted, nextTick } from 'vue'; +import { useI18n } from 'vue-i18n'; +import { useRoute } from 'vue-router'; + +import VnInput from 'src/components/common/VnInput.vue'; +import VnRow from 'components/ui/VnRow.vue'; +import FormModelPopup from 'components/FormModelPopup.vue'; + +const { t } = useI18n(); +const emit = defineEmits(['onDataSaved']); +const route = useRoute(); + +const identifierInputRef = ref(null); +const intrastatFormData = reactive({}); + +const onDataSaved = (formData, requestResponse) => { + emit('onDataSaved', formData, requestResponse); +}; + +onMounted(async () => { + await nextTick(); + identifierInputRef.value.focus(); +}); +</script> + +<template> + <FormModelPopup + :url-update="`Items/${route.params.id}/createIntrastat`" + model="itemGenus" + :title="t('createIntrastatForm.title')" + :form-initial-data="intrastatFormData" + @on-data-saved="onDataSaved" + > + <template #form-inputs="{ data }"> + <VnRow class="row q-gutter-md q-mb-md"> + <VnInput + ref="identifierInputRef" + :label="t('createIntrastatForm.identifier')" + type="number" + v-model.number="data.intrastatId" + :required="true" + /> + <VnInput + :label="t('createIntrastatForm.description')" + v-model="data.description" + :required="true" + /> + </VnRow> + </template> + </FormModelPopup> +</template> diff --git a/src/pages/Item/Card/ItemBasicData.vue b/src/pages/Item/Card/ItemBasicData.vue index 334cf049d5..dc6868fba5 100644 --- a/src/pages/Item/Card/ItemBasicData.vue +++ b/src/pages/Item/Card/ItemBasicData.vue @@ -1 +1,239 @@ -<template>Item basic data</template> +<script setup> +import { ref } from 'vue'; +import { useRoute } from 'vue-router'; +import { useI18n } from 'vue-i18n'; + +import FetchData from 'components/FetchData.vue'; +import FormModel from 'components/FormModel.vue'; +import VnRow from 'components/ui/VnRow.vue'; +import VnInput from 'src/components/common/VnInput.vue'; +import VnSelect from 'src/components/common/VnSelect.vue'; +import VnSelectDialog from 'src/components/common/VnSelectDialog.vue'; +import FilterItemForm from 'src/components/FilterItemForm.vue'; +import CreateIntrastatForm from './CreateIntrastatForm.vue'; + +const route = useRoute(); +const { t } = useI18n(); + +const itemTypesOptions = ref([]); +const itemsWithNameOptions = ref([]); +const intrastatsOptions = ref([]); +const expensesOptions = ref([]); + +const onIntrastatCreated = (response, formData) => { + intrastatsOptions.value = [...intrastatsOptions.value, response]; + formData.intrastatFk = response.id; +}; +</script> +<template> + <FetchData + url="ItemTypes" + :filter="{ + fields: ['id', 'name', 'categoryFk'], + include: 'category', + order: 'name ASC', + }" + @on-fetch="(data) => (itemTypesOptions = data)" + auto-load + /> + <FetchData + url="Items/withName" + :filter="{ + fields: ['id', 'name'], + order: 'id DESC', + }" + @on-fetch="(data) => (itemsWithNameOptions = data)" + auto-load + /> + <FetchData + url="Intrastats" + :filter="{ + fields: ['id', 'description'], + order: 'description ASC', + }" + @on-fetch="(data) => (intrastatsOptions = data)" + auto-load + /> + <FetchData + url="Expenses" + :filter="{ + fields: ['id', 'name'], + order: 'name ASC', + }" + @on-fetch="(data) => (expensesOptions = data)" + auto-load + /> + <FormModel + :url="`Items/${route.params.id}`" + :url-update="`Items/${route.params.id}`" + model="item" + auto-load + :clear-store-on-unmount="false" + > + <template #form="{ data }"> + <VnRow class="row q-gutter-md q-mb-md"> + <VnSelect + :label="t('basicData.type')" + v-model="data.typeFk" + :options="itemTypesOptions" + option-value="id" + option-label="name" + hide-selected + map-options + > + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.name }}</QItemLabel> + <QItemLabel caption> + {{ scope.opt?.category?.name }} + </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelect> + <VnInput :label="t('basicData.reference')" v-model="data.comment" /> + <VnInput :label="t('basicData.relevancy')" v-model="data.relevancy" /> + </VnRow> + <VnRow class="row q-gutter-md q-mb-md"> + <VnInput :label="t('basicData.stems')" v-model="data.stems" /> + <VnInput + :label="t('basicData.multiplier')" + v-model="data.stemMultiplier" + /> + <VnSelectDialog + :label="t('basicData.generic')" + v-model="data.genericFk" + :options="itemsWithNameOptions" + option-value="id" + option-label="name" + map-options + hide-selected + action-icon="filter_alt" + > + <template #form> + <FilterItemForm + url="Items/withName" + @item-selected="data.genericFk = $event" + /> + </template> + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.name }}</QItemLabel> + <QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelectDialog> + </VnRow> + <VnRow class="row q-gutter-md q-mb-md"> + <VnSelectDialog + :label="t('basicData.intrastat')" + v-model="data.intrastatFk" + :options="intrastatsOptions" + option-value="id" + option-label="description" + map-options + hide-selected + > + <template #form> + <CreateIntrastatForm + @on-data-saved=" + (_, requestResponse) => + onIntrastatCreated(requestResponse, data) + " + /> + </template> + <template #option="scope"> + <QItem v-bind="scope.itemProps"> + <QItemSection> + <QItemLabel>{{ scope.opt?.description }}</QItemLabel> + <QItemLabel caption> #{{ scope.opt?.id }} </QItemLabel> + </QItemSection> + </QItem> + </template> + </VnSelectDialog> + <div class="col"> + <VnSelect + :label="t('basicData.expense')" + v-model="data.expenseFk" + :options="expensesOptions" + option-value="id" + option-label="name" + hide-selected + map-options + /> + </div> + </VnRow> + <VnRow class="row q-gutter-md q-mb-md"> + <VnInput + :label="t('basicData.weightByPiece')" + v-model.number="data.weightByPiece" + :min="0" + type="number" + /> + <VnInput + :label="t('basicData.boxUnits')" + v-model.number="data.packingOut" + :min="0" + type="number" + /> + <VnInput + :label="t('basicData.recycledPlastic')" + v-model.number="data.recycledPlastic" + :min="0" + type="number" + /> + <VnInput + :label="t('basicData.nonRecycledPlastic')" + v-model.number="data.nonRecycledPlastic" + :min="0" + type="number" + /> + </VnRow> + <!-- <VnRow class="row q-gutter-md q-mb-md"> + <div class="col"> + <QInput + :label="t('entry.basicData.observation')" + type="textarea" + v-model="data.observation" + :maxlength="45" + counter + fill-input + /> + </div> + </VnRow> --> + <!-- <VnRow class="row q-gutter-md q-mb-md"> + <div class="col"> + <QCheckbox + v-model="data.isOrdered" + :label="t('entry.basicData.ordered')" + /> + </div> + <div class="col"> + <QCheckbox + v-model="data.isConfirmed" + :label="t('entry.basicData.confirmed')" + /> + </div> + <div class="col"> + <QCheckbox + v-model="data.isExcludedFromAvailable" + :label="t('entry.basicData.excludedFromAvailable')" + /> + </div> + <div class="col"> + <QCheckbox v-model="data.isRaid" :label="t('entry.basicData.raid')" /> + </div> + <div class="col"> + <QCheckbox + v-if="isAdministrative()" + v-model="data.isBooked" + :label="t('entry.basicData.booked')" + /> + </div> + </VnRow> --> + </template> + </FormModel> +</template> diff --git a/src/pages/Item/locale/en.yml b/src/pages/Item/locale/en.yml index ec3b134e81..410ed5edcf 100644 --- a/src/pages/Item/locale/en.yml +++ b/src/pages/Item/locale/en.yml @@ -11,3 +11,20 @@ itemDiary: showBefore: Show what's before the inventory since: Since warehouse: Warehouse +basicData: + type: Type + reference: Reference + relevancy: Relevancy + stems: Stems + multiplier: Multiplier + generic: Generic + intrastat: Intrastat + expense: Expense + weightByPiece: Weight/Piece + boxUnits: Units/Box + recycledPlastic: Recycled plastic + nonRecycledPlastic: Non recycled plastic +createIntrastatForm: + title: New intrastat + identifier: Identifier + description: Description diff --git a/src/pages/Item/locale/es.yml b/src/pages/Item/locale/es.yml index 4f76313fa6..6540c36c86 100644 --- a/src/pages/Item/locale/es.yml +++ b/src/pages/Item/locale/es.yml @@ -11,3 +11,20 @@ itemDiary: showBefore: Mostrar lo anterior al inventario since: Desde warehouse: Almacén +basicData: + type: Tipo + reference: Referencia + relevancy: Relevancia + stems: Tallos + multiplier: Multiplicador + generic: Genérico + intrastat: Intrastat + expense: Gasto + weightByPiece: Peso (gramos)/tallo + boxUnits: Unidades/caja + recycledPlastic: Plástico reciclado + nonRecycledPlastic: Plástico no reciclado +createIntrastatForm: + title: Nuevo intrastat + identifier: Identificador + description: Descripción