From 1b1642e51d33ca76d3ad254fb7ea385bc00a5188 Mon Sep 17 00:00:00 2001 From: weiwei Date: Fri, 12 Sep 2025 17:08:00 +0800 Subject: [PATCH] =?UTF-8?q?feat:=E6=A0=91=E5=BD=A2=E5=88=86=E7=B1=BB?= =?UTF-8?q?=E7=9A=84=E6=96=B0=E5=A2=9E=E5=92=8C=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/cabinet/putaway.vue | 11 +- src/pages/integrated/visitor/invitation.vue | 1 - src/pages/prosperity-shop/goods-categary.vue | 91 +++++- src/pages/prosperity-shop/goods-form.vue | 1 - src/pages/tabbar/individualOrder.vue | 2 +- src/pages/tabbar/onlineShop.vue | 1 - src/sheep/api/prosperityShop.ts | 23 ++ src/sheep/components/shop-categary-picker.vue | 9 +- src/sheep/components/shop-categary-tree.vue | 11 +- .../tm-ui/components/tm-drawer/tm-drawer.vue | 303 +++++++++--------- 10 files changed, 276 insertions(+), 177 deletions(-) diff --git a/src/pages/cabinet/putaway.vue b/src/pages/cabinet/putaway.vue index c401b9c..0d5292f 100644 --- a/src/pages/cabinet/putaway.vue +++ b/src/pages/cabinet/putaway.vue @@ -59,16 +59,7 @@ - + {{ item.status == "0" ? "正常" : "禁用" }} - 编辑 - 删除 + 编辑 + 删除 @@ -20,18 +20,39 @@ - 分类名称: - - 父级分类: - + + 基本信息 + + + + + + + + + + 父级分类 + + + + 提 交 + + @@ -47,9 +68,11 @@ const categaryFormDrawer = ref(false) const form = reactive({ id: "", name: "", + status: "0", // 状态(0正常,1下架) parentId: "", }) const categoryTree = ref([]) +const selectedNode = ref({}) onLoad(() => { getGoodsCategory() @@ -69,10 +92,60 @@ const getCategaryTree = async () => { const addCategary = () => { getCategaryTree() + Object.assign(form, { + id: "", + name: "", + status: "0", + parentId: "", + }) + selectedNode.value = {} + categaryFormDrawer.value = true +} + +const editCategary = (item) => { + getCategaryTree() + Object.assign(form, item) + selectedNode.value = { id: item.parentId } categaryFormDrawer.value = true } const currentNode = (item) => { - form.parentId = item.categoryId + // form.parentId = item.categoryId +} + +const saveCategary = async () => { + console.log(form) + if (!form.name) return uni.showToast({ title: "请填写分类名称", icon: "none" }) + if (selectedNode.value.id === form.id) return uni.showToast({ title: "父级分类不能是自身", icon: "none" }) + try { + const params = { ...form, parentId: selectedNode.value.id } + uni.showLoading({ title: "保存中..." }) + const { code, data, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params)) + if (code != 0) return uni.showToast({ title: msg || "保存失败", icon: "none" }) + uni.showToast({ title: "保存成功", icon: "none" }) + categaryFormDrawer.value = false + await getGoodsCategory() + } finally { + uni.hideLoading() + } +} + +// 删除分类 +const delCategary = async (id: string) => { + if (!id) return uni.showToast({ title: "分类id不存在", icon: "none" }) + uni.showModal({ + title: "确定删除分类吗?", + content: "", + success: async (res) => { + if (res.confirm) { + uni.showLoading({ title: "正在删除" }) + const { code, msg } = await prosperityShopApi.delCategary(id) + if (code != 0) return uni.showToast({ title: msg || "删除失败", icon: "none" }) + uni.showToast({ title: "删除成功", icon: "none" }) + getGoodsCategory() + uni.hideLoading() + } + }, + }) } diff --git a/src/pages/prosperity-shop/goods-form.vue b/src/pages/prosperity-shop/goods-form.vue index 02b6341..c4435d3 100644 --- a/src/pages/prosperity-shop/goods-form.vue +++ b/src/pages/prosperity-shop/goods-form.vue @@ -152,7 +152,6 @@ :showClose="true" :showFooter="false" size="auto" - placement="bottom" v-model:show="showCategaryPicker" :duration="100" zIndex="100" diff --git a/src/pages/tabbar/individualOrder.vue b/src/pages/tabbar/individualOrder.vue index e959f35..2987b82 100644 --- a/src/pages/tabbar/individualOrder.vue +++ b/src/pages/tabbar/individualOrder.vue @@ -83,7 +83,7 @@ - + => { + return request({ + url: `/supermarket/app/mall/merchant/category/${id}`, + method: "DELETE", + }) + }, + // 新增商品分类 + addCategary: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/category/create`, + method: "POST", + data, + }) + }, + // 编辑商品分类 + editCategary: (data: any): Promise => { + return request({ + url: `/supermarket/app/mall/merchant/category/update`, + method: "PUT", + data, + }) + }, } diff --git a/src/sheep/components/shop-categary-picker.vue b/src/sheep/components/shop-categary-picker.vue index 51176c9..c678f5b 100644 --- a/src/sheep/components/shop-categary-picker.vue +++ b/src/sheep/components/shop-categary-picker.vue @@ -1,6 +1,6 @@