当前位置: 首页 > news >正文

支持远程搜索、分页加载和多选功能的 el-select 组件

功能点: 远程搜索获取下拉数据

  <dealerMoreSelect  slot="1" v-model="erp" placeholder="ERP/经销商编码"></dealerMoreSelect>组件<template><!-- multiple  需要改下面的 props value 为数组--><el-selectclass="lomoreSelect"v-bind="$attrs"v-loadmore="activityLoadMore"v-model="activityList"size="small"collapse-tagsfilterableremoteclearable:remote-method="remoteMethod":loading="remoteLoading"@clear="clearMethod"><el-optionv-for="item in options":key="item.dealerNo + Math.random()":label="item.dealerShortName":value="item.dealerNo"></el-option></el-select>
</template><script>
// import { getActivityManagementInfos } from '@/views/clue/api/clueConfig'
import { getDealerPage } from '@/views/store/api/index.js'
export default {name: 'dealermoreSelect',props: {value: {type: String,default: () => ''}},data() {return {disabledLoad: false,remoteLoading: false,visibleDialog: false,submitLoading: false,loading: false,name: undefined,pageNum: 1,pageSize: 10,options: []}},computed: {activityList: {get() {return this.value},set(val) {this.$emit('input', val)}}},mounted() {this.init()},methods: {init() {this.visibleDialog = truethis.getList()},// focus() {//   this.name = ''//   this.clearMethod()// },remoteMethod(query) {console.log(query)this.pageNum = 1this.options = []this.remoteLoading = truethis.name = querythis.getList()},clearMethod() {this.pageNum = 1this.name = ''this.options = []this.remoteLoading = truethis.getList()},// 获取活动列表async getList() {const res = await getDealerPage({pageNum: this.pageNum,pageSize: this.pageSize,keyword: this.name,businessStatus: '' // 状态 0-开启 1-关闭})if (res.code === '0') {this.remoteLoading = falseif (res.data?.list?.length < this.pageSize) {this.disabledLoad = true} else {this.disabledLoad = false}this.options = this.options.concat(res.data.list || [])}},activityLoadMore() {if (this.disabledLoad) returnthis.pageNum += 1this.disabledLoad = truethis.getList()},submit() {}}
}
</script><style lang="scss" scoped>
.lomoreSelect{width: 215px !important;/deep/ .el-select__caret:first-child::before {content: "\e6e1";}/deep/ .is-focus {.el-select__caret:first-child {transform: rotateZ(0deg);}}
}
</style>
v-loadmore  指令
export default {loadmore: {bind(el, binding) {const SELECTWRAP_DOM = el.querySelector('.el-select-dropdown .el-select-dropdown__wrap')SELECTWRAP_DOM.addEventListener('scroll', function() {const condition =this.scrollHeight - this.scrollTop <= this.clientHeight + 5if (condition) { binding.value() }})}}
}
http://www.dtcms.com/a/147490.html

相关文章:

  • SpringBoot自定义验证器:企业级参数校验架构设计与实践
  • 流量抓取工具(wireshark)
  • docker 中将dpo后的模型转为ollama能够调用的gguf格式
  • 对程序中使用到的字体进行子集化处理
  • C语言高频面试题——常量指针与指针常量区别
  • 文档处理控件Aspose.Words 教程:在 Word 中删除空白页完整指南
  • 【C++游戏引擎开发】第19篇:Compute Shader实现Tile划分
  • Cursor可视化大屏搭建__0420
  • 软件功能测试和非功能测试有什么区别和联系?
  • 【同济】高等数学6.7.8版答案
  • 1+X: Python程序开发职业技能等级要求(初级)练习资料分享
  • 软件工程师中级考试-上午知识点总结(下)
  • 基于OKR的企业管理数字化实践——以围棋教育机构流程优化为例
  • 【数字图像处理】图像纹理分析
  • 基于STM32的HX711货物称重系统
  • QT文件和文件夹拷贝操作
  • NetApp ONTAP 9 故障磁盘更换操作指南
  • 《零基础入门学习Python》
  • OpenGL shader开发实战学习笔记:第十二章 深入光照
  • Linux指令合集
  • C++ STL:从零开始模拟实现 list 容器
  • ACWing——算法基础课
  • 棉花糖实验新解
  • Linux-scp命令
  • 3DMAX 常用渲染器对比及渲染 101 云平台优势
  • (EtherNet/IP 转 EtherNet/IP)EtherCAT/Ethernet/IP/Profinet/ModbusTCP协议互转工业串口网关
  • 存储器综合:内存条
  • 【NLP 69、KG - BERT】
  • linux sysfs的使用
  • μC/OS 版本演进过程 | uC/OS-II 和 uC/OS-III 有什么区别?