diff --git a/admin/src/api/inventory.ts b/admin/src/api/inventory.ts new file mode 100644 index 00000000..c7f1f2e6 --- /dev/null +++ b/admin/src/api/inventory.ts @@ -0,0 +1,21 @@ +import http from './request' + +export function getInventoryList(params: { page?: number; pageSize?: number; keyword?: string }) { + return http.get('/admin/inventory', { params }) +} + +export function createInventoryItem(data: any) { + return http.post('/admin/inventory', data) +} + +export function deleteInventoryItems(specIds: number[]) { + return http.delete('/admin/inventory', { data: { specIds } }) +} + +export function exportInventory(keyword?: string) { + return http.get('/admin/inventory/export', { params: { keyword }, responseType: 'blob' } as any) +} + +export function getProductsForSelect() { + return http.get('/admin/inventory/products') +} diff --git a/admin/src/layout/AdminLayout.vue b/admin/src/layout/AdminLayout.vue index e87587fd..f034b1d1 100644 --- a/admin/src/layout/AdminLayout.vue +++ b/admin/src/layout/AdminLayout.vue @@ -23,6 +23,10 @@ + + + + @@ -101,6 +105,7 @@ const titleMap: Record = { '/dashboard': '', '/products': '商品管理', '/products/create': '新增商品', + '/inventory': '库存管理', '/categories': '分类管理', '/orders': '订单管理', '/molds': '版房管理', diff --git a/admin/src/router/index.ts b/admin/src/router/index.ts index fc59088d..9e4c7fe4 100644 --- a/admin/src/router/index.ts +++ b/admin/src/router/index.ts @@ -34,6 +34,11 @@ const router = createRouter({ name: 'ProductEdit', component: () => import('../views/product/ProductForm.vue'), }, + { + path: 'inventory', + name: 'InventoryList', + component: () => import('../views/inventory/InventoryList.vue'), + }, { path: 'orders', name: 'OrderList', diff --git a/admin/src/views/inventory/InventoryList.vue b/admin/src/views/inventory/InventoryList.vue new file mode 100644 index 00000000..9eef0a30 --- /dev/null +++ b/admin/src/views/inventory/InventoryList.vue @@ -0,0 +1,359 @@ + + + + + diff --git a/admin/src/views/product/ProductForm.vue b/admin/src/views/product/ProductForm.vue index 518e907a..fb67ac93 100644 --- a/admin/src/views/product/ProductForm.vue +++ b/admin/src/views/product/ProductForm.vue @@ -225,8 +225,8 @@ - - + + @@ -293,10 +293,6 @@ - - - - @@ -328,8 +324,8 @@
工费信息
- - +
读取商品基本信息的工费
+
根据主石副石自动计算
@@ -450,7 +446,7 @@ function resetSpecForm() { goldPrice: globalGoldPrice.value, goldValue: 0, mainStoneCount: 0, mainStoneWeight: 0, mainStoneUnitPrice: 0, mainStoneAmount: 0, sideStoneCount: 0, sideStoneWeight: 0, sideStoneUnitPrice: 0, sideStoneAmount: 0, - accessoryAmount: 0, processingFee: 0, settingFee: 0, totalLaborCost: 0, totalPrice: 0, + accessoryAmount: 0, processingFee: Number(form.laborCost) || 0, settingFee: 0, totalLaborCost: 0, totalPrice: 0, }) } @@ -464,6 +460,21 @@ function recalcSpec() { f.goldValue = +(f.goldLoss * n(f.goldPrice)).toFixed(2) f.mainStoneAmount = +(n(f.mainStoneWeight) * n(f.mainStoneUnitPrice)).toFixed(2) f.sideStoneAmount = +(n(f.sideStoneWeight) * n(f.sideStoneUnitPrice)).toFixed(2) + // 镶石工费自动计算 + const mc = n(f.mainStoneCount) + const mw = n(f.mainStoneWeight) + const sc = n(f.sideStoneCount) + const avg = mc > 0 ? mw / mc : 0 + let unitPrice = 0 + if (mc > 0) { + if (avg <= 0.1) unitPrice = 5 + else if (avg < 0.5) unitPrice = 10 + else if (avg <= 1.0) unitPrice = 20 + else if (avg < 1.5) unitPrice = 30 + else unitPrice = 50 + } + f.settingFee = +(mc * unitPrice + sc * 3).toFixed(2) + f.processingFee = Number(form.laborCost) || 0 f.totalLaborCost = +(n(f.accessoryAmount) + n(f.processingFee) + n(f.settingFee)).toFixed(2) f.totalPrice = +(f.goldValue + f.mainStoneAmount + f.sideStoneAmount + f.totalLaborCost).toFixed(2) } @@ -475,8 +486,8 @@ function onFinenesChange(val: string) { watch( () => [ specForm.goldTotalWeight, specForm.loss, specForm.goldPrice, - specForm.mainStoneWeight, specForm.mainStoneUnitPrice, - specForm.sideStoneWeight, specForm.sideStoneUnitPrice, + specForm.mainStoneCount, specForm.mainStoneWeight, specForm.mainStoneUnitPrice, + specForm.sideStoneCount, specForm.sideStoneWeight, specForm.sideStoneUnitPrice, specForm.accessoryAmount, specForm.processingFee, specForm.settingFee, ], recalcSpec, @@ -498,7 +509,7 @@ function handleEditSpec(row: any) { goldPrice: row.goldPrice, goldValue: row.goldValue, mainStoneCount: row.mainStoneCount, mainStoneWeight: row.mainStoneWeight, mainStoneUnitPrice: row.mainStoneUnitPrice, mainStoneAmount: row.mainStoneAmount, sideStoneCount: row.sideStoneCount, sideStoneWeight: row.sideStoneWeight, sideStoneUnitPrice: row.sideStoneUnitPrice, sideStoneAmount: row.sideStoneAmount, - accessoryAmount: row.accessoryAmount, processingFee: row.processingFee, settingFee: row.settingFee, totalLaborCost: row.totalLaborCost, totalPrice: row.totalPrice, + accessoryAmount: row.accessoryAmount, processingFee: Number(form.laborCost) || 0, settingFee: row.settingFee, totalLaborCost: row.totalLaborCost, totalPrice: row.totalPrice, }) specDialogVisible.value = true } diff --git a/admin/src/views/product/ProductList.vue b/admin/src/views/product/ProductList.vue index d6f70f08..4e6bbff8 100644 --- a/admin/src/views/product/ProductList.vue +++ b/admin/src/views/product/ProductList.vue @@ -27,8 +27,8 @@ :cell-style="{ padding:'6px 0', fontSize:'12px' }"> - - + +