ElementUI 2.x 输入框回车后在调用接口进行远程搜索功能

server/2024/10/11 0:22:11/

输入框回车后在调用接口进行远程搜索功能

主要思路

默认的远程搜索会在输入框聚焦的时候就展示下拉弹窗,而我们需要的是在回车之后才展示下拉弹窗

具体代码

<divv-for="(domain, index) in formData.domains"class="dynamic-input":key="domain.key"><el-form-item:prop="'domains.' + index + '.memberName'"label="会员名称"><div :class="{ formItemSearch: isHidden }"><el-autocompleteclass="inline-input"v-model.trim="domain.memberName":disabled="domain.mainFlag === 1":fetch-suggestions="querySearch":popper-append-to-body="false"placeholder="请输入会员名称"ref="autocomplete"@select="handleSelect"@keyup.enter.native="handleSearch(domain)"></el-autocomplete></div></el-form-item><el-form-item:prop="'domains.' + index + 'creditCode'"label="统一社会信用代码"><el-inputv-model="domain.creditCode":disabled="domain.mainFlag === 1"></el-input></el-form-item><el-button@click.prevent="removeDomain(domain)"v-if="domain.mainFlag === 0 && formData.domains.length > 2">删除</el-button><p v-if="domain.mainFlag === 1">主操作会员</p>
</div>
</div><script>javascript">
// 添加会员
addDomain() {this.formData.domains.push({memberName: "",mainFlag: 0,memberCode: "",creditCode: "",key: Date.now(),});
},
// 删除会员
removeDomain(item) {var index = this.formData.domains.indexOf(item);if (index !== -1) {this.formData.domains.splice(index, 1);}
},// 回车后搜索
handleSearch(domain) {this.isHidden = false; // 打开下拉框this.querySearch(domain.memberName, this.cbFun, false, domain);
},// 自动填写相应信用码
handleSelect(item) {this.formData.domains.filter((i) => {return item.key === i.key;})[0].creditCode = item.creditCode;// 选择完成后关闭下拉建议框this.isHidden = true;
},// 搜索
querySearch(queryString, cb, isHidden = true, domain) {let results = [];this.cbFun = cb;if (isHidden) {this.isHidden = true;} else {this.isHidden = false;// 调用企查查接口Api.getVipInfoByQcc(queryString).then(({ data: data }) => {if (data.data.length > 0) {this.qccList = data.data.map((item) => {return {value: item.name,creditCode: item.creditCode,No: item.No,key: domain.key,};});cb(this.qccList);	} else {cb(results);}}).catch((err) => {cb(results);});}
}
</script>
<style >// 查询下拉框.formItemSearch .el-autocomplete .el-autocomplete-suggestion {display: none !important;}
</style>

http://www.ppmy.cn/server/129863.html

相关文章

【笔记】微分方程

一、微分方程的基本概念: 定义: 微分方程是一个包含未知函数及其一个或多个导数的方程。 阶: 微分方程的阶是指方程中出现的最高阶导数。 线性与非线性: 如果未知函数及其导数都是一次方的,则称为线性微分方程;否则为非线性微分方程。 常微分方程(ODE)与偏微分方程(PDE): 常…

k8s 中存储之 PV 持久卷 与 PVC 持久卷申请

目录 1 PV 与 PVC 介绍 1.1 PersistentVolume&#xff08;持久卷&#xff0c;简称PV&#xff09; 1.2 PersistentVolumeClaim&#xff08;持久卷声明&#xff0c;简称PVC&#xff09; 1.3 使用了PV和PVC之后&#xff0c;工作可以得到进一步的细分&#xff1a; 2 持久卷实验配置…

VAS1800Q奇力科技线性芯片电荷泵热处理

高效恒流LED驱动器——VAS1800Q在汽车应用中的卓越表现 VAS1800Q是一款专为汽车应用设计的高效恒流LED驱动器。它具备多个显著特点&#xff0c;不仅提升了LED驱动效率&#xff0c;还大大减少了热量的产生&#xff0c;使其在汽车照明领域中具有极高的应用价值。本文将详细介绍VA…

QT学习笔记3.1(建立项目、执行_建立第一个工程)

QT学习笔记3.1&#xff08;建立项目、执行_建立第一个工程) 建立第一个工程&#xff0c;使用widget模板 使用的版本是 Qt Creator 4.11.0 Based on Qt 5.14.0 (MSVC 2017, 32 bit) 1.选择Application-》QT Widget Application&#xff08;最常使用&#xff09; 2.项目保存位…

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-03

计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-03 目录 文章目录 计算机前沿技术-人工智能算法-大语言模型-最新研究进展-2024-10-03目录1. A Scalable Data-Driven Framework for Systematic Analysis of SEC 10-K Filings Using Large Language Models摘要研…

5G NR coreset 简介

文章目录 5G 为何引入CORESETCORESET介绍CORESET 分类 5G 为何引入CORESET 在LTE系统中&#xff0c;PDCCH频域占据整个带宽&#xff0c;始于占据每个RB的前1~3个OFDM 符号&#xff0c;这种情况下&#xff0c;UE 只需知道PDCCH 所占据的OFDM 符号数&#xff0c;就可以确定PDCCH…

【韩顺平Java笔记】第8章:面向对象编程(中级部分)【297-313】

文章目录 297. super基本语法297.1 基本介绍297.2 基本语法 298. super使用细节1299. super使用细节2300. super使用细节3301. 方法重写介绍302. 方法重写细节303. 重写课堂练习1304. 重写课堂练习2输出结果&#xff1a; 姓名&#xff1a;田所浩二 年龄:24305. 养宠物引出多态3…

国庆作业

day1 1.开发环境 Linux系统GCCFDBmakefilesqlite3 2.功能描述 项目功能: 服务器&#xff1a;处理客户端的请求&#xff0c;并将数据存入数据库中&#xff0c;客户端请求的数据从数据库进行获取&#xff0c;服务器转发给客户端。 用户客户端&#xff1a;实现账号的注册、登…