作用
实现下拉框查询,并且能够输入关键词匹配下拉框数据
效果图
前端
所有关键代码已做处理
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属性: