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 @@