Java+VUE 实现下拉框联想查询

11 篇文章 1 订阅
该博客介绍了如何在Vue.js中使用Select组件实现下拉框查询功能,通过filterable属性实现关键词匹配。后端使用Java服务获取数据,XML查询语句从数据库中检索信息。示例代码包括前端Vue模板和JS方法,以及后端Service和XML查询。
摘要由CSDN通过智能技术生成

作用

实现下拉框查询,并且能够输入关键词匹配下拉框数据

效果图

效果图

前端

所有关键代码已做处理

VUE:

<Col span="8" class="txtStyle">
                    <Form :label-width="100" ref="receiptForm" :model="receiptForm">
                        <FormItem label="名称" prop="receiptName">
                            <Select v-model="receiptForm.Name" class="ivu-select8" filterable>
                                <Option v-for="dict in receiptList" :value="dict.value" :key="dict.value">{{dict.name}}</Option>
                            </Select>
                        </FormItem>
                    </Form>
                </Col>

JS:

				receiptList:[],
                receiptForm:{
                    receiptName:''
                },
                receiptFormStr:'',

方法:

findAllReceiptInfo(){
                util.ajax.post('/aop/aop', {
                    param:{
                        createperson:this.$store.state.user.loginUser.tableid
                    },
                    className:'Service',
                    method:'findAllInfo'
                }).then(res => {
                    if (res.data.data != null){
                        this.receiptList = res.data.data;
                    } else {
                        this.receiptList = [];
                    }
                });
            },

后端

service:

public Map<String, Object> findAllReceiptInfo(String params) throws Exception{
        List<ReceiptsEntity> list = receiptloanDao.findAllReceiptInfo();
        List<SelectBo> result=new ArrayList<SelectBo>();
        if(list!=null){
            for(ReceiptsEntity obj:list){
                SelectBo bo=new SelectBo();
                bo.setName(obj.getReceiptName());
                bo.setValue(obj.getReceiptName());
                result.add(bo);
            }
        }
        Constants.getSuccMsg(resultMap, result);
        return resultMap;
    }

xml(忽略Dao)

<select id="findAllReceiptInfo" resultType="com.spdb.lease.entity.bussinss.document.ReceiptsEntity">
        select
        id as receiptLoanId,
        name as receiptName
        from a
        where IS_DELETE = 'N'
    </select>

因为用了工厂函数封装,所以各位前端URL和后端Controller 还是要根据自己情况写,联系查询跟查字典值一样,把name和id做为字典值的key和value理解就行

重点是前端 Select 选择器 中的 filterable属性:
filterable

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值