From 886647870630910cf0cac36733a9967df11fcbb4 Mon Sep 17 00:00:00 2001 From: dzq Date: Sat, 20 Dec 2025 17:16:24 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E6=9F=9C=E6=9C=BA=E7=AE=A1=E7=90=86):=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E6=A0=BC=E5=8F=A3=E7=8A=B6=E6=80=81=E5=B1=95?= =?UTF-8?q?=E7=A4=BA=E5=8F=8A=E5=AF=86=E7=A0=81=E6=B8=85=E9=99=A4=E5=8A=9F?= =?UTF-8?q?=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 在柜机管理页面添加格口状态可视化展示,包括空闲和占用状态的SVG图标 - 新增resetCellById API用于清除格口密码 - 优化商品列表加载逻辑,避免重复数据 - 完善类型定义,添加格口状态和类型相关字段 - 根据店铺模式调整UI显示,隐藏部分非必要元素 - 添加清除密码按钮及相关处理逻辑 --- src/common/apis/cabinet/index.ts | 7 ++ src/common/apis/cabinet/type.ts | 23 +++- src/pages/cabinet/index.vue | 179 +++++++++++++++++++++++---- src/pages/manage/goods/goodsList.vue | 11 +- 4 files changed, 188 insertions(+), 32 deletions(-) diff --git a/src/common/apis/cabinet/index.ts b/src/common/apis/cabinet/index.ts index c9de720..743af4f 100644 --- a/src/common/apis/cabinet/index.ts +++ b/src/common/apis/cabinet/index.ts @@ -65,3 +65,10 @@ export const clearGoodsCells = (cellId: number) => { }); }; +export const resetCellById = (cellId: number) => { + return request>({ + url: `/cabinet/reset/${cellId}`, + method: 'put' + }); +}; + diff --git a/src/common/apis/cabinet/type.ts b/src/common/apis/cabinet/type.ts index 20a3842..6b40662 100644 --- a/src/common/apis/cabinet/type.ts +++ b/src/common/apis/cabinet/type.ts @@ -1,7 +1,11 @@ export interface CabinetDetailDTO { + /** 柜机ID */ cabinetId: number + /** 柜机名称 */ cabinetName: string + /** 锁控编号 */ lockControlNo: number + /** 格口列表 */ cells: CellInfoDTO[] } @@ -14,11 +18,13 @@ export interface RentingCabinetDetailDTO { /** 锁控编号 */ lockControlNo: number /** 柜格列表 */ - cells: RetingCellEntity[] + cells: RentingCellEntity[] } -export interface RetingCellEntity extends CabinetCellEntity { +export interface RentingCellEntity extends CabinetCellEntity { + /** 订单ID */ orderId: number; + /** 订单商品ID */ orderGoodsId: number; } @@ -48,14 +54,27 @@ export interface CabinetCellEntity { availableStatus: number /** 商品ID */ goodsId?: number + /** 密码 */ + password?: string } export interface CellInfoDTO { + /** 格口唯一ID */ cellId: number + /** 格口号 */ cellNo: number + /** 针脚序号 */ pinNo: number + /** 库存数量 */ stock: number + /** 密码 */ + password?: string + /** 商品信息 */ product?: ProductInfoDTO + /** 使用状态:1空闲 2已占用 */ + usageStatus: number + /** 格口类型(1小格 2中格 3大格 4超大格) */ + cellType: number } export interface ProductInfoDTO { diff --git a/src/pages/cabinet/index.vue b/src/pages/cabinet/index.vue index 6132628..8629f1f 100644 --- a/src/pages/cabinet/index.vue +++ b/src/pages/cabinet/index.vue @@ -29,11 +29,108 @@ @@ -92,7 +194,7 @@ import { throttle } from 'lodash-es'; import { ref, onMounted, onBeforeUnmount, watch } from 'vue'; import { getShopListApi } from '@/common/apis/shop'; import { ShopEntity } from '@/common/apis/shop/type'; -import { getCabinetDetailApi, openCabinet, changeGoodsCellsStock, clearGoodsCells } from '@/common/apis/cabinet'; +import { getCabinetDetailApi, openCabinet, changeGoodsCellsStock, clearGoodsCells, resetCellById } from '@/common/apis/cabinet'; import type { CabinetDetailDTO } from '@/common/apis/cabinet/type'; import { useWxStore, useWxStoreOutside } from '@/pinia/stores/wx'; import { publicPath } from "@/common/utils/path"; @@ -135,6 +237,9 @@ interface LockerItem { goodsName?: string price?: number coverImg?: string + password?: string + usageStatus?: number + cellType?: number } // 获取机柜列表 @@ -151,8 +256,10 @@ const loadCabinetDetail = async (selectedShopId?: number) => { })) // 根据当前选中柜机加载格口数据 - if (data.length > 0) { + if (data.length > 0 && data[activeCabinet.value]) { updateLockerList(data[activeCabinet.value]) + } else { + lockerList.value = []; } } catch (error) { console.error('获取柜机详情失败:', error) @@ -170,7 +277,10 @@ const updateLockerList = (cabinet: CabinetDetailDTO) => { statusClass: cell.product ? 'occupied' : 'available', goodsName: cell.product?.goodsName, price: cell.product?.price, - coverImg: cell.product?.coverImg + coverImg: cell.product?.coverImg, + password: cell.password, + usageStatus: cell.usageStatus, + cellType: cell.cellType, })) } @@ -182,6 +292,16 @@ const onCabinetChange = (index: number) => { } } +function switchCellType(cellType: number | undefined) { + switch (cellType) { + case 1: return '小格'; + case 2: return '中格'; + case 3: return '大格'; + case 4: return '超大格'; + default: return '未知'; + } +} + const showBindGoods = (locker: LockerItem) => { currentLocker.value = locker; showBindGoodsPopup.value = true; @@ -264,6 +384,17 @@ const handleStockUpdate = (newStock: number) => { } }; +const handleClearPassword = async (locker: LockerItem) => { + try { + await resetCellById(locker.lockerId); + showToast('清除密码成功'); + loadCabinetDetail(); + } catch (error) { + console.error('清除密码失败:', error); + showToast('清除密码失败'); + } +}; + onMounted(() => { init(); scrollListener.push(window.addEventListener('scroll', throttledScroll)); @@ -463,6 +594,10 @@ onBeforeUnmount(() => { border: none; } + .detail-btn-placeholder { + flex: 1; + } + :deep(.van-button--default) { color: #e95d5d; border-color: #e95d5d; diff --git a/src/pages/manage/goods/goodsList.vue b/src/pages/manage/goods/goodsList.vue index abf253f..09342c3 100644 --- a/src/pages/manage/goods/goodsList.vue +++ b/src/pages/manage/goods/goodsList.vue @@ -48,17 +48,12 @@ onUnmounted(() => { debouncedFetchGoodsList.cancel(); }); -// 搜索按钮触发 -const handleSearch = () => { - debouncedFetchGoodsList.cancel(); - fetchGoodsList(); -}; - // 加载数据 const onLoad = async () => { try { const res = await getGoodsList(searchParams); - goodsList.value.push(...res.data.rows); + const rows = res.data.rows.filter(row => goodsList.value.findIndex(g => g.goodsId === row.goodsId) === -1); + goodsList.value.push(...rows); loading.value = false; if (goodsList.value.length >= res.data.total) { @@ -108,7 +103,7 @@ onMounted(fetchGoodsList);
- + 添加商品