解决 vue-antd-jeecg 管理系统中 online生成的在线表格固定高度

在 vue-antd-jeecg 或就jeccg-boot 前端管理系统中,通过低代码生成的在线表格,表格的高度是不固定,这就会造成,表头会随着全局滚动条滚动上移。

再说说antd中a-table表格组件,它是通过定义scroll属性来控制横纵向滚动条的,但是低代码生成的表格,它通过@jeecg/antd-online-mini这个插件来根据配置项来构建表格,但是没有指定scroll固定值。
所以,我这边是通过修改OnlineForm.umd.min.js源码里的scroll值,给他一个固定的值,如下

scroll: {x: 1700, y: 600}

为什么给x设置1700呢,因为如果只设置y值,或将x设置为true,会出现错行的现象,这里将x设置成尽可能大的值,防止出现错行现象,这个问题antd官网也有说明。

用法:将OnlineForm.umd.min.js放到src中的一个文件中。在main.js替换掉原来的引用。

require('@/tool/OnlineForm.umd.min')

全局搜索 antd-online-mini,将所有的引用antd-online-mini都替换成上述代码,我的项目只有在src/utils/util.js中动态生成菜单路由的时候有使用。
补充通过css样式,在App.vue中加入以下样式,但是有时候在Chrome浏览器会失效,其他浏览器未曾发现。

  .ant-table-scroll > .ant-table-header {
    overflow: hidden !important;
    margin-bottom: 0px !important;
    padding-bottom: 0px !important;
  }

  body.cgformList {
    > div > section.ant-layout {
      height: 150%;
    }

    main.ant-layout-content > div.tab-layout-tabs + div {
      height: calc(100% - 76px);
      margin: 12px !important;

      > div.main {
        height: 100%;

        > div.ant-card {
          > div.ant-card-body {
            height: 100%;
            display: flex;
            flex-direction: column;

            > div.table-operator + div {
              flex: 1;
              min-height: 0;
              display: flex;
              flex-direction: column;

              > div.ant-table-wrapper {
                flex: 1;

                .ant-spin-nested-loading > div > .ant-spin {
                  max-height: initial;
                }

                > .ant-spin-nested-loading {
                  height: 100%;

                  > .ant-spin-container {
                    height: 100%;

                    > .ant-table {
                      max-height: calc(100% - 40px);
                      border: 1px solid #e8e8e8;
                      border-radius: 3px;
                      display: flex;
                      flex-direction: column;

                      & .ant-table-content {
                        height: 100%;
                        border: 1px solid #e8e8e8;

                        & .ant-table-body {
                          min-height: 0;
                          flex: 1;

                          > table {
                            height: 100%;
                            border: none;

                            > thead.ant-table-thead {
                              position: sticky;
                              top: 0px;
                              z-index: 2;
                              border-radius: 0px;

                              > tr:first-child > th:first-child {
                                border-top-left-radius: 0px;
                              }

                              > tr:first-child > th:last-child {
                                border-top-right-radius: 0px;
                              }
                            }
                          }

                          .ant-table-placeholder {
                            border: none;

                            td {
                              border: none;
                            }
                          }
                        }
                      }

                      & .ant-table-body {
                        min-height: 0;
                        flex: 1;

                        .ant-table-placeholder {
                          border: none;

                          td {
                            border: none;
                          }
                        }
                      }
                    }
                  }
                }
              }
            }
          }
        }
      }
    }
  }
  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值