zoukankan      html  css  js  c++  java
  • iview table表头自定义筛选

    自定义search input:

    const searchInput = (h, params, that) => (
      <span class="search-area">
        <span>{params.column.title}</span>
        <div class="pop-search-wrapper">
          <Poptip popper-class="table-search-pop" transfer={true} transfer={true} placement="bottom" offset={8}> 
            <Icon type="ios-funnel" class={`search-funnel2 ${!that.serachVal(params.column.value)&&'search-funnel-hover'}`} color={that.serachVal(params.column.value) ? "#2d8cf0" : "#c5c8ce"}/>
              <div class="pop-input-search" slot="content">
                <div class="con-box">
                  <Input search placeholder="" onOn-change={e => that.changeValue(e, params)} value={params.column.value} />
                </div>
                <div class="pop-search-footer ivu-table-filter-footer">
                  <Button disabled={!that.searchs[params.column.key]} type="text" onClick={ e => that.setColumnParams(params)}>筛选</Button>
                  <Button type="text" onClick={ e => that.setColumnParams(params, 'reset')}>重置</Button>
                </div>
              </div>
          </Poptip>
        </div>
      </span>);

    data增加临时searchs存储:

    searchs: {
            name: ''
          }, //临时存储的 search信息
    columns属性对应key的renderHeader
    {
              title: "姓名",
              key: "name",
               200,
              value: "",
              sortable: true,
              renderHeader: (h, params) => searchInput(h, params, this),
            },

    调用的方法:

    setColumnParams(params, type) {  // 重置分页
          this.$refs.selection.$el.click() // 隐藏pop弹框
          const key = params.column.key;
          if(type === 'reset') {
            this.columns[params.index].value =  '';
            this['searchs'][key] = '';
          } else {
            this.columns[params.index].value = this['searchs'][key];
          }
          this.searchData(); //查询api
        }

    涉及样式:

    <style lang="less">
    .ivu-dropdown-transfer{
      position: absolute;
      top: 0;
      left: 0;
    }
    .ivu-dropdown-item:hover{
      background-color: #fff!important;
    }
    .search-area {
      position: relative;
      display: inline-block;
    }
    .search-funnel{
      position: absolute;
      right: -36px;
      top: 3px;
    }
    .search-funnel2{
      position: relative;
      right: -8px;
      transition: color 0.2s ease-in-out;
    }
    .search-funnel-hover{
      &:hover{
        color: #515a6e!important;
      }
    }
    .pop-search-wrapper{
      position: absolute;
      right: -28px;
      top: -1px;
    }
    .pop-search-footer{
      &.ivu-table-filter-footer{
        padding: 0!important;
      }
    }
    .table-search-pop{
      .ivu-poptip-body{
        padding: 0!important;
      }
      .con-box{
        padding: 0 12px 8px;
        .p-checkbox-box{
          margin-bottom: 10px;
        }
      }
    }
    .pop-input-search{
      padding-top: 10px;
      width: 280px;
      background: #fff;
      z-index: 1;
      border-radius: 4px;
    }
    
    .button-box{
      display: flex;
      padding-bottom: 10px;
      margin-bottom: -22px;
      border-top: 1px solid #EFEFEF;
      span{
        flex: 1;
        height: 36px;
        line-height: 36px;
        text-align: center;
        font-size: 14px;
        color: #4390FF;
      }
    }
    .search-checkbox{
      .pop-input-search{
        width: 160px;
      }
    }
    .page-wrapper{
      padding-top: 50px;
      text-align: center;
    }
    </style>
  • 相关阅读:
    HDU-4514 湫湫系列故事——设计风景线 手动扩栈
    HDU-4511 小明系列故事——女友的考验 floyd变种-标号递增最短路
    Codeforces Round #199 (Div. 2)
    HDU-4507 吉哥系列故事——恨7不成妻 数位DP
    ZOJ-2342 Roads 二分图最小权值覆盖
    C++题目一道: 重载`->': 您真的懂成员访问运算符的重载吗?
    FCEUX金手指加强版
    原码,反码与补码之间的转换简记
    stm32开发
    Windows中"打开方式..."无法指定程序的解决办法
  • 原文地址:https://www.cnblogs.com/juexin/p/12911039.html
Copyright © 2011-2022 走看看