From 27f25f611fe14eb3d1c9b0e44b393c90b380fb34 Mon Sep 17 00:00:00 2001 From: carlossa Date: Fri, 6 Sep 2024 14:57:10 +0200 Subject: [PATCH] refs #7283 fix ItemDescriptor warehouse --- src/pages/Item/Card/ItemDescriptor.vue | 19 +++++++++++++------ src/pages/Item/Card/ItemDescriptorImage.vue | 1 - 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/pages/Item/Card/ItemDescriptor.vue b/src/pages/Item/Card/ItemDescriptor.vue index 5d7f1481f..c9766944e 100644 --- a/src/pages/Item/Card/ItemDescriptor.vue +++ b/src/pages/Item/Card/ItemDescriptor.vue @@ -47,7 +47,7 @@ const router = useRouter(); const { t } = useI18n(); const state = useState(); const user = state.getUser(); - +const warehouseConfig = ref(null); const entityId = computed(() => { return $props.id || route.params.id; }); @@ -58,16 +58,23 @@ const visible = ref(null); const salixUrl = ref(); onMounted(async () => { - updateStock(); salixUrl.value = await getUrl(''); + await getItemConfigs(); + await updateStock(); }); const data = ref(useCardDescription()); -const setData = (entity) => { +const setData = async (entity) => { if (!entity) return; data.value = useCardDescription(entity.name, entity.id); + await updateStock(); }; +const getItemConfigs = async () => { + const { data } = await axios.get('ItemConfigs/findOne'); + if (!data) return; + return (warehouseConfig.value = data.warehouseFk); +}; const updateStock = async () => { try { available.value = null; @@ -77,10 +84,10 @@ const updateStock = async () => { warehouseFk: $props.warehouseFk, dated: $props.dated, }; - if (!params.warehouseFk) { - params.warehouseFk = user.value.warehouseFk; - } + if (!params.warehouseFk) { + params.warehouseFk = warehouseConfig.value; + } const { data } = await axios.get(`Items/${entityId.value}/getVisibleAvailable`, { params, }); diff --git a/src/pages/Item/Card/ItemDescriptorImage.vue b/src/pages/Item/Card/ItemDescriptorImage.vue index 71977fb24..a4ef22ce3 100644 --- a/src/pages/Item/Card/ItemDescriptorImage.vue +++ b/src/pages/Item/Card/ItemDescriptorImage.vue @@ -47,7 +47,6 @@ const getWarehouseName = async (warehouseFk) => { const filter = { where: { id: warehouseFk }, }; - const { data } = await axios.get('Warehouses/findOne', { params: { filter: JSON.stringify(filter),