u-table使用虚拟表格 同时懒加载数据 处理 并且最子集 嵌套表格

大数据表格配置

     <u-table
            :highlight-current-row="true"
            :height="treeHeight"
            :row-height="40"
            border
            :data="taskData"
            use-virtual
            class="custom-table"
            v-loading="loading"
            @toggle-tree-expand="toggleTreeExpand" 
            tooltip-effect="dark"
            row-id="id"
            row-key="id"
            ref="controlTable"
            :treeConfig="{ load: loadTree, ...treeConfig}"
            >
      <u-table-column
              min-width="220"
              :tree-node="true"
              prop="taskName"
              :show-overflow-tooltip="true"
              label="名称">
              <template slot="header" slot-scope="scope">
              <span>名称</span>
              <p style="display: none;">{
  {scope.row}}</p>
              </template>
              <template slot-scope="scope">
              <div @click="detail(scope.row)" v-if="!scope.row.hasChild  && scope.row.parent && scope.row.isOpen" class="tree--btn-wrapper-show tree--btn-wrapper mr5"><i class="el-icon-arrow-right"></i></div>
                <div @click="detail(scope.row)" v-if="!scope.row.hasChild && scope.row.parent && !scope.row.isOpen" class="tree--btn-wrapper mr5"><i class="el-icon-arrow-right"></i></div>
                <span class="namelabel">{
  {scope.row.taskName}}</span>
              </template>
            </u-table-column>
            .
            .
          <u-table-column width="1" type="expand" fixed align="right" style="margin-top:10px">
              <template slot-scope="scope">
                <!--此处添加嵌套表格组件 注意表格数据scope.row.-->
              </template>
            </u-table-column>
       </u-table>     

以上是表格示例 ,下面是一些数据/事件

   data () {
   return {
          treeConfig: { hasChildren: 'hasChildren', expandAll: false, indent: 10,  children: 'children', lazy: true, iconOpen: 'el-icon-arrow-down', iconLoaded: 'el-icon-loading', iconClose: 'el-icon-arrow-right' }
    }
   },
   methods: {
    loadTree (row, resolve) {
    // 加载子节点数据的函数,lazy 为 true 时生效,函数第二个参数返回子节点
    },
    toggleTreeExpand (row) {
      const changeChildren = (row) => {
        if (row.children) {
          row.children.forEach((item) => {
            item.isOpen = false
            changeChildren(item)
          })
        }
      }
      changeChildren(row)
    },
   detail (row, column, event) {
      this.$nextTick(() => {
        this.findAccountingFileById(row)
      })
    },
    async findAccountingFileById (row) {
      this.$nextTick(async () => {
        let tableEl = this.$refs.controlTable
        if (row.isOpen) {
          row.isOpen = false
          tableEl.toggleRowExpansion(row, false)
        } else {
          const [err, res] = await 接口
          if (res) {
            tableEl.toggleRowExpansion(row, true)
            row.[嵌套表格数据命名]= res
          }
          this.$nextTick(() => {
            row.isOpen = !row.isOpen
          })
        }
      })
    },  
 
  }

如有疑问 加技术群 978165670 探讨

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2023-12-15 12:20:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2023-12-15 12:20:03       101 阅读
  3. 在Django里面运行非项目文件

    2023-12-15 12:20:03       82 阅读
  4. Python语言-面向对象

    2023-12-15 12:20:03       91 阅读

热门阅读

  1. 【Rust】第四节:通用编程概念

    2023-12-15 12:20:03       68 阅读
  2. python传递给delphi dll只能显示第1个字符?

    2023-12-15 12:20:03       58 阅读
  3. axios不用封装单独上传图片文件

    2023-12-15 12:20:03       50 阅读
  4. redis的hash实现

    2023-12-15 12:20:03       60 阅读
  5. android常用

    2023-12-15 12:20:03       48 阅读
  6. Vue 循环渲染 v-for

    2023-12-15 12:20:03       53 阅读
  7. OSS上传pdf无法解析的问题

    2023-12-15 12:20:03       52 阅读
  8. Python 自动化之处理图片(一)

    2023-12-15 12:20:03       52 阅读
  9. Leetcode724.寻找数组中心下标(通俗易懂版)

    2023-12-15 12:20:03       54 阅读
  10. RocketMQ的架构是什么样的❓

    2023-12-15 12:20:03       66 阅读
  11. LeetCode-232. 用栈实现队列【栈 设计 队列】

    2023-12-15 12:20:03       46 阅读
  12. ARM开发

    ARM开发

    2023-12-15 12:20:03      65 阅读