var isFirstShowTopMsg = true;
$(document).ready(function() {
	if($.cookie("token") == null) {
		window.location.href = "index.html";
	}
	getnew();
	domainPrompt();
	// 历史工单
	loadOld();
	// 一键转接
	getkeyTransferData();
	// 来电弹屏
	laydate.skin("blue");
	laydate({
		elem: "#old_startTime",
		event: "focus",
	});
	laydate({
		elem: "#old_endTime",
		event: "focus",
	});
	laydate({
		elem: "#con_startTime",
		event: "focus",
	});
	laydate({
		elem: "#con_endTime",
		event: "focus",
	});
	laydate({
		elem: '#comprehensiveContentStarttime',
		event: 'focus',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss'
	});
	laydate({
		elem: '#comprehensiveContentEndtime',
		event: 'focus',
		istime: true,
		format: 'YYYY-MM-DD hh:mm:ss'
	});
	//获取消息
	getTopMsgs();
	//获取电话类别
	getPhoneType($("#phonetype"));
	//弹屏右侧切换效果
	// $(".ldtp-cr ul.ld-service li").click(function () {
	//     $(this).addClass("cr-click").siblings().removeClass("cr-click");
	//     loadOld();
	// });

	//最大化 最小化效果
	//最小化
	$(".minClosed").click(function() {
		$(".ldtp-con").removeClass("fadeInDown");
		$(".ldtp-con").addClass("fadeOutUp");
		$(".ldtp-con").css("display", "none");
		$(".maxOpen").show();
		$(".maxOpen").addClass("fadeInDown");
	});

	//最大化
	$(".maxOpen").click(function() {
		//触发来电类型第一个 点击；测试用
		$(".ldtp-con").removeClass("fadeOutUp");
		$(".ldtp-con").addClass("fadeInDown");
		$(".ldtp-con").css("display", "block");
		$(".maxOpen").hide();
		$(".maxOpen").removeClass("fadeInDown");
		$(".maxOpen").addClass("fadeInDown");
		$(".first").removeClass("first");
		$(".ldtp-con").addClass("first");
	});
	//关闭弹框
	$(".Bacha").click(function() {
		//清除来电类型样式
		$("#dicValueList li").find("label").removeClass("checkedDept");
		$(".ldtp-con").removeClass("fadeInDown");
		$(".ldtp-con").addClass("fadeOutUp");
		$(".ldtp-con").css("display", "none");
		$(".repoConte").hide();
		$(".comprehensiveContent").hide();
		Clean();
		$("#phonetype").val('12345')
		$("#phonetype1").hide()
		$("#phonetype2").hide()
		
		$(".SayBusy").addClass("active");
		$(".SayFree").removeClass("active");
		$(".zxzt").removeClass("br").removeClass("by").addClass("bl");
		$(".hwzt").text("空闲");
		$("#isml").val(0);
		SetStateCookie(0);
		obj.Type = "SayFree";
		Send();
	});
	//顶部小头像
	var little_pic = $(".head-pic .hp-box img").attr("src");
	$(".maxOpen li .photo img").attr("src", little_pic);
	//点击左侧菜单来电弹屏显示
	$(".tantan").click(function() {
		$(".maxOpen").trigger("click");
		$(".head-pic .lahei .la-before").show();
		$(".head-pic .lahei .la-after").hide();
	});

	//点击挂断
	$(".head-pic .td-call .take").click(function() {
		//obj.Type = "DropCall";
		obj.Type = "TurnIvr";
		obj.AgentID = $.cookie("zx_user");
		obj.AgentExten = $.cookie("extno");
		obj.IvrName = "MYD";
		obj.IvrPos = "1";
		Send();
	});

	//点击拉黑事件
	$(".head-pic .lahei .la-before").click(function() {
		if(!$(".hidTel").val()) {
			layer.confirm("来电号码为空！", {
				btn: ["确定"],
			});
			return;
		}
		$("#time-word").val("");
		$(".ldtp-con .hei-list").show();
	});
	//拉黑输入框事件
	$(".hei-list .bacha").click(function() {
		$(".ldtp-con .hei-list").hide();
		$("#time-word").val("");
	});
	var reg = /^\+?[1-9][0-9]*$/;

	$("#bc").click(function() {
		var n = $("#time-word").val();
		var val = $("input[name='time']:checked").val();
		if(n) {
			if(!reg.test(n)) {
				layer.confirm("请输入整数时间！", {
					btn: ["确定"],
				});
				return;
			}
		} else {
			if(val == "4") {
				n = 0;
			} else {
				layer.confirm("请输入整数时间！", {
					btn: ["确定"],
				});
				return;
			}
		}
		$.post(
			huayi.config.callcenter_url + "CallInScreen/AddBlack", {
				tel: $(".hidTel").val(),
				num: n,
				type: val,
				token: $.cookie("token"),
			},
			function(result) {
				result = $.parseJSON(result);
				if(result.state.toLowerCase() == "success") {
					layer.msg("拉入黑名单成功");
					$(".la-time .lhtime").text(getNowFormatDate());
					$(".la-shichang .blackTime").html(result.data);
					$(".ldtp-con .hei-list").hide();
					$(".head-pic .lahei .la-before").hide();
					$(".head-pic .lahei .la-after").show();
					$(".head-pic .lahei .retur").show();
				}
			}
		);
	});

	$(".la-after").click(function() {
		if(!$(".hidTel").val()) {
			layer.confirm("来电号码为空！", {
				btn: ["确定"],
			});
			return;
		}
		$("#time-word").val("");
		$(".ldtp-con .hei-list").show();
		$(".ldtp-con .hei-list").removeClass("bounceOutUp");
		$(".ldtp-con .hei-list").addClass("bounceIn");
	});
	$(".head-pic .lahei .retur").click(function() {
		$.getJSON(
			huayi.config.callcenter_url + "CallInScreen/DelBlack", {
				tel: $(".hidTel").val(),
				token: $.cookie("token"),
			},
			function(result) {
				if(result.state.toLowerCase() == "success") {
					layer.msg("取消黑名单成功");
					$(".head-pic .lahei .retur").hide();
					$(".head-pic .lahei .la-after").hide();
					$(".head-pic .lahei .la-before").show();
				}
			}
		);
	});

	if(
		/mobile/i.test(navigator.userAgent) ||
		/android/i.test(navigator.userAgent)
	) {
		$(".title-box").hide();
	}
	obj.AgentExten = $.cookie("extno");
	if(obj.AgentExten == undefined) {
		$(".Gnumbox").hide();
	}
	$(".Gnum").text(obj.AgentExten);

	$.getJSON(
		huayi.config.callcenter_url + "UserAccount/GetNowUser", {
			token: $.cookie("token"),
		},
		function(result) {
			if(result.state.toLowerCase() == "success") {
				$.cookie("code", result.data.role.F_RoleCode);
				$.cookie("userCode", result.data.user.F_UserCode);
				$.cookie("userNameLogin", result.data.user.F_UserName);
				$.cookie("seartGroupID", result.data.user.F_SeartGroupID);
				$.cookie('userMobile', result.data.user.F_Mobile);
				//$.cookie("seartGroupID", "1");
				$("#RoleCode").val(result.data.user.F_RoleCode);
				$("#GroupCode").val(result.data.user.F_GroupCode);
				$(".username").text(result.data.user.F_UserName);
				$(".chat_username").text(result.data.user.F_UserCode);
				$(".user_code").text(result.data.user.F_UserCode);
				$(".group").text(result.data.user.F_SeartGroup);
				//if (result.data.role) {
				//    $(".rolename").text(result.data.role.F_RoleName);
				//}
				$(".deptname").text(result.data.user.depname);
				$(".yhtx").attr(
					"src",
					huayi.config.callcenter_url.substr(
						0,
						huayi.config.callcenter_url.length - 1
					) + result.data.user.F_See
				);
				obj.AgentID = result.data.user.F_UserCode;
				//obj.AgentExten = result.data.user.F_WorkNumber;
				$(".mgh").val(result.data.user.F_UserCode);
				$(".mn").val(result.data.user.F_UserName);
				$(".settingCompany").val(result.data.user.F_Company);
				$(".settingDepartment").val(result.data.user.F_Department);
				$(".settingPost").val(result.data.user.F_Post);
				$(".settingMobile").val(result.data.user.F_Mobile);
				$(".settingTelephone").val(result.data.user.F_Telephone);
				if(result.data.user.F_SeatFlag) {
					Connect();
					if($.cookie("code") == "spdbzy") {
						//layer.open({
							//type: 2,
							//content: "./calloutNew/videoCall.html", //iframe的url，no代表不显示滚动条
							//title: "视频通话窗口",
							//shade: 0,
							//offset: "rb",
							//area: ["22%", "65%"], //宽高
						//});
					}else{
						connectVoice(1); //创建连接 
					}
					//if($.cookie("code") != "spdbzy") {
						//connectVoice(1); //创建连接 
					//}
					//CreateWebSockets();
					//$(".open_chat").show();
					//heartbeat = setInterval(function() {
					//	Heart()
					//}, 60000);
					$("#top-search").show();
					$(".phoneBZ").show();
					$(".zts").show();
					obj.AgentGroup = $.cookie("seartGroupID");
					if($("#RoleCode").val() == "DBHWY") {
						// obj.AgentGroup = "1";
						$(".db_show").show();
						$(".hw_show").hide();
					} else if($("#RoleCode").val() == "ZJZY") {
						// obj.AgentGroup = "2";
						$(".db_show").show();
						$(".hw_show").hide();
					} else {
						// obj.AgentGroup = "364";
						$(".db_show").hide();
						$(".hw_show").show();
					}
				}
				if($("#RoleCode").val() != "EJWLDW") {
					$(".dclgd").eq(0).show();
					$(".cqgd").eq(0).show();
					//rightUp();
					//setInterval(rightUp, 60000);
				}
				if(result.data.role.F_RoleId == "6") {
					CreateWebSockets();
					$(".open_chat").show();
				}
				//              if (result.data.role.F_IsEject == 1) {
				//                  $.getJSON(
				//                      huayi.config.callcenter_url +
				//                          "Index/GetNoDealOrderCounts",
				//                      {
				//                          token: $.cookie("token"),
				//                      },
				//                      function (result) {
				//                          if (result.data.lists.length != 0) {
				//                              //  弹框函数调用
				//                              login_DK();
				//                          }
				//                      }
				//                  );
				//              }
				var roleCode = result.data.role.F_RoleCode
				// 反映类别
				getReactionCategory(roleCode);
				// 多媒体信息
				multimediaPrompt(roleCode);

				// 供暖专员不能添加工单
				if(roleCode === "GNZY") {
					$(".orderForm").hide();
				}
			}
		}
	);
	// getWhetherEditInformation();
	$.ajaxSettings.async = false;
	$.getJSON(
		huayi.config.callcenter_url + "Index/GetMenu", {
			token: $.cookie("token"),
		},
		function(result) {
			$.ajaxSettings.async = true;
			if(result.state.toLowerCase() == "success") {
				$(result.data).each(function(i, n) {
					var html =
						'<li><a href="#" dataid=' +
						n.F_FunctionId +
						// '><i class="fa iconfont">&#xe614;</i><span class="nav-label">' +
						'><i class="fa iconfont">' +
						n.F_ImgUrl +
						'</i><span class="nav-label">' +
						n.F_FunctionName +
						'</span><span class="fa arrow"></span></a>';
					html += '<ul class="nav nav-second-level">';
					$(n.item).each(function(j, m) {
						if(m.item.length > 0) {
							html +=
								'<li><a class="" dataid=' +
								m.F_FunctionId +
								' href="#">' +
								m.F_FunctionName +
								'<span class="' +
								m.F_FunctionCode +
								'"></span><span class="fa arrow"></span></a>'
							html += '<ul class="nav nav-third-level">';
							$(m.item).each(function(k, l) {
								html +=
									'<li><a class="J_menuItem" dataid=' +
									l.F_FunctionId +
									' href="' +
									l.F_OptUrl +
									'">' +
									l.F_FunctionName +
									"</a>" +
									'<span class="label label-warning pull-right lblcount ' +
									l.F_FunctionCode +
									'"></span>' +
									"</li>";
							});
							html += "</li></ul>"
						} else {
							html +=
								'<li><a class="J_menuItem" dataid=' +
								m.F_FunctionId +
								' href="' +
								m.F_OptUrl +
								'">' +
								m.F_FunctionName +
								"</a>" +
								'<span class="label label-warning pull-right lblcount ' +
								m.F_FunctionCode +
								'"></span>' +
								"</li>";
						}
					});
					html += "</ul></li>";
					$(html).appendTo($("#side-menu"));
				});
				$(".J_menuItem").click(function() {
					if($(this).text() == "来电弹屏") {
						$(".maxOpen").trigger("click");
						$(".head-pic .lahei .la-before").show();
						$(".head-pic .lahei .la-after").hide();
					}
				});
			}
		}
	);
	document.onclick = function(e) {
		$(".keyTransferDiv").hide();
	};
	$(".hw_through").click(function(e) {
		$(".keyTransferDiv").toggle();
		e = e || event;
		stopFunc(e);
	});

	function stopFunc(e) {
		e.stopPropagation ? e.stopPropagation() : (e.cancelBubble = true);
	}
	// 一键转接
	function throungh() {
		var guid = uuid();
		obj.Type = "Transfer";
		obj.DestinationNumber = "8" + $(".hw_through").attr("index");
		obj.Header = "8";
		obj.TaskType = "0"; //0:拨号外呼；1:未接来电外呼；2:回访外呼
		obj.TaskPhoneID = ""; //回访的电话ID
		obj.TaskID = guid; //回访记录编号
		Send();

		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Callrecords/UpdateTransferCall",
			async: true,
			dataType: "json",
			data: {
				token: $.cookie("token"),
				callid: $(".hidCallID").val(),
				transfercall: $(".hw_through").attr("index")
			},
			success: function(result) {
				if(result.state.toLowerCase() == "success") {
					debugger
				}
			},
		});
	}

	// 获取转接数据
	function getkeyTransferData() {
		$(".keyTransferDiv dl").empty();
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Dictionary/GetDicValueListById",
			dataType: "json",
			async: false,
			data: {
				token: $.cookie("token"),
				id: 2988,
			},
			success: function(data) {
				if(data.state.toLowerCase() == "success") {
					var content = data.data;
					$(content).each(function(i, n) {
						$("<dt data-number='" + n.F_Remark + "'>" + n.F_Value + "</dt>").appendTo(".keyTransferDiv dl");
					});
				}
			},
		});
	}

	// 转接绑定事件
	$(".keyTransferDiv dl").on("click", "dt", function(e) {
		$(".hw_through").attr("index", $(this).attr("data-number"))
		throungh()
	})

	//话务相关
	$("#top-search li").click(function() {
		if($(this).find("i").hasClass("active")) {
			if(obj.AgentID) {
				var fun = $(this).attr("datafun");
				obj.Type = fun;
				obj.AgentGroup = $.cookie("seartGroupID");
				switch(fun) {
					case "Login":
						// obj.AgentGroup = "364";
						obj.AgentGroup = $.cookie("seartGroupID");
						obj.AgentType = "0";
						Send();
						break; //签入
					case "callOutLogin":
						obj.AgentGroup = "9999";
						obj.AgentType = "0";
						obj.Type = "Login";
						Send();
						break; //外呼签入
					case "MakeCall":
						$(".hidCallID").val("");
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //外呼
					case "Meeting":
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //多方通话
					case "Transfer":
						$("#hidwhtype").val(fun);
						whtp();
						//obj.DestinationNumber = "1012";
						break; //转移
					case "Consult": //协商呼叫
						$("#hidwhtype").val(fun);
						whtp();
						break;
					case "ConfirmTransfer": //确认转移
						obj.EndParmer = "1";
						Send();
						break;
					case "CancelTransfer": //取消转移
						//                		$("#hidwhtype").val(ConfirmTransfer);
						obj.Type = "ConfirmTransfer";
						obj.EndParmer = "3";
						Send();
						break;
					case "TurnIvr": //转IVR
						obj.IvrName = "TurnIvr";
						obj.IvrPos = "1";
						Send();
						break;
					case "MeetingTakeBack": //多方通话回签
						obj.Type = "MeetingTakeBack";
						Send();
						break;
					case "satisfactionEvaluation": //多方通话回签
						satisfactionEvaluationFun();
						break;
					case "keyTransfer": // 一键转接
						break;
					default:
						Send();
						break;
				}
			}
		}
	});
	//知识库查询
	$(".searIcon").click(function() {
		loadZSK();
	});
	//历史记录查询
	$(".searchbtn").click(function() {
		loadOld();
	});
	//新增记录
	$(".addjl").click(function() {
		$(".addgd").show();
		$(".tbold").hide();
	});
	//关闭外呼弹屏
	$(".closes").click(function() {
		$(".WH").removeClass("fadeInDown").addClass("fadeOutUp");
		$(".WH").addClass("hidens");
	});
	//外呼呼出
	$(".CallOut").click(function(event) {
		event.stopPropagation();
		if($("#Result").val()) {
			$.ajax({
				type: "get",
				url: huayi.config.callcenter_url + "CallOutOpt/GetCallOutprefix",
				async: true,
				dataType: "json",
				data: {
					token: $.cookie("token"),
					phone: $("#Result").val(),
				},
				success: function(result) {
					if(result.state.toLowerCase() == "success") {
						var guid = uuid();
						obj.Type = $("#hidwhtype").val();
						obj.DestinationNumber = result.data.phone;
						obj.Header = result.data.fix;
						obj.TaskType = "0"; //0:拨号外呼；1:未接来电外呼；2:回访外呼
						obj.TaskPhoneID = ""; //回访的电话ID
						obj.TaskID = guid; //回访记录编号
						obj.Callee = $("#Result").val(); //被叫号码
						obj.Caller = $.cookie("extno"); //操作人分机号
						Send();
						$("#Result").val("");
						$(".WH").addClass("hidens");
					}
				},
			});
		}
	});
	//外呼弹屏数字键盘样式
	$(".Num_ul div")
		.mousedown(function() {
			$(this).addClass("actives");
			$(".img").removeClass("hidens");
		})
		.mouseup(function() {
			$(this).removeClass("actives");
		});
	//外呼弹屏数字键盘号码输入
	$(".Num_ul li div").click(function() {
		var rt = $("#Result").val() + "";
		if(rt.length < 18) {
			rt = rt + $(this).find("a").text();
			$("#Result").val(rt);
		}
	});
	//外呼弹屏数字键盘号码截取
	$(".img").click(function() {
		var Result = $("#Result").val() + "";
		Result = Result.substr(0, Result.length - 1);
		$("#Result").val(Result);
		if(Result.length == 0) {
			$(".img").addClass("hidens");
		}
	});
	//外呼电话列表
	$(".bg_title li").click(function() {
		$(this).addClass("lactive").siblings().removeClass("lactive");
		loadWH();
	});
	$(".ty").click(function() {
		loadWH();
	});
	//创建投诉工单
	$(".addt_").click(function() {
		Statess = 0;
		Adds();
	});
	//创建投诉工单
	$(".addts").click(function() {
		Statess = 1;
		Adds();
	});
	$(".mapBJ").click(function() {
		$(".mapPos").hide();
		$(".mapBJ").hide();
	});
	$(".reposit").click(function() {
		$(".repoConte").toggle();
	});
	//上传附件
	$("#scwj").click(function() {
		$("#upFile").trigger("click");
	})
	$("#upFile").change(function() {
		upload();
	})
	//加载知识库
	loadZSK();
	//加载左侧导航菜单
	//loadMenu();

	// 综合菜单
	$(".comprehensive").click(function() {
		$(".comprehensiveContent").toggle();
	});
	// 获取坐席
	getSeatData($("#comprehensiveContentSerrchSeat"))
	// 综合查询
	loadComprehensiveList()
	// 搜索
	$(".comprehensiveContentSerrchBtn").click(function() {
		loadComprehensiveList();
	})

	//客户资料
	$(".khzl tbody>tr>td input").attr("readonly", true);
	$(".save").hide();
	$(".cancel").hide();
	$(".edit").click(function() {
		$(".save").show();
		$(".cancel").show();
		$(".edit").hide();
		$(".khzl tbody>tr>td input").attr("readonly", false);
		$(".khzl tbody>tr>td input").css("border-bottom", "1px solid #b3b3b3");
	});
	$(".cancel").click(function() {
		$(".khzl tbody>tr>td input").attr("readonly", true);
		$(".khzl tbody>tr>td input").css("border", "0");
		$(".save").hide();
		$(".cancel").hide();
		$(".edit").show();
	});
	//保存客户
	$(".save").click(function() {
		var khid = $("#khid").val();
		var khmc = $(".khmc").val();
		var tsdh = $(".tsdh").val();
		var lxr = $(".lxr").val();
		var lxdh = $(".lxdh").val();
		var postcode = $(".postcode").val();
		var email = $(".email").val();

		// if (!khmc) {
		//     layer.confirm('请输入客户名称！', {
		//         btn: ['确定']
		//     });
		//     return;
		// }
		$.post(
			huayi.config.callcenter_url + "Customer/AddCustomer", {
				cid: khid,
				name: khmc,
				lxr: lxr,
				mobile: tsdh,
				telphone: lxdh,
				postcode: postcode,
				email: email,
				token: $.cookie("token"),
			},
			function(result) {
				result = $.parseJSON(result);
				if(result.state.toLowerCase() == "success") {
					$("#khid").val(result.data);
					$(".khmc").val(khmc);
					$(".tkhmc").text(khmc);
					$(".lxdh").val(lxdh);
					$(".tsdh").val(tsdh);
					$(".ttsdh").text(tsdh);
					$(".lxr").val(lxr);
					$(".postcode").val(postcode);
					$(".email").val(email);
					layer.msg("保存成功");
					$(".khzl tbody>tr>td input").attr("readonly", true);
					$(".khzl tbody>tr>td input").css("border", "0");
					$(".save").hide();
					$(".cancel").hide();
					$(".edit").show();
				}
			}
		);
	});

	//关闭录音弹出
	$(".setwin").click(function() {
		$(".t-shade").removeClass("cx");
		$("audio")[0].pause();
	});

	//修改密码开始
	$(".shezhi").click(function() {
		$(".personal").show();
	});
	//tab切换
	$(".perTab li").click(function() {
		$(this).addClass("sel").siblings().removeClass("sel");
		var index = $(this).index();
		$(".perTab_con").children("div").eq(index).show().siblings().hide();
	});
	//编辑个人资料
	$(".grzl tbody>tr>td input.zhidu").attr("readonly", true);
	$(".grbj").click(function() {
		$(".grzl tbody>tr>td input.zhidu").attr("readonly", false);
		$(".grzl tbody>tr>td input.zhidu").css(
			"border-bottom",
			"1px solid #b3b3b3"
		);
	});
	//取消编辑
	$(".grqx").click(function() {
		$(".grzl tbody>tr>td input.zhidu").attr("readonly", true);
		$(".grzl tbody>tr>td input.zhidu").css("border-bottom", "none");
	});
	//关闭按钮
	$(".ptr").click(function() {
		$(".personal").hide();
	});
	//修改密码
	$(".grbtn").click(function() {
		var gh = $(".mgh").val();
		var xm = $(".mn").val();
		var ymm = $(".spwd").val();
		var xmm = $(".npwd").val();
		var qmm = $(".epwd").val();
		if(xmm !== qmm) {
			$(".wrong").show();
			$(".npwd").val("");
			$(".epwd").val("");
		} else if(xmm == "") {
			layer.msg("密码不允许为空！");
		} else {
			$(".wrong").hide();
			$(".grzl tbody>tr>td input").attr("readonly", true);
			$(".grzl tbody>tr>td input").css("border-bottom", "none");
			$.ajax({
				type: "post",
				url: huayi.config.callcenter_url + "UserAccount/UpdatePwd",
				async: true,
				dataType: "json",
				data: {
					token: $.cookie("token"),
					usercode: gh,
					pwd: $.md5(xmm),
					oldpwd: $.md5(ymm),
					name: $(".mn").val(),
					company: $(".settingCompany").val(),
					department: $(".settingDepartment").val(),
					post: $(".settingPost").val(),
					mobile: $(".settingMobile").val(),
					phone: $(".settingTelephone").val(),
					code: $(".settingCode").val(),
				},
				success: function(result) {
					if(result.state.toLowerCase() == "success") {
						layer.msg("修改成功！");
						window.location.href = "login.html";
					} else {
						$(".grzl tbody>tr>td input.zhidu").attr("readonly", false);
						$(".grzl tbody>tr>td input.zhidu").css(
							"border-bottom",
							"1px solid #b3b3b3"
						);
					}
				},
			});
		}
	});
	//获取验证码
	function getVerificationCode() {
		if($(".settingMobile").val() == "") {
			layer.msg("请输入手机号码！");
			return;
		}
		$.ajax({
			type: "post",
			url: huayi.config.callcenter_url + "UserAccount/SendCode",
			async: true,
			dataType: "json",
			data: {
				token: $.cookie("token"),
				mobile: $(".settingMobile").val(),
			},
			success: function(result) {
				if(result.state.toLowerCase() == "success") {
					layer.msg("获取成功！");
					$(".btnVerificationCode").attr("disabled", true);
					$(".grzl tbody>tr>td input.zhidu").attr("readonly", false);
					$(".verificationCodeTips").show();
					setTimeout(function() {
						$(".btnVerificationCode").attr("disabled", false);
						$(".verificationCodeTips").hide();
					}, 60000);
				}
			},
		});
	}
	$(".btnVerificationCode").click(function() {
		$(".grzl tbody>tr>td input.zhidu").attr("readonly", false);
		$(".grzl tbody>tr>td input.zhidu").css(
			"border-bottom",
			"1px solid #b3b3b3"
		);
		getVerificationCode();
	});
	//是否需要编辑用户信息
	function getWhetherEditInformation() {
		$.ajax({
			type: "post",
			url: huayi.config.callcenter_url + "UserAccount/GetUserModify",
			async: true,
			dataType: "json",
			data: {
				token: $.cookie("token"),
				usercode: $(".mgh").val(),
			},
			success: function(result) {
				if(result.state.toLowerCase() == "success") {

				} else {

					$(".personal").show();
					$(".ptr").hide();
					$(".personalMask").show();

				}
			},
			error: function(result) {},
		});
	}
	//图片裁剪
	var o = $(".image-crop > img");
	$(o).cropper({
		aspectRatio: 1 / 1,
		resizable: false,
		dragCrop: false,
		preview: ".img-preview",
		done: function() {},
	});
	var r = $("#inputImage");
	if(window.FileReader) {
		r.change(function() {
			var e,
				i = new FileReader(),
				t = this.files;
			if(t.length && ((e = t[0]), /^image\/\w+$/.test(e.type))) {
				i.readAsDataURL(e);
				i.onload = function() {
					r.val("");
					o.cropper("reset", !0).cropper("replace", this.result);
				};
			} else {
				layer.msg("请选择图片文件");
			}
		});
		$("#setDrag").click(function() {
			o.cropper("setDragMode", "crop");
			//          var img = o.cropper("getDataURL");
			var img = o.cropper("getCroppedCanvas").toDataURL("image/png");
			$.post(
				huayi.config.callcenter_url + "Index/UploadTX64", {
					dataurl: encodeURIComponent(img),
					token: $.cookie("token"),
				},
				function(result) {
					result = $.parseJSON(result);
					if(result.state.toLowerCase() == "success") {
						$(".yhtx").attr(
							"src",
							huayi.config.callcenter_url.substr(
								0,
								huayi.config.callcenter_url.length - 1
							) + result.data
						);
						layer.msg("上传成功");
						$(".personal").hide();
					}
				}
			);
		});
		$("#zoomIn").click(function() {
			o.cropper("zoom", 0.1);
		});
		$("#zoomOut").click(function() {
			o.cropper("zoom", -0.1);
		});
		$("#rotateLeft").click(function() {
			o.cropper("rotate", 45);
		});
		$("#rotateRight").click(function() {
			o.cropper("rotate", -45);
		});
	} else {
		r.addClass("hide");
	}

	$("#zxTable tbody").on("click", "tr", function() {
		$(this).addClass("tr_bg");
		$(this).siblings().removeClass("tr_bg");
		$("#Result").val($(this).attr("fjh"));
	});

	//工单
	//当即办理
	//$(".Nows").change(function () {
	//    $(".Nows_box").toggle();
	//});
	$('input:radio[name="banli"]').change(function() {
		if($(this).val() == "1") {
			$(".Nows_box").show();
		} else {
			$(".Nows_box").hide();
		}
	});
	//区县，主干道、乡镇，路社区村三级联动（目前在来电弹屏中使用）
	// helper.getDropList.getLocations($("#sourcearea"));
	QY($("#sourcearea"));
	// 获取乡镇，默认文峰区
	getTownshipVillage($("#township"), 4965);
	LB($("#type"));
	ZT($("#keys"));
	//加载来电类型 默认是 已受理并发送id
	GetDicValueList();

	$(".right-tab li").click(function() {
		messages($(this).index());
	});

	//全部已读
	$(".readed").click(function() {
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Index/CloseChat",
			async: true,
			dataType: "json",
			data: {
				token: $.cookie("token"),
				id: 0,
			},
			success: function(data) {
				if(data.total > 0) {
					messages();
				} else {
					layer.msg("设置失败！");
				}
			},
		});
	});

	//主动发消息
	$(".sele_send").click(function() {
		layer.open({
			type: 2,
			content: "replyChat.html", //iframe的url，no代表不显示滚动条
			title: "发送消息",
			area: ["50%", "60%"], //宽高
		});
	});

	var ru, rd, msgs;
	$(".mid").val(0);
	var mid = $(".mid").val();
	$(".tuBiao").click(function() {
		if($(".drm").css("display") == "block") {
			$(".drm").css("display", "none");
		} else {
			$(".drm").css("display", "block");
		}
	});
	$("#small-chat").click(function() {
		if($(".small-chat-box").hasClass("active")) {
			rightDown();
			rd = setInterval(rightDown, 60000);
		} else {
			clearInterval(rd);
		}
	});
	//即时通讯 消息总数
	message_total();
	//setInterval(message_total, 5000);
	function message_total() {
		helper.init.isload = 0;
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Index/GetChatCount",
			async: true,
			dataType: "json",
			data: {
				token: $.cookie("token"),
				top: 50,
			},
			success: function(data) {
				helper.init.isload = 1;
				if(data.total <= 0) {
					$(".chat_count").hide();
					$(".chat").removeClass("come_mess");
				} else {
					$(".chat_count").show();
					$(".chat_count").html(data.total);
					$(".chat").addClass("come_mess");
				}
			},
		});
	}
	$(".chat").click(function() {
		$("#right-sidebar").toggleClass("sidebar-open");
		if($("#right-sidebar").hasClass("sidebar-open")) {
			messages();
			msgs = setInterval(messages, 5000, 0); //未读消息定时刷新
		} else {
			clearInterval(msgs);
		}
	});
	$("#reflectCategory").bind("input propertychange", function() {
		$(".layui-dropdown").hide();
		if($("#reflectCategory").val() == "") {
			$(".reflectCategoryList-wrapper").hide();
			return;
		}
		var debounceGetSearchReactionCategory = debounce(
			getSearchReactionCategory,
			500
		);
		$(".reflectCategoryList-wrapper").show();
		debounceGetSearchReactionCategory($("#reflectCategory").val());
	});
	$("#reflectCategoryList").on("click", "li", function() {
		$(".reflectCategoryList-wrapper").hide();
		$("#reflectCategory").val($(this).attr("indexName"));
		$("#PID").val($(this).attr("index"));
	});
	// 获取工单数量
	workcount();
});

