refactor(shop): 重构柜机商品管理页面布局并优化组件逻辑

重构了柜机商品管理页面的布局,将柜机列表移至左侧,提升用户体验。同时优化了 `cabinet-goods-config-modal.vue` 组件的逻辑,添加了 `watch` 和 `onMounted` 钩子以确保数据及时更新。此外,移除了导航栏和侧边栏中不必要的组件注释,保持界面简洁。
This commit is contained in:
dzq 2025-04-22 15:39:45 +08:00
parent 524e5dd84b
commit 51fde85acc
5 changed files with 135 additions and 95 deletions

View File

@ -37,9 +37,9 @@ const {
<!-- 二维码 --> <!-- 二维码 -->
<QrCodeHover /> <QrCodeHover />
<!-- 菜单搜索 --> <!-- 菜单搜索 -->
<Search /> <!-- <Search /> -->
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <!-- <Notice id="header-notice" /> -->
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none"> <span class="el-dropdown-link navbar-bg-hover select-none">
@ -61,9 +61,9 @@ const {
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel"> <!-- <span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
<IconifyIconOffline :icon="Setting" /> <IconifyIconOffline :icon="Setting" />
</span> </span> -->
</div> </div>
</div> </div>
</template> </template>

View File

@ -47,9 +47,9 @@ nextTick(() => {
<!-- 二维码 --> <!-- 二维码 -->
<QrCodeHover /> <QrCodeHover />
<!-- 菜单搜索 --> <!-- 菜单搜索 -->
<Search /> <!-- <Search /> -->
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <!-- <Notice id="header-notice" /> -->
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover"> <span class="el-dropdown-link navbar-bg-hover">
@ -65,9 +65,9 @@ nextTick(() => {
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel"> <!-- <span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
<IconifyIconOffline :icon="Setting" /> <IconifyIconOffline :icon="Setting" />
</span> </span> -->
</div> </div>
</div> </div>
</template> </template>

View File

@ -76,9 +76,9 @@ watch(
<!-- 二维码 --> <!-- 二维码 -->
<QrCodeHover /> <QrCodeHover />
<!-- 菜单搜索 --> <!-- 菜单搜索 -->
<Search /> <!-- <Search /> -->
<!-- 通知 --> <!-- 通知 -->
<Notice id="header-notice" /> <!-- <Notice id="header-notice" /> -->
<!-- 退出登录 --> <!-- 退出登录 -->
<el-dropdown trigger="click"> <el-dropdown trigger="click">
<span class="el-dropdown-link navbar-bg-hover select-none"> <span class="el-dropdown-link navbar-bg-hover select-none">
@ -94,9 +94,9 @@ watch(
</el-dropdown-menu> </el-dropdown-menu>
</template> </template>
</el-dropdown> </el-dropdown>
<span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel"> <!-- <span class="set-icon navbar-bg-hover" title="打开项目配置" @click="onPanel">
<IconifyIconOffline :icon="Setting" /> <IconifyIconOffline :icon="Setting" />
</span> </span> -->
</div> </div>
</div> </div>
</template> </template>

View File

@ -1,5 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { ref } from "vue"; import { onMounted, ref, watch } from "vue";
import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { getGoodsListApi, type GoodsDTO } from "@/api/shop/goods"; import { getGoodsListApi, type GoodsDTO } from "@/api/shop/goods";
import { configureGoodsCellsStock } from "@/api/cabinet/cabinet-cell"; import { configureGoodsCellsStock } from "@/api/cabinet/cabinet-cell";
@ -76,6 +76,17 @@ const handleConfigure = async (row: GoodsDTO) => {
} }
}; };
watch(
() => props.cellId,
() => {
getList();
}
);
onMounted(() => {
getList();
})
defineExpose({ getList }); defineExpose({ getList });
</script> </script>

View File

@ -191,89 +191,118 @@ const handleClearGoods = async (row: CabinetCellDTO) => {
</script> </script>
<template> <template>
<div class="main"> <div class="main flex">
<el-form ref="formRef" :inline="true" :model="searchFormParams" <!-- 左侧柜机列表 -->
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]"> <div class="w-[200px] pr-4 border-r h-full left-list">
<el-form-item label="柜机:" prop="cabinetId"> <div class="text-lg font-bold mb-4 px-2">柜机列表</div>
<el-select v-model.number="searchFormParams.cabinetId" placeholder="请选择柜机" clearable class="!w-[200px]"> <div class="h-[calc(100vh-180px)] overflow-y-auto">
<el-option v-for="cabinet in cabinets" :key="cabinet.cabinetId" :label="cabinet.cabinetName" <div class="cabinet-list">
:value="cabinet.cabinetId" /> <div v-for="cabinet in cabinets" :key="cabinet.cabinetId"
</el-select> class="cabinet-item p-3 mb-2 cursor-pointer rounded hover:bg-gray-100 transition-colors"
</el-form-item> :class="{ 'bg-blue-50': searchFormParams.cabinetId === cabinet.cabinetId }"
<el-form-item label="单元格号:" prop="cellNo"> @click="searchFormParams.cabinetId = cabinet.cabinetId; onSearch()">
<el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" /> {{ cabinet.cabinetName }}
</el-form-item> </div>
<el-form-item label="单元格类型:" prop="cellType"> </div>
<el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]"> </div>
<el-option label="小格" :value="1" /> </div>
<el-option label="中格" :value="2" />
<el-option label="大格" :value="3" />
<el-option label="超大格" :value="4" />
</el-select>
</el-form-item>
<el-form-item>
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
搜索
</el-button>
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
重置
</el-button>
</el-form-item>
</el-form>
<PureTableBar title="柜体单元格管理" @refresh="getList"> <!-- 右侧内容 -->
<template #buttons> <div class="flex-1 pl-4">
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0" <el-form ref="formRef" :inline="true" :model="searchFormParams" class="search-form bg-bg_color w-full pt-[12px]">
@click="handleBulkDelete"> <el-form-item label="单元格号:" prop="cellNo">
批量删除 <el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" />
</el-button> </el-form-item>
</template> <el-form-item label="单元格类型:" prop="cellType">
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId" <el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]">
@selection-change="handleSelectionChange" border> <el-option label="小格" :value="1" />
<el-table-column type="selection" width="55" /> <el-option label="中格" :value="2" />
<el-table-column label="商品图片" width="120"> <el-option label="大格" :value="3" />
<template #default="{ row }"> <el-option label="超大格" :value="4" />
<el-image :src="row.coverImg" :preview-src-list="[row.coverImg]" :z-index="9999" :preview-teleported="true" </el-select>
:hide-on-click-modal="true" fit="cover" class="rounded" width="60" height="60" /> </el-form-item>
</template> <el-form-item>
</el-table-column> <el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
<el-table-column label="商品名称"> 搜索
<template #default="{ row }"> </el-button>
{{ row.goodsId ? row.goodsName : '未配置商品' }} <el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
</template> 重置
</el-table-column> </el-button>
<el-table-column label="价格" prop="price" width="120" /> </el-form-item>
<el-table-column label="库存" prop="stock" width="120" /> </el-form>
<el-table-column label="单元格号" prop="cellNo" width="120" />
<el-table-column label="单元格类型" prop="cellType"> <PureTableBar title="柜体单元格管理" @refresh="getList">
<template #default="{ row }"> <template #buttons>
{{ switchCellType(row.cellType) }} <el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
</template> @click="handleBulkDelete">
</el-table-column> 批量删除
<el-table-column label="操作" width="150" fixed="right"> </el-button>
<template #default="{ row }"> </template>
<el-button type="success" link :icon="useRenderIcon(AddFill)" @click="handleConfigure(row)"> <el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
配置商品 @selection-change="handleSelectionChange" border>
</el-button> <el-table-column type="selection" width="55" />
<el-button v-if="row.goodsId" type="warning" link :icon="useRenderIcon(EditPen)" <el-table-column label="商品图片" width="120">
@click="handleStockConfig(row)"> <template #default="{ row }">
配置库存 <el-image :src="row.coverImg" :preview-src-list="[row.coverImg]" :z-index="9999"
</el-button> :preview-teleported="true" :hide-on-click-modal="true" fit="cover" class="rounded" width="60"
<el-button v-if="row.goodsId" type="danger" link :icon="useRenderIcon(Delete)" height="60" />
@click="handleClearGoods(row)"> </template>
下架商品 </el-table-column>
</el-button> <el-table-column label="商品名称">
</template> <template #default="{ row }">
</el-table-column> {{ row.goodsId ? row.goodsName : '未配置商品' }}
</el-table> </template>
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize" </el-table-column>
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total" <el-table-column label="价格" prop="price" width="120" />
@size-change="onSizeChange" @current-change="onCurrentChange" /> <el-table-column label="库存" prop="stock" width="120" />
</PureTableBar> <el-table-column label="单元格号" prop="cellNo" width="120" />
<el-dialog v-model="configVisible" title="配置商品" width="80%"> <el-table-column label="单元格类型" prop="cellType">
<CabinetGoodsConfigModal v-model="configVisible" :cell-id="currentCellId" @refresh="getList" /> <template #default="{ row }">
</el-dialog> {{ switchCellType(row.cellType) }}
</template>
</el-table-column>
<el-table-column label="操作" width="150" fixed="right">
<template #default="{ row }">
<el-button type="success" link :icon="useRenderIcon(AddFill)" @click="handleConfigure(row)">
配置商品
</el-button>
<el-button v-if="row.goodsId" type="warning" link :icon="useRenderIcon(EditPen)"
@click="handleStockConfig(row)">
配置库存
</el-button>
<el-button v-if="row.goodsId" type="danger" link :icon="useRenderIcon(Delete)"
@click="handleClearGoods(row)">
下架商品
</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination v-model:current-page="pagination.currentPage" v-model:page-size="pagination.pageSize"
:page-sizes="[10, 20, 50]" layout="total, sizes, prev, pager, next, jumper" :total="pagination.total"
@size-change="onSizeChange" @current-change="onCurrentChange" />
</PureTableBar>
<el-dialog v-model="configVisible" title="配置商品" width="80%">
<CabinetGoodsConfigModal v-model="configVisible" :cell-id="currentCellId" @refresh="getList" />
</el-dialog>
</div>
</div> </div>
</template> </template>
<style scoped></style> <style scoped>
.flex {
display: flex;
}
.border-r {
border-right: 1px solid #ebeef5;
}
.left-list {
background: #FFFFFF;
padding: 15px;
}
.search-form {
padding-left: 10px;
}
</style>