<div class="layui-form-item layui-form-item-my" >
<label class="layui-form-label">行业</label>
<div class="layui-input-block">
<div id="industrySel" ></div>
<input type="hidden" name="industryId" >
<input type="hidden" name="industry">
</div>
</div>
var industryTreeData = [];
var rtnIndustry = admin.syncReq(ctx+'/base/baseIndustryCategory/industryTreeList',{});
if(rtnIndustry.code==0){
industryTreeData = rtnIndustry.data;
}
var industryXmSelect = xmSelect.render({
el: '#industrySel',
prop:{name:'name',value:'id'},
clickClose:true,
radio:true,
filterable: true,
data: industryTreeData,
tree:{
show:true,
expandedKeys:[],
strict:false,
},
on:function (data) {
setTimeout(function () {
var valueStr = industryXmSelect.getValue("valueStr");
var nameStr = industryXmSelect.getValue("nameStr");
if(valueStr){
$("[name=industryId]").val(valueStr);
}else{
$("[name=industryId]").val("");
}
if(nameStr){
$("[name=industry]").val(nameStr);
}else{
$("[name=industry]").val(nameStr);
}
},500)
}
});
var industryId = formData.industryId;
if(industryId){
industryXmSelect.setValue((""+industryId).split(","))
}
效果: