<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

       

       
       
       

       1 <template>     
       2 <el-tree
       3         :data="datas"
       4         node-key="code"
       5         :highlight-current="bmhighlight"
       6         @node-click="handleNodeClickbm"
       7         :props="defaultProps"
       8         ref="tree"
       9       >
      10         <span class="custom-tree-node" slot-scope="{ node, data }">
      11           <span style="font-size:0.45rem;display:flex;">
      12             {{ node.label }}
      13             <span class="csse" style=""> ( {{ data.resourcecount }} ) </span>
      14           </span>
      15         </span>
      16       </el-tree>
      17 </template>
      18 <script>
      19 import { arrayToTree } from "../../share/treeanalys";
      20 export default{
      21 data{return{
      22    defaultProps: {
      23         children: "children",
      24         label: "name"
      25       },
      26 datas:[]
      27 }
      28 }
      29 methods:{
      30   getTreeData() {
      31       let query = {
      32         user_id: 1,
      33         type: 3,
      34         k_words:this.filterText
      35       };
      36       getTreeList(query)
      37         .then(res => {
      38           // 成功之后的操作
      39           console.log(res, "total");
      40           this.datas = res.data;
      41           arrayToTree(this.datas);
      42           const treeObj = arrayToTree(this.datas, "guid", "pguid");
      43           this.datas = treeObj.rooter.children;
      44           console.log(this.datas, "this.datas");
      45           // this.datass =
      46           // this.data[0].children = res.data;
      47           // this.data[0].children.map((item,index)=>{
      48           //   item.label = item.alias
      49           // })
      50         })
      51         .catch(res => {
      52           // 失敗時候的操作
      53         });
      54     },
      55 }
      56 }
      57 </script>
      View Code
      <template>     
      <el-tree
              :data="datas"
              node-key="code"
              :highlight-current="bmhighlight"
              @node-click="handleNodeClickbm"
              :props="defaultProps"
              ref="tree"
            >
              <span class="custom-tree-node" slot-scope="{ node, data }">
                <span style="font-size:0.45rem;display:flex;">
                  {{ node.label }}
                  <span class="csse" style=""> ( {{ data.resourcecount }} ) </span>
                </span>
              </span>
            </el-tree>
      </template>
      <script>
      import { arrayToTree } from "../../share/treeanalys";
      export default{
      data{return{
         defaultProps: {
              children: "children",
              label: "name"
            },
      datas:[]
      }
      }
      methods:{
        getTreeData() {
            let query = {
              user_id: 1,
              type: 3,
              k_words:this.filterText
            };
            getTreeList(query)
              .then(res => {
                // 成功之后的操作
                console.log(res, "total");
                this.datas = res.data;
                arrayToTree(this.datas);
                const treeObj = arrayToTree(this.datas, "guid", "pguid");
                this.datas = treeObj.rooter.children;
                console.log(this.datas, "this.datas");
                // this.datass =
                // this.data[0].children = res.data;
                // this.data[0].children.map((item,index)=>{
                //   item.label = item.alias
                // })
              })
              .catch(res => {
                // 失敗時候的操作
              });
          },
      }
      }
      </script>
      處理前的數據

       

       

      處理后的數據
       

       

       下面是兩個處理js的源碼

      deepclone.js


      /**
       * deepClone
       * ToDo : 循環引用以及函數拷貝
       *
       * @param {any} obj
       * @returns any
       */
       function deepClone(obj) {
          if (obj == null) {
            return obj
          }
          if (typeof obj !== 'object') {
            return obj
          }
          if (obj instanceof RegExp) {
            return new RegExp(obj)
          }
          if (obj instanceof Date) {
            return new Date(obj)
          }
          if (obj instanceof Array) {
            return obj.map(item => {
              return deepClone(item)
            })
          }
          let newObj = {}
          for (let key in obj) {
            newObj[key] = deepClone(obj[key])
          }
          return newObj
        }
       
        export { deepClone }
       
      treeanalys.js
      import {deepClone} from './deepclone'


      /**
       * 數組轉換成樹
       *
       * @param {Array} arr array
       * @param {string} idField the id field
       * @param {string} pidField the parent's id field
       * @param {Funcction} rooterFunc the Function to judge array item is rooter node or is not
       * @param {string} childrenName the name of node's children when createing tree,default 'children'
       * @returns {Object{mapObj,rooter}} { mapObj, rooter }
       */
      export function arrayToTree(arr, idField, pidField, rooterFunc, childrenName = 'children') {
          // 克隆數組,否則當數組項為對象時,會修改原數組
          let arrCloned = deepClone(arr)
          // 先生成一個映射對象
          const mapObj = arrCloned.reduce((total, current) => {
            total[current[idField]] = current
            return total
          }, {})
          let rooter = null
          // 保存沒有父節點的節點,如果沒有傳rooterFunc,自己創建一個根節點,把數組放進去返回根節點
          const noParentNodes = []
          // 循環掛載節點,返回根節點
          arrCloned.forEach(element => {
            if (rooterFunc && !rooter && rooterFunc(element)) {
              rooter = element
            }
            const parentNode = mapObj[element[pidField]]
            if (parentNode) {
              if (!parentNode[childrenName]) {
                parentNode[childrenName] = []
              }
              parentNode[childrenName].push(element)
            } else {
              noParentNodes.push(element[idField])
            }
          })
          // 當根節點是空的時候,創建一個根節點,把沒有父節點的節點放進去
          if (rooter === null) {
            rooter = {
              [childrenName]: noParentNodes.map(noParentNodeId => {
                return mapObj[noParentNodeId]
              })
            }
          }
          return { mapObj, rooter }
        }

       

      posted on 2022-03-24 14:07  風中追風w  閱讀(902)  評論(0)    收藏  舉報
      主站蜘蛛池模板: 精精国产xxxx视频在线| 中文字幕在线日韩| 最近中文国语字幕在线播放| 亚洲综合在线日韩av| 99久久免费精品色老| 最近中文字幕日韩有码| 久久无码中文字幕免费影院蜜桃| 最新亚洲人成网站在线影院 | 搡老熟女老女人一区二区| 久久国产成人高清精品亚洲| 久操线在视频在线观看| 岛国岛国免费v片在线观看| 免费久久人人爽人人爽AV| 日韩av综合中文字幕| 绥棱县| 亚洲成av人片天堂网无码| 久久婷婷五月综合97色直播| 久久久国产一区二区三区四区小说 | 最新偷拍一区二区三区| 国产精品亚洲а∨天堂2021| 国产成人午夜福利在线播放| 亚洲国产精品无码一区二区三区| 亚洲精品国产老熟女久久| 少妇被多人c夜夜爽爽av| 在线无码免费看黄网站| 国产成人精品亚洲精品密奴| 亚洲欧美一区二区成人片| 午夜福利国产精品视频| 一出一进一爽一粗一大视频| 天天做天天爱夜夜爽导航 | 国产乱人激情H在线观看| 白丝乳交内射一二三区| 91精品91久久久久久| 换着玩人妻中文字幕| 久久婷婷综合色丁香五月| 黄色一级片一区二区三区| 白嫩少妇无套内谢视频| 亚洲中文字幕无码久久精品1| 狠狠亚洲狠狠欧洲2019| 真人无码作爱免费视频| 国产亚洲精品久久777777|