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",
		async:false,
		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);
			localStorage.setItem("oneselectyj",data.data[0].child[0].id)
			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);
				  
				  
				  /**
				   * 选择运检站后会根据运检id重新查询页面内容
				   */
				  localStorage.setItem("oneselectyj", item.id)
				  var iframe = $("#indexFrame")[0];
				  var iframeWindow = iframe.contentWindow;
				  iframeWindow.setData();
				  
				  
				  var viewResultFrame = $("#viewResultFrame")[0];
				  var viewResultWindow = viewResultFrame.contentWindow;
				  viewResultWindow.init();
				  
				  var viewPlanFrame = $("#viewPlanFrame")[0];
				  var viewPlanWindow = viewPlanFrame.contentWindow;
				  viewPlanWindow.init();
				  
				  
				  var staffFrame = $("#staffFrame")[0];
				  var staffWindow = staffFrame.contentWindow;
				  staffWindow.init();
				  
				  
				  var projectFrame = $("#projectFrame")[0];
				  var projectWindow = projectFrame.contentWindow;
				  projectWindow.init();
				  
				  var attendanceFrame = $("#attendanceFrame")[0];
				  var attendanceWindow = attendanceFrame.contentWindow;
				  attendanceWindow.initTable1();
				  
				  var wagesFrame = $("#wagesFrame")[0];
				  var wagesWindow = wagesFrame.contentWindow;
				  wagesWindow.init();
				},
			});
		},
		error: function (XMLHttpRequest, textStatus, e) {
			layer.msg('数据请求发生异常,请稍后重试', {icon: 16, scrollbar: false});
			top.layer.close(addLoadingMsg); //再执行关闭
		}
	});
}