feat(柜体管理): 添加格口号列和柜机列表功能

在柜体管理页面中,新增了格口号列以展示单元格编号,并添加了左侧柜机列表,方便用户快速切换柜体进行管理。同时优化了页面布局和样式,提升了用户体验。
This commit is contained in:
dzq 2025-05-13 10:42:57 +08:00
parent 312fb7ae81
commit 4146851ac2
3 changed files with 182 additions and 103 deletions

View File

@ -4,6 +4,7 @@ import { PureTableBar } from "@/components/RePureTableBar";
import { onBeforeRouteUpdate, useRoute } from "vue-router"; import { onBeforeRouteUpdate, useRoute } from "vue-router";
import { useRenderIcon } from "@/components/ReIcon/src/hooks"; import { useRenderIcon } from "@/components/ReIcon/src/hooks";
import { getCabinetCellList, deleteCabinetCell, CabinetCellDTO } from "@/api/cabinet/cabinet-cell"; import { getCabinetCellList, deleteCabinetCell, CabinetCellDTO } from "@/api/cabinet/cabinet-cell";
import { allCabinets, SmartCabinetDTO } from "@/api/cabinet/smart-cabinet";
import EditPen from "@iconify-icons/ep/edit-pen"; import EditPen from "@iconify-icons/ep/edit-pen";
import Delete from "@iconify-icons/ep/delete"; import Delete from "@iconify-icons/ep/delete";
import AddFill from "@iconify-icons/ri/add-circle-line"; import AddFill from "@iconify-icons/ri/add-circle-line";
@ -14,39 +15,56 @@ import CellEditModal from "./cell-edit-modal.vue";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import { on } from "events"; import { on } from "events";
//
defineOptions({ defineOptions({
name: "CabinetCell" name: "CabinetCell" //
}); });
//
const formRef = ref(); const formRef = ref();
//
const tableRef = ref(); const tableRef = ref();
//
const modalVisible = ref(false); const modalVisible = ref(false);
//
const searchFormParams = ref({ const searchFormParams = ref({
cabinetId: null, cabinetId: null, // ID
cellNo: null, cellNo: null, //
cellType: null cellType: null //
}); });
//
const pagination = ref({ const pagination = ref({
pageSize: 10, pageSize: 10, //
currentPage: 1, currentPage: 1, //
total: 0 total: 0 //
}); });
//
const loading = ref(false); const loading = ref(false);
//
const dataList = ref([]); const dataList = ref([]);
//
const multipleSelection = ref<number[]>([]); const multipleSelection = ref<number[]>([]);
//
const editVisible = ref(false); const editVisible = ref(false);
//
const currentRow = ref<CabinetCellDTO>(); const currentRow = ref<CabinetCellDTO>();
//
const route = useRoute(); const route = useRoute();
onMounted(() => { //
const cabinets = ref<SmartCabinetDTO[]>([]);
onMounted(async () => {
const { data } = await allCabinets();
cabinets.value = data;
if (route.query.cabinetId) { if (route.query.cabinetId) {
searchFormParams.value.cabinetId = Number(route.query.cabinetId); searchFormParams.value.cabinetId = Number(route.query.cabinetId);
getList();
} }
getList();
}); });
onBeforeRouteUpdate(() => { onBeforeRouteUpdate(() => {
if (route.query.cabinetId) { if (route.query.cabinetId) {
@ -55,24 +73,33 @@ onBeforeRouteUpdate(() => {
} }
}); });
/**
* 获取单元格列表数据
* @returns {Promise<void>}
*/
const getList = async () => { const getList = async () => {
try { try {
loading.value = true; loading.value = true; //
// API
const { data } = await getCabinetCellList({ const { data } = await getCabinetCellList({
...searchFormParams.value, ...searchFormParams.value, //
pageSize: pagination.value.pageSize, pageSize: pagination.value.pageSize, //
pageNum: pagination.value.currentPage pageNum: pagination.value.currentPage //
}); });
dataList.value = data.rows; dataList.value = data.rows; //
pagination.value.total = data.total; pagination.value.total = data.total; //
} finally { } finally {
loading.value = false; loading.value = false; //
} }
}; };
/**
* 搜索按钮点击事件
* 重置页码为第一页并重新获取数据
*/
const onSearch = () => { const onSearch = () => {
pagination.value.currentPage = 1; pagination.value.currentPage = 1; //
getList(); getList(); //
}; };
const resetForm = () => { const resetForm = () => {
@ -90,13 +117,18 @@ const onCurrentChange = (val: number) => {
getList(); getList();
}; };
/**
* 删除单元格
* @param {CabinetCellDTO} row - 要删除的单元格数据
*/
const handleDelete = async (row: CabinetCellDTO) => { const handleDelete = async (row: CabinetCellDTO) => {
try { try {
// API
await deleteCabinetCell(row.cellId!.toString()); await deleteCabinetCell(row.cellId!.toString());
ElMessage.success("删除成功"); ElMessage.success("删除成功"); //
getList(); getList(); //
} catch (error) { } catch (error) {
console.error("删除失败", error); console.error("删除失败", error); //
} }
}; };
@ -128,6 +160,11 @@ const handleEdit = (row: CabinetCellDTO) => {
editVisible.value = true; editVisible.value = true;
}; };
/**
* 转换单元格类型为中文描述
* @param {number} cellType - 单元格类型编号
* @returns {string} 单元格类型中文描述
*/
const switchCellType = (cellType: number) => { const switchCellType = (cellType: number) => {
switch (cellType) { switch (cellType) {
case 1: case 1:
@ -146,7 +183,24 @@ const switchCellType = (cellType: number) => {
</script> </script>
<template> <template>
<div class="main"> <div class="main flex">
<!-- 左侧柜机列表 -->
<div class="w-[200px] pr-4 border-r h-full left-list">
<div class="text-lg font-bold mb-4 px-2">柜机列表</div>
<div class="h-[calc(100vh-180px)] overflow-y-auto">
<div class="cabinet-list">
<div v-for="cabinet in cabinets" :key="cabinet.cabinetId"
class="cabinet-item p-3 mb-2 cursor-pointer rounded hover:bg-gray-100 transition-colors"
:class="{ 'bg-blue-50': searchFormParams.cabinetId === cabinet.cabinetId }"
@click="searchFormParams.cabinetId = cabinet.cabinetId; onSearch()">
{{ cabinet.cabinetName }}
</div>
</div>
</div>
</div>
<!-- 右侧内容 -->
<div class="flex-1 pl-4">
<el-form ref="formRef" :inline="true" :model="searchFormParams" <el-form ref="formRef" :inline="true" :model="searchFormParams"
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]"> class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
<el-form-item label="柜体ID" prop="cabinetId"> <el-form-item label="柜体ID" prop="cabinetId">
@ -229,6 +283,20 @@ const switchCellType = (cellType: number) => {
@refresh="getList" /> @refresh="getList" />
<cell-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" /> <cell-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
</div> </div>
</div>
</template> </template>
<style scoped></style> <style lang="scss" scoped>
.flex {
display: flex;
}
.border-r {
border-right: 1px solid #ebeef5;
}
.left-list {
background: #FFFFFF;
padding: 15px;
}
</style>

View File

@ -12,6 +12,7 @@ import Qrcode from "@iconify-icons/ep/iphone";
import { ElMessage, ElMessageBox } from "element-plus"; import { ElMessage, ElMessageBox } from "element-plus";
import ShopFormModal from "./shop-form-modal.vue"; import ShopFormModal from "./shop-form-modal.vue";
import ReQrcode from "@/components/ReQrcode"; import ReQrcode from "@/components/ReQrcode";
import { copyTextToClipboard } from "@pureadmin/utils";
defineOptions({ defineOptions({
name: "Shop" name: "Shop"
@ -123,6 +124,12 @@ const showQrCode = (shopId: number) => {
qrVisible.value = true; qrVisible.value = true;
}; };
const copyLink = () => {
const url = `http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${currentShopId.value}`;
const success = copyTextToClipboard(url);
success ? ElMessage.success('链接复制成功') : ElMessage.error('复制失败,请手动复制');
};
getList(); getList();
</script> </script>
@ -188,6 +195,9 @@ getList();
<ReQrcode :text="`http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${currentShopId}`" <ReQrcode :text="`http://wxshop.ab98.cn/shop-api/api/shop/wechatAuth?shopId=${currentShopId}`"
:options="{ width: 200 }" /> :options="{ width: 200 }" />
<div class="mt-2 text-sm text-gray-500">微信扫码访问</div> <div class="mt-2 text-sm text-gray-500">微信扫码访问</div>
<el-button class="mt-2" type="primary" size="small" @click="copyLink">
复制链接
</el-button>
</div> </div>
</el-dialog> </el-dialog>
</div> </div>

View File

@ -261,6 +261,7 @@ const handleClearGoods = async (row: CabinetCellDTO) => {
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId" <el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
@selection-change="handleSelectionChange" border> @selection-change="handleSelectionChange" border>
<el-table-column label="格口ID" prop="cellId" width="80" /> <el-table-column label="格口ID" prop="cellId" width="80" />
<el-table-column label="格口号" prop="cellNo" width="80" />
<el-table-column label="商品图片" width="120"> <el-table-column label="商品图片" width="120">
<template #default="{ row }"> <template #default="{ row }">
<el-image :src="row.coverImg" :preview-src-list="[row.coverImg]" :z-index="9999" <el-image :src="row.coverImg" :preview-src-list="[row.coverImg]" :z-index="9999"