| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306 |
- /**
- * 外呼计划增加或编辑
- * */
- var wavpath = ''; //语音路径
- $(function() {
- autosize($('textarea'));
- var nowDate = helper.DateFormat.getNowDate();
- var edit_id = helper.request.queryString("edit_id");
- var isStart = helper.request.queryString("isStart");
- //初始化时间
- laydate.render({
- elem: '#pro_times',
- range: '~',
- // type: 'datetime',
- theme: '#249fea',
- min: nowDate,
- });
- laydate.render({
- elem: '#wtime1',
- type: 'time',
- range: '~',
- theme: '#249fea',
- });
- $('#wtime1').val("08:30:00 ~ 12:00:00");
- laydate.render({
- elem: '#wtime2',
- type: 'time',
- range: '~',
- theme: '#249fea',
- });
- $('#wtime2').val("14:00:00 ~ 18:00:00");
- //上传语音文件
- $("#btndr").click(function() {
- $("#upFile").trigger("click");
- });
- $("#upFile").change(function() {
- upload();
- });
- if(edit_id) { //修改
- getPlan(edit_id, isStart);
- }
- //呼叫方式的change
- $('#calltype').on('change', calltypeChange);
- //添加编辑保存按钮点击
- $('#pro_save').on('click', savePlan);
- });
- //呼叫方式的change
- function calltypeChange() {
- //0为不播放直接转坐席,1为播放转坐席,2为播放后按键转坐席
- switch($(this).find('input[name="calltype_radio"]:checked').val()) {
- case '1':
- $('.fielContext').show();
- $('.pressnum').hide();
- break;
- case '2':
- $('.fielContext').show();
- // $('.pressnum').show();
- break;
- default:
- $('.fielContext').hide();
- $('.pressnum').hide();
- break;
- }
- }
- //获取单个计划
- function getPlan(ids, isStart) {
- if(isStart != '0'){
- $('#calltype').find('input[name="calltype_radio"]').attr('disabled', true);
- $('#btndr').attr('disabled', true);
- $('#pressnum').attr('disabled', true);
- }
- $.getJSON(huayi.config.callcenter_url + "callcenterapi/api/autocallouttask/getsingle", {
- id: ids, //是 string 标识id
- }, function(data) {
- if(data.state == "success") {
- var res = data.data;
- if(res) {
- $('#pro_title').val(res.taskname); //计划名称
- if(res.starttime && res.endtime) {
- $('#pro_times').val(res.starttime + ' ~ ' + res.endtime); //计划起止日期
- }
- if(res.workstarttimes1 && res.workendtimes1) {
- $('#wtime1').val(res.workstarttimes1 + ' ~ ' + res.workendtimes1); // 否 string 工作开始时间1工作结束时间1
- }
- if(res.workstarttimes2 && res.workendtimes2) {
- $('#wtime2').val(res.workstarttimes2 + ' ~ ' + res.workendtimes2); // 否 string 工作开始时间2工作结束时间2
- }
- // 否 int 呼叫方式:0为不播放直接转坐席,1为播放转坐席,2为播放后按键转坐席
- $('#calltype').find('input[name="calltype_radio"][value="' + res.calltype + '"]').prop('checked', true).trigger('change'); // 否 int 并发类型
- if(res.voicepath && res.voicepath.length > 0) {
- $('.audioCon').attr('src', res.voicepath[0].fileurl);
- wavpath = res.voicepath[0].fileurl; // 否 string 语音文件路径
- }
- // $('#pressnum').val(res.pressnum); // 否 string 按键
-
- if(res.bftype) {
- $('#bftype').find('input[name="bftype_radio"][value="' + res.bftype + '"]').prop('checked', true); // 否 int 并发类型
- }
- $('#bfnum').val(res.bfnum); // 否 string 并发数
- $('#pro_content').val(res.taskremark); //说明备注
- }
- }
- });
- }
- //保存计划
- function savePlan() {
- var edit_id = helper.request.queryString("edit_id");
- var wUrl, loadIndex;
- //0为不播放直接转坐席,1为播放转坐席,2为播放后按键转坐席3不转坐席
- var callTypeVal = $('#calltype').find('input[name="calltype_radio"]:checked').val();
- if(!$.trim($('#pro_title').val())) {
- layer.confirm('计划名称不能为空!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#pro_times').val())) {
- layer.confirm('您还没有选择计划起止日期!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#wtime1').val())) {
- layer.confirm('您还没有选择工作时段一!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!$.trim($('#wtime2').val())) {
- layer.confirm('您还没有选择工作时段二!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- if(!regexs.num.test($.trim($('#bfnum').val()))) {
- layer.confirm('并发数/进号速率(只能输入数字)!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- switch(callTypeVal) {
- case '1':
- if(!wavpath) {
- layer.confirm('您还没有上传语音文件!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- $('#pressnum').val('');
- break;
- case '2':
- if(!wavpath) {
- layer.confirm('您还没有上传语音文件!', {
- icon: 2,
- btn: ['确定'] //按钮
- });
- return;
- }
- $('#pressnum').val('1');
- // if(!regexs.pressnumReg.test($.trim($('#pressnum').val()))) {
- // layer.confirm('按键只能输入0-9的一位数字!', {
- // icon: 2,
- // btn: ['确定'] //按钮
- // });
- // return;
- // }
- break;
- default:
- wavpath = '';
- $('#pressnum').val('');
- break;
- }
- if(edit_id) {
- wURL = "callcenterapi/api/autocallouttask/update";
- } else {
- wURL = "callcenterapi/api/autocallouttask/add";
- }
- $.ajax({
- type: "post",
- url: huayi.config.callcenter_url + wURL,
- dataType: 'json',
- async: true,
- beforeSend: function() { //触发ajax请求开始时执行
- loadIndex = layer.load();
- $('#pro_save').attr("disabled", true);
- $('#pro_save').text('保存中...');
- $(document).off('click', '#pro_save', savePlan);
- },
- data: {
- id: edit_id, //edit_id为空的时候添加
- taskname: $('#pro_title').val(), // 是 string 任务名称
- stime: $('#pro_times').val() && $('#pro_times').val().split(' ~ ')[0], //否 string 任务开始时间
- etime: $('#pro_times').val() && $('#pro_times').val().split(' ~ ')[1], //否 string 任务结束时间
- swtime1: $('#wtime1').val() && $('#wtime1').val().split(' ~ ')[0], // 否 string 工作开始时间1
- ewtime1: $('#wtime1').val() && $('#wtime1').val().split(' ~ ')[1], // 否 string 工作结束时间1
- swtime2: $('#wtime2').val() && $('#wtime2').val().split(' ~ ')[0], // 否 string 工作开始时间2
- ewtime2: $('#wtime2').val() && $('#wtime2').val().split(' ~ ')[1], // 否 string 工作结束时间2
- calltype: callTypeVal, // 否 int 呼叫方式:0为不播放直接转坐席,1为播放转坐席,2为播放后按键转坐席
- voicepath: wavpath, // 否 string 语音文件路径
- pressnum: $('#pressnum').val(), // 否 string 按键
- bftype: $('#bftype').find('input[name="bftype_radio"]:checked').val(), // 否 int 并发类型
- bfnum: $('#bfnum').val(), // 否 string 并发数
- taskremark: $('#pro_content').val(), //否 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('网络繁忙,请稍后再试...', {
- icon: 7,
- closeBtn: 0,
- btn: ['确定'] //按钮
- });
- $('#pro_save').text('保存');
- $('#pro_save').attr("disabled", false);
- $(document).off('click', '#pro_save', savePlan);
- $(document).on('click', '#pro_save', savePlan);
- },
- 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: ['确定'] //按钮
- });
- }
- $('#pro_save').text('保存');
- $('#pro_save').attr("disabled", false);
- $(document).off('click', '#pro_save', savePlan);
- $(document).on('click', '#pro_save', savePlan);
- },
- });
- }
- //上传文件
- function upload() {
- if(document.getElementById("upFile").files.length > 0) {
- var formData = new FormData();
- formData.append("upFile", document.getElementById("upFile").files[0]);
- formData.append("uploadtype", 'outCall');
- $.ajax({
- url: huayi.config.callcenter_url + "fileserverapi/Api/Upload",
- type: "POST",
- data: formData,
- /**
- *必须false才会自动加上正确的Content-Type
- */
- contentType: false,
- /**
- * 必须false才会避开jQuery对 formdata 的默认处理
- * XMLHttpRequest会对 formdata 进行正确的处理
- */
- processData: false,
- success: function(result) {
- document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
- $("#upFile").change(function() {
- upload();
- });
- var r = $.parseJSON(result);
- if(r.state.toLowerCase() == "success") {
- $('.audioCon').attr('src', r.data[0].fileurl)
- wavpath = r.data;
- layer.msg("语音上传成功");
- }
- }
- });
- } else {
- layer.confirm('请上传文件!', {
- icon: 7,
- btn: ['确定']
- });
- }
- }
|