• 数据过多,select优化


    封装Select组件
    
    <template>
      <div>
        <el-select
          ref="selectRef"
          v-bind="$attrs"
          v-on="$listeners"
          clearable
          filterable
          remote
        >
          <div class="option">
            <el-option
              v-for="(item, index) in options"
              :key="index"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </div>
          <div class="pagin">
            <el-pagination
              small
              background
              layout="prev,pager,next,total"
              v-bind="$attrs"
              v-on="$listeners"
            ></el-pagination>
          </div>
        </el-select>
      </div>
    </template>
    
    <script>
    export default {
      props: {
        options: {
          type: Array,
          default: ()=>[]
        },
      },
        data() {
            return {
              
            }
        },
    };
    </script>
    
    <style lang="scss" scoped>
    .option{
        min-height: 50px;
        height: auto;
        max-height: 150px;
        overflow-y: auto;
    }
    .pagin{
        background:#fff;
    }
    ::-webkit-scrollbar{
        width: 2px;
    }
    </style>
    
    
    

    使用

     <EverSelect
              :page-size="selectParam.pageSize"
              :total="selectParam.total"
              :current-page="selectParam.currentPage"
              :options="selectList"
              @change="selectChange"
              :value="form.data.productName"
              :remote-method="remoteSearch"
              :hide-on-single-page="true"
            />
    
       // 远程搜索
        remoteSearch(val) {
          this.getList({
            page: this.selectParam.pageNum,
            rows: this.selectParam.pageSize,
            productBusinessTypeIds: [1, 3, 4],
            productName:val
          });
        },
        //选取item
    selectChange(val){
          let info = this.selectList.find(item=> item.id ==val)
          this.$set(this.form.data, "productId", info.id);
          this.$set(this.form.data, "numberType", "1");
          this.$set(
            this.form.data,
            "productBusinessTypeId",
            info.productBusinessTypeId
          );
          this.$set(this.form.data, "productName", info.productName);
          this.$set(this.form.data, "productNum", info.productNum);
        },
        /* 切换页 */
        currentPage(val) {
          this.$set(this.selectParam, "pageNum", val);
          this.getList()
        },
      getList() {
          let param = {
            page: this.selectParam.pageNum,
            rows: this.selectParam.pageSize,
            productBusinessTypeIds: [1, 3, 4],
          };
          requestData("toChooseListQueryPageDigital", param).then((res) => {
            if (res.code == 1000) {
             this.selectList = res.data.records.map(item=>{
               return {
                 ...item,
                 label:item.productName,
                 value:item.id,
               }
              })
              this.$set(this.selectParam, "total",res.data.total);
              this.$set(this.selectParam, "currentPage",res.data.pages);
            }
          });
        },
    

    效果图
    在这里插入图片描述

  • 相关阅读:
    16、window11+visual studio 2022+cuda+ffmpeg进行拉流和解码(RTX3050)
    Mybatis - 查询功能
    ZKP5.1 Plonk Interactive Oracle Proofs (KZG‘10)
    由 Base64 展开的知识探讨
    Spring基础:接口实现AOP
    第五章《类的继承》第2节:子类对象的构建过程
    面试题整理:防抖函数的应用场景和实现方式?
    Allure精通指南(02)Mac和Windows系统环境配置
    【Swift 60秒】56 - Closures with multiple parameters
    今年十个学软件测试九个在待业,看我如何破局成功且年薪50w,怎么才能做到?
  • 原文地址:https://blog.csdn.net/weixin_43852916/article/details/126951594