| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295 |
- /**
- * 给计划分配坐席
- * */
- var arruser = []; //分配的坐席数组
- var groupLists = []; //坐席組数组
- var rolesLists = []; //角色数组
- var loadIndex;
- $(function() {
- var edit_id = helper.request.queryString("edit_id");
- //获取坐席组
- $.when(getGroups(), getRoles()).then(function() {
- getSeatLists(); //获取全部坐席
- });
- $('#sc_btns').on('click', getSeatLists);
- if(edit_id) {
- $(document).on('click', '#allocationGoodTask', ensureAllot);
- }
- });
- //获取全部坐席
- function getSeatLists() {
- $.ajax({
- type: "get",
- url: huayi.config.callcenter_url + "signtokenapi/api/useraccount/getseatlist",
- dataType: 'json',
- async: true,
- beforeSend: function() { //触发ajax请求开始时执行
- loadIndex = layer.load();
- },
- data: {
- key: $('#allocation_Name').val(),//否 string 模糊查询,坐席工号或坐席名字
- },
- success: function(data) {
- layer.close(loadIndex);
- if(data.state.toLowerCase() === "success") {
- data = data.data;
- $('#seat_lists').html('');
- arruser = [];
- if(data && data.length > 0) {
- $.each(data, function(i, v) {
- arruser.push(v.usercode);
- $('#seat_lists').append('<div class="col-md-6 clearfix" id="seatItem_' + v.id + '">' +
- '<div class="seat_item seat_item_active" data-userCode="' + v.usercode + '">' +
- '<div class="seat_img">' +
- '<img id="headImg_' + v.id + '" class="img-circle" src="' + v.head_small_img + '" alt="头像" />' +
- '</div>' +
- '<ul class="seat_content clearfix">' +
- '<li><span>工号:</span><span>' + v.usercode + '</span></li>' +
- '<li><span>姓名:</span><span>' + v.username + '</span></li>' +
- '<li><span>用户类型:</span><span>' + formatterType(v.type) + '</span></li>' +
- '<li><span>坐席组:</span><span>' + formatterGroups(groupLists, v.group) + '</span></li>' +
- '<li><span>角色:</span><span>' + formatterGroups(rolesLists, v.role_id) + '</span></li>' +
- '<li><span>性别:</span><span>' + formatterNull(v.sex) + '</span></li>' +
- '<li><span>手机:</span><span>' + v.mobile + '</span></li>' +
- '<li><span>邮箱:</span><span>' + formatterNull(v.mail) + '</span></li>' +
- '<li><span>入职时间:</span><span>' + formatterNull(v.entrytime) + '</span></li>' +
- '<li><span>转正时间:</span><span>' + formatterNull(v.transfertime) + '</span></li>' +
- '</ul>' +
- '</div>' +
- '</div>');
- //头像
- var ipUrl = v.head_small_img;
- if(ipUrl) {
- $('#headImg_' + v.id).attr('src', ipUrl);
- } else {
- $('#headImg_' + v.id).attr('src', '');
- }
- });
- $('.seat_item').on('click', changeActive);
- }else{
- $('#seat_lists').html('<p class="text-center">没有找到您想要的记录呢!我会努力的...</p>');
- }
- }
- },
- error: function(textStatus) {
- layer.close(loadIndex);
- layer.confirm('网络繁忙,请稍后再试...', {
- 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('网络超时,请稍后再试...', {
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- }
- },
- });
- }
- //选中和去掉选中
- function changeActive() {
- $(this).toggleClass('seat_item_active');
- getSeatArrs();
- }
- //获取选中坐席数组
- function getSeatArrs() {
- var seat_item = $('#seat_lists').find("[id*=seatItem_]").find('.seat_item');
- arruser = [];
- if(seat_item && seat_item.length > 0){
- $.each(seat_item, function(i, v) {
- if($(v).hasClass('seat_item_active')) {
- arruser.push($(v).attr('data-userCode'));
- }
- });
- if(seat_item.length === arruser.length) {
- $('#CheckAllBtn').text('取消全选');
- } else {
- $('#CheckAllBtn').text('全选');
- }
- }
- //console.log(arruser);
- }
- $('#CheckAllBtn').on('click', CheckAllOrNot);
- //是否全选
- function CheckAllOrNot() {
- var seat_item = $('#seat_lists').find("[id*=seatItem_]").find('.seat_item');
- if(seat_item && seat_item.length > 0){
- switch($(this).text()) {
- case "全选":
- $(this).text('取消全选');
- checkAll();
- break;
- case "取消全选":
- $(this).text('全选');
- unCheckAll();
- break;
- }
- }
- }
- //取消全选
- function unCheckAll() {
- $('#seat_lists').find("[id*=seatItem_]").find('.seat_item').removeClass('seat_item_active');
- getSeatArrs()
- }
- //全选
- function checkAll() {
- $('#seat_lists').find("[id*=seatItem_]").find('.seat_item').addClass('seat_item_active');
- getSeatArrs();
- }
- /**
- * 去除 null
- *optionnull 参数
- */
- function formatterNull(optionnull) {
- return optionnull = optionnull === null ? '-' : optionnull;
- }
- /**
- * 获取坐席组
- */
- function getGroups() {
- var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
- $.getJSON(huayi.config.callcenter_url + "callcenterapi/api/sysseatgroup/getlist", function(data) {
- if(data.state.toLowerCase() == "success") {
- var content = data.data;
- if(content && content.length > 0) {
- $(content).each(function(i, n) {
- groupLists.push({
- 'id': n.id,
- 'names': n.zxzname
- })
- });
- }
- dtd.resolve(); // 改变Deferred对象的执行状态
- }
- })
- return dtd.promise(); // 返回promise对象
- }
- //获取角色
- function getRoles() {
- var dtd = $.Deferred(); //在函数内部,新建一个Deferred对象
- $.getJSON(huayi.config.callcenter_url + "configurationapi/api/RoleInfo/getlistdrop", function(data) {
- if(data.state.toLowerCase() == "success") {
- var content = data.data;
- $(content).each(function(i, n) {
- rolesLists.push({
- 'id': n.id,
- 'names': n.role_name
- })
- });
- dtd.resolve(); // 改变Deferred对象的执行状态
- }
- })
- return dtd.promise(); // 返回promise对象
- }
- /**
- * 格式化坐席组 角色
- * option1 数组
- * option2 id
- */
- function formatterGroups(option1, option2) {
- var groupName = '';
- $(option1).each(function(i, n) {
- if(option2 === n.id) {
- groupName = n.names;
- }
- });
- return groupName;
- }
- /**
- * 格式化用户类型
- * option type值
- */
- function formatterType(option) {
- var str = ""
- switch(option + '') {
- case '0':
- str = "内部员工";
- break;
- case '1':
- str = "客户";
- break;
- default:
- str = "其他";
- break;
- }
- return str
- }
- //确定分配
- function ensureAllot() {
- var edit_id = helper.request.queryString("edit_id");
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + "callcenterapi/api/autocallouttask/fpdata",
- dataType: 'json',
- async: true,
- beforeSend: function() { //触发ajax请求开始时执行
- $('#allocationGoodTask').attr("disabled", true);
- $('#allocationGoodTask').text('分配中...');
- $(document).off('click', '#allocationGoodTask', ensureAllot);
- loadIndex = layer.load();
- },
- data: {
- taskid: edit_id, // 是 string 任务id
- arruser: arruser, // 否 string[] 分配坐席
- },
- success: function(data) {
- layer.close(loadIndex);
- if(data.state.toLowerCase() === "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.$('#outcryTable').bootstrapTable('refresh');
- parent.layer.msg("分配成功!");
- }
- },
- error: function(textStatus) {
- layer.close(loadIndex);
- layer.confirm('网络繁忙,请稍后再试...', {
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- $('#allocationGoodTask').text('分配');
- $('#allocationGoodTask').attr("disabled", false);
- $(document).off('click', '#allocationGoodTask', ensureAllot);
- $(document).on('click', '#allocationGoodTask', ensureAllot);
- },
- 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('网络超时,请稍后再试...', {
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- }
- $('#allocationGoodTask').text('分配');
- $('#allocationGoodTask').attr("disabled", false);
- $(document).off('click', '#allocationGoodTask', ensureAllot);
- $(document).on('click', '#allocationGoodTask', ensureAllot);
- },
- });
- }
|