function Adds() {
	var callid = $(".hidCallID").val();
	var value = $(' input[name="banli"]:checked ').val();
	var ispd = $("#automaticDispatch").val() === "1" ? "1" : "0" // 自动派单
	var threeWayCall;
	if($("#threeWayCall").is(":checked")) {
		threeWayCall = 1;
	} else {
		threeWayCall = 0;
	}
	if(!$("#cusphone").val()) {
		layer.msg("请输入来电号码");
		return;
	} else if(!$("#title").val()) {
		layer.msg("请输入标题");
		return;
	} else if(!$("#content").val()) {
		layer.msg("请输入内容");
		return;
	} else if(!$("#PID").val()) {
		layer.msg("请选择反映类别");
		return;
	} else if(value == 1 && !$("#result").val()) {
		layer.msg("请输入直办内容");
		return;
	} else if(!$("#sourcearea").val()) {
		layer.msg("请输入事发区域");
		return;
	}

	$.ajax({
		type: "post",
		url: huayi.config.callcenter_url + "/WorkOrder/AddWorkOrder",
		dataType: "json",
		async: true,
		beforeSend: function() {
			//触发ajax请求开始时执行
			$(".addt_").attr("disabled", true);
			$(".addts").attr("disabled", true);
			$(".addt_").text("提交中...");
			$(".addts").text("提交中...");
		},
		data: {
			bigtype: $("#phonetype2").val(),
			cusname: $("#cusname").val(), //=来电人姓名
			cussex: $("#cussex").val(),
			cusphone: $("#cusphone").val().replace(/\s+/g, ""), //=来电人电话
			email: $("#email").val(),
			zipcode: $("#zipcode").val(),
			conphone: $("#conphone").val(),
			title: $("#title").val(),
			ispd:ispd,
			content: $("#content").val(),
			callid: callid,
			sourcearea: $("#sourcearea").val(), //=事发地域id
			township: $("#township").val(), // 乡镇
			village: $("#village").val(), // 村
			sourceaddress: $("#sourceaddress").val(), //=事发详细地址
			source: $("#sourceSelect").val(), //=来源
			phonetype: $("#phonetype").val(), // 电话类别
			isresult: $(' input[name="banli"]:checked ').val(), //=（0转办1直办）
			result: $("#result").val(),
			longitude: $(".store_Lng").val(),
			latitude: $(".store_Lat").val(),
			keys: $("#PID").val(), //=关键词id(多个用英文逗号,隔开)
			type: $("#type").val(), //=类型
			isprotect: $(' input[name="mj"]:checked ').val(), //=(0普通1保密)
			level: $("#level").val(), //=(1普通2紧急)
			visittype: $("#visittype").val(), // 回访方式
			isbusiness: $("#isbusiness").val(),
			issubmit: Statess, //=（0保存1保存并提交） 
			business: threeWayCall,
			file: $("#file").val(), // 办理附件(多个用英文逗号,隔开)
			token: $.cookie("token"),
		},
		success: function(data) {
			if(data.state.toLowerCase() == "success") {
				$(".addt_").attr("disabled", false);
				$(".addts").attr("disabled", false);
				$(".addt_").text("保存");
				$(".addts").text("保存并提交");
				layer.msg("操作成功");
				$("#phonetype1").hide()
				$("#phonetype2").hide()
				$("#phonetype").val('12345')
				Clean();
			} else {
				$(".addt_").attr("disabled", false);
				$(".addts").attr("disabled", false);
				$(".addt_").text("保存");
				$(".addts").text("保存并提交");
			}
		},
	});
}

