feat(柜体管理): 添加格口号列和柜机列表功能
在柜体管理页面中,新增了格口号列以展示单元格编号,并添加了左侧柜机列表,方便用户快速切换柜体进行管理。同时优化了页面布局和样式,提升了用户体验。
This commit is contained in:
parent
312fb7ae81
commit
4146851ac2
|
@ -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,89 +183,120 @@ const switchCellType = (cellType: number) => {
|
||||||
</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="柜体ID:" prop="cabinetId">
|
<div class="text-lg font-bold mb-4 px-2">柜机列表</div>
|
||||||
<el-input v-model.number="searchFormParams.cabinetId" placeholder="请输入柜体ID" clearable class="!w-[200px]" />
|
<div class="h-[calc(100vh-180px)] overflow-y-auto">
|
||||||
</el-form-item>
|
<div class="cabinet-list">
|
||||||
<el-form-item label="单元格号:" prop="cellNo">
|
<div v-for="cabinet in cabinets" :key="cabinet.cabinetId"
|
||||||
<el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" />
|
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="cellType">
|
@click="searchFormParams.cabinetId = cabinet.cabinetId; onSearch()">
|
||||||
<el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]">
|
{{ cabinet.cabinetName }}
|
||||||
<el-option label="小格" :value="1" />
|
</div>
|
||||||
<el-option label="中格" :value="2" />
|
</div>
|
||||||
<el-option label="大格" :value="3" />
|
</div>
|
||||||
<el-option label="超大格" :value="4" />
|
</div>
|
||||||
</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="primary" :icon="useRenderIcon(AddFill)" @click="modalVisible = true">
|
<el-form ref="formRef" :inline="true" :model="searchFormParams"
|
||||||
新增单元格
|
class="search-form bg-bg_color w-[99/100] pl-8 pt-[12px]">
|
||||||
</el-button>
|
<el-form-item label="柜体ID:" prop="cabinetId">
|
||||||
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
<el-input v-model.number="searchFormParams.cabinetId" placeholder="请输入柜体ID" clearable class="!w-[200px]" />
|
||||||
@click="handleBulkDelete">
|
</el-form-item>
|
||||||
批量删除
|
<el-form-item label="单元格号:" prop="cellNo">
|
||||||
</el-button>
|
<el-input v-model.number="searchFormParams.cellNo" placeholder="请输入单元格号" clearable class="!w-[180px]" />
|
||||||
</template>
|
</el-form-item>
|
||||||
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
|
<el-form-item label="单元格类型:" prop="cellType">
|
||||||
@selection-change="handleSelectionChange" border>
|
<el-select v-model="searchFormParams.cellType" placeholder="请选择类型" clearable class="!w-[180px]">
|
||||||
<el-table-column type="selection" width="55" />
|
<el-option label="小格" :value="1" />
|
||||||
<el-table-column label="柜体ID" prop="cabinetId" width="100" />
|
<el-option label="中格" :value="2" />
|
||||||
<el-table-column label="单元格号" prop="cellNo" width="120" />
|
<el-option label="大格" :value="3" />
|
||||||
<el-table-column label="针脚号" prop="pinNo" width="120" />
|
<el-option label="超大格" :value="4" />
|
||||||
<el-table-column label="单元格类型" prop="cellType">
|
</el-select>
|
||||||
<template #default="{ row }">
|
</el-form-item>
|
||||||
{{ switchCellType(row.cellType) }}
|
<el-form-item>
|
||||||
</template>
|
<el-button type="primary" :icon="useRenderIcon(Search)" @click="onSearch">
|
||||||
</el-table-column>
|
搜索
|
||||||
<el-table-column label="使用状态" prop="usageStatus" width="120">
|
</el-button>
|
||||||
<template #default="{ row }">
|
<el-button :icon="useRenderIcon(Refresh)" @click="resetForm">
|
||||||
{{ { 1: '空闲', 2: '已占用' }[row.usageStatus] || '未知' }}
|
重置
|
||||||
</template>
|
</el-button>
|
||||||
</el-table-column>
|
</el-form-item>
|
||||||
<el-table-column label="可用状态" prop="availableStatus" width="120">
|
</el-form>
|
||||||
<template #default="{ row }">
|
|
||||||
<el-tag :type="row.availableStatus === 1 ? 'success' : 'danger'">
|
<PureTableBar title="柜体单元格管理" @refresh="getList">
|
||||||
{{ { 1: '正常', 2: '故障' }[row.availableStatus] || '未知' }}
|
<template #buttons>
|
||||||
</el-tag>
|
<el-button type="primary" :icon="useRenderIcon(AddFill)" @click="modalVisible = true">
|
||||||
</template>
|
新增单元格
|
||||||
</el-table-column>
|
</el-button>
|
||||||
<el-table-column label="操作" width="150" fixed="right">
|
<el-button type="danger" :icon="useRenderIcon(Delete)" :disabled="multipleSelection.length === 0"
|
||||||
<template #default="{ row }">
|
@click="handleBulkDelete">
|
||||||
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
批量删除
|
||||||
编辑
|
</el-button>
|
||||||
</el-button>
|
</template>
|
||||||
<el-popconfirm :title="`确认删除【${row.cellNo}】号单元格?`" @confirm="handleDelete(row)">
|
<el-table ref="tableRef" v-loading="loading" :data="dataList" row-key="cellId"
|
||||||
<template #reference>
|
@selection-change="handleSelectionChange" border>
|
||||||
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
<el-table-column type="selection" width="55" />
|
||||||
删除
|
<el-table-column label="柜体ID" prop="cabinetId" width="100" />
|
||||||
</el-button>
|
<el-table-column label="单元格号" prop="cellNo" width="120" />
|
||||||
</template>
|
<el-table-column label="针脚号" prop="pinNo" width="120" />
|
||||||
</el-popconfirm>
|
<el-table-column label="单元格类型" prop="cellType">
|
||||||
</template>
|
<template #default="{ row }">
|
||||||
</el-table-column>
|
{{ switchCellType(row.cellType) }}
|
||||||
</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="usageStatus" width="120">
|
||||||
@size-change="onSizeChange" @current-change="onCurrentChange" />
|
<template #default="{ row }">
|
||||||
</PureTableBar>
|
{{ { 1: '空闲', 2: '已占用' }[row.usageStatus] || '未知' }}
|
||||||
<cell-form-modal v-model:visible="modalVisible" :initial-cabinet-id="searchFormParams.cabinetId"
|
</template>
|
||||||
@refresh="getList" />
|
</el-table-column>
|
||||||
<cell-edit-modal v-model:visible="editVisible" :row="currentRow" @refresh="getList" />
|
<el-table-column label="可用状态" prop="availableStatus" width="120">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-tag :type="row.availableStatus === 1 ? 'success' : 'danger'">
|
||||||
|
{{ { 1: '正常', 2: '故障' }[row.availableStatus] || '未知' }}
|
||||||
|
</el-tag>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
|
<el-table-column label="操作" width="150" fixed="right">
|
||||||
|
<template #default="{ row }">
|
||||||
|
<el-button type="primary" link :icon="useRenderIcon(EditPen)" @click="handleEdit(row)">
|
||||||
|
编辑
|
||||||
|
</el-button>
|
||||||
|
<el-popconfirm :title="`确认删除【${row.cellNo}】号单元格?`" @confirm="handleDelete(row)">
|
||||||
|
<template #reference>
|
||||||
|
<el-button type="danger" link :icon="useRenderIcon(Delete)">
|
||||||
|
删除
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-popconfirm>
|
||||||
|
</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>
|
||||||
|
<cell-form-modal v-model:visible="modalVisible" :initial-cabinet-id="searchFormParams.cabinetId"
|
||||||
|
@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>
|
||||||
|
|
|
@ -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>
|
||||||
|
|
|
@ -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"
|
||||||
|
|
Loading…
Reference in New Issue