Ioufer 2021-10-16 14:37 采纳率: 88%
浏览 15
已结题

tree中,一级和二级的标题是固定的,动态得到数据,然后把数据放到二级中的某一个对应的标题中

<el-tree
                ref="tree"
                hghlight-currenti
                node-key="ID"
                lazy
                :load="loadNode"
                :data="treeData"
                :props="defaultProps"
              />
data() {
return {
treeData: [{ ID: 1, CODE: 'AAA', children: [] }, { ID: 2, CODE: 'BBB', children: [] }],
      // leftTreeDevices: [],
      telChildren: [{ ID: 1020200001, CODE: 'aa', SPEC_ID: '1020200001', isTag: true },
        { ID: 1020200002, CODE: 'bb', SPEC_ID: '1020200002', isTag: true },
        { ID: 1020200003, CODE: 'cc', SPEC_ID: '1020200003', isTag: true },
        { ID: 1020200004, CODE: 'dd', SPEC_ID: '1020200004', isTag: true }
      ],
  defaultProps: {
        children: 'children',
        label: 'CODE'
      },

}
}
methods{
loadNode(node, resolve) {
      if (node.level === 0) {
        return resolve(this.treeData)
      }
      if (node.level === 1) {
        if (node.data.ID === 1) {
          return resolve(this.telChildren)
        }
        // else if (node.data.ID === 2) {
        //   return resolve(this.wlwChildren)
        // } 
        else {
          resolve(null)
        }
      }
      if (node.level > 1) {
        setTimeout(() => {
          const conditionList = {
            counted: true,
            entityspecId: node.data.SPEC_ID,
            paginationMapParameter: {
              order: [{ attribute: 'CODE', type: 'ASC', nullsFirst: 'true' }],
              query: [],
              specItem: this.specItem
            },
            reduced: false,
            regionCode: ''
          }
          entity.queryWithoutPagination(conditionList).then(data => {
            const dataInfo = []
            if (data.count) {
              data.items.forEach(item => {
                item.entityInfo.isLeaf = true
                dataInfo.push(item.entityInfo)
              })
              resolve(dataInfo)
            } else {
              resolve(null)
            }
          }).catch(item => { resolve(null) })
        }, 1000)
      }
    },
//查询数据的接口
query2() {
      const relations = {
        // 机房规格ID
        aSpecId: 1010000000,
        zSpecId: '',
        // 关系规格ID
        relationSpecId: 1010210210000,
        specItem: [{ attribute: 'CODE' }],
        aCondition: [],
        zCondition: [],
        order: [{ attribute: 'CODE', type: 'ASC', nullsFirst: 'true' }],
        pagination: { index: this.pageNumber2, size: this.pageSize2 }
      }
      relations.aCondition.push({ attribute: 'ID', criteriaType: '21', value: this.deviceFacilityId })
      this.leftTreeOcableSegs = []

      relation.queryA(relations).then((rows) => {
        if (rows) {
          const dataInfo = []
          rows.items.forEach(item => { dataInfo.push(item.entityInfo) })
          // leftTreeOcableSegs得到的是数据库中返回的数据,
          //要把这个数据方法二级标题dd中显示,要怎么写
          this.leftTreeOcableSegs[0].children = dataInfo
          console.log(dataInfo)
          this.total2 = rows.count
          this.loading2 = false
        }
      }).catch(item => { this.loading2 = false })
    },

}
  • 写回答

2条回答 默认 最新

  • Ioufer 2021-10-18 16:53
    关注

    已解决

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

问题事件

  • 系统已结题 10月26日
  • 已采纳回答 10月18日
  • 创建了问题 10月16日

悬赏问题

  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)