From e5ec24ab608cc50b4c45ab56207816d83695a75f Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 9 Mar 2026 16:25:09 +0800 Subject: [PATCH] =?UTF-8?q?style=EF=BC=9A=E5=87=BA=E5=85=A5=E5=BA=93?= =?UTF-8?q?=E6=98=8E=E7=BB=86-tabs=E6=A0=8F=E6=94=B9=E6=88=90=E4=BB=8E?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/views/erp/stock/record/index.vue | 30 +++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/views/erp/stock/record/index.vue b/src/views/erp/stock/record/index.vue index 0c5728a0..870711f1 100644 --- a/src/views/erp/stock/record/index.vue +++ b/src/views/erp/stock/record/index.vue @@ -104,12 +104,7 @@ - - - - - - + ([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 +const categoryTabs = ref([]) /** 查询列表 */ const getList = async () => { @@ -282,7 +279,7 @@ onActivated(() => { }) onMounted(async () => { - queryParams.categoryId = 2 + await loadCategoryTabs() await getList() // 加载产品、仓库列表 productList.value = await ProductApi.getProductSimpleList() @@ -290,9 +287,24 @@ onMounted(async () => { }) /** tab 切换 */ -let activeName = '2' +const activeName = ref('') const handleTabClick = (tab: TabsPaneContext) => { - queryParams.categoryId = tab.paneName + queryParams.categoryId = tab.paneName ? Number(tab.paneName) : undefined handleQuery() } + +const loadCategoryTabs = async () => { + try { + const data = await ProductCategoryApi.getProductCategoryList({}) + const roots = (data || []).filter((item: any) => item && (item.parentId === 0 || item.parentId === null || item.parentId === undefined)) + categoryTabs.value = roots.sort((a: any, b: any) => Number(a?.sort ?? 0) - Number(b?.sort ?? 0)) + const defaultId = categoryTabs.value.find((v) => String(v.id) === '2')?.id ?? categoryTabs.value[0]?.id + queryParams.categoryId = defaultId + activeName.value = defaultId !== undefined && defaultId !== null ? String(defaultId) : '' + } catch { + categoryTabs.value = [] + queryParams.categoryId = undefined + activeName.value = '' + } +}