123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280 |
- 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 "<a onclick=houseYaohao('" + row.securityPerson.id + "','" + row.securityPerson.securityNum + "','"+ row.securityPerson.name + "') style='cursor:pointer' >房源摇号</a>";
- }
- };
-
- /**
- * 房源摇号
- * @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.length;i++){
- $("#communityList").append("<div style='cursor:pointer' onclick=houseSelect('" + yaohaoId + "','" + securityPersonId + "','" + roomType + "','" + communityArray[i].communityId + "') class='lottery-community-unit'><div class='lottery-people-name'>" + communityArray[i].communityName + "</div><div class='lottery-people-idcard'>剩余:" + communityArray[i].remainHouse + "</div></div>");
- }
- $('#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<this.length;i++)
- {
- if(this[i]!=this[dx])
- {
- this[n++]=this[i];
- }
- }
- this.length-=1;
- }
|