Нет описания

joinTask.js 7.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. /**
  2. * 给计划分配坐席
  3. * */
  4. var loadIndex;
  5. $(function() {
  6. getTaskLits(); //获取全部任务
  7. });
  8. //获取全部任务
  9. function getTaskLits() {
  10. var wURL = '';
  11. var isLogin = helper.request.queryString("isLogin");//是否是签入
  12. if(isLogin === "true"){
  13. wURL = 'callcenterapi/api/autocallouttask/getqrjoinlist';
  14. }else{
  15. wURL = 'callcenterapi/api/autocallouttask/getjoinlist';
  16. }
  17. $.ajax({
  18. type: "get",
  19. url: huayi.config.callcenter_url + wURL,
  20. dataType: 'json',
  21. async: true,
  22. beforeSend: function() { //触发ajax请求开始时执行
  23. loadIndex = layer.load();
  24. },
  25. data: {
  26. },
  27. success: function(data) {
  28. layer.close(loadIndex);
  29. if(data.state.toLowerCase() === "success") {
  30. data = data.data;
  31. $('#task_lists').html('');
  32. if(data && data.length > 0) {
  33. $.each(data, function(i, v) {
  34. $('#task_lists').append('<div class="col-sm-12 clearfix">'+
  35. '<div class="seat_item" id="seat_item_'+ v.id +'">'+
  36. '<ul class="seat_content clearfix">'+
  37. '<li><span>任务名称:</span><span>'+ v.taskname +'</span></li>'+
  38. '<li><span>创建人:</span><span>'+ v.createusercode +'</span></li>'+
  39. '<li><span>任务量:</span><span style="color: red">'+ v.totalnum +'条</span></li>'+
  40. '<li><span>剩余:</span><span style="color: red">'+ v.surplusnum +'条</span></li>'+
  41. '<li><span>接通:</span><span style="color: red">'+ v.successnum +'条</span></li>'+
  42. // '<li><span>成交:</span><span style="color: #f0f">20条</span></li>'+
  43. '<li><span>'+ formatterbfType(v.bftype) +':</span><span>'+ v.bfnum +'</span></li>'+
  44. '<li style="width: 100%;"><span>呼叫方式:</span><span>'+ formattercallType(v.calltype) +'</span></li>'+
  45. '<li style="width: 100%;"><span>起止日期:</span><span>'+ v.starttime +' 到 '+ v.endtime +'</span></li>'+
  46. '<li style="width: 100%;"><span>说明备注:</span><span>'+ (v.taskremark == null ? '' : v.taskremark) +'</span></li>'+
  47. '</ul>'+
  48. '<button id="btn_join_'+ v.id +'" type="button" class="btn btn-primary join_btn">立即参与</button>'+
  49. '</div>'+
  50. '</div>');
  51. //0未参与任务,1参与任务
  52. if(v.joinflag === 1){
  53. $('#seat_item_'+ v.id).addClass('seat_item_active');
  54. $('#btn_join_'+ v.id).text('取消参与');
  55. }
  56. });
  57. $('.join_btn').on('click', joinChange);
  58. }else{
  59. $('#task_lists').append('<p class="text-center text-warning">暂无任务信息!</p>');
  60. }
  61. }
  62. },
  63. error: function(textStatus) {
  64. layer.close(loadIndex);
  65. layer.confirm('网络繁忙,请稍后再试...', {
  66. icon: 7,
  67. closeBtn: 0,
  68. btn: ['确定'] //按钮
  69. });
  70. },
  71. complete: function(XMLHttpRequest, textStatus) {
  72. layer.close(loadIndex);
  73. if(textStatus == 'timeout') {
  74. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  75. xmlhttp.abort();
  76. layer.confirm('网络超时,请稍后再试...', {
  77. icon: 7,
  78. closeBtn: 0,
  79. btn: ['确定'] //按钮
  80. });    
  81. }
  82. },
  83. });
  84. }
  85. //是否参与
  86. function joinChange() {
  87. var tid = $(this).attr('id') && $(this).attr('id').split('btn_join_')[1];
  88. switch($(this).text()) {
  89. case "立即参与":
  90. var self = this;
  91. var seatItemEl = $('#task_lists').find('.seat_item_active');
  92. if(seatItemEl.length > 0){
  93. //其他先取消参与 再让当前参与
  94. var curTid = seatItemEl.find('.join_btn').attr('id').split('btn_join_')[1];
  95. seatItemEl.removeClass('seat_item_active');
  96. seatItemEl.find('.join_btn').text('立即参与');
  97. joinNow(curTid, 0).then(function(){
  98. $(self).parent().addClass('seat_item_active');
  99. $(self).text('取消参与');
  100. joinNow(tid, 1);
  101. });
  102. }else{
  103. $(self).parent().addClass('seat_item_active');
  104. $(self).text('取消参与');
  105. joinNow(tid, 1);
  106. }
  107. break;
  108. case "取消参与":
  109. $(this).text('立即参与');
  110. $('#task_lists').find('.seat_item').removeClass('seat_item_active');
  111. joinNow(tid, 0);
  112. break;
  113. }
  114. }
  115. /**
  116. * 格式化呼叫方式
  117. * option type值
  118. */
  119. function formattercallType(option) {
  120. //0 不播放语音直接转坐席 1 播放语音后转坐席 2 播放语音后按1键转坐席
  121. var str = ""
  122. switch(option + '') {
  123. case '0':
  124. str = "不播放语音直接转坐席";
  125. break;
  126. case '1':
  127. str = "播放语音后转坐席";
  128. break;
  129. case '2':
  130. str = "播放语音后按1键转坐席";
  131. break;
  132. default:
  133. str = "不播放语音直接转坐席";
  134. break;
  135. }
  136. return str;
  137. }
  138. /**
  139. * 格式化并发类型
  140. * option type值
  141. */
  142. function formatterbfType(option) {
  143. //0 并发数 1 进号码速率
  144. var str = ""
  145. switch(option + '') {
  146. case '0':
  147. str = "并发数";
  148. break;
  149. case '1':
  150. str = "进号码速率";
  151. break;
  152. }
  153. return str;
  154. }
  155. /**
  156. * 立即参与
  157. * taskid 任务id
  158. * joinflag 参与标志(1为参与,0为不参与)
  159. */
  160. function joinNow(taskid, joinflag) {
  161. var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
  162. $.ajax({
  163. type: "post",
  164. url: huayi.config.callcenter_url + "callcenterapi/api/autocall/joinprecall",
  165. dataType: 'json',
  166. async: true,
  167. data: {
  168. taskid: taskid,// 是 string 任务id
  169. agentid: window.localStorage.getItem('userCode'),// 是 string 坐席工号
  170. joinflag: joinflag,// 是 int 参与标志(1为参与,0为不参与)
  171. },
  172. success: function(data) {
  173. layer.close(loadIndex);
  174. if(data.state.toLowerCase() === "success") {
  175. if(joinflag === 1){
  176. var index = parent.layer.getFrameIndex(window.name);
  177. parent.layer.close(index);
  178. parent.layer.msg("参与成功!");
  179. parent.getTaskRealInfo();//更新右上角任务信息
  180. updateSeatRealIngo(taskid);//更新自动外呼监控/外呼分配/我的呼叫任务
  181. }else{
  182. parent.layer.msg("取消成功!");
  183. parent.getTaskRealInfo();//更新右上角任务信息
  184. updateSeatRealIngo(taskid);//更新自动外呼监控/外呼分配/我的呼叫任务
  185. }
  186. }
  187. dtd.resolve(); // 改变Deferred对象的执行状态
  188. },
  189. error: function(textStatus) {
  190. layer.close(loadIndex);
  191. layer.confirm('网络繁忙,请稍后再试...', {
  192. icon: 7,
  193. closeBtn: 0,
  194. btn: ['确定'] //按钮
  195. });
  196. },
  197. complete: function(XMLHttpRequest, textStatus) {
  198. layer.close(loadIndex);
  199. if(textStatus == 'timeout') {
  200. var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp");
  201. xmlhttp.abort();
  202. layer.confirm('网络超时,请稍后再试...', {
  203. icon: 7,
  204. closeBtn: 0,
  205. btn: ['确定'] //按钮
  206. });    
  207. }
  208. },
  209. });
  210. return dtd.promise(); // 返回promise对象
  211. }
  212. /**
  213. * 更新自动外呼监控/外呼分配/我的呼叫任务
  214. * taskid任务id
  215. */
  216. function updateSeatRealIngo(taskid){
  217. var curW = top.$("iframe:visible")[0].contentWindow;
  218. var curC = top.$("iframe:visible").contents();
  219. if(curC.find('#autoCallMonitor').length > 0){
  220. // curW.location.reload(true);//刷新页面
  221. curW.getTaskSeats(taskid);//更新参与任务的坐席
  222. curW.getTaskDetails(taskid);//更新任务监控信息
  223. }
  224. if(curC.find('#outBoundAllo').length > 0){
  225. curW.setPersonInfos(taskid);//更新外呼分配 参与坐席
  226. }
  227. if(curC.find('#myCallTaskManage').length > 0){
  228. curW.initTable();//更新我的呼叫任务
  229. }
  230. }