From 255c80eaab206330e7e0dc5bcbb9790c846eed09 Mon Sep 17 00:00:00 2001 From: Apcallover <1503963513@qq.com> Date: Fri, 17 May 2024 17:18:00 +0800 Subject: [PATCH] =?UTF-8?q?flat:=20=E5=9C=B0=E5=8C=BA=E9=80=89=E6=8B=A9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/store/modules/area.js | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/store/modules/area.js b/src/store/modules/area.js index 38d94ed..3c7a39e 100644 --- a/src/store/modules/area.js +++ b/src/store/modules/area.js @@ -29,17 +29,29 @@ function format(data) { } else { dic[item.areaId] = node; } - const nodeCopy = JSON.parse(JSON.stringify(node)) - nodeCopy.valueId = nodeCopy.value - nodeCopy.value = item.areaName + const nodeR = { + label: item.areaName, + value: item.areaName, + quickQuery: item.quickQuery, + simpleSpelling: item.simpleSpelling, + parentId: item.parentId, + valueId: item.areaId, + }; if (labelChild.hasOwnProperty(item.parentId)) { if (!labelChild[item.parentId].children) { labelChild[item.parentId].children = []; } - labelChild[item.parentId].children.push(nodeCopy); + labelChild[item.parentId].children.push(nodeR); } else { - labelChild[item.parentId] = {children: [nodeCopy]}; + labelChild[item.parentId] = {children: [nodeR]}; } + if (labelChild.hasOwnProperty(item.areaId)) { + labelChild[item.areaId].label = item.areaName; + labelChild[item.areaId].value = item.areaName; + } else { + labelChild[item.areaId] = nodeR; + } + }); return {data: result, dic, labelData: labelResult}; }