
$(function () {
	var syscPerm = $("#perm-sysc").val();
	var ERROR_OK = 200;
	var contextPath = $("#contextPath").val();
	var table;
	var orgList = [];
	var addressList = [];
	var departList = [];
	var companyList = [];
	var userNumber="";
	var cheakedArr = []
	var messageType //短信：1 邮件：2
	template.config("escape", false);
	var orgId = "";
	pushOrgId = '' //推送时候传的统一orgId（在选中的用户中拿）
	var virAccountInfo = $("#virAccountInfo").val();
	
	$("#operate").click(function () {
		//operateSetting.search_fuzzy();
		layui.use('layer', function(){
			
			layer = layui.layer;
			$('#showVirPerm').empty();
			$('#showRole').empty();
			$("#role").empty();
			$("#virPerm").empty();
			operateSetting.getVirPerm(function(virList){
				operateSetting.getRoleList(function(roleList){
					operateSetting.getGoodsConfig(virList,roleList);
				});
			});
			layer_index=layer.open({
				type: 1,
				area: ['722px', '534px'], //宽高
				title: '配置流程', //不显示标题
				content: $('#block_1'), //捕获的元素，注意：最好该指定的元素要存放在body最外层，否则可能被其它的相对元素所影响
				cancel: function(){
					// layer.msg('捕获就是从页面已经存在的元素上，包裹layer的结构', {time: 5000, icon:6});
				}
			});
			$(".cancel-btn").on("click",function(){
				
				layer.closeAll(); 
			})
		});
	})
	$('#addVirPerm').click(function(){
		if($("#virPerm").val()===''||$("#virPerm").val()===null){
			return false;
		}
		$('#showVirPerm').append('<span class="del-select-btn delRole" data-role="'+$("#virPerm").val()+'">'+$("#virPerm").find("option:selected").text()+'<i class="del"></i></span>');
	})
	$("#showVirPerm").on('click','.delRole',function(){
		this.remove();
	});
	$('#addRole').click(function(){
		if($("#role").val()===''||$("#role").val()===null){
			return false;
		}
		$('#showRole').append('<span class="del-select-btn delRole" data-role="'+$("#role").val()+'">'+$("#role").find("option:selected").text()+'<i class="del"></i></span>');
	})
	$("#showRole").on('click','.delRole',function(){
		this.remove();
	});
	$('#sure').click(function(){
        let vir = '';
        let rol = '';
        $.each($('#showRole span'),function (item) {
            rol+=$(this).attr('data-role')+";";
        })
        $.each($('#showVirPerm span'),function (item) {
            vir+=$(this).attr('data-role')+";";
        })
        rol=rol.substring(0,rol.length-1);
        vir=vir.substring(0,vir.length-1);
        if(rol===''&&vir===''){
            layer.msg("请选择功能权限");
            return false;
        }
		operateSetting.saveOrUpdateGoodsConfig(vir,rol);
	})
var operateSetting={
	    //公司审核
		getVirPerm:function (callback) {
      let that=this;
			$.ajax({
				type: "post",
				url: $("#contextPath").val()+ "/admin/virPerm/getPermByCheckRole",
				data: {
					orgId: $("#block_1 #orgId").attr('org__id')
				},
				success: function(data){
					if(data.code== ERROR_OK){
						data.data.forEach(function (item) {
							$("#virPerm").append("<option value='"+item.id+"'>"+item.name+"</option>");
						})
						callback && callback(data.data)
					}else{
						layer.msg(data.msg);
					}
				},
				error: function(){
				}
			});
		},
		//物业
		getRoleList:function (callback) {
			let that=this;
			$.ajax({
				type: "post",
				url: $("#contextPath").val()+ "/admin/role/getRoleByOrgAndSysCode",
				data: {
					orgId: $("#block_1 #orgId").attr('org__id')
				},
				success: function(data){
					if(data.code== ERROR_OK){
						data.data.forEach(function (item) {
							$("#block_1 #role").append("<option value='"+item.ID+"'>"+item.NAME+"</option>");
						})
						callback && callback(data.data)
					}else{
						layer.msg(data.msg);
					}
				},
				error: function(){
				}
			});
		},
		saveOrUpdateGoodsConfig:function (virList,proList) {
			
			let that=this;
			$.ajax({
				type: "post",
				url: $("#contextPath").val()+ "/admin/virPerm/saveOrUpdateGoodsConfig",
				data: {
					orgId: $("#block_1 #orgId").attr('org__id'),
					passVirList:virList,
					passProList:proList
				},
				success: function(data){
					if(data.code== ERROR_OK){
						layer.close(layer_index);
					}else{
						layer.msg(data.msg);
					}
				},
				error: function(){
				}
			});
		},
		getGoodsConfig:function (virList,roleList) {
			let that=this;
			$.ajax({
				type: "post",
				url: $("#contextPath").val()+ "/admin/virPerm/getGoodsConfig",
				data: {
					orgId: $("#block_1 #orgId").attr('org__id')
				},
				success: function(data){
					if(data.code== ERROR_OK){
						var virtObj = {},roleObj ={};
						for(var i=0;i<virList.length;i++){
							virtObj[virList[i].id] = virList[i].name
						}
						//console.log('virtObj',virtObj)
						for(var j=0;j<roleList.length;j++){
							roleObj[roleList[j].ID] = roleList[j].NAME
						}
						//console.log('roleObj',roleObj)
						data.data.passVirList.forEach(function (val) {
							//console.log(virtObj[val.roleId]);
							$('#showVirPerm').append('<span class="del-select-btn delRole" data-role="'+val.roleId+'">'+virtObj[val.roleId]+'<i class="del"></i></span>');
						})
						data.data.passProList.forEach(function (val) {
							$('#showRole').append('<span class="del-select-btn delRole" data-role="'+val.roleId+'">'+roleObj[val.roleId]+'<i class="del"></i></span>');
						})
					}else{
						layer.msg(data.msg);
					}
				},
				error: function(){
				}
			});
		},
		search_fuzzy: function(){
			 $('body').on("input",'#block_1 #orgId',function(event){
		            var _this = $(this)
		            cjqt.search_fuzzy.event_input(_this,'org__id','org__span',$("#contextPath").val(),'/admin/templ/getOrgListByName')
		          });
		          $('body').on("focus",'#orgId',function(event){
		            var _this = $(this)
		            cjqt.search_fuzzy.event_focus(_this,'org__id','org__span',$("#contextPath").val(),'/admin/templ/getOrgListByName')
		          });
		          $('body').on('blur','#orgId',function(event) {
		            var _this = $(this)
		            cjqt.search_fuzzy.event_blur(_this,'org__id')
		          });
		          $('body').on('click','.select_wrap>.org__span', function(event) {
		            event.preventDefault();
		            event.stopPropagation();
		            /* Act on the event */
		            var _this = $(this)
		            cjqt.search_fuzzy.event_click(_this,'org__id','#orgId')
		            $('#showVirPerm').empty();
		            $('#showRole').empty();
		            $("#role").empty();
		            $("#virPerm").empty();
		            operateSetting.getVirPerm(function(virList){
						operateSetting.getRoleList(function(roleList){
							operateSetting.getGoodsConfig(virList,roleList);
						});
					});
		          });
		}
	}
	var tpl = {
		"checkTpl":  '<div class="dialog-wp">\
			<div class="mask"></div>\
			<div class="dialog dialog-check-con">\
				<div class="title-wp">\
					<span>提示</span>\
					<span class="close-btn"></button>\
				</div>\
				<div class="dialog-check-wp ">\
					<div class="dialog-choose-person-header">\
						<h2 class="check-title">\
							<% if(type ==1){%>\
								通过申请！\
							<% }else{ %>	\
								拒绝申请！\
							<%}%>\
						</h2>\
						<div class="check-reason-wp clearfloat">\
							<span class="tips">\
								<% if(type ==1){%>\
									通过意见\
								<% }else{ %>	\
									拒绝意见\
								<%}%>\
							</span>\
							<textarea class="check-reason" placeholder="请输入意见"></textarea>\
						</div>\
					</div>\
					<div class="dialog-choose-person-footer">\
						<button class="btn-red sure-operate" data-type="<%=type%>">\
							<% if(type ==1){%>\
								确认通过\
							<% }else{ %>	\
								确认拒绝\
							<%}%>\
						</button>\
					</div>\
			   </div>		\
			</div>\
		</div>	',
		"detailTpl":  '<div class="dialog-wp">\
			<div class="mask"></div>\
			<div class="dialog dialog-detail-con">\
				<div class="title-wp">\
					<span>详情</span>\
					<span class="close-btn"></button>\
				</div>\
				<div class="dialog-detail-wp ">\
					<div class="title-wrapper">\
						<span class="icon"></span>\
						<span class="code-wp">放行单编号：<%=releaseCode%></span>\
						<%if(releaseStatus==1){%>\
							<span class="status">待放行</span>\
						<%}else if(releaseStatus==5){%>\
							<span class="status">已放行</span>\
						<%}else if(releaseStatus==10){%>\
							<span class="status">审核中</span>\
						<%}else if(releaseStatus==15){%>\
							<span class="status">已拒绝</span>\
						<%}%>\
					</div>\
					<div class="detail-list">\
						<div class="detail-item">\
							<div class="tip">发起时间：</div>\
							<div class="content"><%=releaseCode%></div>\
						</div>\
						<div class="detail-item">\
							<div class="tip">发起人：</div>\
							<div class="content"><%=applyUserInfo%></div>\
						</div>\
						<div class="detail-item border-tip">\
							<div class="tip">校区：</div>\
							<div class="content"><%=companyName%></div>\
						</div>\
						<div class="detail-item">\
							<div class="tip">籍贯：</div>\
							<div class="content"><%=nativePlace%></div>\
						</div>\
						<div class="detail-item">\
							<div class="tip">人员类型：</div>\
							<div class="content"><%=personTypeName%></div>\
						</div>\
						<%if(personType==2){%>\
							<div class="detail-item">\
								<div class="tip">何时离开本市：</div>\
								<div class="content"><%=leaveCityTime%></div>\
							</div>\
							<div class="detail-item">\
								<div class="tip">何时返回本市：</div>\
								<div class="content"><%=returnCityTime%></div>\
							</div>\
							<div class="detail-item">\
								<div class="tip">春节假期居住地：</div>\
								<div class="content"><%=habitation%></div>\
							</div>\
						<%}%>\
						<div class="detail-item">\
							<div class="tip">有无去过疫情严重区域：</div>\
							<div class="content"><%=isToepidemicName%></div>\
						</div>\
						<div class="detail-item">\
							<div class="tip">是否有如下症状：</div>\
							<div class="content"><%=symptomName%></div>\
						</div>\
						<div class="detail-item remark-tip">\
							<div class="tip">其他情况备注：</div>\
							<div class="content"><%=releaseDesc%></div>\
						</div>\
						<div class="detail-item list-tip">\
							<%for(var i=0;i<operateDto.length;i++){%>\
								<div class="tip"><%=operateDto[i].auditTime%></div>\
								<div class="content"><%=operateDto[i].auditUser%><%if(i==0){%> <%=operateDto[i].auditResult%> <%}%><%=operateDto[i].remark%></div>\
							<%}%>\
						</div>\
						<div class="detail-item pass-tip">\
							<div class="pass-title">通行凭证</div>\
							<%for(var j=0;j<applyList.length;j++){%>\
								<div class="img-item">\
									<div class="img" style="background-image:url(<%=applyList[j].url%>)"></div>\
								</div>\
							<%}%> \
						</div>\
					</div>\
			   </div>		\
			</div>\
		</div>	',
	};
	
	var api = {
		init: function () {
			this.render();
			this.bindEvent();
		},
		render: function () {
			this.rendertable();
		},
		bindEvent: function () {
			var _this = this;	
			//重置
			$(".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});
				 }
				});
			$("#importTemplate").on("click",function(){
				_this.exportList();
			})
			_this.search_fuzzy()
		},

		// 模糊搜索事件
		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)
					 $('#showVirPerm').empty();
		            $('#showRole').empty();
		            $("#role").empty();
		            $("#virPerm").empty();
		            operateSetting.getVirPerm(function(virList){
						operateSetting.getRoleList(function(roleList){
							operateSetting.getGoodsConfig(virList,roleList);
						});
					});
				});

			}
			// 搜索联动
			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','laydate'], function () {
				table = layui.table;
				var layer = layui.layer,
				laydate = layui.laydate;
				//日期
				laydate.render({
					elem: '#date1'
				});
				laydate.render({
					elem: '#date2'
				});
				//方法级渲染
				table.render({
					elem: '#LAY_table_user',
					url: $("#contextPath").val() + "/release/list",
					method: "post",
					skin: 'nob' //行边框风格
						,
					even: true //开启隔行背景
						,
					size: 'lg' //小尺寸的表格
						,
					cols: [
						[{
							field: 'index',
							title: '序号',
							width: '80',
							templet: '#indexTpl'
						}, 
						{
							field: 'orgName',
							title: '校区',
							minWidth: 300
						},  
						//{
						//	field: 'companyName',
						//	title: '企业',
						//	minWidth: 300
						//},
						{
							field: 'releaseCode',
							title: '申请编号',
							minWidth: 250
						}, 
						{
							field: 'createTime',
							title: '申请时间',
							minWidth: 150
						}, 
						{
							field: 'applyUserInfo',
							title: '申请人',
							minWidth: 250
							
						}, 
						{
							field: 'symptomName',
							title: '审核状态',
							width: 120,
							align: 'center',
							templet: function (data) {
								
								
								//放行状态(1 待放行 5 已放行 10审核中 15 已拒绝)
								if(data.releaseStatus==1){
									  return '待通行'
								  }else if(data.releaseStatus==5){
									  return '已通行'
								  }else if(data.releaseStatus==10){
									  return '审核中'
								  }else if(data.releaseStatus==15){
									  return '已拒绝'
								  }	
								
							}
							
						},
						{
							field: 'nativePlace',
							title: '籍贯',
							minWidth: 250
						},
						{
							field: 'personTypeName',
							title: '人员类型',
							minWidth: 150
						},
						{
							field: 'isToepidemicName',
							title: '有无去过疫区严重地区',
							minWidth: 260
						},
						{
							field: 'symptomName',
							title: '是否有如下症状',
							minWidth: 220,
							
							
						},
						
						{
							title: '可操作',
							fixed: 'right',
							width: 200,
							align: 'center',
							templet: function (data) {
								
								var str = '';
								//放行状态(1 待放行 5 已放行 10审核中 15 已拒绝)
								if(data.releaseStatus==10){
									str += '<button class="t-btn t-red-btn t-publish-btn" data-id='+data.id+' data-type="1" data-roleid='+data.roleId+'>通过</button>';
		  							str += '<button class="t-btn t-white-btn t-reject-btn" data-id='+data.id+' data-type="2" data-roleid='+data.roleId+'>拒绝</button>'; 
									
								}
								str += '<button class="t-btn t-red-btn t-detail-btn" data-id=' + data.id + ' data-type="1" >详情</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"),
						applyType: 1
					},
					done: function (res, curr, count) {
						//通过
				    	$(".t-reject-btn").on("click",function(){
				    		var id = $(this).data("id");
				    		var type = $(this).data("type");
				    		var roleId = $(this).data("roleid")
				    		_this.showPassDialog(type,id,roleId)
				    	});
				    	//拒绝
				    	$(".t-publish-btn").on("click",function(){
				    		var id = $(this).data("id");
				    		var type = $(this).data("type");
				    		var roleId = $(this).data("roleid")
				    		_this.showPassDialog(type,id,roleId)
				    	});
						$(".t-detail-btn").on("click",function(){
							var id = $(this).data("id");
							_this.showDetailDialog(id)
						})			
					}
				});

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

					_this.againRenderTable();
				});
			});
		},
		/*重新渲染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"),
							applyUser: $(".loginName").val(),
							applyType: 1,
							billStartDate: $("#date1").val(),
							billEndDate: $("#date2").val(),
							releaseStatus:$(".releaseStatus").val()
						},
						page: {
							curr: 1 //重新从第 1 页开始
						}
					});
				}else{
					table.reload('testReload', {
						where: {
							
							orgId: $orgId.length?orgId:'',
							virtualArchId: '',
							applyUser: $(".loginName").val(),
							applyType: 1,
							billStartDate: $("#date1").val(),
							billEndDate: $("#date2").val(),
							releaseStatus:$(".releaseStatus").val()
						},
						page: {
							curr: 1 //重新从第 1 页开始
						}
					});
				}
			}else{
				table.reload('testReload', {
					where: {
						orgId: orgId,
						virtualArchId: $("#companyId").attr('com__id') || '',
						applyUser: $(".loginName").val(),
						applyType: 1,
						billStartDate: $("#date1").val(),
						billEndDate: $("#date2").val(),
						releaseStatus:$(".releaseStatus").val()
					},
					page: {
						curr: 1 //重新从第 1 页开始
					}
				});
			}
		},
		/**
		 * 显示拒绝或者通过弹窗
		 * @param type 1通过 2拒绝
		 * @param id
		 * @param roleId
		 */
		showPassDialog: function(type,id,roleId){
			var _this = this;
			$("body").append(template.render(tpl.checkTpl)({type: type}));
		    $(".sure-operate").on("click",function(){
			   var $dom = $(this).closest(".dialog-wp")
			   _this.ajaxEnterReason($dom,type,id,roleId);
		    })
			$(".close-btn").on("click",function(){
			   $(this).closest(".dialog-wp").remove();
		    });
		},
		/**
		 * 发送拒绝或者通过原因
		 * @param $dom
		 * @param type
		 * @param enterId
		 */
		ajaxEnterReason: function($dom,type,id,roleId){
			var _this = this;
			var reason = $dom.find(".check-reason").val();
			if(!reason && type ==2){
				layer.alert("请输入意见！");
				return false;
			}
			if(type==1){
				_this.ajaxPass(id,reason,$dom,roleId)
			}else{
				_this.ajaxFail(id,reason,$dom,roleId);
			}
		},
		/**
		 * 通过
		 * @paranm id
		 * @param remark
		 */
		ajaxPass: function(id,remark,$dom,roleId){
			
			var _this = this;
			var formData = new FormData();
			formData.append("id",id);
			formData.append("remark",remark);
			formData.append("roleId",roleId);
			$.ajax({
				   type: "post",
				   url: $("#contextPath").val()+ "/release/agree", 
				   data: formData,
				   cache: false,                      // 不缓存
			        processData: false,                // 告诉jQuery不要去处理发送的数据
			        contentType: false,     
				   success: function(data){
					   if(data.code== ERROR_OK){
							layer.msg("通过成功！")  ;
						   $dom.remove();
						   _this.againRenderTable();
					   }else{
						   layer.msg(data.msg);
					   }   
				   },
				   error: function(){   
				   }
		   });
		},
		/**
		 * 通过
		 * @paranm id
		 * @param remark
		 * @param $dom 弹窗dom
		 */
		ajaxFail: function(id,remark,$dom,roleId){
			var _this = this;
			$.ajax({
				   type: "post",
				   url: $("#contextPath").val()+ "/release/refuse", 
				   data: {
					   remark: remark,
					   id: id,
					   roleId:roleId
				   },
				   success: function(data){
					   if(data.code== ERROR_OK){
							layer.msg("拒绝成功！")  ;
						   $dom.remove();
						   _this.againRenderTable();
					   }else{
						   layer.msg(data.msg);
					   }   
				   },
				   error: function(){   
				   }
		   });
		},
		//获取详情
		showDetailDialog: function(id){
			$.ajax({
				   type: "post",
				   url: $("#contextPath").val()+ "/release/getDetail", 
				   data: {
					   id: id
				   },
				   success: function(data){
					   if(data.code== ERROR_OK){
						   let applyList = [];
						   if (!!data.data.applypicUrl) {
					            let applyArr = data.data.applypicUrl.split(";");
					            for (let i = 0; i < applyArr.length; i++) {
					              applyList.push({
					                url: applyArr[i].split("@")[0],
					                content: applyArr[i].split("@")[1],
					                showImg: false
					              });
					            }
					          }
						   data.data.applyList = applyList;
						   $("body").append(template.render(tpl.detailTpl)(data.data));
						    
							$(".close-btn").on("click",function(){
							   $(this).closest(".dialog-wp").remove();
						    });
					   }else{
						   layer.msg(data.msg);
					   }   
				   },
				   error: function(){   
				   }
		   });
		},
		exportList: function(){
			var $orgId = $("#conditionform  .single-orgid");
			var orgId = $("#conditionform  #orgId").attr('org__id')
			$.ajax({
				   type: "post",
				   url: $("#contextPath").val()+ "/release/exportApplyManage", 
				   data: {
					   orgId: orgId,
					   virtualArchId: $("#companyId").attr('com__id') || '',
						applyUser: $(".loginName").val(),
						applyType: 1,
						billStartDate: $("#date1").val(),
						billEndDate: $("#date2").val(),
						releaseStatus:$(".releaseStatus").val()
				   },
				   success: function(data){
					   if(data.code== ERROR_OK){
						   location.href = $("#contextPath").val() + "/upload/ApplyPassManage.xls";
					   }else{
						   layer.msg(data.msg);
					   }   
				   },
				   error: function(){   
				   }
		   });
		}
	};
	api.init();
})
