Нет описания

transferTimeSetting.js 3.0KB

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