//上传文件
function upload() {
	var Files = document.getElementById("upFile").files;
	console.log(Files);
	if(Files.length > 0) {
		var formData = new FormData();
		for(var i = 0; i < Files.length; i++) {
			formData.append('file' + i, Files[i]);
		}
		formData.append("token", $.cookie("token"));
		var typeName = Files[0].name.split('.')[Files[0].name.split('.').length - 1];
		if(typeName == "png" || typeName == 'jpg' || typeName == 'mp4' || typeName == 'avi' || typeName ==
			'wmv' || typeName == 'mp3' || typeName == 'pdf' || typeName == 'doc' || typeName == 'docx' ||
			typeName == 'xls' || typeName == 'xlsx') {
			$.ajax({
				url: huayi.config.callcenter_url + "/WorkOrder/UploadFile",
				type: "POST",
				data: formData,
				/**
				 *必须false才会自动加上正确的Content-Type
				 */
				contentType: false,
				/**
				 * 必须false才会避开jQuery对 formdata 的默认处理
				 * XMLHttpRequest会对 formdata 进行正确的处理
				 */
				processData: false,
				success: function(result) {
					document.getElementById("upFile").outerHTML = document.getElementById("upFile")
						.outerHTML;
					$("#upFile").change(function() {
						upload();
					});
					var r = $.parseJSON(result);
					if(r.state.toLowerCase() == "success") {

						var a = r.data;
						$(a).each(function(i, n) {
							var strs = '<span class="files" fiel-num="' + n.F_FileId +
								'">' + n.F_FileName.substring(19) +
								'<i class="fa fa-remove del_file"></i></span>'
							$(strs).appendTo($('.fileBox')).find('.del_file').click(
								function(event) {
									event.stopPropagation();
									$(this).parent().remove();
									file_num()
								})
						})
						file_num();
					}
				}
			});
		} else {
			layer.msg("格式不正确");
		}

	} else {
		layer.confirm('请上传文件！', {
			btn: ['确定']
		});
	}
}
//上传文件隐藏域值
function file_num() {
	var str = '';
	var Str;
	$('.fileBox .files').each(function(j, m) {
		var aa = $(m).attr("fiel-num")
		console.log(aa);
		str += aa + ",";
		Str = (str.substring(str.length - 1) == ',') ? str.substring(0, str.length - 1) : str;
	})
	$("#file").val(Str);
}

