/*发送短信*/


/*发送邮件*/
$("#sendEmail").on("click",function(){
//console.log("send mail");
var customerArrEmail = "";
$("input[name='selectCustomer']").each(function(){
if( $(this).prop("checked")){
var customerEmail = $(this).parent().parent().find("td:eq(3)").find("input").val();
if(customerEmail != "")
customerArrEmail += customerEmail+";";
}
});
console.log(customerArrEmail);
$("#emailVal").val(customerArrEmail);
$("#phoneVal").val("");
$("#sendOption").submit();
});

/*发送短信*/
$("#sendPhone").on("click",function(){
var customerArrPhone = "";
$("input[name='selectCustomer']").each(function(){
if( $(this).prop("checked")){
var customerPhone = $(this).parent().parent().find("td:eq(2)").html();
if(customerPhone != "")
customerArrPhone += customerPhone+";";
}
});
console.log(customerArrPhone);
if(customerArrPhone == ""){
customerArrPhone = "phone";
}
$("#phoneVal").val(customerArrPhone);
$("#emailVal").val("");
$("#sendOption").submit();
});

/*创建线索*/
$("#btn_createsales").on("click",function(){
location.href = "${rc.contextPath}/saleclues/new";
});

/*得到checkbox中所选择的客户Id */
function getSelectedIds(){
  var customerArr = [];
  if($("#allCheck").prop("checked")){
  $("input[name='hobby']").each(function(){
/* var customerId = $(this).val();
cu stomerArr += customerId+",";*/
customerArr.push($(this).val());
   });
  }else{
  $("input[name='hobby']").each(function(){
  if( $(this).prop("checked")){
/* var customerId = $(this).val();
cus tomerArr += customerId+",";*/
customerArr.push($(this).val());
}
   });
  }
  return customerArr.join(",");
}


/*分配 */
var d;
$('#allotsaleclues').click(function(){
d = dialog(this);
d.open();
});
$("#confirmButton").click(function(){
  var selectedIds = getSelectedIds();
  if(selectedIds != ""){
  $.ajax({
  url:"<c:url value='/saleclues/allotsaleclues'/>",
  type:"post",
  dataType:"json",
  data:{
  selectedIds:selectedIds,
  newOrgId:3
  },
  success:function(data){
  if(data.type == "1"){
  console.log('bb');
  //alert(data.msg);
  d.close();
  }else
     alert(data.msg);
  }
  })
  }else
               alert("请选择数据");  
});
$("#cancelButton").click(function(){
d.close();
})
/*分配 */

/*回收*/
var d2;
$('#recyclesaleclues').click(function(){
d2 = dialog(this);
d2.open();
});
$("#confirmButton2").click(function(){
  var selectedIds = getSelectedIds();
  if(selectedIds != ""){
  $.ajax({
  url:"<c:url value='/saleclues/recyclesaleclues'/>",
  type:"post",
  dataType:"json",
  data:{
  selectedIds:selectedIds
  },
  success:function(data){
  if(data.type == "1"){
  console.log('bb');
  //alert(data.msg);
  d2.close();
  }else
     alert(data.msg);
  }
  })
  }else
               alert("请选择数据");  
});
$("#cancelButton2").click(function(){
d2.close();
})
/*回收 */

/*关闭*/
var d3;
$('#closesaleclues').click(function(){
d3 = dialog(this);
d3.open();
});
$("#confirmButton3").click(function(){
  var selectedIds = getSelectedIds();
  if(selectedIds != ""){
  $.ajax({
  url:"<c:url value='/saleclues/closesaleclues'/>",
  type:"post",
  dataType:"json",
  data:{
  selectedIds:selectedIds,
  reason:'客户反悔了'
  },
  success:function(data){
  if(data.type == "1"){
  console.log('bb');
  //alert(data.msg);
  d3.close();
  }else
     alert(data.msg);
  }
  })
  }else
               alert("请选择数据");  
});
$("#cancelButton3").click(function(){
d3.close();
})
/*关闭*/



你可能感兴趣的:(短信)