From 71803eabe8bc4df726882a2474317021209209e6 Mon Sep 17 00:00:00 2001 From: weiwei Date: Sun, 28 Sep 2025 10:12:36 +0800 Subject: [PATCH] =?UTF-8?q?fix:tree-node=E5=88=A4=E6=96=AD=E5=B1=82?= =?UTF-8?q?=E7=BA=A7=EF=BC=9B=E4=BF=AE=E5=A4=8D=E5=88=86=E7=B1=BB=E5=9B=BE?= =?UTF-8?q?=E7=89=87=E4=B8=8A=E4=BC=A0picUrl=E6=A0=BC=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/prosperity-shop/categary-manage.vue | 18 ++++++------- src/sheep/components/node-tree.vue | 26 +++++++++++++------ src/sheep/components/shop-categary-picker.vue | 8 ++++-- 3 files changed, 33 insertions(+), 19 deletions(-) diff --git a/src/pages/prosperity-shop/categary-manage.vue b/src/pages/prosperity-shop/categary-manage.vue index 5c3208a..bddec77 100644 --- a/src/pages/prosperity-shop/categary-manage.vue +++ b/src/pages/prosperity-shop/categary-manage.vue @@ -46,12 +46,12 @@ { label: '下架', value: '1' }, ]" :key="index" - > + /> 父级分类 - + 分类图 ({ picUrl: [], }) const categoryTree = ref([]) -const selectedNode = ref({}) +const selectedNodeId = ref("") const { categoryList, getGoodsCategory, delCategary } = useCategaryManage() @@ -113,28 +113,28 @@ const addCategary = () => { parentId: "", picUrl: [], }) - selectedNode.value = {} + selectedNodeId.value = "" categaryFormDrawer.value = true } // 编辑分类 const editCategary = (item) => { getCategaryTree() - const picUrl = [{ path: filePath(item.picUrl), response: JSON.stringify({ data: { url: item.picUrl } }) }] + const picUrl = item.picUrl ? [{ path: filePath(item.picUrl), response: JSON.stringify({ data: { url: item.picUrl } }) }] : [] Object.assign(form, { ...item, picUrl }) - selectedNode.value = { id: item.parentId } + selectedNodeId.value = item.parentId categaryFormDrawer.value = true } // 提交保存 const saveCategary = async () => { if (!form.name) return uni.showToast({ title: "请填写分类名称", icon: "none" }) - if (selectedNode.value.id === form.id) return uni.showToast({ title: "父级分类不能是自己", icon: "none" }) + if (selectedNodeId.value === form.id) return uni.showToast({ title: "父级分类不能是自己", icon: "none" }) try { const params = { ...form, - parentId: selectedNode.value.id, - picUrl: JSON.parse(form.picUrl[0].response).data.url, + parentId: selectedNodeId.value, + picUrl: form.picUrl?.length ? JSON.parse(form.picUrl[0].response).data.url : "", } uni.showLoading({ title: "保存中..." }) const { code, msg } = await (form.id ? prosperityShopApi.editCategary(params) : prosperityShopApi.addCategary(params)) diff --git a/src/sheep/components/node-tree.vue b/src/sheep/components/node-tree.vue index 4c9f844..8a698d1 100644 --- a/src/sheep/components/node-tree.vue +++ b/src/sheep/components/node-tree.vue @@ -3,7 +3,7 @@ @@ -11,10 +11,10 @@ @@ -22,19 +22,29 @@ @@ -44,7 +54,7 @@ const getLevel = (level) => { overflow: hidden; } .tree-item { - border: 4rpx solid #e4e7ed77; + border: 4rpx solid #e4e7ed; margin-bottom: 16rpx; display: flex; align-items: center; diff --git a/src/sheep/components/shop-categary-picker.vue b/src/sheep/components/shop-categary-picker.vue index 8c94128..bd271e4 100644 --- a/src/sheep/components/shop-categary-picker.vue +++ b/src/sheep/components/shop-categary-picker.vue @@ -1,6 +1,6 @@