//清空
function Clean() {
	//左侧
	//debugger;
	$(".ldname").val(""); //来电人
	$("#khid").val("");
	$(".tsdh").val(""); //来电号码
	$(".ldlocation").text("未知"); //归属地
	$(".lxr").val(""); //联系人
	$(".lxdh").val(""); //联系电话
	$(".postcode").val(""); //邮编
	$(".email").val(""); //email
	$(".ldtime").val(""); //录入时间
	$(":radio[name='banli'][value='0']").prop("checked", "checked");
	$(".Nows_box").hide();
	//右侧
	$("#cusname").val(""); //=来电人姓名
	$("#cussex").val("");
	$("#cusphone").val(""); //=来电人电话
	$("#email").val("");
	$("#zipcode").val("");
	$("#conphone").val("");
	$("#title").val("");
	$("#content").val("");
	$("#sourceaddress").val(""); //=事发详细地址
	$("input[name='baomi'][value='1']").prop("checked", true); //=（0转办1直办）
	$("#type option:first").prop("selected", "selected");
	$("#level option:first").prop("selected", "selected");
	$("#visittype option:first").prop("selected", "selected");
	$("#isbusiness option:first").prop("selected", "selected");
	console.log($("#isbusiness").val())

	$("#keys option:first").prop("selected", "selected");
	$("#sourcearea").val("0").trigger("change"); //=事发地域id
	$("#sourcearea option:first").prop("selected", "selected");
	$("#township").val(""); // 乡镇
	$("#village").val(""); // 村
	$("#result").val("");
	$(".inps").val("");
	$("#PID").val("");
	$("#reflectCategory").val("");
	$("#Dpment").val("");
	$(".Cleans").hide();
	$("#file").val('');
	$(".fileBox").html('')
}

function clearworkorder() {
	$("#xxlb").val("");
	$("#xxlb").trigger("change");
	$("#FArea").val("");
	$("#FArea").trigger("change");
	$("#sfdz").val("");
	$("#tskh").val("");
	$("#tsdh").val("");
	$("#email").val("");
	$("#postcode").val("");
	$("#lxr").val("");
	$("#lxdh").val("");
	$("#content").val("");
	$("#result").val("");
	$("#JArea").val("");
	$("#JArea").trigger("change");
	$("#remark").val("");

	$("#khid").val("");
	$(".khmc").val("");
	$(".tsdh").val("");
	$(".lxr").val("");
	$(".lxdh").val("");
	$(".postcode").val("");
	$(".email").val("");
}
//获取历史记录
function loadOld() {
	// var type = $(".ldtp-cr ul.ld-service .cr-click").attr("itemtype");
	// $(".complain").hide();
	// $(".complain")
	//     .eq(type * 1)
	//     .show();
	// if (type == "2") {
	//先销毁表格
	$("#orderlist").bootstrapTable("destroy");
	//初始化表格,动态从服务器加载数据
	$("#orderlist").bootstrapTable({
		method: "get", //使用get请求到服务器获取数据
		url: huayi.config.callcenter_url + "WorkOrder/GetList", //获取数据的Servlet地址
		contentType: "application/x-www-form-urlencoded",
		striped: true, //表格显示条纹
		pagination: true, //启动分页
		pageSize: 5, //每页显示的记录数
		pageNumber: 1, //当前第几页
		pageList: [5, 10], //记录数可选列表
		search: false, //是否启用查询
		showColumns: false, //显示下拉框勾选要显示的列
		showRefresh: false, //显示刷新按钮
		sidePagination: "server", //表示服务端请求
		//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
		//设置为limit可以获取limit, offset, search, sort, order
		queryParamsType: "undefined",
		queryParams: function queryParams(params) {
			//设置查询参数
			var param = {
				page: params.pageNumber,
				pagesize: params.pageSize,
				tel: $(".hidTel").val(),
				starttime: $("#con_startTime").val(),
				endtime: $("#con_endTime").val(),
				token: $.cookie("token"),
			};
			return param;
		},
		onLoadSuccess: function() {
			//加载成功时执行
			//layer.msg("加载成功");
		},
		onLoadError: function() {
			//加载失败时执行
			//layer.msg("加载数据失败", { time: 1500, icon: 2 });
		},
	});
	// } else if (type == "1") {
	//先销毁表格
	$("#oldlist").bootstrapTable("destroy");
	//初始化表格,动态从服务器加载数据
	$("#oldlist").bootstrapTable({
		method: "get", //使用get请求到服务器获取数据
		url: huayi.config.callcenter_url + "CallInScreen/GetOldList", //获取数据的Servlet地址
		contentType: "application/x-www-form-urlencoded",
		striped: true, //表格显示条纹
		pagination: true, //启动分页
		pageSize: 5, //每页显示的记录数
		pageNumber: 1, //当前第几页
		pageList: [5, 10], //记录数可选列表
		search: false, //是否启用查询
		showColumns: false, //显示下拉框勾选要显示的列
		showRefresh: false, //显示刷新按钮
		sidePagination: "server", //表示服务端请求
		//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
		//设置为limit可以获取limit, offset, search, sort, order
		queryParamsType: "undefined",
		queryParams: function queryParams(params) {
			//设置查询参数
			var param = {
				page: params.pageNumber,
				pagesize: params.pageSize,
				tel: $(".hidTel").val(),
				starttime: $("#old_startTime").val(),
				endtime: $("#old_endTime").val(),
				token: $.cookie("token"),
			};
			return param;
		},
		onLoadSuccess: function() {
			//加载成功时执行
			//layer.msg("加载成功");
		},
		onLoadError: function() {
			//加载失败时执行
			//layer.msg("加载数据失败", { time: 1500, icon: 2 });
		},
	});
	// }
}

//格式化工单号
function formatWorkOrderNum(val, row) {

	if(val) {
		return '<a class="xg" onclick="ckxq(\'' + val + '\')" title="点击查看工单详情">' + val + '</a>';
	}

}
//编号
function Code(val, row, index) {
	return index + 1;
}

function GetCallState(val) {
	if(val == "1") {
		return "已接通";
	} else {
		return "未接通";
	}
}

