var preList = [];
function UpdateFuncList(idx) {
	console.log(preList[idx]);
	var html = '<table border="0" cellspacing="0" style="border-collapse: collapse; border-spacing: 0;">';
	for (var i = 0; i < preList[idx].funcList.length; i++) {
		var checked = preList[idx].funcList[i].checked ? 'checked' : '';
		html += '<tr>\
				  <td style="width:150px;border:1px solid #DDDDDD;padding: 0px 2px;color:#555555;">\
					<div class="checkbox-wp level-1"><span class="checkbox-input"><input class="check-item staple-food" type="checkbox" disabled '+checked+'><span class="checkbox-inner"></span></span><label class="checkbox-con">'+preList[idx].funcList[i].name+'</label></div>\
				  </td>\
				  <td style="width:150px;border:1px solid #DDDDDD;padding: 0px 2px;color:#555555;">';
		for (var j = 0; j < preList[idx].funcChildList.length; j++) {
			if (preList[idx].funcChildList[j].serviceId != preList[idx].funcList[i].serviceId) continue;
			checked = preList[idx].funcChildList[j].checked ? 'checked' : '';
			html += '<div class="checkbox-wp level-2"><span class="checkbox-input"><input class="check-item staple-food" type="checkbox" disabled '+checked+'><span class="checkbox-inner"></span></span><label class="checkbox-con">'+preList[idx].funcChildList[j].name+'</label></div>';
		}
		html += '</td></tr>';
	}
	html += '</table>';
	$(".funcList").html(html);
}

