From a16081f1fac39f990e4fd987c06939c637918f3e Mon Sep 17 00:00:00 2001 From: WUSIJIAN <13825895+wsj0228@user.noreply.gitee.com> Date: Fri, 23 Jan 2026 15:48:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E8=B5=84=E4=BA=A7=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E9=80=89=E6=8B=A9=E5=8A=9F=E8=83=BD,=E9=99=90?= =?UTF-8?q?=E5=88=B6=E5=8F=AA=E8=83=BD=E9=80=89=E6=8B=A9=E6=9C=80=E4=B8=8B?= =?UTF-8?q?=E7=BA=A7=E5=88=86=E7=B1=BB=E8=8A=82=E7=82=B9,=E5=90=8C?= =?UTF-8?q?=E6=97=B6=E5=9C=A8=E8=B5=84=E4=BA=A7=E8=A1=A8=E5=8D=95=E4=B8=AD?= =?UTF-8?q?=E6=96=B0=E5=A2=9EcategoryPath=E5=AD=97=E6=AE=B5=E7=94=A8?= =?UTF-8?q?=E4=BA=8E=E8=AE=B0=E5=BD=95=E5=88=86=E7=B1=BB=E8=B7=AF=E5=BE=84?= =?UTF-8?q?,=E5=9C=A8=E5=88=86=E7=B1=BB=E5=8F=98=E6=9B=B4=E6=97=B6?= =?UTF-8?q?=E8=87=AA=E5=8A=A8=E4=BB=8E=E5=88=86=E7=B1=BB=E6=A0=91=E6=88=96?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=8E=B7=E5=8F=96=E5=B9=B6=E4=BF=9D=E5=AD=98?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E8=B7=AF=E5=BE=84=E4=BF=A1=E6=81=AF,?= =?UTF-8?q?=E7=A7=BB=E9=99=A4=E8=AE=A2=E9=98=85=E9=A1=B5=E9=9D=A2=E4=B8=AD?= =?UTF-8?q?=E7=9A=84=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97=E8=BE=93=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- public/web/subscribe.html | 4 +- .../assets/asset/component/editAsset.vue | 41 ++++++++++++++++++- 2 files changed, 41 insertions(+), 4 deletions(-) diff --git a/public/web/subscribe.html b/public/web/subscribe.html index a584e41..0b0b185 100644 --- a/public/web/subscribe.html +++ b/public/web/subscribe.html @@ -665,8 +665,8 @@ // 延迟跳转回原页面 const targetUrl = decodeURIComponent(returnUrl); - console.log('[subscribe] 开通成功,即将跳转到:', targetUrl); - console.log('[subscribe] 原始 returnUrl:', returnUrl); + // console.log('[subscribe] 开通成功,即将跳转到:', targetUrl); + // console.log('[subscribe] 原始 returnUrl:', returnUrl); setTimeout(() => { let finalUrl; diff --git a/src/views/assets/asset/component/editAsset.vue b/src/views/assets/asset/component/editAsset.vue index 92b57af..eba6a3e 100644 --- a/src/views/assets/asset/component/editAsset.vue +++ b/src/views/assets/asset/component/editAsset.vue @@ -24,7 +24,7 @@ ([]); const categoryAttrs = ref([]); + +// 分类选择器配置 - 只能选择最下级节点(isLeafNode: true) +const categoryProps = { + checkStrictly: true, + emitPath: false, + value: 'id', + label: 'name', + children: 'children', + disabled: (data: any) => !data.isLeafNode, +}; const isTimeSlotLimitReached = computed(() => ruleForm.serviceAssetConfig.serviceAssetArrivalConfig.schedule.timeSlots.length >= MAX_TIME_SLOTS); // 获取属性的key @@ -609,6 +620,7 @@ const getInitialForm = (): RuleForm => ({ name: '', type: 'physical', categoryId: '', + categoryPath: '', description: '', onlineTime: '', offlineTime: '', @@ -872,15 +884,38 @@ const fetchCategories = () => { }); }; -// 分类变更时获取分类属性 +// 递归查找分类节点 +const findCategoryNode = (nodes: any[], id: string): any => { + for (const node of nodes) { + if (node.id === id) return node; + if (node.children?.length) { + const found = findCategoryNode(node.children, id); + if (found) return found; + } + } + return null; +}; + +// 分类变更时获取分类属性和path const onCategoryChange = (categoryId: string) => { categoryAttrs.value = []; ruleForm.metadata = {}; + ruleForm.categoryPath = ''; if (!categoryId) return; + // 从分类树中查找选中节点,获取path + const node = findCategoryNode(categoryOptions.value, categoryId); + if (node?.path !== undefined) { + ruleForm.categoryPath = node.path; + } + getCategory(categoryId) .then((res: any) => { const data = res.data; + // 如果接口返回了path,优先使用接口返回的 + if (data?.path !== undefined) { + ruleForm.categoryPath = data.path; + } if (data?.attrs && Array.isArray(data.attrs)) { categoryAttrs.value = data.attrs; // 初始化属性值,确保 boolean 类型默认为 false @@ -915,6 +950,7 @@ const openDialog = (row?: any, edit?: boolean) => { ruleForm.name = data.name || ''; ruleForm.type = data.type || 'physical'; ruleForm.categoryId = data.categoryId || ''; + ruleForm.categoryPath = data.categoryPath || ''; ruleForm.description = data.description || ''; ruleForm.onlineTime = data.onlineTime || ''; ruleForm.offlineTime = data.offlineTime || ''; @@ -1116,6 +1152,7 @@ const buildRequestBody = async (): Promise => { name: ruleForm.name, type: ruleForm.type, categoryId: ruleForm.categoryId, + categoryPath: ruleForm.categoryPath || '', description: ruleForm.description || '', };