let layer,laypage,table,form,element,dropdown; layui.use(['element', 'layer', 'form', 'element','laypage'], function(){ layer = layui.layer; //弹层 element = layui.element; //分页 laypage = layui.laypage; //分页 table = layui.table; //表格 form=layui.form; dropdown = layui.dropdown; init() }) function init(){ $.ajax({ type: 'POST', url: PATH_URL + '/homePageSelect/getLineProtectorSubComAndStandDropdown', // 请求地址 contentType: "application/json; charset=utf-8", data: {}, //获取提交的表单字段 success: function (data) { console.log("datadatasss:", data.data) $("#taskSourceId").val(data.data[0].child[0].parentName + ' / ' + data.data[0].child[0].title); $("#taskSourceId").attr("stationId", data.data[0].child[0].id); $("#taskSourceId").attr("stationName", data.data[0].child[0].title); $("#taskSourceId").attr("gsName", data.data[0].child[0].parentName); dropdown.render({ elem: '#taskSourceId', accordion: true, data: data.data, click: function(item){ console.log("item:", item) $("#taskSourceId").val(`${item.parentName + ' / ' + item.title}`); $("#taskSourceId").attr("stationId", item.id); $("#taskSourceId").attr("stationName", item.title); $("#taskSourceId").attr("gsName", item.parentName); var iframe = $("#indexFrame")[0]; var iframeWindow = iframe.contentWindow; iframeWindow.setData(); }, }); }, error: function (XMLHttpRequest, textStatus, e) { layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false}); top.layer.close(addLoadingMsg); //再执行关闭 } }); }