赞
踩
<el-select v-model="getListParams.usedStatus" placeholder="请选择状态" filterable :filter-method="filterList" clearable @clear="clearList" > <el-option v-for="item in allListTop15" :key="item.baselineId" :label="item.baselineName" :value="item.baselineId" > </el-option> </el-select>
// 获取所有数据 getAllList() { getBaselineList({ page: 1, rows: 1000 }, (data) => { const { code, message } = data if (code !== '200') { this.$message.error(message) return } this.allList = data.data.list || [] // 编辑回显 filter 返回的是数组 let currenItem = this.allList.filter((item) => item.baselineId === 'AQJX0033231') this.allListTop15 = this.allList.slice(0, 15) // 取前15条展示 // 数组去重 this.allListTop15 = [...new Set([...currenItem, ...this.allListTop15])] }) }, // 自定义搜索方法 字符串、数组 都可以用 includes filterList(query) { if (query) { let result= this.allList.filter((item) => item.baselineName.includes(query)) this.allListTop15 = result.length > 15 ? result.slice(0, 15) : result } }, // 清空按钮时触发 clearList() { this.allListTop15 = this.allList.slice(0, 15) }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。