diff --git a/src/views/cabinet/cabinet-cell/index.vue b/src/views/cabinet/cabinet-cell/index.vue index 6a5f540..3ac7a02 100644 --- a/src/views/cabinet/cabinet-cell/index.vue +++ b/src/views/cabinet/cabinet-cell/index.vue @@ -4,6 +4,7 @@ import { PureTableBar } from "@/components/RePureTableBar"; import { onBeforeRouteUpdate, useRoute } from "vue-router"; import { useRenderIcon } from "@/components/ReIcon/src/hooks"; 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 Delete from "@iconify-icons/ep/delete"; 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 { on } from "events"; +// 定义组件选项 defineOptions({ - name: "CabinetCell" + name: "CabinetCell" // 组件名称 }); +// 表单引用 const formRef = ref(); +// 表格引用 const tableRef = ref(); +// 新增单元格模态框显示状态 const modalVisible = ref(false); +// 搜索表单参数 const searchFormParams = ref({ - cabinetId: null, - cellNo: null, - cellType: null + cabinetId: null, // 柜体ID + cellNo: null, // 单元格号 + cellType: null // 单元格类型 }); +// 分页参数 const pagination = ref({ - pageSize: 10, - currentPage: 1, - total: 0 + pageSize: 10, // 每页显示数量 + currentPage: 1, // 当前页码 + total: 0 // 总条数 }); +// 加载状态 const loading = ref(false); +// 表格数据列表 const dataList = ref([]); +// 多选选中项 const multipleSelection = ref([]); +// 编辑单元格模态框显示状态 const editVisible = ref(false); +// 当前编辑行数据 const currentRow = ref(); +// 路由实例 const route = useRoute(); -onMounted(() => { +// 柜机列表数据 +const cabinets = ref([]); + +onMounted(async () => { + const { data } = await allCabinets(); + cabinets.value = data; if (route.query.cabinetId) { searchFormParams.value.cabinetId = Number(route.query.cabinetId); - getList(); } + getList(); }); onBeforeRouteUpdate(() => { if (route.query.cabinetId) { @@ -55,24 +73,33 @@ onBeforeRouteUpdate(() => { } }); +/** + * 获取单元格列表数据 + * @returns {Promise} + */ const getList = async () => { try { - loading.value = true; + loading.value = true; // 显示加载状态 + // 调用API获取单元格列表 const { data } = await getCabinetCellList({ - ...searchFormParams.value, - pageSize: pagination.value.pageSize, - pageNum: pagination.value.currentPage + ...searchFormParams.value, // 搜索参数 + pageSize: pagination.value.pageSize, // 每页数量 + pageNum: pagination.value.currentPage // 当前页码 }); - dataList.value = data.rows; - pagination.value.total = data.total; + dataList.value = data.rows; // 更新表格数据 + pagination.value.total = data.total; // 更新总条数 } finally { - loading.value = false; + loading.value = false; // 隐藏加载状态 } }; +/** + * 搜索按钮点击事件 + * 重置页码为第一页并重新获取数据 + */ const onSearch = () => { - pagination.value.currentPage = 1; - getList(); + pagination.value.currentPage = 1; // 重置页码 + getList(); // 重新获取数据 }; const resetForm = () => { @@ -90,13 +117,18 @@ const onCurrentChange = (val: number) => { getList(); }; +/** + * 删除单元格 + * @param {CabinetCellDTO} row - 要删除的单元格数据 + */ const handleDelete = async (row: CabinetCellDTO) => { try { + // 调用API删除单元格 await deleteCabinetCell(row.cellId!.toString()); - ElMessage.success("删除成功"); - getList(); + ElMessage.success("删除成功"); // 显示成功消息 + getList(); // 刷新列表 } catch (error) { - console.error("删除失败", error); + console.error("删除失败", error); // 打印错误信息 } }; @@ -128,6 +160,11 @@ const handleEdit = (row: CabinetCellDTO) => { editVisible.value = true; }; +/** + * 转换单元格类型为中文描述 + * @param {number} cellType - 单元格类型编号 + * @returns {string} 单元格类型中文描述 + */ const switchCellType = (cellType: number) => { switch (cellType) { case 1: @@ -146,89 +183,120 @@ const switchCellType = (cellType: number) => { - + diff --git a/src/views/cabinet/shop/index.vue b/src/views/cabinet/shop/index.vue index 947e499..221e14a 100644 --- a/src/views/cabinet/shop/index.vue +++ b/src/views/cabinet/shop/index.vue @@ -12,6 +12,7 @@ import Qrcode from "@iconify-icons/ep/iphone"; import { ElMessage, ElMessageBox } from "element-plus"; import ShopFormModal from "./shop-form-modal.vue"; import ReQrcode from "@/components/ReQrcode"; +import { copyTextToClipboard } from "@pureadmin/utils"; defineOptions({ name: "Shop" @@ -123,6 +124,12 @@ const showQrCode = (shopId: number) => { 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(); @@ -188,6 +195,9 @@ getList();
微信扫码访问
+ + 复制链接 + diff --git a/src/views/shop/cabinet-goods/index.vue b/src/views/shop/cabinet-goods/index.vue index 43f2786..9b60931 100644 --- a/src/views/shop/cabinet-goods/index.vue +++ b/src/views/shop/cabinet-goods/index.vue @@ -261,6 +261,7 @@ const handleClearGoods = async (row: CabinetCellDTO) => { +