Няма описание

transferTimeSetting.js 3.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. var token = $.cookie("token");
  2. $(document).ready(function(){
  3. $.ajax({
  4. type:"get",
  5. url:huayi.config.callcenter_url + 'UserAccount/GetCallForwarding',
  6. async:true,
  7. dataType:'json',
  8. data:{
  9. token: token,
  10. },
  11. success:function(res){
  12. if(res.state.toLowerCase()=='success'){
  13. $('.tables').html('');
  14. $(res.data).each(function(i,n){
  15. $('<tr>'+
  16. '<th><a href="javaScript:;" class="removes" onclick="del(this)"><i class="fa fa-remove"></i></a>时间段'+ parseInt(i+1) +':</th>'+
  17. '<td>'+
  18. '<div class="timeBox">'+
  19. '<i class="fa fa-clock-o tub"></i>'+
  20. '<input type="text" class="test-item" id="usestrTime2" value="'+ n.starttime+'" />'+
  21. '</div> &nbsp;'+
  22. '<span>至</span> &nbsp;'+
  23. '<div class="timeBox">'+
  24. '<i class="fa fa-clock-o tub"></i>'+
  25. '<input type="text" class="test-item" id="usestrTime22" value="'+ n.endtime +'" name="starttime1" />'+
  26. '</div>'+
  27. '</td>'+
  28. '</tr>').appendTo('.tables');
  29. })
  30. layerdate()
  31. }
  32. }
  33. });
  34. //时间赋值 layerdate
  35. function layerdate(){
  36. lay('.test-item').each(function(){
  37. laydate.render({
  38. elem: this
  39. ,trigger: 'click'
  40. ,type: 'time'
  41. });
  42. });
  43. }
  44. $('#addto').click(function(){
  45. var trs=$('.tables tr').length,lths=parseInt(trs+1);
  46. console.log(trs);
  47. for(var i=trs;i<lths;i++){
  48. $('<tr>'+
  49. '<th><a href="javaScript:;" class="removes" onclick="del(this)"><i class="fa fa-remove"></i></a>时间段'+ parseInt(i+1) +':</th>'+
  50. '<td>'+
  51. '<div class="timeBox">'+
  52. '<i class="fa fa-clock-o tub"></i>'+
  53. '<input type="text" class="test-item" id="usestrTime2" />'+
  54. '</div> &nbsp;'+
  55. '<span>至</span> &nbsp;'+
  56. '<div class="timeBox">'+
  57. '<i class="fa fa-clock-o tub"></i>'+
  58. '<input type="text" class="test-item" id="usestrTime22" />'+
  59. '</div>'+
  60. '</td>'+
  61. '</tr>').appendTo('.tables');
  62. }
  63. layerdate()
  64. })
  65. $('#del').click(function(){
  66. $('.removes').show();
  67. })
  68. $('#save').click(function(){
  69. save()
  70. })
  71. })
  72. //删除
  73. function del(a){
  74. $(a).parent().parent('tr').remove();
  75. save();
  76. }
  77. //拼字符串
  78. function str(){
  79. var arr='';
  80. $('.tables tr').each(function(i,n){
  81. var htmlStr='';
  82. // console.log($(n).find('input'))
  83. $($(n).find('input')).each(function(k,m){
  84. if(htmlStr){
  85. htmlStr +=','
  86. htmlStr +=m.value;
  87. }else{
  88. htmlStr +=m.value;
  89. }
  90. })
  91. if(arr){
  92. arr +='|'
  93. arr +=htmlStr;
  94. }else{
  95. arr +=htmlStr;
  96. }
  97. })
  98. return arr
  99. }
  100. //保存提交
  101. function save(){
  102. $.ajax({
  103. type:"get",
  104. url:huayi.config.callcenter_url +'UserAccount/EditCallForwarding',
  105. async:true,
  106. dataType:'json',
  107. data:{
  108. token: token,
  109. timestr:str()
  110. },
  111. success:function(res){
  112. if(res.state.toLowerCase()=='success'){
  113. layer.msg(res.message)
  114. }
  115. }
  116. })
  117. }