style:出入库明细-tabs栏改成从接口获取

main
黄伟杰 2 weeks ago
parent 1be69e069e
commit e5ec24ab60

@ -104,12 +104,7 @@
<!-- 列表 -->
<ContentWrap>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane :label="t('ErpStock.Record.categoryProduct')" name="2" />
<el-tab-pane :label="t('ErpStock.Record.categoryMaterial')" name="1" />
<el-tab-pane :label="t('ErpStock.Record.categorySpare')" name="5" />
<el-tab-pane :label="t('ErpStock.Record.categoryTool')" name="3" />
<el-tab-pane :label="t('ErpStock.Record.categoryConsumable')" name="4" />
<el-tab-pane :label="t('ErpStock.Record.categoryOther')" name="0" />
<el-tab-pane v-for="item in categoryTabs" :key="item.id" :label="item.name" :name="String(item.id)" />
</el-tabs>
<el-table
@ -181,6 +176,7 @@ import download from '@/utils/download'
import { StockRecordApi, StockRecordVO } from '@/api/erp/stock/record'
import { ProductApi, ProductVO } from '@/api/erp/product/product'
import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse'
import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category'
import { erpCountTableColumnFormatter } from '@/utils'
/** ERP 产品库存明细列表 */
@ -206,6 +202,7 @@ const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) //
const productList = ref<ProductVO[]>([]) //
const warehouseList = ref<WarehouseVO[]>([]) //
const categoryTabs = ref<ProductCategoryVO[]>([])
/** 查询列表 */
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 = ''
}
}
</script>

Loading…
Cancel
Save