//音频
function setCode(val) {
	if(val) {
		return(
			'<div class="imgs" style="cursor: pointer;">' +
			'<img src="./img/vice.png" alt="" onclick= "recording(this)" item="' +
			val +
			'" />' +
			"</div>"
		);
	} else {
		return "";
	}
}

function recording(ele) {
	var path = $(ele).attr("item");
	layer.open({
		type: 2,
		content: "./CommonHtml/recording.html?path=" + path, //iframe的url，no代表不显示滚动条
		title: '录音',
		area: ['30%', '20%'], //宽高
		maxmin: true,
		shade: 0
	});
}

function GetLink(val) {
	if(val) {
		return "<a onclick=\"ckxq('" + val + "')\" style='word-break: break-all;'>" + val + "</a>";
	} else {
		return "";
	}
}

function formatterResult(val) {
	if(val) {
		//  	+ ' title="' + val + '" ';
		var strResult = val;
		if(strResult.length > 20) {
			strResult = strResult.substring(0, 20) + "...";
		}
		strResult = "<div title='" + val + "'>" + strResult + "</div>"
		return strResult;
	}
}
//查看详情
function ckxq(str) {
	layer.open({
		type: 2,
		content: "CommonHtml/WorkDatil.html?wid=" + str, //iframe的url，no代表不显示滚动条
		title: "工单详情",
		area: ["80%", "80%"], //宽高
	});
}
//截取字符串
function GetCont(val) {
	if(val) {
		var str = "<div ";
		if(val.length > 20) {
			str = str + ' title="' + val + '" ';
			val = val.substr(0, 20) + "...";
		}
		return str + ">" + val + "</div>";
	} else {
		return "";
	}
}

//加载字典
function loadDic(obj, pid) {
	obj.empty();
	obj.append('<option selected="selected" value="">请选择</option>');
	if(!pid) {
		pid = -1;
	}
	$.getJSON(
		huayi.config.callcenter_url + "Dictionary/GetDicValueListByParentId", {
			token: $.cookie("token"),
			pid: pid,
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_ValueId +
						"'>" +
						n.F_Value +
						"</option>"
					).appendTo(obj);
				});
			}
		}
	);
}

//获取知识库
function loadZSK(type = "1") {
	var table = $("#tableList" + type);
	$(".tableWarpper" + type)
		.show()
		.siblings()
		.hide();
	table.bootstrapTable("destroy");
	if(type === "1") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "Professor/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "2") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "LawGuide/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					key: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "3") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "HotspotGlossary/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					key: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "4") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "Policy/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					key: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "5") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "NounInterpretation/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					key: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "6") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "Functions/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {
					page: params.pageNumber,
					pagesize: params.pageSize,
					token: $.cookie("token"),
					keyvalue: "",
					key: "",
					stime: "",
					etime: "",
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "7") {
		//初始化表格,动态从服务器加载数据
		table.bootstrapTable({
			method: "get", //使用get请求到服务器获取数据
			url: huayi.config.callcenter_url + "Repository/GetList", //获取数据的Servlet地址
			contentType: "application/x-www-form-urlencoded",
			striped: true, //表格显示条纹
			pagination: true, //启动分页
			pageSize: 10, //每页显示的记录数
			pageNumber: 1, //当前第几页
			pageList: [10, 20, 50, 100], //记录数可选列表
			search: false, //是否启用查询
			showColumns: false, //显示下拉框勾选要显示的列
			showRefresh: false, //显示刷新按钮
			sidePagination: "server", //表示服务端请求
			//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
			//设置为limit可以获取limit, offset, search, sort, order
			queryParamsType: "undefined",
			queryParams: function queryParams(params) {
				//设置查询参数
				var param = {					
					page: params.pageNumber,
                    pagesize: params.pageSize,
                    token: $.cookie("token"),
                    type:1,
                    key:$('.rightSearchKey').val(),
				};
				return param;
			},
			onLoadSuccess: function() {
				//加载成功时执行
				//layer.msg("加载成功");
			},
			onLoadError: function() {
				//加载失败时执行
				//layer.msg("加载数据失败", { time: 1500, icon: 2 });
			},
		});
	} else if(type === "8") {
//		document.getElementById("J_iframe").src="https://www.baidu.com/";
	}
}
$('#rightSearch').click(function(){
	loadZSK("7");
})
$(".ldcrb-top ul li").click(function() {
	$(this).addClass("activity").siblings().removeClass("activity");
	var type = $(this).attr("data-type");
	loadZSK(type);
});

// 序号
function serialNumber(val, row, index) {
	return index + 1;
}
// 操作
function operation1(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn1(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}

// 操作
function operation2(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn2(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}

// 操作
function operation3(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn3(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}

// 操作
function operation4(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn4(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}

// 操作
function operation5(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn5(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}

// 操作
function operation6(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn6(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		"</div>"
	);
}
// 操作
function operation7(val, row) {
	return(
		'<div class="tool_downs">' +
		'<a href="javascript:;" class="aBtn" style="margin-left:0px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="detailBtn7(\'' +
		row.F_Id +
		'\')" title="详情">详情</a>' +
		'<a href="javascript:;" class="aBtn" style="margin-left:8px;" authorize="yes"  id="HY_details_' +
		row.F_Id +
		'" onclick="noSolve(\'' +
		row.F_Id +
		'\')" title="未解决">未解决</a>' +
		"</div>"
	);
}
// 详情
function detailBtn1(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detailZhiShiKuPolicyExpert.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "政策专家库",
		area: ["80%", "80%"], //宽高
	});
}

// 详情
function detailBtn2(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detailZhiShiKuGuide.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "办事指南",
		area: ["80%", "80%"], //宽高
	});
}

// 详情
function detailBtn3(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detailZhiShiKuHotLssues.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "热点问题",
		area: ["80%", "80%"], //宽高
	});
}

// 详情
function detailBtn4(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detaileZhiShiKuPoliciesRegulations.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "政策法规",
		area: ["80%", "80%"], //宽高
	});
}

// 详情
function detailBtn5(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detailZhiShiKuGlossary.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "名词解释",
		area: ["80%", "80%"], //宽高
	});
}

// 详情
function detailBtn6(id) {
	layer.open({
		type: 2,
		content: "./zhiShiKu/detailZhiShiKuFunctional.html?id=" + id, //iframe的url，no代表不显示滚动条
		title: "部门职能",
		area: ["80%", "80%"], //宽高
	});
}
// 详情
function detailBtn7(id) {
    layer.open({
      	type: 2,
      	title: '查看知识库详情',
      	area: ['70%', '60%'],
      	maxmin:true,
      	content: './zhiShiKu/newRepositoryDetail.html?ids='+ id+"&screen=1"
    });
}
// 获取坐席
function getSeatData(obj) {
	obj.empty();
	$.getJSON(
		huayi.config.callcenter_url + "UserAccount/GetSeatList", {
			token: $.cookie("token"),
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_UserCode +
						"'>" +
						n.F_UserName +
						"</option>"
					).appendTo(obj);
				});
				obj.selectpicker({
					noneSelectedText: "请选择", //默认显示内容
				});
				obj.selectpicker("refresh");
			}
		}
	);
}

// 综合查询
function loadComprehensiveList() {
	//先销毁表格
	$("#comprehensiveContentList").bootstrapTable("destroy");
	//初始化表格,动态从服务器加载数据
	$("#comprehensiveContentList").bootstrapTable({
		method: "get", //使用get请求到服务器获取数据
		url: huayi.config.callcenter_url + "WorkOrder/GetList", //获取数据的Servlet地址
		contentType: "application/x-www-form-urlencoded",
		striped: true, //表格显示条纹
		pagination: true, //启动分页
		pageSize: 10, //每页显示的记录数
		pageNumber: 1, //当前第几页
		pageList: [10, 20, 50, 100], //记录数可选列表
		search: false, //是否启用查询
		showColumns: false, //显示下拉框勾选要显示的列
		showRefresh: false, //显示刷新按钮
		sidePagination: "server", //表示服务端请求
		//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
		//设置为limit可以获取limit, offset, search, sort, order
		queryParamsType: "undefined",
		queryParams: function queryParams(params) {
			//设置查询参数
			var param = {
				page: params.pageNumber,
				pagesize: params.pageSize,
				workid: $("#wids").val().replace(/\s+/g, ""),
				ComTitle: $("#workOrderTitle").val().replace(/\s+/g, ""), // 工单标题
				ComContent: $("#workOrderContent").val().replace(/\s+/g, ""), // 工单内容
				Result: $("#workOrderProcessingResult").val().replace(/\s+/g, ""), // 办理结果
				tel: $("#comprehensiveContentSerrchTel").val().replace(/\s+/g, ""), // 来电号码
				usercode: conversionBootstrapSelectData($("#comprehensiveContentSerrchSeat")), // 受话坐席
				// starttime: $("#starttime").val(), //=开始时间
				// endtime: $("#endtime").val(), //=结束时间
				comprehensive: 1,
				token: $.cookie("token"),
			};
			return param;
		},
		onLoadSuccess: function(data) {
			//加载成功时执行
			//						layer.msg("加载成功");
		},
		onLoadError: function() {
			//加载失败时执行
			//layer.msg("加载数据失败", { time: 1500, icon: 2 });
		},
	});
}

function conversionBootstrapSelectData(obj) {
	var returnData = "";
	var selectedData = obj.val();
	if(selectedData != null) {
		for(var i = 0; i < selectedData.length; i++) {
			returnData += selectedData[i] + ","
		}
		returnData = returnData.slice(0, -1);
	} else {
		returnData = ""
	}
	return returnData;
}

