device-cat-select.js 1.12 KB
function loadParentCat($dataurl){$.ajax({type:"post",url:$dataurl,dataType:"json",data:$.csrf({parentId:0}),success:function(msg){if(1==msg.status){var data=eval(msg.modelList),html="<option value=''>--请选择--</option>";for(var s in data)html=html+"<option value='"+data[s].id+"'>"+data[s].name+"</option>";$("#deviceParentCat").html(html)}else alert("加载失败")},error:function(msg){alert("加载异常")}})}function loadDeviceCat($dataurl){var pid=$("#deviceParentCat").val();return""==pid?($("#deviceChildCat").html("<option value=''>--请选择二级分类--</option>"),!1):void $.ajax({type:"post",url:$dataurl,dataType:"json",data:$.csrf({parentId:pid}),success:function(msg){if(1==msg.status){var data=eval(msg.modelList),html="<option value=''>--请选择二级分类--</option>",cat_id=$("#hid_cat_id").val();for(var s in data)html=parseInt(cat_id)==parseInt(data[s].id)?html+"<option value='"+data[s].id+'\' selected="selected">'+data[s].name+"</option>":html+"<option value='"+data[s].id+"'>"+data[s].name+"</option>";$("#deviceChildCat").html(html)}else alert("加载失败")},error:function(msg){alert("加载异常")}})}