From 4c1d95010dd2a82505101dad3ffadc6244486b34 Mon Sep 17 00:00:00 2001 From: hwj Date: Mon, 15 Jun 2026 18:22:47 +0800 Subject: [PATCH] =?UTF-8?q?feat=EF=BC=9A=E5=BA=93=E5=AD=98=E6=8A=A5?= =?UTF-8?q?=E8=A1=A8=E6=A8=A1=E5=9D=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/erp/stock/stock/index.ts | 20 +++++ src/locales/en.ts | 11 ++- src/locales/zh-CN.ts | 11 ++- src/views/erp/stock/stock/index.vue | 121 +++++++++++++++++----------- 4 files changed, 106 insertions(+), 57 deletions(-) diff --git a/src/api/erp/stock/stock/index.ts b/src/api/erp/stock/stock/index.ts index 4de86fb1..d0e2a28a 100644 --- a/src/api/erp/stock/stock/index.ts +++ b/src/api/erp/stock/stock/index.ts @@ -6,10 +6,30 @@ export interface StockVO { id: number // 产品编号 productId: number + name?: string + productName?: string + barCode?: string + categoryName?: string + unitName?: string + // 产品分类类型 + categoryType?: number // 仓库编号 warehouseId: number + warehouseName?: string + areaId?: number + areaName?: string // 库存数量 count: number + latestInTime?: number | string + lastInTime?: number | string + recentInTime?: number | string + latestStockInTime?: number | string + lastStockInTime?: number | string + latestOutTime?: number | string + lastOutTime?: number | string + recentOutTime?: number | string + latestStockOutTime?: number | string + lastStockOutTime?: number | string } // ERP 产品库存 API diff --git a/src/locales/en.ts b/src/locales/en.ts index be85d31b..4a826ac3 100644 --- a/src/locales/en.ts +++ b/src/locales/en.ts @@ -345,11 +345,14 @@ export default { Stock: { product: 'Product', warehouse: 'Warehouse', - code: 'Code', - name: 'Name', - category: 'Category', + code: 'Material Code', + name: 'Material Name', + category: 'Material Category', + area: 'Area', unit: 'Unit', - count: 'Stock Quantity', + count: 'Base Quantity', + latestInTime: 'Latest Inbound', + latestOutTime: 'Latest Outbound', placeholderProduct: 'Please select product', placeholderWarehouse: 'Please select warehouse', exportName: 'Product Stock.xls' diff --git a/src/locales/zh-CN.ts b/src/locales/zh-CN.ts index 04d09cd1..9d992190 100644 --- a/src/locales/zh-CN.ts +++ b/src/locales/zh-CN.ts @@ -345,11 +345,14 @@ export default { Stock: { product: '产品', warehouse: '仓库', - code: '编码', - name: '名称', - category: '分类', + code: '物料编码', + name: '物料名称', + category: '物料大类', + area: '库区', unit: '单位', - count: '库存量', + count: '基本数量', + latestInTime: '最近入库', + latestOutTime: '最近出库', placeholderProduct: '请选择产品', placeholderWarehouse: '请选择仓库', exportName: '产品库存.xls' diff --git a/src/views/erp/stock/stock/index.vue b/src/views/erp/stock/stock/index.vue index 64e074dd..f851338e 100644 --- a/src/views/erp/stock/stock/index.vue +++ b/src/views/erp/stock/stock/index.vue @@ -69,22 +69,13 @@ - - - + - - - - - - - + + + + + + + + + + + + + + + + + import download from '@/utils/download' +import { DICT_TYPE, getIntDictOptions } from '@/utils/dict' import { StockApi, StockVO } from '@/api/erp/stock/stock' import { ProductApi, ProductVO } from '@/api/erp/product/product' import { WarehouseApi, WarehouseVO } from '@/api/erp/stock/warehouse' -import { erpCountTableColumnFormatter } from '@/utils' -import { ProductCategoryApi, ProductCategoryVO } from '@/api/erp/product/category' -import { handleTree } from '@/utils/tree' +import { useDictStoreWithOut } from '@/store/modules/dict' +import { formatDate } from '@/utils/formatTime' /** ERP 产品库存列表 */ defineOptions({ name: 'ErpStock' }) const message = useMessage() // 消息弹窗 const { t } = useI18n() // 国际化 +const dictStore = useDictStoreWithOut() const loading = ref(true) // 列表的加载中 const list = ref([]) // 列表的数据 const total = ref(0) // 列表的总页数 -const queryParams = reactive({ +const queryParams = reactive<{ + pageNo: number + pageSize: number + productId?: number + warehouseId?: number + categoryType?: number +}>({ pageNo: 1, pageSize: 10, productId: undefined, warehouseId: undefined, - categoryId: undefined + categoryType: undefined }) const queryFormRef = ref() // 搜索的表单 const exportLoading = ref(false) // 导出的加载中 const productList = ref([]) // 产品列表 const warehouseList = ref([]) // 仓库列表 -const categoryList = ref([]) // 产品分类列表 -const parentList = ref([]) +const categoryTabs = computed(() => getIntDictOptions(DICT_TYPE.MATERIAL_CLASSIFICATION_TYPE)) + +const formatStockCount = (value: number | string | undefined) => { + if (value === undefined || value === null || value === '') return '-' + const num = Number(value) + return Number.isFinite(num) ? num.toLocaleString() : String(value) +} + +const formatStockTime = (value: any) => { + return value ? formatDate(value, 'YYYY-MM-DD HH:mm:ss') : '-' +} + +const getLatestInTime = (row: any) => { + return row.latestInTime ?? row.lastInTime ?? row.recentInTime ?? row.latestStockInTime ?? row.lastStockInTime +} + +const getLatestOutTime = (row: any) => { + return row.latestOutTime ?? row.lastOutTime ?? row.recentOutTime ?? row.latestStockOutTime ?? row.lastStockOutTime +} /** 查询列表 */ const getList = async () => { @@ -221,28 +248,24 @@ const handleSelectionChange = (rows: StockVO[]) => { /** 初始化 **/ onMounted(async () => { - queryParams.categoryId = 2 + await dictStore.setDictMap() + await loadCategoryTabs() await getList() // 加载产品、仓库列表 productList.value = await ProductApi.getProductSimpleList() warehouseList.value = await WarehouseApi.getWarehouseSimpleList() - // 产品分类 - const categoryData = await ProductCategoryApi.getProductCategorySimpleList() - categoryList.value = handleTree(categoryData, 'id', 'parentId') - // 获取顶层分类 - for (let i = 0; i < categoryData.length; i++) { - if (categoryData[i].parentId === 0) { - parentList.value.push(categoryData[i]); - } - } - // 排序 - parentList.value.sort((a, b) => a.sort - b.sort); }) /** tab 切换 */ -let activeName = '2' +const activeName = ref('') const handleTabClick = (tab: TabsPaneContext) => { - queryParams.categoryId = tab.paneName + queryParams.categoryType = tab.paneName ? Number(tab.paneName) : undefined handleQuery() } + +const loadCategoryTabs = async () => { + const defaultValue = categoryTabs.value[0]?.value + queryParams.categoryType = defaultValue !== undefined && defaultValue !== null ? Number(defaultValue) : undefined + activeName.value = defaultValue !== undefined && defaultValue !== null ? String(defaultValue) : '' +}