/** * 给计划分配坐席 * */ var loadIndex; $(function() { getTaskLits(); //获取全部任务 }); //获取全部任务 function getTaskLits() { var wURL = ''; var isLogin = helper.request.queryString("isLogin");//是否是签入 if(isLogin === "true"){ wURL = 'callcenterapi/api/autocallouttask/getqrjoinlist'; }else{ wURL = 'callcenterapi/api/autocallouttask/getjoinlist'; } $.ajax({ type: "get", url: huayi.config.callcenter_url + wURL, dataType: 'json', async: true, beforeSend: function() { //触发ajax请求开始时执行 loadIndex = layer.load(); }, data: { }, success: function(data) { layer.close(loadIndex); if(data.state.toLowerCase() === "success") { data = data.data; $('#task_lists').html(''); if(data && data.length > 0) { $.each(data, function(i, v) { $('#task_lists').append('
暂无任务信息!
'); } } }, error: function(textStatus) { layer.close(loadIndex); layer.confirm('网络繁忙,请稍后再试...', { icon: 7, closeBtn: 0, btn: ['确定'] //按钮 }); }, complete: function(XMLHttpRequest, textStatus) { layer.close(loadIndex); if(textStatus == 'timeout') { var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp"); xmlhttp.abort(); layer.confirm('网络超时,请稍后再试...', { icon: 7, closeBtn: 0, btn: ['确定'] //按钮 }); } }, }); } //是否参与 function joinChange() { var tid = $(this).attr('id') && $(this).attr('id').split('btn_join_')[1]; switch($(this).text()) { case "立即参与": var self = this; var seatItemEl = $('#task_lists').find('.seat_item_active'); if(seatItemEl.length > 0){ //其他先取消参与 再让当前参与 var curTid = seatItemEl.find('.join_btn').attr('id').split('btn_join_')[1]; seatItemEl.removeClass('seat_item_active'); seatItemEl.find('.join_btn').text('立即参与'); joinNow(curTid, 0).then(function(){ $(self).parent().addClass('seat_item_active'); $(self).text('取消参与'); joinNow(tid, 1); }); }else{ $(self).parent().addClass('seat_item_active'); $(self).text('取消参与'); joinNow(tid, 1); } break; case "取消参与": $(this).text('立即参与'); $('#task_lists').find('.seat_item').removeClass('seat_item_active'); joinNow(tid, 0); break; } } /** * 格式化呼叫方式 * option type值 */ function formattercallType(option) { //0 不播放语音直接转坐席 1 播放语音后转坐席 2 播放语音后按1键转坐席 var str = "" switch(option + '') { case '0': str = "不播放语音直接转坐席"; break; case '1': str = "播放语音后转坐席"; break; case '2': str = "播放语音后按1键转坐席"; break; default: str = "不播放语音直接转坐席"; break; } return str; } /** * 格式化并发类型 * option type值 */ function formatterbfType(option) { //0 并发数 1 进号码速率 var str = "" switch(option + '') { case '0': str = "并发数"; break; case '1': str = "进号码速率"; break; } return str; } /** * 立即参与 * taskid 任务id * joinflag 参与标志(1为参与,0为不参与) */ function joinNow(taskid, joinflag) { var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象 $.ajax({ type: "post", url: huayi.config.callcenter_url + "callcenterapi/api/autocall/joinprecall", dataType: 'json', async: true, data: { taskid: taskid,// 是 string 任务id agentid: window.localStorage.getItem('userCode'),// 是 string 坐席工号 joinflag: joinflag,// 是 int 参与标志(1为参与,0为不参与) }, success: function(data) { layer.close(loadIndex); if(data.state.toLowerCase() === "success") { if(joinflag === 1){ var index = parent.layer.getFrameIndex(window.name); parent.layer.close(index); parent.layer.msg("参与成功!"); parent.getTaskRealInfo();//更新右上角任务信息 updateSeatRealIngo(taskid);//更新自动外呼监控/外呼分配/我的呼叫任务 }else{ parent.layer.msg("取消成功!"); parent.getTaskRealInfo();//更新右上角任务信息 updateSeatRealIngo(taskid);//更新自动外呼监控/外呼分配/我的呼叫任务 } } dtd.resolve(); // 改变Deferred对象的执行状态 }, error: function(textStatus) { layer.close(loadIndex); layer.confirm('网络繁忙,请稍后再试...', { icon: 7, closeBtn: 0, btn: ['确定'] //按钮 }); }, complete: function(XMLHttpRequest, textStatus) { layer.close(loadIndex); if(textStatus == 'timeout') { var xmlhttp = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHttp"); xmlhttp.abort(); layer.confirm('网络超时,请稍后再试...', { icon: 7, closeBtn: 0, btn: ['确定'] //按钮 }); } }, }); return dtd.promise(); // 返回promise对象 } /** * 更新自动外呼监控/外呼分配/我的呼叫任务 * taskid任务id */ function updateSeatRealIngo(taskid){ var curW = top.$("iframe:visible")[0].contentWindow; var curC = top.$("iframe:visible").contents(); if(curC.find('#autoCallMonitor').length > 0){ // curW.location.reload(true);//刷新页面 curW.getTaskSeats(taskid);//更新参与任务的坐席 curW.getTaskDetails(taskid);//更新任务监控信息 } if(curC.find('#outBoundAllo').length > 0){ curW.setPersonInfos(taskid);//更新外呼分配 参与坐席 } if(curC.find('#myCallTaskManage').length > 0){ curW.initTable();//更新我的呼叫任务 } }