$(function () {
	$.ajaxSetup({
	  async: false
	});
	var syscPerm = $("#perm-sysc").val();
	var ERROK = 200;
	var contextPath = $("#contextPath").val();
	var table;
	var orgList = [];
	var addressList = [];
	var departList = [];
	var companyList = [];
	var userNumber="";
	var cheakedArr = []
	var messageType //短信：1 邮件：2
	//	//记录选中的数据:做缓存使用,作为参数传递给后台
	//	var ids = [];
	//	var idsArr = [];
	//	//当前表格中的全部数据:在表格的checkbox全选的时候没有得到数据, 因此用全局存放变量
	//	var table_data = [];
	template.config("escape", false);
	var orgId = "";
	pushOrgId = '' //推送时候传的统一orgId（在选中的用户中拿）
	var virAccountInfo = $("#virAccountInfo").val()
	var tpl = {
		"addTpl": '<div class="dialog-wp">\
					<div class="mask"></div>\
					<div class="dialog dialog-account-con">\
						<div class="title-wp">\
							<span>新增账号</span>\
							<span class="close-btn"></button>\
						</div>\
						<div class="dialog-account-wp ">\
				 			<div class="account-list">\
								 \
								 <% if(orgList!=null&&orgList.length>1){ %>\
									 <div class="account-item required clearfloat">\
										<div class="item-tip"><span class="red">*</span>项目：</div>\
										<div class="item-con">\
											<input class="item-select organ-id" name="orgId" id="orgId"  autocomplete="off" placeholder="请输入项目名称"／>\
		              						<span class="select_wrap _hide"></span>\
									 	</div>\
									</div>\
								<%}else if(orgList!=null&&orgList.length==1){%>\
									 <div class="account-item required clearfloat" style="display: none">\
										<div class="item-tip"><span class="red">*</span>项目：</div>\
										<div class="item-con">\
											<input class="item-select" type="hidden" id="orgId" value="<%=orgList[0].id %>" org__id="<%=orgList[0].id%>" />\
									 	</div>\
									</div>\
								<%}%>\
									<div class="account-item required clearfloat">\
										<div class="item-tip"><span class="red">*</span>企业：</div>\
										<div class="item-con">\
										<%if(!virAccountInfo){%>\
											<input class="item-select company-id" name="companyId" id="companyId"  autocomplete="off" placeholder="请输入企业名称"／>\
											<span class="select_wrap _hide"></span>\
										<%}%>\
										<%if(virAccountInfo){%>\
											<input class="item-select company-id" disabled name="companyId" com__id="<%=virId%>" value="<%=virName%>" id="companyId" autocomplete="off"/>\
										<%}%>\
									 	</div>\
									</div>\
									<div class="account-item required clearfloat">\
									<div class="item-tip">部门：</div>\
									<div class="item-con">\
									<input class="item-select dept" name="departmentId" id="departmentId"  autocomplete="off" placeholder="请输入部门名称"／>\
										<span class="select_wrap _hide"></span>\
									</div>\
								</div>\
									<div class="account-item required clearfloat">\
									<div class="item-tip"><span class="red">*</span>手机号码：</div>\
									<div class="item-con">\
										<input  type="text" class="item-input mobile-phone" placeholder="请输入手机号码">\
									</div>\
								</div>\
								 <div class="account-item required clearfloat">\
									<div class="item-tip"><span class="red">*</span>姓名：</div>\
									<div class="item-con">\
										<input  type="text" class="item-input user-name" placeholder="请输入姓名">\
									</div>\
								</div>\
								<div class="account-item required clearfloat">\
								<div class="item-tip">工号：</div>\
								<div class="item-con">\
									<span class="userNumber"><%=userNumber %></span>\
								</div>\
							    </div>\
								<div class="account-item required clearfloat">\
									<div class="item-tip">性别：</div>\
									<div class="item-con">\
										<select class="item-select userSex">\
											<option value="">请选择性别</option>\
											<option value="1">男</option>\
											<option value="2">女</option>\
										</select>\
									</div>\
								</div>\
								<div class="account-item required clearfloat">\
									<div class="item-tip">邮箱：</div>\
									<div class="item-con">\
										<input  type="text" class="item-input email" placeholder="请输入邮箱">\
									</div>\
								</div>\
								<div class="account-item required clearfloat">\
									<div class="item-tip">身份类型：</div>\
									<div class="item-con">\
										<select class="item-select" id="permType">\
											<option value="">请选择身份类型</option>\
										</select>\
										<div class="funcList" style="border:none;"></div>\
									</div>\
								</div>\
								<div class="account-item clearfloat required _hide addFace">\
									<div class="item-tip "><span class="red"></span>识别图片：</div>\
									<div class="item-con">\
										<div class="photo-list-wp clearfloat">\
											<div class="photo-list clearfloat">\
											\
											</div>\
											<div class="photo-btn">\
												<input class="photo-file" type="file"/>\
											</div>\
										</div>\
									</div>\
								</div>\
				 			</div>\
							<div class="dialog-btns">\
								<button class="sure-add-btn btn-red">确定</button>\
							</div>\
						</div>\
					</div>\
				</div>	',
		"infoPushTpl": '<div class="dialog-wp set-permession">\
					<div class="mask"></div>\
					<div class="dialog dialog-account-con">\
						<div class="title-wp">\
							<span>消息推送</span>\
							<span class="close-btn"></button>\
						</div>\
						<div class="dialog-meal-wp">\
							<div class="choose-wrapper">\
								<h3 class="title">选择类型</h3>\
								<div class="circle-wp">\
									<div class="circle-con group-btn" data-type="1"></div>\
									<div class="name">发送短信</div>\
								</div>\
								<div class="circle-wp">\
									<div class="circle-con single-btn" data-type="2"></div>\
									<div class="name">发送邮件</div>\
								</div>\
							</div>\
							<div class="choose-content-wrapper">\
								<div class="pushInfo_wrap _hide">\
									<div class="dialog-account-wp ">\
										 <div class="account-list">\
											 <ul class="list1">\
												<li class="li1">\
													<label class="mt15"><span class="red">*</span>目标用户：</label>\
													<div class="set-account-num">\
													<%for(var i=0;i<personList.length;i++){%>\
														<label><input type="checkbox" name="account" value="<%=personList[i].id%>"  class="account_info" phone="<%=personList[i].mobile%>" checked="checked"> <span><%=personList[i].userName%></span><span><%=personList[i].mobile%></span><span class="dots_span"><%=personList[i].virName%></span></label>\
													<%}%>\
													</div>\
													<div style="padding-left:88px">共计：<span class="txt_blue total current_iofo_user_len"><%=personLen%>人</span></div>\
												</li>\
											 </ul>\
											 <ul class="list1">\
												<li class="li1">\
													<label class="mt15"><span class="red">*</span>短信内容：</label>\
													<div class="set-account-num">\
														<textarea class="pushInfoArea"></textarea>\
													</div>\
													<div style="padding-left:88px"><span class="txt_blue total">建议字数不超过140个</span><span class="red float-right current_iofo_content_len">0/140</span></div>\
												</li>\
											 </ul>\
											<div class="dialog-btns" style="border: 0">\
												 <button class="sure-add-btn btn-red pushInfo-btn" style="margin-top: 25px">确认</button>\
											</div>\
										</div>\
									</div>\
								</div>\
								<div class="pushEmail_wrap _hide">\
										<div class="dialog-account-wp ">\
											 <div class="account-list">\
												 <ul class="list1">\
													<li class="li1 clearfloat"><label><span class="red">*</span>发件邮箱：</label>\
														<select id ="groupId" class="item-select group-id send-email-num" >\
															<option value="" >请选择发件邮箱</option>\
															<%if(names.length){%>\
																<%for(var i=0;i<names.length;i++){%>\
																	<option value="<%=names[i].id%>" data-company="<%=names[i].virList%>"><%=names[i].email_address%></option>\
																<%}%>\
															<%}%>\
														</select>\
													</li>\
													<li class="li1 clearfloat">\
														<label class="mt15"><span class="red">*</span>设置账号：</label>\
														<div class="set-account-num">\
														<%for(var i=0;i<personList.length;i++){%>\
															<label><input type="checkbox" name="account" class="account_email" email="<%=personList[i].email%>" value="<%=personList[i].id%>" checked="checked"><span><%=personList[i].userName%></span><span><%=personList[i].email%></span><span class="dots_span"><%=personList[i].virName%></span></label>\
														<%}%>\
														</div>\
														<div style="padding-left:88px">共计：<span class="txt_blue total current_email_user_len"><%=personLen%>人</span></div>\
													</li>\
													<li class="li1 clearfloat  email-theme-li">\
														<label class="mt15"><span class="red">*</span>邮件标题：</label>\
														<input class="email-theme-input" type="text"/>\
													</li>\
													<li class="li1 clearfloat editor_li">\
														<label class="mt15"><span class="red">*</span>邮件内容：</label>\
														<div class="set-account-num eamil_wrap">\
															<div class="email-inform-con">\
												 				<div class="email-inform" id="myeditor"></div>\
												 			</div>\
														</div>\
													</li>\
													<li class="li1 clearfloat editor_li">\
													 	<div class="add-attach-wp">\
										 					<div class="add-attach-btn">\
										 						<button class="btn-white-width90 btn">添加附件</button>\
										 						<input type="file" class="file-input" id="attach_File" name="uploadfile"/>\
										 					</div>\
										 					<div class="attach-list clearfloat"></div>\
										 				</div>\
										 			</li>\
												 </ul>\
												 <div class="dialog-btns" style="border: 0">\
													 <button class="sure-add-btn btn-red pushEmail-btn">确认</button>\
												</div>\
											</div>\
										</div>\
								</div>\
						</div>\
					</div>\
				</div>	',
		"attachTpl": '\
						<div class="attach-item" data-url="<%= url %>" data-name="<%= name%>">\
 							<span class="attach-item-name"><%= name%></span>\
 							<span class="a-item-del-btn"></span>\
 						</div>\
						',
		"attachListTpl": '<% for(var i=0;i<list.length;i++){%>\
							<div class="attach-item" data-url="<%= list[i].split(";")[0] %>" data-name="<%= list[i].split(";")[1]%>">\
								<span class="attach-item-name"><%= list[i].split(";")[1]%></span>\
								<span class="a-item-del-btn"></span>\
							</div>\
						   <%}%>	\
						',
		"updateTpl": '<div class="dialog-wp">\
						<div class="mask"></div>\
						<div class="dialog dialog-account-con">\
							<div class="title-wp">\
								<span>修改账号</span>\
								<span class="close-btn"></button>\
							</div>\
							<div class="dialog-account-wp ">\
					 			<div class="account-list">\
									 <div class="account-item required clearfloat" style="display: none">\
										<div class="item-tip"><span class="red">*</span>项目：</div>\
										<div class="item-con">\
											<input type="hidden" id="orgId" class="orgUpdate" value="<%=orgId %>" org__id="<%=orgId %>"/>\
										</div>\
									</div>\
									<div class="account-item required clearfloat">\
										<div class="item-tip"><span class="red">*</span>企业：</div>\
										<div class="item-con">\
											<input class="item-select company-id companyUpdate" name="companyUpdate" id="companyUpdate"  autocomplete="off" placeholder="请输入企业名称" com__id="<%=virtualArchId %>" value="<%=comName %>"／>\
		              						<span class="select_wrap _hide"></span>\
									 	</div>\
									</div>\
									 <div class="account-item required clearfloat">\
									<div class="item-tip">部门：</div>\
									<div class="item-con">\
										<input class="item-select dept depUpdate" name="depUpdate" id="depUpdate"  autocomplete="off" placeholder="请输入部门名称" dep__id="<%=dept %>" value="<%=deptStr %>" ／>\
											<span class="select_wrap _hide"></span>\
									</div>\
								</div>\
									<div class="account-item required clearfloat">\
									<div class="item-tip"><span class="red">*</span>手机号码：</div>\
									<div class="item-con">\
										<input  type="text" class="item-input mobile-phone" placeholder="请输入手机号码" value="<%=mobile %>">\
									</div>\
								</div>\
									 <div class="account-item required clearfloat">\
										<div class="item-tip"><span class="red">*</span>姓名：</div>\
										<div class="item-con">\
											<input  type="text" class="item-input user-name" placeholder="请输入姓名" value="<%=userName %>">\
										</div>\
									</div>\
									<div class="account-item required clearfloat">\
									<div class="item-tip">工号：</div>\
									<div class="item-con">\
									<span class="userNumber"><%=userNumber %></span>\
									</div>\
								    </div>\
									<div class="account-item required clearfloat">\
									<div class="item-tip">性别：</div>\
									<div class="item-con">\
										<select class="item-select userSex">\
											<option value="">请选择性别</option>\
											<option value="1"   <%if(userSex==1){%> selected <%}%>  > 男 </option> \
											<option value="2"  <%if(userSex==2){%> selected <%}%> > 女 </option> \
										</select>\
									</div>\
								</div>\
									 <div class="account-item required clearfloat">\
									<div class="item-tip">邮箱：</div>\
									<div class="item-con">\
										<input  type="text" class="item-input email" placeholder="请输入邮箱" value="<%=email %>">\
									</div>\
								   </div>\
									<div class="account-item required clearfloat _hide">\
										<div class="item-tip"><span class="red">*</span>积分余额：</div>\
										<div class="item-con">\
											<input  type="number" class="item-input integral-balance" placeholder="请输入积分余额" value="<%=integrale %>" onkeyup="this.value=this.value.replace(/^\d+$/,&apos;&apos;);">\
										</div>\
									</div>\
									<div class="account-item required clearfloat _hide">\
										<div class="item-tip"><span class="red">*</span>送餐地址：</div>\
										<div class="item-con">\
											\
											 <select class="item-select dinner-address">\
												<option value="">请选择送餐地址</option>\
												<%if(addressList){%>\
												<%for(var j=0;j<addressList.length;j++){%>\
													<option value="<%=addressList[j].id%>" <%if(addressList[j].id==address){%> selected <%}%> ><%=addressList[j].itemname%></option>\
												<%}%>\
												<%}%>\
											</select>\
										</div>\
									</div>\
									<div class="account-item required clearfloat">\
										<div class="item-tip">身份类型：</div>\
										<div class="item-con">\
											<select class="item-select" id="permType">\
											<option value="">请选择身份类型</option>\
											<%var slt=0%>\
											<%if(funcList.length>0){%>\
												<%for(var i=0;i<funcList.length;i++){%>\
													<option value="<%=funcList[i].id%>" <%if(funcList[i].id==permId){slt=i;%> selected <%}%> data-func="<%=i%>"><%=funcList[i].permName%></option>\
												<%}%>\
											<%}%>\
											</select>\
											<%if(funcList.length>0){%>\
											<div class="funcList" style="margin-top: 10px;border:none;">\
												<table border="0" cellspacing="0" style="border-collapse: collapse; border-spacing: 0;">\
												  <%for(var i=0;i<funcList[slt].funcList.length;i++){%>\
													<tr>\
													  <td style="width:150px;border:1px solid #DDDDDD;padding: 0px 2px;color:#555555;">\
														<div class="checkbox-wp level-1"><input style="display:none;" type="checkbox" disabled <%if(funcList[slt].funcList[i].checked){%>checked<%}%>><%=funcList[slt].funcList[i].name%></div>\
													  </td>\
													  <td style="width:150px;border:1px solid #DDDDDD;padding: 0px 2px;color:#555555;">\
														<%for(var j=0;j<funcList[slt].funcChildList.length;j++){if(funcList[slt].funcChildList[j].serviceId!=funcList[slt].funcList[i].serviceId)continue;%>\
														  <div class="checkbox-wp level-2"><input style="display:none;" type="checkbox" disabled <%if(funcList[slt].funcChildList[j].checked){%>checked<%}%>><%=funcList[slt].funcChildList[j].name%></div>\
														<%}%>\
													  </td>\
													</tr>\
												  <%}%>\
												</table>\
											</div>\
											<%}%>\
										</div>\
									</div>\
									<%if(passType == 1){%>\
										<div class="account-item clearfloat required">\
											<div class="item-tip "><span class="red"></span>识别图片：</div>\
											<div class="item-con">\
												<div class="photo-list-wp clearfloat">\
													<div class="photo-list clearfloat">\
													<%if(facePicList){%>\
														<%for(var i=0;i<facePicList.length;i++){%>\
															<div class="photo-item" data-imageid="<%=facePicList[i].imageId%>">\
																<div class="photo-item-img" style="background-image: url(<%=serveImgUrl+facePicList[i].imageUrl%>)"></div>\
																<div class="del-btn"></div>\
															</div>\
														<%}%>\
														<%}%>\
													</div>\
													<div class="photo-btn">\
														<input class="photo-file" type="file"/>\
													</div>\
												</div>\
											</div>\
										</div>\
									<%}%>\
									<div class="account-item required clearfloat _hide">\
										<div class="item-tip"><span class="red">*</span>类型：</div>\
										<div class="item-con">\
											 <div class="radio-wp">\
											   <span class="radio-input">\
												 <input type="radio" id="zu" class="radio-item user-type" data-status="2" name="userType" <%if(roleType==2){%>checked<%}%>/>\
												  <span class="radio-inner"></span>\
											   </span>		\
											   <label class="radio-con" for="zu">个人账号</label>\
											</div>\
											 <div class="radio-wp">\
											   <span class="radio-input">\
												 <input type="radio" id="zu1" class="radio-item user-type" data-status="1" name="userType" <%if(roleType==1){%>checked<%}%>/>\
												  <span class="radio-inner"></span>\
											   </span>		\
											   <label class="radio-con" for="zu1">管理员</label>\
											</div>\
											<div class="radio-wp">\
											<span class="radio-input">\
											<input type="radio" id="zu2" class="radio-item user-type" data-status="3" name="userType" <%if(roleType==3){%>checked<%}%>/>\
											 <span class="radio-inner"></span>\
											</span>		\
											<label class="radio-con" for="zu2">可被代订</label>\
									 </div>\
										</div>\
									</div>\
					 			</div>\
								 <div class="dialog-btns">\
									<button class="sure-add-btn btn-red">确定</button>\
								</div>\
							</div>\
						</div>\
					</div>	',
		"detailOne": '<div class="dialog-wp detailOne">\
					<div class="mask"></div>\
					<div class="dialog dialog-account-con">\
						<div class="title-wp">\
							<span>账号详情</span>\
							<span class="close-btn"></button>\
						</div>\
						<div class="dialog-account-wp ">\
							 <div class="account-list">\
								 <ul class="list1">\
									<li class="li1"><label>项&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;目：</label><span><%=orgName%></span></li>\
									<li class="li1"><label>企&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;业：</label><span><%=virName%></span></li>\
									<li class="li1"><label>部&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;门：</label><span><%=depName%></span></li>\
									<li class="li1"><label>手机号码：</label><span><%=mobile%></span></li>\
									<li class="li1"><label>姓&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;名：</label><span><%=userName%></span></li>\
									<li class="li1"><label>工&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;号：</label><span><%=userNumber%></span></li>\
									<li class="li1"><label>性&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;别：</label><span><% if(userSex==1){%>男<%}else if(userSex==2){%>女<%}%></span></li>\
									<li class="li1"><label>邮&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;箱：</label><span><%=email%></span></li>\
									<li class="li1"><label>身份类型：</label><span><%=permName%></span><div class="funcList" style="display:block;margin-left: 80px;">功能权限：<%=funcListStr%></div>\</li>\
									<li class="other_image lis">\
										<label>识别图片：</label>\
										<% if(facePicList != null){ %>\
											<%for (var i=0;i<facePicList.length;i++){ %>\
												<img class="mr8" src="<%=serveImgUrl+facePicList[i].imageUrl%>" onclick="boostImg(this)"/>\
											<%}%>\
										<%}%>\
									</li>\
								 </ul>\
								 <div class="dialog-btns">\
								 	<button class="sure-detail-btn btn-red">确定</button>\
							 	 </div>\
						</div>\
					</div>\
				</div>	',
		"photoTpl": '<div class="photo-item" data-url="<%=imageUrl%>">\
					<div class="photo-item-img" style="background-image: url(<%=url%>)"></div>\
					<div class="del-btn"></div>\
				</div>',
		exportTpl: '<div class="dialog-wp">\
						<div class="mask"></div>\
						<div class="dialog export-or-download-con">\
							<div class="title-wp">\
								<span>导入账号</span>\
								<span class="close-btn"></button>\
							</div>\
							<div class="export-or-download-wp">\
								<div class="choose-item-wp">\
									<span class="tip">项目</span>\
									<input class="default-select d-orgid" name="orgId" id="orgId"  autocomplete="off" placeholder="请输入项目名称"/>\
		              				<span class="select_wrap _hide"></span>\
								</div>\
								<div class="export-or-download-btns">\
							 		<button class="sure-operate-btn sure-operate-btn-mult btn-red-width90" type="button">导入<input class="excelFile" type="file" id="excelFile" name="excelFile" /></button> \
								</div>\
							</div>\
						</div>\
          </div>',
          			// <div class="choose-item-wp">\
								// 	<span class="tip">企业</span>\
								// 	<input class="default-select d-companyid"  autocomplete="off" placeholder="请输入企业名称"/>\
		            //   				<span class="select_wrap _hide"></span>\
								// </div>\
		exportTplNo: '<div class="dialog-wp">\
						<div class="mask"></div>\
						<div class="dialog export-or-download-con">\
							<div class="title-wp">\
								<span>导入账号</span>\
								<span class="close-btn"></button>\
							</div>\
							<div class="export-or-download-wp">\
								<input type="hidden" class="default-select d-orgid" name="orgId" id="orgId" org__id="<%=orgId %>"/>\
								<div class="export-or-download-btns">\
							 		<button class="sure-operate-btn sure-operate-btn-single btn-red-width90" type="button">导入<input class="excelFile" type="file" id="excelFile" name="excelFile" /></button> \
								</div>\
							</div>\
						</div>\
          </div>',
        //   <div class="choose-item-wp">\
        //   <span class="tip">企业</span>\
        //   <%if(!virAccountInfo){%>\
        //     <input class="default-select d-companyid"  autocomplete="off" placeholder="请输入企业名称"/>\
        //     <span class="select_wrap _hide"></span>\
        //   <%}%>\
        //   <%if(virAccountInfo){%>\
        //     <input class="default-select d-companyid" disabled com__id="<%=virId%>" value="<%=virName%>" autocomplete="off"/>\
        //   <%}%>\
        //   <span class="select_wrap _hide"></span>\
        // </div>\
		"setPermissionsTpl": '<div class="dialog-wp set-permession">\
			<div class="mask"></div>\
			<div class="dialog dialog-account-con">\
				<div class="title-wp">\
					<span>批量设置通行权限</span>\
					<span class="close-btn"></button>\
				</div>\
				<div class="dialog-account-wp ">\
					 <div class="account-list">\
						 <ul class="list1">\
							<li class="li1"><label><span class="red">*</span>名称：</label>\
								<select id ="groupId" class="item-select group-id" >\
									<option value="">请选择名称</option>\
									<%for(var i=0;i<names.length;i++){%>\
										<option value="<%=names[i].id%>"><%=names[i].groupName%></option>\
									<%}%>\
								</select>\
							</li>\
							<li class="li1 hadPeople" style="display:none">\
								<label class="mt15">已有人员：</label>\
								<div class="set-account-num">\
								</div>\
							</li>\
							<li class="li1">\
								<label class="mt15"><span class="red">*</span>设置账号：</label>\
								<div class="set-account-num">\
								<%for(var i=0;i<personList.length;i++){%>\
									<label><input type="checkbox" name="account" value="<%=personList[i].id%>" checked="checked"><span><%=personList[i].userName%></span><span style="padding-left: 8px;"><%=personList[i].mobile%></span></label>\
								<%}%>\
								</div>\
								<div style="padding-left:88px">共计：<span class="txt_blue total"><%=personLen%>人</span></div>\
							</li>\
						 </ul>\
						 <div class="dialog-btns" style="border: 0">\
							 <button class="sure-add-btn btn-red" style="margin-top: 25px">确认</button>\
							</div>\
				</div>\
			</div>\
		</div>',
		"sendCardTpl": '<div class="dialog-wp sendCardTpl">\
    <div class="mask"></div>\
    <div class="dialog dialog-account-con">\
      <div class="title-wp">\
        <span>发卡</span>\
        <span class="close-btn"></button>\
      </div>\
			<div class="dialog-account-wp ">\
					<div class="account-list">\
						<div class="account-item required clearfloat">\
							<div class="item-tip">手机号码：</div>\
							<div class="item-con">\
								<label><%=mobile%></label>\
							</div>\
						</div>\
						<div class="account-item required clearfloat">\
							<div class="item-tip">姓名：</div>\
							<div class="item-con">\
								<label><%=userName%></label>\
							</div>\
						</div>\
						<div class="account-item required clearfloat">\
							<div class="item-tip">实体卡号：</div>\
							<div class="item-con">\
								<input class="item-input cardNumber" type="text" value="" placeholder="请输入实体卡号">\
							</div>\
						</div>\
						<div class="dialog-btns" style="border: 0;">\
							<button class="sure-add-btn btn-red">确定</button>\
						</div>\
      		</div>\
    	</div>\
 	 </div>	',
	};

	var api = {
		init: function () {
			this.render();
			this.bindEvent();
		},
		render: function () {
			this.rendertable();
			this.itemAjax();
			// this.ajaxDepartAndAddress();
			this.ajaxCompanyList($("#conditionform #orgId").attr('org__id'), function (data) {
				let comArr = "";
				$.each(data, function (index, item) {
					comArr += "<option value='" + item.id + "'>" + item.name + "</option>"
				})
				$("#conditionform #companyId").append(comArr);
			});
		},
		bindEvent: function () {
			var _this = this;
			layui.use('laydate', function () {
				var laydate = layui.laydate;
				//执行一个laydate实例
				laydate.render({
					elem: '#beginTime' //提交开始时间
				});
				laydate.render({
					elem: '#endTime' //提交结束时间
				});
			});
			//重置
			$(".set-btn").on("click", function () {
				if(virAccountInfo){
          var $dom = $("#conditionform #departmentId")
          $dom.val("").removeAttr('dep__id')
          _this.againRenderTable({type:1});
				}else{
					var $orgId = $("#conditionform  .single-orgid");
					var $dom = $("#conditionform input,#conditionform select")
					if($orgId.length){
						$dom.val("").removeAttr('com__id dep__id')
					}else{
						$dom.val("").removeAttr('org__id com__id dep__id')
					}
					_this.againRenderTable({type:1});
				}
			});
			// 信息同步
			$(".info-same-btn").on("click", function () {
				_this.ajaxInfoSame(function () {
					_this.againRenderTable();
				})
			});
			//导入模板

			// $(".main-operate-wp #excelFile").live("change", function () {
			// 	var $orgId = $("#conditionform  .single-orgid");
			// 	_this.exportFile($orgId.length);
			// 	//					_this.exportFile();
			// });
			//单项目
			$(".main-operate-wp .export-wp-no input").on("change", function () {
				var $orgId = $("#conditionform  .single-orgid");
				_this.exportFile($orgId.length,function(){
					var virId = $(".d-companyid").attr('com__id');
					_this.exportFileAjax($("#conditionform  .single-orgid").val(), function () {
						console.log('项目导入')
					}, $("#conditionform #companyId").attr("com__id"))
				});
			})
			//多项目
			$(".main-operate-wp .export-btn").on("click", function () {
				_this.exportFile();
			})
			// 模版事件
			$("body").on("click",'.close-btn', function () {
				$(".dialog-wp").remove();
			});
			// (单)
//			$("body").on("change", ".sure-operate-btn-single input", function () {
//				var virId = $(".d-companyid").attr('com__id');
//				_this.exportFileAjax($("#conditionform  .single-orgid").val(), function () {
//					console.log('项目导入')
//				}, $("#conditionform #companyId").attr("com__id"))
//			});
			// (多)
			$("body").on("change", ".sure-operate-btn-mult input", function () {
				var orgId = $(".d-orgid").attr('org__id');
				if (!orgId) {
					layer.msg("请选择项目");
					$(this).val('');
					return false;
				};
				_this.exportFileAjax(orgId, function () {
					$(".dialog-wp").remove();
				})
			});
			//下载模板
			$("#importTemplate").on("click", function () {
				location.href = $("#contextPath").val() + "/upload/Consumer.xlsx";
			});
			//新增
			$(".add-ele-btn").on("click", function () {
				$("body").append(template.render(tpl.addTpl)({
					orgList: orgList,
					addressList: addressList,
					departList: departList,
					companyList: companyList,
					userNumber:userNumber,
					virAccountInfo: virAccountInfo,
					virId: $("#conditionform #companyId").attr("com__id"),
					virName: $("#conditionform #companyId").val()
				}));
				let virPermId = ''
				// 身份类型列表
				$("#permType").on("focus",function(){
					let orgId = $(".item-con #orgId").attr('org__id');
					if(orgId){
						_this.getPermList(orgId)
					}else{
						layer.msg("请选择项目")
					}
				})
				// 身份类型选择
				$("#permType").on("change",function() {
					// console.log($(this).val())
					// virPermId = $(this).val()
					// if($(this).val()){
					// 	let funcList = $("#permType").find("option:selected").attr('data-func')
					// 	$(".funcList").show()
					// 	let str = "功能权限："
					// 		str +=  funcList
					// 	$(".funcList").html(str)
					// }else{
					// 	$(".funcList").hide()
					// }
					var idx = $("#permType")[0].selectedIndex;
					if(idx > 0){
						idx--;
						$(".funcList").show();
						UpdateFuncList(idx);
					}else{
						$(".funcList").hide()
					}
				});
				//上传识别图片
				$(".photo-file").on("change", function () {
					if (!$(".company-id").attr('com__id')) {
						layer.msg("请先选择企业!");
						return false;
					}
					var file = $(this)[0].files[0];
					var fileName = $(this)[0].value;
					var suffixIndex = fileName.lastIndexOf(".");
					var suffix = fileName.substring(suffixIndex + 1).toUpperCase();
					if ($(".photo-item").length == 3) {
						layer.msg("识别图片最多上传3张!");
						return false;
					}
					if (suffix != "BMP" && suffix != "JPG" && suffix != "JPEG" && suffix != "PNG" && suffix != "GIF") {
						layer.alert("请上传图片（格式BMP、JPG、JPEG、PNG等）!");
						return false;
					}
					lrz(file, {
						quality: 0.8, //设置压缩率
						width: 400
					}).then(function (results) {
						_this.upload(results.base64);
					});
				});
				//关闭弹窗
				$(".close-btn,.cancel-add-btn").on("click", function () {
					$(".dialog-wp").remove();
				});
				//确认添加
				$(".sure-add-btn").on("click", function () {
					_this.submitAdd(virPermId,function () {
						$(".dialog-wp").remove();
						layer.msg("新增成功！")
						_this.againRenderTable();
					});
				});
			});
			//群发消息推送
			$("#pushInfo").on("click", function () {
				var checkStatus = table.checkStatus('testReload');
				var checkedArr = checkStatus.data || []
				var flag_repeat = false
				console.log(checkedArr)
				if(!checkedArr.length){layer.msg("请选择推送人");return}
				// 循环判断是否都在同一项目下
				var firstOrgId = checkedArr[0].organizationId
				var pushOrgIdArr = []
				checkedArr.forEach(function(item,index,arr){
					pushOrgIdArr.push(item.organizationId)
				})
				pushOrgIdArr.forEach(function(item,index,arr){
					pushOrgId = item
					if(item != firstOrgId){
						flag_repeat = true
					}
				})
				if(flag_repeat){
					layer.msg("请选择相同项目下的推送人");
					return
				}
				// 获取发件人邮箱地址
				var emailArr = []
				$.ajax({
					type: "post",
					url: contextPath + "/notice/emailSend/getUserEmail",
					data: {
						orgIds:pushOrgId
					},
					async: false,
					success: function (data) {
						var obj =  JSON.parse(data)
						emailArr = obj.data['items']
					},
					error: function (error) {
						layer.msg('error')
					}
				});
				$("body").append(template.render(tpl.infoPushTpl)({
					personLen: checkedArr.length,
            		personList: checkedArr,
            		names:emailArr
				}));
				//关闭弹窗
				$(".close-btn,.cancel-add-btn").on("click", function() {
					$(".dialog-wp").remove();
				});
				//选择短信还是邮件
				$(".circle-con").on("click", function() {
					var type = $(this).data("type"); //type 为1 短信 为2邮件
					messageType = type
					$(".choose-wrapper").hide();
					$(".choose-content-wrapper").data("type", type).show();
					//单品和组合显示不同
					if (type == 1) {
						$('.pushEmail_wrap').hide()
						$('.pushInfo_wrap').show()
					} else {
						$('.pushInfo_wrap').hide()
						$('.pushEmail_wrap').show()
						editor = new UE.ui.Editor({
							imageActionName: 'ueAction',
							imageFieldName: "uploadfile",
							fileActionName: "ueAction",
							fileFieldName: "uploadfile",
							fileAllowFiles: [
								".png", ".jpg", ".jpeg", ".gif", ".bmp",
								".flv", ".swf", ".mkv", ".avi", ".rm", ".rmvb", ".mpeg", ".mpg",
								".ogg", ".ogv", ".mov", ".wmv", ".mp4", ".webm", ".mp3", ".wav", ".mid",
								".rar", ".zip", ".tar", ".gz", ".7z", ".bz2", ".cab", ".iso",
								".doc", ".docx", ".xls", ".xlsx", ".ppt", ".pptx", ".pdf", ".txt", ".md", ".xml"
							],
							imageAllowFiles: [".png", ".jpg", ".jpeg", ".gif", ".bmp"],
							/* 上传图片格式显示 */
							imageUrlPrefix: contextPath //contextPath
						});
						editor.render("myeditor");
						editor.ready(function() {
							editor.setHeight(270);
							//editor.addListener("afterUpfile",_this._afterUpfile);
						});
					}
				});
				//发送信息
				$(".pushInfo-btn").on("click", function() {
					_this.pushInfo_fn(function() {
						$(".dialog-wp").remove();
						// _this.againRenderTable();
					})
				});
				// 消息字数监听
				$('.pushInfoArea').on('input', function(event) {
					event.preventDefault();
					/* Act on the event */
					var num = $(this).val().length
					$('.current_iofo_content_len').text(num+'/140')
				});
				// 目标用户选中监听
				$('.account_info').on('change', function(event) {
					event.preventDefault();
					var domCheckedlen = $('.account_info:checked').length
					$('.current_iofo_user_len').text(domCheckedlen+'人')
				});
				$('.account_email').on('change', function(event) {
					event.preventDefault();
					var domCheckedlen = $('.account_email:checked').length
					$('.current_email_user_len').text(domCheckedlen+'人')
				});
				//发送邮件
				$(".pushEmail-btn").on("click", function() {
					_this.pushEmail_fn(function() {
						$(".dialog-wp").remove();
						// _this.againRenderTable();
					})
				});
				//添加附件
				$(".file-input").on("change", function () {
					var name = $(this)[0].files[0].name;
					_this.addAttach(name);
				});
			});
			// 关闭修改弹窗
			$('body').on("click",'.close-btn,.sure-detail-btn', function () {
				$(".dialog-wp").remove();
			});
			_this.search_fuzzy()
		},

		// 群发信息
		pushInfo_fn: function(callback){
			var userIdStr = ''
			var phoneStr = ''
			var contentStr = $('.pushInfoArea').val()
			var dom = $('.account_info')
			var domCheckedlen = $('.account_info:checked').length
			if(domCheckedlen <= 0){
				layer.msg('请选择目标收件人');
				return
			}
			if(!contentStr){
				layer.msg('请输入短信内容');
				return
			}
			$.each(dom,function(index, el) {
				if($(el).is(':checked')){
					userIdStr += $(el).attr('value') + ','
					phoneStr += $(el).attr('phone') + ','
				}
			});
			$.ajax({
				type: "post",
				url: contextPath + "/notice/phoneMessage/saveOrUpdate",
				data: {
					userIds: userIdStr,
					"orgId": pushOrgId,
					"phones": phoneStr,
					"content": contentStr
				},
				success: function (data) {
					var data = JSON.parse(data);
					if (data.code == '200') {
						layer.msg('提交发送成功！');
						if(callback){
							callback()
						}
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		// 群发邮件
		pushEmail_fn: function(callback){
			var userIdStr = ''
			var recipient_email = ''
			var contentStr = $('.pushInfoArea').val()
			var domCheaked = $('.account_email:checked')
			var domCheckedlen = $('.account_email:checked').length
			var flag_empty = false
			$.each(domCheaked,function(index, el) {
				userIdStr += $(el).attr('value') + ','
				if(!$(el).attr('email')){
					flag_empty = true
					return
				}
			});
			// 如果有邮箱为空给提示
			if(flag_empty){
				layer.msg('部分用户邮箱未填写');
				return
			}
			//邮件消息id
			var id = $(".e-sure-btn").data("id");
			//发件人邮箱id
			var emailaccount_id = $(".send-email-num").val();
			//主题
			var email_theme = $(".email-theme-input").val();
			//收件箱
			$.each(domCheaked,function(index, el) {
				if($(el).attr('email')){
					recipient_email += $(el).attr('email') + ';'
				}
			});
			//邮箱内容
			var ue = UE.getEditor('myeditor');
			var email_centent = ue.getContent();
			var contentTxt = ue.getContentTxt();;
			//附件地址
			var urlList = [];
			$(".attach-item").each(function (index, ele) {
				var str = $(ele).data("url")
				urlList.push(str)
			})
			var attach_ment = urlList.join(",");
			if (!emailaccount_id) {
				layer.msg("请选择发件邮箱");
				return false;
			}
			if(domCheckedlen <= 0){
				layer.msg('请选择目标收件人');
				return
			}
			if (!email_theme) {
				layer.msg("请输入邮件标题");
				return false;
			};
			if (!email_centent) {
				layer.msg("请输入邮箱内容");
				return false;
			}

			$(".e-sure-btn").attr("disabled", true)
			$.ajax({
				type: "post",
				url: contextPath + "/notice/emailSend/saveOrUpdate",
				data: {
					"email_theme": email_theme,
					"recipient_email": recipient_email,
					"email_centent": email_centent,
					"attach_ment": attach_ment,
					"emailaccount_id": emailaccount_id,
					"id": !!id ? id : '',
					"orgId": pushOrgId,
					contentTxt: contentTxt,
					userIds:userIdStr,
					type:messageType
				},
				success: function (data) {
					var data = JSON.parse(data);
					if (data.code == '200') {
						if (!!id) {
							window.location.href = contextPath + '/notice/audit/noticeEmailVerify';
						} else {
							ue.setContent('');
							$(".email-list,.email-theme-input,.send-email-num").val("");
							$(".attach-list").html("");
							layer.msg('提交发送成功！');
							if(callback){
								callback()
							}
						}
					} else {
						layer.msg(data.msg)
					}
					$(".e-sure-btn").attr("disabled", false)
				},
				error: function (error) {
					$(".e-sure-btn").attr("disabled", false)
					layer.msg('error')
				}
			});
		},
		/**
		 * 添加附件
		 * @param name
		 */
		addAttach: function (name) {
			var _this = this;
			$.ajaxFileUpload({
				url: contextPath + "/notice/emailSend/uploadFile", //用于文件上传的服务器端请求地址
				secureuri: false, //是否需要安全协议，一般设置为false
				fileElementId: 'attach_File', //文件上传域的ID
				dataType: 'String', //返回值类型 一般设置为json
				success: function (data, status) //服务器成功响应处理函数
				{
					// console.log(data,222);
					var data = JSON.parse(data);
					//选择文件
					$(".file-input").on("change", function () {
						var name = $(this)[0].files[0].name;
						_this.addAttach(name);
					});
					if (data.code == '200') {
						var name = data.data.split(";")[1];
						$(".attach-list").append(template.render(tpl.attachTpl)({
							name: name,
							url: data.data
						}));
						//删除附件
						$(".a-item-del-btn").on("click", function () {
							$(this).closest(".attach-item").remove();
						})
					} else {
						alert(data.msg);

					}
				}
			})
		},
		// 模糊搜索事件
		search_fuzzy: function(){
			var default_option = {
				org_attrName:'org__id',
				com_attrName:'com__id',
				dep_attrName:'dep__id',
				org_spanName:'org__span',
				com_spanName:'com__span',
				dep_spanName:'dep__span',
				org_path:'/admin/templ/getOrgListByName',
				com_path:'/admin/templ/getVirList',
				dep_path:'/admin/templ/getDept',
				contextPath:$("#contextPath").val()
			}
			var option_1 = $.extend(true,{},default_option,{
				org_target:'.default-select#orgId',
				com_target:'.default-select#companyId',
				dep_target:'.default-select#departmentId',
			});
			var option_2 = $.extend(true,{},default_option,{
				org_target:'.item-select#orgId',
				com_target:'.item-select#companyId',
				dep_target:'.item-select#departmentId',
			});
			var option_3 = $.extend(true,{},default_option,{
				org_target:'.d-orgid',
				com_target:'.d-companyid'
			});
			var option_4 = $.extend(true,{},default_option,{
				org_target:'.orgUpdate',
				com_target:'.companyUpdate',
				dep_target:'.depUpdate',
			});


			function eve(option_,otherOption){
				var obj = $.extend(true, {}, option_, otherOption);
				var type = obj.type
				var _path, _target, _attrName, _spanName
				if(type == 1){
					_path = obj.org_path
					_target = obj.org_target
					_attrName = obj.org_attrName
					_spanName = obj.org_spanName
				}else if(type == 2){
					_path = obj.com_path
					_target = obj.com_target
					_attrName = obj.com_attrName
					_spanName = obj.com_spanName
				}else if(type == 3){
					_path = obj.dep_path
					_target = obj.dep_target
					_attrName = obj.dep_attrName
					_spanName = obj.dep_spanName
				}
				$('body').on("input",_target,function(event){
					var _this = $(this)
					var obj_input = $.extend(true,{}, obj,{"_this":_this});
					cjqt.search_fuzzy.event_input(_this,_attrName,_spanName,contextPath,_path,obj_input)
				});
				$('body').on("focus",_target,function(event){
					var _this = $(this)
					var obj_focus = $.extend(true,{},obj,{"_this":_this});
					cjqt.search_fuzzy.event_focus(_this,_attrName,_spanName,contextPath,_path,obj_focus)
				});
				$('body').on('blur',_target,function(event) {
					var _this = $(this)
					var obj_blur = $.extend(true,{},obj,{"_this":_this});
					cjqt.search_fuzzy.event_blur(_this,_attrName,obj_blur)
				});
				$('body').on('click',_target+'~.select_wrap>.'+_spanName, function(event) {
					event.preventDefault();
					event.stopPropagation();
					/* Act on the event */
					var _this = $(this)
					var obj_click = $.extend(true,{},obj,{"_this":_this});
					cjqt.search_fuzzy.event_click(_this,_attrName,_target,obj_click)
				});

			}
			// 搜索联动
			eve(option_1,{type:1})
			eve(option_1,{type:2})
			eve(option_1,{type:3})
			// 新增联动
			eve(option_2,{type:1,click_callback:function(){
				var orgId = $('.item-select#orgId').attr('org__id')
				$.ajax({
					type: "post",
					url: contextPath + "/admin/appUser/getPassType",
					data:{
						orgId:orgId
					},
					success: function (data) {
						if(data.code==200){
							if(data.data==1){
								$('.addFace').show()
							}else{
								$('.addFace').hide()
							}
						}
					},
					error: function (error) {
						layer.msg('error')
					}
				});
			}})
			eve(option_2,{type:2})
			eve(option_2,{type:3})
			//导入联动
			eve(option_3,{type:1})
			eve(option_3,{type:2})
			//修改联动
			eve(option_4,{type:2})
			eve(option_4,{type:3})
		},
		rendertable: function () {
			var _this = this;
			layui.use('table', function () {
				table = layui.table;
				//方法级渲染
				table.render({
					elem: '#LAY_table_user',
					url: $("#contextPath").val() + "/admin/appUser/getConsumerList",
					method: "post",
					skin: 'nob' //行边框风格
						,
					even: true //开启隔行背景
						,
					size: 'lg' //小尺寸的表格
						,
					cols: [
						[{
							type: 'checkbox',
							fixed: 'left'
						},{
							field: 'index',
							title: '序号',
							width: '80',
							templet: '#indexTpl'
						},
						{
							field: 'orgName',
							title: '项目',
							minWidth: 180
						},
						{
							field: 'virName',
							title: '企业',
							minWidth: 180
						},
						{
							field: 'dept',
							title: '部门',
							minWidth: 150
						},
						{
							field: 'mobile',
							title: '手机号码',
							minWidth: 150,
							templet: function (data) {
								return _this.phoneLize(data.mobile)
							}
						},
						{
							field: 'userName',
							title: '姓名',
							minWidth: 100
							//							}, {
							//								field: 'integral',
							//								title: '积分余额',
							//								minWidth: 200

							//							}, {
							//								field: 'address',
							//								title: '送餐地址',
							//								minWidth: 200
						},
						{
							field: 'userNumber',
							title: '工号',
							minWidth: 100
						},
						{
							field: 'userSex',
							title: '性别',
							minWidth: 50
						},
						{
							field: 'email',
							title: '邮箱',
							minWidth: 200
						},
						{
							field: 'permName',
							title: '身份类型',
							minWidth: 200,
							style:'cursor: pointer;',
							event: 'readType'
						},
						{
							field: 'status',
							title: '状态',
							width: 100,
							templet: function (data) {
								//1启用0禁用
								if (data.isEnabled == 1) {
									return '已启用'
								} else if (data.isEnabled == 0) {
									return '已禁用'
								}
							}
						},
						{
							field: 'createTime',
							title: '创建时间',
							minWidth: 200

							//							}, {
							//								field: 'roleType',
							//								title: '类型',
							//								width: 120,
							//								templet: function (data) {
							//									//1管理员2普通用户
							//									if (data.roleType == 1) {
							//										return '管理员'
							//									} else if (data.roleType == 2) {
							//										return '普通用户'
							//									} else if (data.roleType == 3) {
							//										return '可被代订'
							//									}
							//								}
						},
						{
							title: '可操作',
							fixed: 'right',
							width: 260,
							align: 'center',
							templet: function (data) {
								var str = '';
								// if (data.passType == "2" && data.cardCode) {
								// 	str += '<button class="t-btn t-red-btn t-collection-btn" data-id=' + data.id + ' data-type="1" data-cardid =' + data.cardId + ' data-cardcode =' + data.cardCode + '>收卡</button>';
								// } else if (data.passType == "2" && !data.cardCode) {
								// 	str += '<button class="t-btn t-red-btn t-payment-btn" data-id=' + data.id + ' data-type="1">发卡</button>';
								// }
								if (syscPerm == 1) {
									str += '<button class="t-btn t-red-btn t-info-btn" data-id=' + data.id + ' data-type="1">同步</button>';
								}
								if (data.isEnabled == 1) {
									str += '<button class="t-btn t-red-btn t-delete-btn" data-id=' + data.id + ' data-type="1">禁用</button>';
								} else if (data.isEnabled == 0) {
									str += '<button class="t-btn t-red-btn t-delete-btn" data-id=' + data.id + ' data-type="2">启用</button>';
								}
								str += '<button class="t-btn t-red-btn t-edit-btn" data-id=' + data.id + '  >修改</button>';
								str += '<button class="t-btn t-red-btn t-publish-btn" data-id=' + data.id + ' data-type="1" lay-event="detail" >详情</button>';

								return str;
							}
						}]
					],
					id: 'testReload',
					page: true,
					response: {
						statusName: 'code' //数据状态的字段名称，默认：code
							,
						statusCode: 200 //成功的状态码，默认：0
							,
						countName: "count" //数据总数的字段名称，默认：count
							,
						dataName: "data" //数据列表的字段名称，默认：data
							,
						msgName: 'msg' //规定状态信息的字段名称，默认：msg
					},
					request: {
						pageName: 'pageNo' //页码的参数名称，默认：page
							,
						limitName: 'pageSize' //每页数据量的参数名，默认：limit
					},
					where: {
						orgId: $("#conditionform  #orgId").attr('org__id'),
						virtualArchId: $("#conditionform #companyId").attr("com__id")
					},
					done: function (res, curr, count) {
						console.log(res)
						//如果是异步请求数据方式，res即为你接口返回的信息。
						//删除
						$(".t-delete-btn").on("click", function () {
							var id = $(this).data("id");
							var type = $(this).data("type");
							_this.ajaxDelTemp(id, type, function () {
								_this.againRenderTable();
							})
						});
						//修改
						$(".t-edit-btn").on("click", function () {
							var id = $(this).data("id");
							_this.ajaxDetail(id, function (data) {
								var data = data;
								//把地址信息存一下
								_this.ajaxDepartAndAddress_(data.orgId,2,function(res){
									addressList = res.data;
									data.addressList = addressList
								})
								_this.getPermList(data.orgId,function(res) {
									data.funcList = res;
									preList = res;
								})
								_this.ajaxCompanyList(data.orgId, function (result) {
									var comName = ''
									data.companyList = result;
									$.each(result,function(index,item){
									  	if(data.virtualArchId == item.id){
									  		comName = item.name
									  		data.comName = comName
									  		return false
									  	}
									});
									let virPermId = data.permId;
									var imageIds = [];
									var imageUrlids = [];
									var removeUrlids = [];

									_this.ajaxDepart(data.orgId, data.virtualArchId, function (list) {
										data.departList = list;
										console.log(data,'111111111111')
										$("body").append(template.render(tpl.updateTpl)(data));
										//关闭弹窗
										$(".close-btn,.cancel-add-btn").on("click", function () {
											$(".dialog-wp").remove();
										});
										$(".del-btn").on("click", function () {
											$(this).closest(".photo-item").remove();
											if ($(".photo-item").length < 3) {
												$(".photo-btn").css("display", "block")
											}
										})
										// 身份类型选择
										$("#permType").on("change",function() {
											var idx = $("#permType").find("option:selected").attr('data-func');
											console.log($(this).val())
											virPermId = $(this).val()
											if($(this).val()){
												$(".funcList").show();
												UpdateFuncList(idx);
											}else{
												$(".funcList").hide()
											}
										})
										if($("#permType").val()){
											var idx = $("#permType").find("option:selected").attr('data-func');
											if(idx>=0){
												$(".funcList").show();
												UpdateFuncList(idx);
											}else{
												$(".funcList").hide()
											}
										}
										if ($(".photo-item").length == 3) {
											$(".photo-btn").css("display", "none");
										}
										if ($(".photo-item").length) {
											for (var i = 0; i < $(".photo-item").length; i++) {
												imageIds.push($(".photo-item")[i].getAttribute("data-imageid"));
											}
										}
										//上传识别图片
										$(".photo-file").on("change", function () {
											if (!$(".company-id").attr('com__id')) {
												layer.msg("请先选择企业!");
												return false;
											}
											var file = $(this)[0].files[0];
											var fileName = $(this)[0].value;
											var suffixIndex = fileName.lastIndexOf(".");
											var suffix = fileName.substring(suffixIndex + 1).toUpperCase();
											if ($(".photo-item").length == 3) {
												layer.msg("识别图片最多上传3张!");
												return false;
											}
											if (suffix != "BMP" && suffix != "JPG" && suffix != "JPEG" && suffix != "PNG" && suffix != "GIF") {
												layer.alert("请上传图片（格式BMP、JPG、JPEG、PNG等）!");
												return false;
											}
											lrz(file, {
												quality: 0.8, //设置压缩率
												width: 400
											}).then(function (results) {
												_this.upload(results.base64);
											});
										})
										//确认添加
										$(".sure-add-btn").on("click", function () {
											// console.log(imageIds);
											// console.log(imageUrlids);
											for (var i = 0; i < $(".photo-item").length; i++) {
												imageUrlids.push($(".photo-item")[i].getAttribute("data-imageid"));
											};
											removeUrlids = _this.array_diff(imageIds, imageUrlids);
											_this.submitAdd(virPermId,function () {
												$(".dialog-wp").remove();
												layer.msg("修改成功！")
												_this.againRenderTable();
											}, data.id, imageUrlids, removeUrlids);
										})
									})
								});
							})
						});
						table.on('tool(user)', function (obj) {
							console.log(obj.event); //点击事件
							console.log(obj.data, 'ddd');
							if(obj.event == 'readType') {
								layer.msg('功能权限：'+obj.data.funcListStr, {
									time: 20000, //20s后自动关闭
								});
							}
						});
						//详情
						$(".t-publish-btn").on("click", function () {
							var id = $(this).data("id");
							_this.ajaxDetail(id, function (data) {
								var data = data;
								_this.ajaxDepart(data.orgId, data.virtualArchId, function (list) {
									data.departList = list;
									var depName = '';
									$.each(data.departList,function(index,item){
									  	if(data.dept == item.id){
									  		depName = item.name
									  		data.depName = depName
									  		return false
									  	}
									});
									$("body").append(template.render(tpl.detailOne)(data));
								})

							})

						});
						//发卡
						$(".t-payment-btn").on("click", function () {
							var id = $(this).data("id");
							_this.ajaxDetail(id, function (data) {
								$("body").append(template.render(tpl.sendCardTpl)(data));
								//关闭弹窗
								$(".close-btn,.sure-detail-btn").on("click", function () {
									$(".dialog-wp").remove();
								});
								//确认添加
								$(".sure-add-btn").on("click", function () {
									_this.sendCard(id, function () {
										$(".dialog-wp").remove();
										layer.msg("发卡成功！")
										_this.againRenderTable();
									});
								});
							})
						});

						//收卡
						$(".t-collection-btn").on("click", function () {
							var cardId = $(this).data("cardid");
							var cardCode = $(this).data("cardcode")
							_this.deleteCard(cardId, cardCode, function () {
								layer.msg("收卡成功！")
								_this.againRenderTable();
							});
						});
						// 同步
						$(".t-info-btn").on("click", function () {
							var id = $(this).data("id");
							_this.ajaxInfoSame(function () {
								_this.againRenderTable();
							}, id)
						});
					}
				});

				//查询
				$('#conditionform  .search-btn').on('click', function () {

					_this.againRenderTable();
				});
			});
		},
		/**
		 * 手机号中间4位数字用*代替
		 * @param data 原始数据
		 */
		phoneLize: function(data){
			if(data){
				let start = data.slice(0, 3)
				let end = data.slice(-4)
				return start + '****' + end
			}
		},
		/**
		 * 导入账号数据
		 * @param length 判断是单项目还是多项目 ，为0多项目 不为0单项目
		 */
		exportFile: function (length,callback) {
			var _this = this;
			if (!!length) {
				callback && callback();
//				$("body").append(template.render(tpl.exportTplNo)({
//					companyList: companyList,
//					orgId:$("#conditionform  .single-orgid").attr('org__id'),
//					virAccountInfo: virAccountInfo,
//					virId: $("#conditionform #companyId").attr("com__id"),
//					virName: $("#conditionform #companyId").val()
//        }));
			} else {
				$("body").append(template.render(tpl.exportTpl)({
					orgList: orgList,
					companyList: companyList
				}));
			}
		},
		/**
		 * 导入用户请求
		 * @param orgId 项目id
		 * @param callback
		 */
		exportFileAjax: function (orgId, callback, virId) {
			var _this = this;
			var fileName = $("#excelFile").val();
			var extension = fileName.substring(fileName.lastIndexOf(".") + 1, fileName.length);
			var formData = new FormData();
			if (extension == "xlsx") {
				if (fileName == null || fileName == "") {
					layer.alert("数据导入为空,请按照模板填写资料后再导入!");
					return;
				};
		        formData.append("orgId", orgId);
		        if(virId){
		          formData.append("virId", virId);
		        }
				formData.append("excelFile", $("#excelFile")[0].files[0]);
				$.ajax({
					type: "post",
					url: $("#contextPath").val() + "/admin/appUser/importUserInfo",
					data: formData,
					cache: false, // 不缓存
					processData: false, // 告诉jQuery不要去处理发送的数据
					contentType: false, // 告诉jQuery不要去设置Content-Type请求头
					success: function (data) {
						if (data.code == '200') {
							layer.msg(data.msg);
							callback && callback();
							_this.againRenderTable();
						} else {
							layer.msg(data.msg);
							$(".dialog-wp").remove();
						}
					},
					error: function () {

						layer.msg('error')
					}
				});
			} else {
				layer.alert("请上传xlsx格式的文件");
			}
		},
		/**
		 * 删除模板
		 * @param id 模板id
		 * @param callback
		 */
		ajaxDelTemp: function (id, type, callback) {
			var str = "";
			if (type == "1") {
				str = "确认禁用?";
			} else if (type == "2") {
				str = "确认启用?";
			} else if (type == "3") {
				str = "确认删除?";
			}
			layer.confirm(str, {
				btn: ['确定', '取消']
			}, function (index, layero) {
				layer.close(index); //如果设定了yes回调，需进行手工关闭
				$.ajax({
					type: "post",
					url: $("#contextPath").val() + "/admin/appUser/updateConsumer",
					data: {
						"id": id,
						"type": type
					},
					success: function (data) {
						if (data.code == 200) {
							callback();
						} else {
							layer.msg(data.msg)
						}
					},
					error: function () {
						// layer.msg('系统繁忙...')
					}
				});
			}, function (index) {

			});
		},
		/*重新渲染table*/
		againRenderTable: function (option) {
			var obj = $.extend(true, {}, option);
			var type =  obj.type || ''
			var $orgId = $("#conditionform  .single-orgid");
			var orgId = $("#conditionform  #orgId").attr('org__id')
			if(type == 1){
				if(virAccountInfo){
					table.reload('testReload', {
						where: {
							orgId: $orgId.length?orgId:'',
							virtualArchId: $("#conditionform #companyId").attr("com__id"),
							mobile: '',
							userName: '',
							roleType: '',
							dept: ''
						},
						page: {
							curr: 1 //重新从第 1 页开始
						}
					});
				}else{
					table.reload('testReload', {
						where: {
							mobile: '',
							userName: '',
							roleType: '',
							orgId: $orgId.length?orgId:'',
							virtualArchId: '',
							dept: ''
						},
						page: {
							curr: 1 //重新从第 1 页开始
						}
					});
				}
			}else{
				table.reload('testReload', {
					where: {
						mobile: $("#conditionform .loginName").val(),
						userName: $("#conditionform .userName").val(),
						roleType: $("#conditionform .roleType").val(),
						orgId: orgId,
						virtualArchId: $("#companyId").attr('com__id') || '',
            dept: $("#departmentId").attr('dep__id') || '',
            isEnabled:  $("#conditionform .isEnabled").val()
					},
					page: {
						curr: 1 //重新从第 1 页开始
					}
				});
			}
		},
		//请求项目列表
		itemAjax: function () {
			$.ajax({
				type: "post",
				url: contextPath + "/admin/templ/getOrgList",
				success: function (data) {
					if (data.code == ERROK) {
						orgList = data.data;
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},

		//请求工号
		userNumberAjax: function () {
			$.ajax({
				type: "post",
				url: contextPath + "/admin/appUser/getUserNumber",
				success: function (data) {
					if (data.code == ERROK) {
						userNumber = data.data;
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},

		//请求权限组列表
		permissionListAjax: function (orgId, callback) {
			$.ajax({
				type: "post",
				url: contextPath + "/lingling/getDeviceGroupList",
				data: {
					pageSize: 1000,
					pageNo: 1,
					orgId: orgId
				},
				success: function (data) {
					if (data.code == ERROK) {
						callback(data.data)
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		// 添加权限用户关系
		setUserPerm: function (list, callback) {
			var userIds = list.join(";");
			$.ajax({
				type: "post",
				url: contextPath + "/lingling/setUserPerm",
				data: {
					groupId: $("#groupId").val(),
					userIds: userIds
				},
				success: function (data) {
					if (data.code == ERROK) {
						callback()
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		/**
		 * 请求详情
		 * @param id
		 * @param callback
		 */
		ajaxDetail: function (id, callback) {
			var _this = this;
			$.ajax({
				type: "post",
				url: contextPath + "/admin/appUser/getConsumerInfo",
				data: {
					id: id
				},
				success: function (data) {
					if (data.code == ERROK) {
						data.data.addressList = addressList;
						data.data.id = id;
						callback(data.data)
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		/**
		 * 新增或修改账号
		 * @param callback
		 * @param id
		 */
		submitAdd: function (virPermId,callback, id, imageUrlids, removeUrlids) {
			var _this = this;
			var formdata = new FormData();
			if (!!id) {
				formdata.append("id", id)
			}
			if(virPermId) {
				formdata.append("virPermId", virPermId)
			}
			//项目
			var orgId = $(".item-con #orgId").attr('org__id');
			if (!orgId) {
				layer.msg("请选择项目");
				return false;
			};
			formdata.append("orgId", orgId)

			// 企业
			var virtualArchId = $(".company-id").attr('com__id');
			if (!virtualArchId) {
				layer.msg("请选择企业");
				return false;
			};
			formdata.append("virtualArchId", $(".company-id").attr('com__id'));


			//手机号码
			var myreg = /^1[3456789]\d{9}$/;
			if (!$(".mobile-phone").val()) {
				layer.msg("请选择手机号码");
				return false;
			}
			if (!myreg.test($(".mobile-phone").val())) {
				layer.msg("请输入正确的手机号码！");
				return false;
			}
			formdata.append("mobilePhone", $(".mobile-phone").val())

			//姓名
			var name = $(".user-name").val()
			if (!name) {
				layer.msg("请输入姓名");
				return false;
			}
			if (_this.strlen(name) > 20) {
				layer.msg("姓名最多10个汉字");
				return false;
			}
			formdata.append("userName", $(".user-name").val())

			var userSex = $(".userSex").val()
			formdata.append("userSex", userSex)
			var email = $(".email").val();
			if(email){
				var myreg =/^(\w-*\.*)+@(\w-?)+(\.\w{2,})+$/;
				if(!myreg.test(email))
				{
					layer.msg("邮箱格式不正确");
					return false;
				}
			}
			formdata.append("email", email)
			//积分
			var integral = $(".integral-balance").val() || '';
			// if (!integral) {
			// 	layer.msg("请输入积分");
			// 	return false;
			// }
			formdata.append("integral", integral)

			//部门
			var dept = $(".dept").val() || '';
			// if (!dept) {
			// 	layer.msg("请选择部门");
			// 	return false;
			// }
			formdata.append("deptid", $(".dept").attr('dep__id') || '');
			formdata.append("deptStr", dept)

			//送餐地址
			var address = $(".dinner-address").val() || '';
			// if (!address) {
			// 	layer.msg("请选择送餐地址！");
			// 	return false;
			// }
			// if (_this.strlen(address) > 100) {
			// 	layer.msg("送餐地址最多50个汉字");
			// 	return false;
			// }
			formdata.append("dinnerAddress", address);


			let addimgUrls = "";
			// 识别图片
			for (var i = 0; i < $(".photo-item").length; i++) {
				if ($(".photo-item")[i].getAttribute("data-url")) {
					addimgUrls += $(".photo-item")[i].getAttribute("data-url") + ",";
				}
			}
			// console.log(addimgUrls);
			formdata.append("addimgUrls", addimgUrls);

			//类型
			formdata.append("userType", ($(".user-type:checked").data("status") || ''));
			if (!id) {
				_this.ajaxAdd(formdata, function () {
					callback();
				})
			} else {
				formdata.append("imageUrlids", imageUrlids.join(","));
				formdata.append("removeUrlids", removeUrlids.join(","));
				_this.ajaxUpdate(formdata, function () {
					callback();
				})
			}
		},
		/**
		 * 新增
		 * @param data
		 * @param callbck
		 */
		ajaxAdd: function (data, callback) {
			$.ajax({
				type: "post",
				url: $("#contextPath").val() + "/admin/appUser/saveUpdateUserInfo",
				data: data,
				cache: false, // 不缓存
				processData: false, // 告诉jQuery不要去处理发送的数据
				contentType: false, // 告诉jQuery不要去设置Content-Type请求头
				success: function (data) {
					if (data.code == 200) {

						callback();
					} else {
						layer.msg(data.msg)
					}
				},
				error: function () {
					// layer.msg('系统繁忙.....')
				}
			});
		},
		/**
		 * 修改
		 * @param data
		 * @param callbck
		 */
		ajaxUpdate: function (data, callback) {
			$.ajax({
				type: "post",
				url: $("#contextPath").val() + "/admin/appUser/saveUpdateUserInfo",
				data: data,
				cache: false, // 不缓存
				processData: false, // 告诉jQuery不要去处理发送的数据
				contentType: false, // 告诉jQuery不要去设置Content-Type请求头
				success: function (data) {
					if (data.code == 200) {

						callback();
					} else {
						layer.msg(data.msg)
					}
				},
				error: function () {
					// layer.msg('系统繁忙.....')
				}
			});
		},
		strlen: function (str) {
			var len = 0;
			for (var i = 0; i < str.length; i++) {
				var c = str.charCodeAt(i);
				//单字节加1
				if ((c >= 0x0001 && c <= 0x007e) || (0xff60 <= c && c <= 0xff9f)) {
					len++;
				} else {
					len += 2;
				}
			}
			return len;
		},
		/**
		 * 获取部门和地址
		 * @param id
		 */
		ajaxDepartAndAddress: function (id) {
			var _this = this;
			//获取部门
			$.ajax({
				type: "post",
				url: contextPath + "/admin/appUser/getDeptAndAddress",
				data: {
					type: 1
				},
				success: function (data) {
					if (data.code == ERROK) {
						departList = data.data;
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
			//获取地址
			$.ajax({
				type: "post",
				url: contextPath + "/admin/appUser/getDeptAndAddress",
				data: {
					type: 2
				},
				success: function (data) {
					if (data.code == ERROK) {
						addressList = data.data;
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		/**
		 * 获取部门和地址
		 * @param id
		 */
		ajaxDepartAndAddress_: function (orgId, type, callback) {
			var _this = this;
			//获取部门
			$.ajax({
				type: "post",
				url: contextPath + "/admin/appUser/getDeptAndAddress",
				data: {
					orgId: orgId,
					type: type
				},
				success: function (data) {
					if (data.code == ERROK) {
						if(callback != undefined && (typeof callback) == "function"){
							callback(data)
						}
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		/**
		 * 获取部门
		 * @param id
		 */
		ajaxDepart: function (orgId, virId, callback) {
			var _this = this;
			//获取部门
			$.ajax({
				type: "post",
				url: contextPath + "/admin/templ/getDept",
				data: {
					orgId: orgId,
					virId: virId
				},
				success: function (data) {
					if (data.code == ERROK) {
						callback(data.data)
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (error) {
					layer.msg('error')
				}
			});
			// //获取地址
			// $.ajax({
			// 	type: "post",
			// 	url: contextPath + "/admin/appUser/getDeptAndAddress",
			// 	data: {
			// 		type: 2
			// 	},
			// 	success: function (data) {
			// 		if (data.code == ERROK) {
			// 			addressList = data.data;
			// 		} else {
			// 			layer.msg(data.msg)
			// 		}
			// 	},
			// 	error: function (error) {
			// 		layer.msg('error')
			// 	}
			// });
		},
		/**
		 * 获取企业列表
		 * @param organizationId
		 */
		ajaxCompanyList: function (organizationId, callback) {
			var _this = this;
			//获取部门
			$.ajax({
				type: "post",
				url: contextPath + "/busi/property/getvirtualArchTypeOne",
				data: {
					organizationId: organizationId
				},
				success: function (data) {
					companyList = data;
					callback(companyList);
				},
				error: function (error) {
					layer.msg('error')
				}
			});
		},
		/**
		 * 上传人脸识别图片
		 * @param file file文件
		 */
		upload: function (clearBase64) {
			$.ajax({
				url: $("#contextPath").val() + "/member/validateImage",
				type: "POST",
				dataType: "json",
				data: {
					imageUrl: clearBase64,
					virtualArchId: $(".company-id").attr('com__id')
				},
				timeout: 30000,
				beforeSend: function (xhr) {

				},
				success: function (data) {
					if (data.flag) {
						$(".photo-list").append(template.render(tpl.photoTpl)(data));
						if ($(".photo-item").length == 3) {
							$(".photo-btn").css("display", "none")
						}
						$(".del-btn").on("click", function () {
							$(this).closest(".photo-item").remove();

							$(".photo-file").val("");
							if ($(".photo-item").length < 3) {
								$(".photo-btn").css("display", "block")
							}
						})
					} else {
						layer.msg(data.desc)
					}
				},
				error: function (xhr, textStatus) {

				}
			});
		},
		// 两个数组去重
		array_diff: function (a, b) {
			for (var i = 0; i < b.length; i++) {
				for (var j = 0; j < a.length; j++) {
					if (a[j] == b[i]) {
						a.splice(j, 1);
						j = j - 1;
					}
				}
			}
			return a;
		},
		/**
		 * 发卡
		 * @param id
		 * @param callback
		 */
		sendCard: function (id, callback) {
			if (!$(".cardNumber").val()) {
				layer.msg("请输入实体卡号");
				return false
			}
			$.ajax({
				url: $("#contextPath").val() + "/lingling/provideCard",
				type: "POST",
				data: {
					cardCode: $(".cardNumber").val(),
					userId: id
				},
				success: function (data) {
					if (data.code == ERROK) {
						callback();
					} else {
						layer.msg(data.msg)
					}
				},
				error: function (xhr, textStatus) {

				}
			});
		},
		/**
		 * 收卡
		 * @param id
		 * @param callback
		 */
		deleteCard: function (id, cardCode, callback) {
			var str = "确认收卡?";
			layer.confirm(str, {
				btn: ['确定', '取消']
			}, function (index, layero) {
				layer.close(index); //如果设定了yes回调，需进行手工关闭
				$.ajax({
					url: $("#contextPath").val() + "/lingling/recycleCard",
					type: "POST",
					data: {
						id: id,
						cardCode: cardCode
					},
					success: function (data) {
						if (data.code == ERROK) {
							callback();
						} else {
							layer.msg(data.msg)
						}
					},
					error: function (xhr, textStatus) {}
				});
			}, function (index) {});
		},
		/**
		 * 获取权限组下的用户列表
		 * @param id
		 * @param callback
		 */
		ajaxCustomerList: function (groupId) {
			$.ajax({
				url: $("#contextPath").val() + "/lingling/getGroupUser",
				type: "POST",
				data: {
					groupId: groupId
				},
				success: function (data) {
					if (data.code == ERROK) {
						if (data.data.length > 0) {
							// $(".hadPeople .set-account-num").html('');
							var str = "";
							var list = data.data;
							$.each(list, function (index, item) {
								str += "<label><input type='checkbox' name='personed' value='" + item.userId + "' checked='checked'><span>" + item.userName + "</span><span style='padding-left: 8px;'>" + item.mobile + "</span></label>"
							})
							$(".hadPeople").css("display", "block");
							$(".hadPeople .set-account-num").append(str);
						} else {
							$(".hadPeople").css("display", "none");
						}
					} else {
						// layer.msg(data.msg)
					}
				},
				error: function (xhr, textStatus) {

				}
			});
		},
		/**
		 * 信息同步
		 * @param id
		 * @param callback
		 */
		ajaxInfoSame: function (callback, userIds) {
			var str = "是否确认同步信息";
			layer.confirm(str, {
				btn: ['确定', '取消']
			}, function (index, layero) {
				layer.close(index); //如果设定了yes回调，需进行手工关闭
				$.ajax({
					url: $("#contextPath").val() + "/weixiao/syncEmployeeInfo",
					type: "POST",
					data: {
						orgId: $("#orgId").attr('org__id'),
						userIds: userIds
					},
					success: function (data) {
						if (data.code == ERROK) {
							callback();
						} else {
							layer.msg(data.msg)
						}
					},
					error: function (xhr, textStatus) {
						layer.msg("系统繁忙")
					}
				});
			}, function (index) {});

		},
		/**
     * 身份类型列表
     * @param callback
     * @param orgId
     */
    getPermList: function (orgId,callback) {
      $.ajax({
        type: "post",
        url: contextPath + "/admin/virPerm/virPermList",
        data: {
					orgId: orgId,
					permType: '1',
					pageSize: 100000,
					pageNo: 1
        },
        success: function (data) {
			preList = data.data;
          if (data.code == ERROK) {
						console.log(data.data,'身份类型列表')
						$("#permType").html("<option value=''>请选择身份类型</option>")
						let list = data.data
						let html = ''
            for(let i=0; i<list.length; i++){
              html += "<option value='"+list[i].id+"' data-func='"+list[i].funcList+"'>"+list[i].permName+"</option>"
            }
						$("#permType").append(html)
						callback(list)
          } else {
            layer.msg(data.msg)
          }
        },
        error: function (error) {
          layer.msg('error')
        }
      });
    }
	};
	api.init();
})

function boostImg(obj) {
	console.log(obj.src);
	$(".alert-bo").css("display", "block")
	$(".alert-bo img").attr("src", obj.src)
}

function closeAlert() {
	$(".alert-bo").css("display", "none")
}