//解决
function resolve(id) {
	var laye = layer.confirm(
		"确定解决？", {
			btn: ["确定", "取消"], //可以无限个按钮
		},
		function() {
			//按钮【按钮一】的回调
			$.ajax({
				type: "post",
				url: huayi.config.callcenter_url + "Repository/OptRep",
				async: true,
				dataType: "json",
				data: {
					token: $.cookie("token"),
					repid: id,
					type: 1,
				},
				success: function(data) {
					if(data.state.toLowerCase() == "success") {
						layer.msg("提交成功！");
						layer.close(laye);
					}
				},
			});
		},
		function(index) {
			//按钮【按钮二】的回调
			layer.close(laye);
		}
	);
}
//未解决
function noSolve(id) {
	var laye = layer.open({
		type: 1,
		shade: false,
		area: ["430px", "260px"],
		title: "请输入未解决原因", //不显示标题
		content: '<div style="padding-top:10px;padding-left:20px;">\n' +
			'<textarea id="resultNoSolve" style="width:300px; height:120px" type="text" placeholder="请输入未解决原因"></textarea>' +
			"</div>",
		cancel: function() {
			layer.close();
		},
		btn: ["确定", "取消"], //按钮
		yes: function() {
			console.log($("#resultNoSolve").val())
			if(!$("#resultNoSolve").val()) {
				layer.msg("请填写未解决原因!");
				return false;
			} else {
				$.ajax({
					type: "post",
					url: huayi.config.callcenter_url + "Repository/OptRep",
					async: true,
					dataType: "json",
					data: {
						token: $.cookie("token"),
						repid: id,
						reason: $("#resultNoSolve").val(),
						type: 2,
					},
					success: function(data) {
						if(data.state.toLowerCase() == "success") {
							layer.msg("提交成功！");
							layer.close(laye);
							loadZSK("7");
						}
					},
				});
			}
		},
	});
}
//外呼弹屏
function whtp() {
	$("#Result").val("");
	if($(".WH").hasClass("fadeOutUp")) {
		$(".WH").removeClass("fadeOutUp").addClass("fadeInDown");
	}
	$(".WH").removeClass("hidens");
	$(".first").removeClass("first");
	$(".WH").addClass("first");

	loadWH();
}
//加载外呼电话列表
function loadWH() {
	$(".phonediv").hide();
	var n = $(".bg_title .lactive").attr("itemid");

	switch(n) {
		case "0":
			var obj0 = $(".phonediv").eq(0);
			obj0.show();

			//先销毁表格
			var table = obj0.find(".phonelist");
			table.bootstrapTable("destroy");
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url + "CallOutScreen/GetPhoneList", //获取数据的Servlet地址
				contentType: "application/x-www-form-urlencoded",
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) {
					//设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						tel: $("#lastphone").val(),
						token: $.cookie("token"),
					};
					return param;
				},
				onLoadSuccess: function() {
					//加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() {
					//加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				},
			});
			break;
		case "1":
			var obj1 = $(".phonediv").eq(1);
			obj1.show();
			var table = obj1.find(".phonelist");
			table.bootstrapTable("destroy");
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url + "CallOutScreen/GetUserList", //获取数据的Servlet地址
				contentType: "application/x-www-form-urlencoded",
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) {
					//设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						tel: $("#gsphone").val(),
						name: $("#gsname").val(),
						token: $.cookie("token"),
					};
					return param;
				},
				onLoadSuccess: function() {
					//加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() {
					//加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				},
			});
			break;
		case "2":
			var obj2 = $(".phonediv").eq(2);
			obj2.show();
			var table = obj2.find(".phonelist");
			table.bootstrapTable("destroy");
			//初始化表格,动态从服务器加载数据
			table.bootstrapTable({
				method: "get", //使用get请求到服务器获取数据
				url: huayi.config.callcenter_url +
					"CallOutScreen/GetCustomerList", //获取数据的Servlet地址
				contentType: "application/x-www-form-urlencoded",
				striped: true, //表格显示条纹
				pagination: true, //启动分页
				pageSize: 10, //每页显示的记录数
				pageNumber: 1, //当前第几页
				pageList: [10, 20, 50, 100], //记录数可选列表
				search: false, //是否启用查询
				showColumns: false, //显示下拉框勾选要显示的列
				showRefresh: false, //显示刷新按钮
				sidePagination: "server", //表示服务端请求
				//设置为undefined可以获取pageNumber，pageSize，searchText，sortName，sortOrder
				//设置为limit可以获取limit, offset, search, sort, order
				queryParamsType: "undefined",
				queryParams: function queryParams(params) {
					//设置查询参数
					var param = {
						page: params.pageNumber,
						pagesize: params.pageSize,
						tel: $("#khphone").val(),
						name: $("#khname").val(),
						token: $.cookie("token"),
					};
					return param;
				},
				onLoadSuccess: function() {
					//加载成功时执行
					//layer.msg("加载成功");
				},
				onLoadError: function() {
					//加载失败时执行
					//layer.msg("加载数据失败", { time: 1500, icon: 2 });
				},
			});
			break;
		case "3":
			$(".phonediv").eq(3).show();
			$("#zxTable tbody").html("");
			if(obj.AgentID) {
				obj.Type = "GetAgentList";
				Send();
			}

			break;
	}
}

function view(val) {
	var str = "";
	if(val) {
		str = "<a onclick=\"call('" + val + "')\">" + val + "</a>";
	}
	return str;
}

function call(val) {
	$("#Result").val(val);
	$(".img").removeClass("hidens");
}

function ftime(val) {
	if(val) {
		return helper.DateFormat.getFormatTime(val);
	} else {
		return "";
	}
}

function logout() {
	$.ajax({
		url: huayi.config.callcenter_url + "Login/Logout",
		data: {
			token: $.cookie("token"),
		},
		dataType: "json",
		success: function(res) {
			if(res.state) {
				$.cookie("token", "");
				window.localStorage.removeItem("token");
				window.localStorage.removeItem("extno");
				window.localStorage.removeItem("zx_user");
				window.localStorage.removeItem("socket_state");
				location.href = "./login.html";
			}
		},
	});
}
//跳转
function Jumps() {
	$("iframe:visible")[0].src = "widgets.html";
}
////子页面返回主页
//function home_index() {
//	top.$("iframe:visible")[0].src = "widgets.html";
//}

// 获取乡镇
$("#sourcearea").change(function() {
	getTownshipVillage($("#township"), $("#sourcearea").val());
});

// 获取村
$("#township").change(function() {
	getTownshipVillage($("#village"), $("#township").val());
});

//区域
function QY(obj) {
	obj.empty();
	obj.append('<option selected="selected" value="">请选择</option>');
	$.getJSON(
		huayi.config.callcenter_url + "Area/GetAreaListById", {
			token: $.cookie("token"),
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					if(n.F_AreaName !== "市区") {
						if(n.F_AreaName === "文峰区") {
							$(
								"<option value='" +
								n.F_AreaId +
								"' selected='selected'>" +
								n.F_AreaName +
								"</option>"
							).appendTo(obj);
						} else {
							$(
								"<option value='" +
								n.F_AreaId +
								"'>" +
								n.F_AreaName +
								"</option>"
							).appendTo(obj);
						}
					}
				});
			}
		}
	);
}

//获取乡镇，村
function getTownshipVillage(obj, parentid) {
	obj.empty();
	obj.append('<option selected="selected" value="">请选择</option>');
	$.getJSON(
		huayi.config.callcenter_url + "Area/GetAreaChildren", {
			token: $.cookie("token"),
			parentid: parentid,
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_AreaId +
						"'>" +
						n.F_AreaName +
						"</option>"
					).appendTo(obj);
				});
			}
		}
	);
}

//来源
function LY(obj) {
	obj.empty();
	$.getJSON(
		huayi.config.callcenter_url + "Dictionary/GetDicValueListById", {
			token: $.cookie("token"),
			id: 1,
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_ValueId +
						"'>" +
						n.F_Value +
						"</option>"
					).appendTo(obj);
				});
			}
		}
	);
}
//类别
function LB(obj) {
	obj.empty();
	$.getJSON(
		huayi.config.callcenter_url + "Dictionary/GetDicValueListById", {
			token: $.cookie("token"),
			id: 2,
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_ValueId +
						"'>" +
						n.F_Value +
						"</option>"
					).appendTo(obj);
				});
			}
		}
	);
}
//主题
function ZT(obj) {
	obj.empty();
	$.getJSON(
		huayi.config.callcenter_url + "Dictionary/GetDicValueListById", {
			token: $.cookie("token"),
			id: 3,
		},
		function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_ValueId +
						"'>" +
						n.F_Value +
						"</option>"
					).appendTo(obj);
				});
			}
		}
	);
}

//电话类别
function getPhoneType(obj) {
	obj.empty();
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + "Dictionary/GetDicValueListById",
		dataType: "json",
		async: true,
		data: {
			token: $.cookie("token"),
			id: 2498,
		},
		success: function(data) {
			if(data.state.toLowerCase() == "success") {
				var content = data.data;
				$(content).each(function(i, n) {
					$(
						"<option value='" +
						n.F_Value +
						"'>" +
						n.F_Remark +
						"</option>"
					).appendTo(obj);
				});
			}
		},
	});
}

//获取来电类型
function GetDicValueList() {
	$("#dicValueList ul").html("");
	$.getJSON(
		huayi.config.callcenter_url + "Dictionary/GetDicValueListById", {
			id: 45,
			token: $.cookie("token"),
		},
		function(result) {
			if(result.state.toLowerCase() == "success") {
				for(var i = 0; i < result.data.length; i++) {
					$("#dicValueList ul").append(
						'<li><label data-valDic="' +
						result.data[i].F_ValueId +
						'" id="unit' +
						i +
						'">' +
						result.data[i].F_Value +
						"</label></li>"
					);
				}
			}
		}
	);
}

//点击来电类型
var dicTypeid = 46; //默认是 已受理
$(document).on("click", "#dicValueList li label", function() {
	if($.cookie("code")==="spdbzy"){
		return
	}
	if(!$(this).hasClass("checkedDept")) {
		var $that = $(this);
		if($(".hidCallID").val()) {
			dicTypeid = 46; //默认是 已受理
			dicTypeid =
				$(this).attr("data-valDic") != 46 ?
				$(this).attr("data-valDic") :
				46;
			$.post(
				huayi.config.callcenter_url + "CallInScreen/UpdateCallInType", {
					callid: $(".hidCallID").val(),
					//				callid: 59054,
					typeid: dicTypeid,
					token: $.cookie("token"),
				},
				function(result) {
					//debugger;
					var results = JSON.parse(result);
					if(results.state.toLowerCase() == "success") {
						//console.info('传递来电类型成功，ID为：'+ dicTypeid);
						$that
							.addClass("checkedDept")
							.parent()
							.siblings()
							.children()
							.removeClass("checkedDept");
						if(dicTypeid != 46) {
							//                          $("#dicForms").hide();
							layer.msg("来电类型保存成功！");
							if(dicTypeid == 50) {
								loadOld();
							}
						} else {
							$("#dicForms").show();
						}
					}
				}
			);
		} else {
			//console.info('传递来电类型失败');
		}
	} else {
		//$(this).removeClass('checkedDept');
		//layer.msg('来电类型已经保存成功！不用重复点击提交');
	}
});

// 历史工单状态
function historyOrderStates(val, row) {
	var html = "";
	switch(val + "") {
		case "0":
			html = "新工单";
			if(row.F_IsReturn == 1) {
				html = "新工单（回退）";
			}
			break;
		case "1":
			html = "待交办";
			break;
		case "2":
			html = '<span style="color:#FF0000;">待查收</span>';
			break;
		case "3":
			html = "退回审核中";
			break;
		case "4":
			html = "办理中";
			break;
		case "5":
			html = "延时审核";
			break;
		case "6":
			if(row.F_IsProtect === 2 || row.F_IsProtect === 3) {
				html = "已办未果";
			} else {
				html = "已办理";
			}
			break;
		case "7":
			html = "已回访";
			break;
		case "8":
			if(row.F_Identification === 0) {
				html = "重置转发";
			} else if(row.F_Identification === 1) {
				html = "退回重办";
			} else {
				html = "重办中";
			}
			break;
		case "9":
			html = "已结案";
			break;
		case "10":
			html = "待审核";
			break;
		case "11":
			html = "重办待交办";
			break;
		case "13":
			html = "重办驳回";
			break;
	}
	return html;
}

