var whzl = whzl || {}; whzl.basePath = '<%=basePath%>'; $("#housefold").click(function(){ if($("div[name='house']").is(':hidden')){ $("div[name='house']").slideToggle(); $('#housefold1').toggleClass('fa-angle-double-down fa-angle-double-up'); }else{ $("div[name='house']").slideToggle(); $('#housefold1').toggleClass('fa-angle-double-up fa-angle-double-down'); } }); $("#peoplefold").click(function(){ if($("div[name='people']").is(':hidden')){ $("div[name='people']").slideToggle(); $('#peoplefold1').toggleClass('fa-angle-double-down fa-angle-double-up'); }else{ $("div[name='people']").slideToggle(); $('#peoplefold1').toggleClass('fa-angle-double-up fa-angle-double-down'); } }); var yaohaoId = null; //人员属性 var securityPersonArray = null; var securityPersonIndex = -1; var currentIds = null; var isJumps = false; var yaohaoNos = null; $(function() { yaohaoId = $("#yaohaoId").val(); getSecurityPersonArray(); $('#yaohaoItemDataGrid').datagrid({ rownumbers:false, border:false, sortOrder:'desc', url:'yaohaoAction_listYaohaoItemByYaohaoId?yaohaoItem.yaohao.id='+yaohaoId, checkOnSelect:true, selectOnCheck:false, loadFilter:function(result){ if(result.success){ return result.obj; }else{ $.messager.alert("提示",result.message); return ; } } }); }); /**房屋地址*/ var houseAddressFormatter = function(value , row , index){ if(row.house!=null){ return row.house.address; }else{ return ""; } }; /**人员姓名*/ var securityPersonNameFormatter = function(value , row , index){ if(row.securityPerson!=null){ return row.securityPerson.name; }else{ return ""; } }; /**人员IdCard*/ var securityPersonIdCardFormatter = function(value , row , index){ if(row.securityPerson!=null){ return row.securityPerson.idCard; }else{ return ""; } }; /**房屋摇号*/ var houseYaohaoFormatter = function(value , row , index){ if(row.house!=null){ return ""; }else{ return "房源摇号"; } }; /** * 房源摇号 * @param id * @return */ var houseYaohao = function(securityPersonId,securityNum,securityPersonName){ var roomType = null; if(securityNum >=3){ roomType = 2; }else{ roomType = 1; } $.ajax({ type: "post",//使用post方法访问后台 dataType: "json",//返回json格式的数据 url: "yaohaoAction_listCommunityByYaohaoId",//要访问的后台地址 data:{"yaohaoId":yaohaoId ,"roomType" :roomType }, success: function(msg){//msg为返回的数据,在这里做数据绑定 if(msg.success){ communityArray = msg.obj.rows; $("#communityList").children().remove(); $("#currentPersonName").text(securityPersonName); if(securityNum >= 3){ $("#currentRoomType").text("二居室"); $("#currentRoomType1").text("二居室"); }else{ $("#currentRoomType").text("一居室"); $("#currentRoomType1").text("一居室"); } for(i=0;i
" + communityArray[i].communityName + "
剩余:" + communityArray[i].remainHouse + "
"); } $('#communitySelect').modal(); } } }); } var houseSelect = function(yaohaoId,securityPersonId,roomType,communityId){ $("#houseYaohaoDialog").dialog( { href:"yaohaoAction_houseYaohao?yaohaoId=" + yaohaoId + "&securityPersonId=" + securityPersonId + "&roomType=" + roomType + "&communityId=" + communityId , } ); /*$("#houseYaohaoDialog").modal({ remote:"yaohaoAction_houseYaohao?yaohaoId=" + yaohaoId + "&securityPersonId=" + securityPersonId + "&roomType=" + roomType + "&communityName=" + communityName });*/ } //点击开始摇号 $("#securityPersonBegin").click( function(){ if(isJumps == false){ isJumps = true; jumps(); } } ); //点击停止摇号 $("#securityPersonOK").click( function(){ if(isJumps == true){ isJumps = false; var sum = GetRandomNum(securityPersonArray.length,securityPersonArray.length*2); $('#currentSecurityPersonName').text(""); $('#currentYaohaoNos').text(""); stops(sum); } } ); //根据摇号id获取人员列表 var getSecurityPersonArray = function(){ $.ajax({ type: "post",//使用post方法访问后台 dataType: "json",//返回json格式的数据 url: "yaohaoAction_listSecurityPersonByYaohao",//要访问的后台地址 data:{"yaohao.id":yaohaoId }, success: function(msg){//msg为返回的数据,在这里做数据绑定 if(msg.success){ securityPersonArray = msg.obj.rows; if(securityPersonArray[0] != null ){ currentIds = securityPersonArray[0].id; } yaohaoNos = msg.obj.total; } } }); } //获取房源数组中下一个元素的id var getNextIds = function(){ if(securityPersonArray != null && securityPersonArray.length >0){ if(securityPersonIndex >= securityPersonArray.length-1 ){ securityPersonIndex = 0; }else{ securityPersonIndex++; } return securityPersonArray[securityPersonIndex].id; } } var jumps = function(){ if(!isJumps) { return; }else{ $("#securityPerson_" + currentIds ).removeClass('active'); currentIds = getNextIds(); $("#securityPerson_" + currentIds ).addClass('active'); setTimeout("jumps()",30); } } var stops = function(count){ if(count == 0){ setTimeout("reviewSecurityPerson()",400); return ; }else{ $("#securityPerson_" + currentIds ).removeClass('active'); currentIds = getNextIds(); $("#securityPerson_" + currentIds ).addClass('active'); count--; setTimeout("stops("+ count + ")",30 + 400/count); } } var reviewSecurityPerson = function (){ yaohaoNos++; $.ajax({ type: "post",//使用post方法访问后台 dataType: "json",//返回json格式的数据 url: "yaohaoAction_updateYaohaoItem1",//要访问的后台地址 data:{"yaohao.id":yaohaoId , "securityPerson.id":currentIds , "yaohaoNo":yaohaoNos }, success: function(msg){//msg为返回的数据,在这里做数据绑定 if(msg.success){ $('#yaohaoItemDataGrid').datagrid('reload'); //$('#currentSecurityPersonName').text(msg.obj.securityPerson.name); //$('#currentYaohaoNos').text(msg.obj.yaohaoNo); } } }); $('#currentSecurityPersonName').text($("#securityPersonName_" + currentIds ).text()); $('#currentYaohaoNos').text(yaohaoNos); $("#securityPerson_" + currentIds ).removeClass('active'); $("#securityPerson_" + currentIds ).addClass('ignore'); $('#securityPersonstop').modal(); securityPersonArray.remove(securityPersonIndex); } //获取随机数 function GetRandomNum(Min,Max) { var Range = Max - Min; var Rand = Math.random(); return(Min + Math.round(Rand * Range)); } /* * 方法:Array.remove(dx) 通过遍历,重构数组 * 功能:删除数组元素. * 参数:dx删除元素的下标. */ Array.prototype.remove=function(dx) { if(isNaN(dx)||dx>this.length){return false;} for(var i=0,n=0;i