With a string spliced by value, how to match the corresponding key:value in the tree data and save it in the array?

problem description

1. Several departmental UID strings have been obtained from the backend, separated by "," commas
2. At the same time, the tree data is obtained from the backend (see code for details)

requirements: store departmental UID matching UID and its label, in tree data as an array of objects for use in the select drop-down box

the environmental background of the problems and what methods you have tried

there is an error in the traversal method, and the data read is incomplete

related codes

/ / Please paste the code text below (do not replace the code with pictures)
1 department UID string
str: "ADMIN,27cfb184cba7497f8bc34af8d228b988,712803a9c33e4110961ed40a113db874,0747714bf99b4cf2919ee73eb4ac7662"

2 Tree data (id and text > in read data are matched and stored as label:value), as follows:
-Tree data begin

[
{
"id": "ADMIN",
"checked": false,
"text": "",
"leaf": true,
"priority": -1,
"children": []},{"id": "27cfb184cba7497f8bc34af8d228b988",
"checked": false,
"text": "",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "898f63e4fc144dc19abd973a403645e6",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "aa5f74be66f04e62bbcea34717133624",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "bada5b2760ab4e879f9d7200536917b6",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "cb781db8f4e84ad7b0570eca9960a954",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 1,
    "children": []}]},{"id": "f3cdf3e6949b49c19b624eee6a08f0e8",
"checked": false,
"text": "",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "0747714bf99b4cf2919ee73eb4ac7662",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "712803a9c33e4110961ed40a113db874",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  }
]}]

-Tree data end

what result do you expect? What is the error message actually seen?

I want to get this data format:

 BGuidArr: [
    {
      label: "",
      value: "ADMIN"
    },
    {
      lable: "",
      value: "27cfb184cba7497f8bc34af8d228b988"
    },
    {
      lable: "",
      value: "712803a9c33e4110961ed40a113db874"
    },
    {
      lable: "",
      value: "0747714bf99b4cf2919ee73eb4ac7662"
    }
  ],


is to create a method to traverse the array, and then if there is children , call it again with children , push all the data that has occurred to one place, and finally output the result.

str="ADMIN,27cfb184cba7497f8bc34af8d228b988,712803a9c33e4110961ed40a113db874,0747714bf99b4cf2919ee73eb4ac7662".split(',');

((_list)=>{
    var arr = [];
    var _fun = (__arr)=>{
        __arr.forEach(v=>{
            if(!!~str.indexOf(v.id)) arr.push({label:v.text,value:v.id})
            if(v.children.length) _fun(v.children)
        });
    }
    _fun(_list);
    return arr
})([
{
"id": "ADMIN",
"checked": false,
"text": "",
"leaf": true,
"priority": -1,
"children": []},{"id": "27cfb184cba7497f8bc34af8d228b988",
"checked": false,
"text": "",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "898f63e4fc144dc19abd973a403645e6",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "aa5f74be66f04e62bbcea34717133624",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "bada5b2760ab4e879f9d7200536917b6",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "cb781db8f4e84ad7b0570eca9960a954",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 1,
    "children": []}]},{"id": "f3cdf3e6949b49c19b624eee6a08f0e8",
"checked": false,
"text": "",
"leaf": false,
"priority": 123,
"children": [
  {
    "id": "0747714bf99b4cf2919ee73eb4ac7662",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  },
  {
    "id": "712803a9c33e4110961ed40a113db874",
    "checked": false,
    "text": "",
    "leaf": true,
    "priority": 123,
    "children": []
  }
]}])

Click the link and open the console to view the results
https://codepen.io/vizocn/pen.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e5b1f6-44b4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e5b1f6-44b4b.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?