// 历史工单操作
function historyOrderOperation(val, row) {
	var roleCode = $.cookie("code");
	if(roleCode === "GNZY") {
		return(
			'<a class="xg" onclick="tj(\'' +
			row.F_WorkOrderId +
			'\')" title="提交">提交</a>&nbsp;' +
			'<a class="xg" onclick="workOrderEdit(\'' +
			row.F_WorkOrderId +
			'\')" title="编辑">编辑</a>'
		);
	} else {
		return "-";
	}
}

//提交
function tj(str) {
	layer.confirm(
		"确定要提交工单么？", {
			btn: ["确定", "取消"], //按钮
		},
		function() {
			//请求后台数据
			/*发送请求*/
			$.post(
				huayi.config.callcenter_url + "WorkOrder/SubmitWorkOrder", {
					ids: str,
					token: $.cookie("token"),
				},
				function(result) {
					result = JSON.parse(result);
					if(result.state.toLowerCase() == "success") {
						layer.msg("提交成功");
						$("#orderlist").bootstrapTable("refresh");
						//load();
					}
				}
			);
		}
	);
}

// 编辑
function workOrderEdit(str) {
	layer.open({
		type: 2,
		content: "./CommonHtml/AddAppeal.html?wid=" + str, //iframe的url，no代表不显示滚动条
		title: "编辑",
		area: ["80%", "80%"], //宽高
	});
}

function reminder(str, depId) {
	layer.open({
		type: 2,
		content: "./CommonHtml/reminder.html?wid=" +
			str +
			"&depId=" +
			depId +
			"&callid=" +
			$(".hidCallID").val() +
			"", //iframe的url，no代表不显示滚动条
		title: "催单内容",
		area: ["40%", "40%"], //宽高
	});
}
//跳转超期共单列表
$(".surIcon").click(function() {
	top.$("iframe:visible")[0].src = "./Appeal/expiredWorkOrders.html";
});

//右上角消息列表
function rightUp() {
	helper.init.isload = 0;
	$(".drm").html("");
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + "Index/GetNoDealOrder",
		async: true,
		dataType: "json",
		data: {
			token: $.cookie("token"),
			top: 5,
			//mid:$('.mid').val()
		},
		success: function(data) {
			helper.init.isload = 1;
			$(".mid").val(data.maxid);
			//						helper.cookies.set("mid", data.maxid, 7);
			$(".xx_count").html(data.total);
			$(".sur_count").html(data.timeoutcount);
			$("#cqorder").val(data.timeoutcount);
			if(data.rows) {
				$.each(data.rows, function(i, n) {
					if(i < 10) {
						$(
							"<li>" +
							'<a href="javaScript:;" class="xx" onclick="ckxq(' +
							n.F_WorkOrderId +
							')">' +
							'<div class="tipCon">' +
							n.F_ComContent +
							"</div>" +
							'<div class="order_time clearfix">' +
							'<span class="work_order">订单号：' +
							n.F_WorkOrderId +
							"</span>" +
							'<span class="ort">' +
							n.F_CreateTime +
							"</span>" +
							"</div>" +
							'</a></li><li class="divider"></li>'
						).appendTo(".drm");
					}
				});
			}

			$(
				'<li><a href="javaScript:;" class="seeMore" onclick="goDC()">' +
				'<div class="order_time clearfix">' +
				'<span class="work_order">查看更多</span>' +
				'<span class="ort"> ' +
				">>" +
				"</span>" +
				"</div>" +
				"</a></li>"
			).appendTo(".drm");
		},
	});
}

function goDC() {
	top.$("iframe:visible")[0].src = "Business/WorkDC.html";
}

//右下角消息弹框
function rightDown() {
	helper.init.isload = 0;

	var tota = 0;
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + "Index/GetNoDealWorkTotal",
		async: true,
		dataType: "json",
		data: {
			token: $.cookie("token"),
		},
		success: function(data) {
			helper.init.isload = 1;
			$(".rightDown_list").html("");
			var con = data.data;
			if(con.length > 0) {
				con.push({
					state: 15,
					con: $("#cqorder").val()
				});
			}
			$(con).each(function(i, n) {
				var sts = "";
				switch(n.state) {
					case 0:
						sts = "待处理";
						break;
					case 1:
						sts = "待交办";
						break;
					case 2:
						sts = "待查收";
						break;
					case 3:
						sts = "退回审核中";
						break;
					case 4:
						sts = "办理中(主办)";
						break;
					case 5:
						sts = "延时审核中";
						break;
					case 6:
						sts = "待回访";
						break;
					case 7:
						sts = "已回访";
						break;
					case 8:
						sts = "重办中";
						break;
					case 9:
						sts = "已结案";
						break;
					case 10:
						sts = "办理中(协办)";
						break;
					case 11:
						sts = "待处理";
						break;
					case 12:
						sts = "待审核";
						break;
					case 13:
						sts = "待督办";
						break;
					case 15:
						sts = "超期工单";
						break;
					case 16:
						sts = "重办驳回";
						break;
					default:
						sts = "其他";
						break;
				}
				$(
					'<li onclick="turnTo(this)">' +
					'<a href="javaScript:;" data-index="' +
					n.state +
					'">' +
					"<div>" +
					sts +
					'<span class="pull-right text-muted small">' +
					n.con +
					"条</span>" +
					"</div>" +
					"</a>" +
					"</li>"
				).appendTo(".rightDown_list");
				tota = tota + parseInt(n.con);
			});
			$(".messageTotal").html(tota);
		},
	});
}

function turnTo(a) {
	var state = $(a).children("a").attr("data-index");
	switch(state) {
		case "0":
			$("iframe:visible")[0].src = "Business/ZXDCL.html";
			break;
		case "1":
			$("iframe:visible")[0].src =
				"Business/LeaderDCL.html?states=" + state;
			break; //代交办
		case "2":
			$("iframe:visible")[0].src = "Business/WorkDC.html?states=" + state;
			break; //待查收
		case "3":
			$("iframe:visible")[0].src =
				"Business/LeaderDCL.html?states=" + state;
			break; //退回审核中
		case "4":
			$("iframe:visible")[0].src = "Business/WorkDC.html?states=" + state;
			break; //办理中（主办）
		case "5":
			$("iframe:visible")[0].src =
				"Business/LeaderDCL.html?states=" + state;
			break; //延时审核中
		case "6":
			$("iframe:visible")[0].src = "Business/ZXDCL.html?states=" + state;
			break;
		case "7":
			$("iframe:visible")[0].src =
				"Business/LeaderDCL.html?states=" + state;
			break; //已回访
		case "8":
			$("iframe:visible")[0].src = "Business/WorkDC.html?states=" + state;
			break; //重办中
		case "10":
			$("iframe:visible")[0].src =
				"Business/WorkDCCO.html?states=" + state;
			break; //办理中协办
		case "11":
			$("iframe:visible")[0].src = "Business/WorkDC_EJ.html";
			break; //办理中协办
		case "12":
			$("iframe:visible")[0].src = "Appeal/toAuditList.html";
			break; //待审核
		case "13":
			$("iframe:visible")[0].src = "Appeal/toSupervList.html";
			break; //待督办

		case "15":
			$("iframe:visible")[0].src = "Appeal/expiredWorkOrders.html";
			break; //超期工单
		case "16":
			$("iframe:visible")[0].src = "Business/LeaderBH.html";
			break; //重办驳回工单
		default:
			sts = "其他";
			break;
	}
}

///拖拽效果

//拖动事件
var box = document.getElementById("box");
//鼠标按下的函数
box.onmousedown = function(ev) {
	var oEvent = ev || event;
	//求出鼠标和box的位置差值
	var x = oEvent.clientX - box.offsetLeft;
	var y = oEvent.clientY - box.offsetTop;
	//鼠标移动的函数
	//把事件加在document上，解决因为鼠标移动太快时，
	//鼠标超过box后就没有了拖拽的效果的问题
	document.onmousemove = function(ev) {
		var oEvent = ev || event;
		//保证拖拽框一直保持在浏览器窗口内部，不能被拖出的浏览器窗口的范围
		var l = oEvent.clientX - x;
		var t = oEvent.clientY - y;
		if(l < 0) {
			l = 0;
		} else if(l > document.documentElement.clientWidth - box.offsetWidth) {
			l = document.documentElement.clientWidth - box.offsetWidth;
		}
		if(t < 0) {
			t = 0;
		} else if(
			t >
			document.documentElement.clientHeight - box.offsetHeight
		) {
			t = document.documentElement.clientHeight - box.offsetHeight;
		}
		box.style.left = l + "px";
		box.style.top = t + "px";
	};
	//鼠标抬起的函数
	document.onmouseup = function() {
		document.onmousemove = null;
		document.onmouseup = null;
	};
	//火狐浏览器在拖拽空div时会出现bug
	//return false阻止默认事件，解决火狐的bug
	//  return false;
};

function messages(type) {
	if(!type) {
		type = $(".right-tab li.active").index();
	}
	var html = $("#tab-" + (type + 1)).find(".chat_box");
	html.html("");
	helper.init.isload = 0;
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + "Index/GetChatLists",
		async: true,
		dataType: "json",
		data: {
			token: $.cookie("token"),
			isread: type,
			top: 50,
			fromid: 0,
		},
		success: function(data) {
			helper.init.isload = 1;
			$("#tab-1").find(".message_count").html(data.total);
			if(type == 0) {
				if(data.total == 0) {
					$(".readed").hide();
				} else {
					$(".readed").show();
				}
				$(".close_chat").show();
			}
			$(data.rows).each(function(i, n) {
				var str = "";
				str =
					'<div class="sidebar-message">' +
					'<a href="#">' +
					'<div class="pull-left text-center">' +
					'<img alt="image" class="img-circle message-avatar" src="img/chat_pic.jpg">' +
					'<div class="m-t-xs">' +
					n.F_UserName +
					"</div>" +
					"</div>" +
					'<div class="media-body">' +
					'<div class="chat_content">' +
					GetCont(n.Content) +
					"</div>" +
					'<small class="text-muted">' +
					n.CreateDate +
					"</small>" +
					'<span class="reply"  data-FromUserId="' +
					n.FromUserId +
					'" data-ToUserId="' +
					n.ToUserId +
					'" data-roleId="' +
					n.F_RoleId +
					'" onclick="resply(this)">回复</span>';
				if(n.IsRead != 1) {
					str +=
						'<span class="reply close_chat" data-index="' +
						n.Id +
						'" onclick="closed(this)">关闭</span>';
				}
				"</div>" + "</a>" + "</div>";
				html.append(str);
			});
		},
	});
}

function closed(a) {
	var id = $(a).attr("data-index");
	$.ajax({
		type: "post",
		url: huayi.config.callcenter_url + "Index/CloseChat",
		async: true,
		dataType: "json",
		data: {
			token: $.cookie("token"),
			id: id,
		},
		success: function(data) {
			if(data.total > 0) {
				messages();
			} else {
				layer.msg("关闭消息失败！");
			}
		},
	});
}

function resply(a) {
	var userId = $(a).attr("data-FromUserId");
	var toId = $(a).attr("data-ToUserId");
	var roleId = $(a).attr("data-roleId");
	layer.open({
		type: 2,
		content: "replyChat.html?userId=" +
			userId +
			"&roleId=" +
			roleId +
			"&toId=" +
			toId, //iframe的url，no代表不显示滚动条
		title: "回复消息",
		area: ["50%", "60%"], //宽高
	});
}
//登陆弹窗函数
function login_DK() {
	layer.open({
		type: 2,
		content: ["CommonHtml/elasticFrame.html", "no"], //iframe的url，no代表不显示滚动条
		title: "提示",
		area: ["25%", "55%"], //宽高
	});
}
// 顶部消息
function showTopMsgs() {
	$("#top_notices_lists").toggle();
}

// 获取顶部消息（只展示未读消息 0未读 1已读）
function getTopMsgs() {
	helper.init.isload = 0;
	$.getJSON(
		huayi.config.callcenter_url + "InternalMessages/GetMsg", {
			token: $.cookie("token"),
			smstype: 1,
		},
		function(result) {
			if(result.state.toLowerCase() === "success") {
				helper.init.isload = 1;
				$("#top_notices_lists").empty();
				result = result.data;
				var str = "";
				if(result && result.length) {
					if(isFirstShowTopMsg) {
						$("#top_notices_lists").hide();
						isFirstShowTopMsg = false;
					}
					$("#top_notices_num").text(result.length);
					if(result.length > 99) {
						$("#top_notices_num").text(result.length);
					}
					for(var i = 0; i < result.length; i++) {
						str +=
							'<li class="top_notices_item">' +
							'<span title="' +
							result[i].SMS_Content +
							'" class="top_notices_con">' +
							result[i].SMS_Content +
							"</span>" +
							'<button type="button" class="btn btn-primary btn-sm" onclick="signRead(' +
							result[i].SMS_Id +
							', event)">未读</button>' +
							"</li>" +
							'<li class="divider"></li>';
					}
				} else {
					str =
						'<li class="top_notices_item">' +
						'<span class="top_notices_con">暂无消息！</span>' +
						"</li>";
					$("#top_notices_num").text(0);
				}
				$("#top_notices_lists").append(str);
				$("#top_notices_lists").find(".divider:last").remove();
			}
		}
	);
}

// 标记消息状态
function signRead(signid, e) {
	e.stopPropagation();
	layer.confirm(
		"确认已读后该条消息将不再提示，请慎重", {
			icon: 7,
			btn: ["确认", "取消"], //按钮
		},
		function(index) {
			$.ajax({
				type: "get",
				url: huayi.config.callcenter_url +
					"InternalMessages/UpdateState",
				dataType: "json",
				async: true,
				data: {
					ids: signid,
					state: 1, //状态，0未读 1已读
					token: $.cookie("token"),
				},
				success: function(data) {
					if(data.state.toLowerCase() === "success") {
						// 更新顶部消息内容和数量
						getTopMsgs();
						$("#top_notices_lists").hide();
						layer.close(index);
					}
				},
			});
		}
	);
}

function getnew() {
	helper.init.isload = 0;
	$.getJSON(
		huayi.config.callcenter_url + "InternalMessages/GetMsg", {
			token: $.cookie("token"),
			smstype: 2,
		},
		function(result) {
			helper.init.isload = 1;
			if(result.state.toLowerCase() === "success") {
				result = result.data;
				var str = "";
				$("#top_notices_lists1").empty();
				if(result && result.length) {
					$(".tan_ping").css("display", "block");
					for(var i = 0; i < result.length; i++) {
						var contant1 = result[i].SMS_Content.split("|")[0];
						if(contant1.length > 68) {
							contant2 = contant1.substr(0, 68) + "...";
						} else {
							contant2 = contant1;
						}
						var contant3 = result[i].SMS_Content.split("|")[1];
						str +=
							'<li class="top_notices_item top_notices_item1">' +
							'<span title="有坐席向您索要关于“' +
							contant1 +
							"”的内容，截止至" +
							contant3 +
							'，请尽快处理" data_id="' +
							result[i].SMS_Id +
							'" class="top_notices_con1">有坐席向您索要关于“' +
							contant2 +
							'”的内容</span><br /><span class="top_notices_con1">截止至<i style="color:red;font-style:normal">' +
							contant3 +
							"</i>，请尽快处理</span>" +
							//						'<button type="button" class="btn btn-primary btn-sm" onclick="signRead('+ result[i].SMS_Id +', event)">未读</button>' +
							"</li>" +
							'<li class="divider"></li>';
					}
				} else {
					str =
						'<li class="top_notices_item">' +
						'<span class="top_notices_con">暂无消息！</span>' +
						"</li>";
				}
				$("#top_notices_lists1").append(str);
			}
		}
	);
}
$("#know").on("click", function() {
	var data_id = $(".top_notices_con1").attr("data_id");
	Read(data_id, event);
	$(".tan_ping").css("display", "none");
	getnew();
});
//跳转索要列表
$("#chuli").on("click", function() {
	var data_id = $(".top_notices_con1").attr("data_id");
	Read(data_id, event);
	$(".tan_ping").css("display", "none");
	getnew();
	$("iframe:visible")[0].src = "zhiShiKu/askRecords1.html";
});

function Read(signid, e) {
	e.stopPropagation();
	$.ajax({
		type: "get",
		url: huayi.config.callcenter_url + "InternalMessages/UpdateState",
		dataType: "json",
		async: true,
		data: {
			ids: signid,
			state: 1, //状态，0未读 1已读
			token: $.cookie("token"),
		},
		success: function(data) {
			if(data.state.toLowerCase() === "success") {
				// 更新顶部消息内容和数量
				getTopMsgs();
				$("#top_notices_lists").hide();
				//					layer.close(index);
			}
		},
	});
}

// 获取工单数量
function workcount() {
	$.getJSON(
		huayi.config.callcenter_url + "WorkOrder/GetDWCount", {
			token: $.cookie("token"),
		},
		function(result) {
			if(result.state.toLowerCase() == "success") {
				var data = result.data.DWCount[0];
				$(".YWJD_DCLS").text(data.DaiBan); // 待办事项
				$(".WorkTHCB").text(data.TuiHui); // 退回重办
				$(".workOverdue").text(data.ChaoQi); // 超期工单
				$(".WorkXJDWTH").text(data.XiaJiTH); // 下级单位退回
				$(".WorkYBLTJ").text(data.DaiShenHen); // 待审核下级单位
				$(".WorkTHBJJ").text(data.TuiHuiJuJue); // 退回被拒绝
				$(".WorkYSBJJ").text(data.YanShiJuJue); // 延时被拒绝
				$(".UnsuccessfulLevel2").text(data.YiBsnWeiGuo); // 已办未果
				$(".superviseCommission").text(data.DB); // 督办工单
			}
		}
	);
}

function domainPrompt() {
	var content =
		'<div style="padding: 20px; font-size: 30px; line-height: 40px;">为了系统平台的安全考虑，系统登录地址改为：<a href="http://12345rx.zwfw.anyang.gov.cn:9999/home.html" target="block">http://12345rx.zwfw.anyang.gov.cn:9999/home.html</a>，新系统地址5月28日开始正式使用，老系统将于6月5日正式停止访问，请互相转告，谢谢！</div>';
	if(window.location.host === "125.45.12.146:9999") {
		layer.open({
			type: 1,
			title: "提示",
			content: content, //这里content是一个普通的String
			area: ["50%", "50%"],
		});
	}
}

$("#hangUpEvaluation").click(function() {
	satisfactionEvaluationFun();
});

function satisfactionEvaluationFun() {
	obj.Type = "TurnIvr";
	obj.AgentID = $.cookie("zx_user");
	obj.AgentExten = $.cookie("extno");
	obj.IvrName = "MYD";
	obj.IvrPos = "1";
	Send();
}

// 多媒体提示信息
function multimediaPrompt(roleCode) {
	if(roleCode === "MTDD") {
		$.ajax({
			type: "get",
			url: huayi.config.callcenter_url + "Info/GetMultiCount",
			dataType: "json",
			async: true,
			data: {
				token: $.cookie("token"),
			},
			success: function(data) {
				if(data.state.toLowerCase() === "success") {
					var data = data.data
					var content =
						'<div style="padding: 20px; font-size: 20px; line-height: 40px;"><p><ul>' +
						'<li>当日来信：' + data.lxcount[0].Column1 + '</li>' +
						'<li>退件数量：' + data.thcount[0].Column1 + '</li>' +
						'<li>延期数量：' + data.yscount[0].Column1 + '</li>' +
						'<li>办结数量：' + data.bjcount[0].Column1 + '</li>' +
						'</ul></p></div>';
					layer.open({
						type: 1,
						title: "提示",
						content: content, //这里content是一个普通的String
						area: ["25%", "30%"],
					});
				}
			},
		});
	}
}

function getReactionCategory(roleCode, pid = 38) {
	// var roleCode = $.cookie("code");
	// 供暖专员只获取供暖问题
	if(roleCode === "GNZY") {
		pid = 2460;
	} else {
		pid = 38;
	}
	$.get(
		huayi.config.callcenter_url + "Dictionary/GetZTreeNew", {
			token: $.cookie("token"),
			pid: pid,
		},
		function(result) {
			result = $.parseJSON(result);
			var content = JSON.parse(result.data);
			layui.use("dropdown", function() {
				var dropdown = layui.dropdown;
				dropdown.render({
					elem: "#reflectCategory", //可绑定在任意元素中，此处以上述按钮为例
					data: content,
					id: "reflectCategory",
					//菜单被点击的事件
					click: function(obj) {
						$("#reflectCategory").val(obj.title);
						$("#PID").val(obj.id);
					},
				});
			});
		}
	);
}

function getSearchReactionCategory(key) {
	$("#reflectCategoryList").empty();
	$.get(
		huayi.config.callcenter_url + "Dictionary/GetKeyListNew", {
			token: $.cookie("token"),
			key: key,
		},
		function(result) {
			result = $.parseJSON(result);
			if(result.state.toLowerCase() === "success") {
				var content = result.data;
				if(content.length > 0) {
					content.forEach(function(e, i) {
						$(
							"<li index='" +
							e.id +
							"' indexName='" +
							e.name +
							"'>" +
							e.names +
							"</li>"
						).appendTo("#reflectCategoryList");
					});
				} else {
					$("<li index='' indexName=''>没有相关数据</li>").appendTo(
						"#reflectCategoryList"
					);
				}
			}
		}
	);
}

function debounce(fun, delay) {
	return function(args) {
		var that = this;
		var _args = args;
		clearTimeout(fun.id);
		fun.id = setTimeout(function() {
			fun.call(that, _args);
		}, delay);
	};
}

// 监听浏览器关闭
window.onunload = function(e) {
	logout();
	return;
};

//获取知识库消息
setInterval(getnew, 180000);