| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="UTF-8">
- <title>添加或修改IVR欢迎词管理</title>
- <meta name="viewport" content="width=device-width, initial-scale=1.0">
- <script src="../../Script/Common/huayi.load.js"></script>
- <script src="../../Script/Common/huayi.config.js"></script>
- <script src="../../js/laydate/laydate.js"></script>
- <link href="../../css/Table/table1.css" rel="stylesheet" />
- <link href="../../css/init.css" rel="stylesheet" />
- <link href="../css/addOrEditTel.css" rel="stylesheet" />
- </head>
- <body>
- <div class="container greetings">
- <ul class="row clearfix form-horizontal">
- <li class="form-group">
- <label for="greetingTitle" class="col-md-2"><b class="text_require">*</b>欢迎词标题</label>
- <div class="col-md-4">
- <input id="greetingTitle" class="form-control" type="text" autofocus="true" autocomplete="off" />
- </div>
- </li>
- <li class="form-group">
- <label for="" class="col-md-2"><b class="text_require">*</b>添加方式</label>
- <div class="col-md-4" id="">
- <label class="radio-inline">
- <input type="radio" name="addWays" value="1" checked="checked"> 文本
- </label>
- <label class="radio-inline">
- <input type="radio" name="addWays" value="2"> 语音文件
- </label>
- </div>
- </li>
-
- <li class="form-group textContent">
- <label for="greetingContent" class="col-md-2"><b class="text_require">*</b>欢迎词内容</label>
- <div class="col-md-9">
- <textarea id="greetingContent" class="form-control" rows="7"></textarea>
- </div>
- </li>
- <li class="form-group fielContext" style="display: none;" >
- <label for="" class="col-md-2"><b class="text_require">*</b>上传文件</label>
- <div class="col-md-9">
- <input id="btndr" type="button" class="btns" style="margin:0;" value="上传语音文件" />
- <!--<input type="file" name="upFile" id="upFile" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" style="display: none;">-->
- <input type="file" name="upFile" id="upFile" accept="audio/*" style="display: none;">
- </div>
-
- </li>
- <li class="form-group fielContext" style="display: none;">
- <label for="" class="col-md-2"><b class="text_require">*</b>录音文件</label>
- <div class="col-md-9">
- <audio style="width: 95%;"class="audioCon" src="" controls="controls" ></audio>
- </div>
-
-
- </li>
- <li class="form-group">
- <label for="greetingStart" class="col-md-2"><b class="text_require">*</b>是否启动生效</label>
- <div class="col-md-4" id="greetingStart">
- <label class="radio-inline">
- <input type="radio" name="inlineRadioOptions" value="1" checked="checked"> 启动
- </label>
- <label class="radio-inline">
- <input type="radio" name="inlineRadioOptions" value="0"> 不启动
- </label>
- </div>
- </li>
- <li class="form-group">
- <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>生效时间</label>
- <div class="col-md-4 time-box">
- <i class="tub fa fa-calendar"></i>
- <input class="form-control" type="text" id="greetingTimes">
- </div>
- </li>
-
- <li class="form-group">
- <label for="greetingRemark" class="col-md-2">备注</label>
- <div class="col-md-9">
- <textarea id="greetingRemark" class="form-control" rows="7"></textarea>
- </div>
- </li>
- </ul>
- <div class="form-group row clearfix">
- <div class="col-md-offset-2 col-md-10">
- <button class="btn sc_btn" id="greetingSave" type="button" onclick="addEdit()">保存</button>
- </div>
- </div>
- <input type="hidden" id="wavpath"/>
- </div>
- <script src="../../js/autosize/autosize.min.js"></script>
- <script>
-
- var greetingId = helper.request.queryString("greetingId");
- var wavpath;
- $(document).ready(function() {
- autosize($('textarea'));
- laydate.render({
- elem: '#greetingTimes',
- range: '~',
- type: 'datetime',
- //max : 31,
- // min: 0,
- theme: '#249fea',
- });
- if(greetingId){//修改
- getIVRWords(greetingId);
- }
- $('input[name="addWays"]').change(function(){
- var value=$(this).val();
- if(value==1){
- $('.textContent').show();
- $('.fielContext').hide();
- }else{
- $('.fielContext').show();
- $('.textContent').hide();
- }
-
- })
- });
-
- //获取欢迎词信息
- function getIVRWords(ids){
- $.getJSON(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/getsingle", {
- id: ids //主键ID
- }, function(data) {
- if(data.state == "success") {
- $('#greetingTitle').val(data.data.title);//标题
- $('#greetingContent').val(data.data.content);//内容
- $('#greetingStart').find('input[value="'+ data.data.isstate +'"]').attr('checked','checked');//是否启动生效(0不启动,1启动)
- $('#greetingTimes').val(data.data.startdate + ' ~ ' + data.data.enddate);
- $('#greetingRemark').val(data.data.remark);//备注
- if(data.data.wavfile.length>0){
- $('.audioCon').attr('src',data.data.wavfile[0].fileurl);
- wavpath=data.data.wavfile;
- }
- $('input[name="addWays"][value="'+data.data.type+'"]').prop("checked","checked");
- if(data.data.type==1){
- $('.textContent').show();
- $('.fielContext').hide();
- }else{
- $('.fielContext').show();
- $('.textContent').hide();
- }
-
- }
- });
- }
- //点击保存后修改或增加
- function addEdit() {
- if (!$.trim($('#greetingTitle').val())) {
- layer.confirm('请输入欢迎词标题!', {
- icon: 2,
- btn: ['确定'],
- });
- return;
- }
- if( $('input[name="addWays"]:checked').val()==1){
- if (!$.trim($('#greetingContent').val())) {
- layer.confirm('请输入欢迎词内容!', {
- icon: 2,
- btn: ['确定'],
- });
- return;
- }
- }
-
- if (!$.trim($('#greetingTimes').val())) {
- layer.confirm('请选择生效时间!', {
- icon: 2,
- btn: ['确定'],
- });
- return;
- }
- //id为增加 >0修改
- if(greetingId){
- $.post(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/update", {
- id: greetingId, //主键ID
- title: $('#greetingTitle').val(),//标题
- content: $('#greetingContent').val(),//内容
- isstate: $('#greetingStart').find('input[type="radio"]:checked').val(),//是否启动生效(0不启动,1启动)
- startdate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//生效时间
- enddate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//失效时间
- remark: $('#greetingRemark').val(),//备注
- type: $('input[name="addWays"]:checked').val(),//添加方式
- wavstr: wavpath
- }, function(data) {
- data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.layer.msg(data.message);
- parent.initTable1();
- }
- });
-
- }else{
- $.post(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/add", {
- id: greetingId, //主键ID
- title: $('#greetingTitle').val(),//标题
- content: $('#greetingContent').val(),//内容
- isstate: $('#greetingStart').find('input[type="radio"]:checked').val(),//是否启动生效(0不启动,1启动)
- sdate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//生效时间
- edate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//失效时间
- remark: $('#greetingRemark').val(),//备注
- type: $('input[name="addWays"]:checked').val(),//添加方式
- wavstr: wavpath
- }, function(data) {
- data = JSON.parse(data);
- if(data.state == "success") {
- var index = parent.layer.getFrameIndex(window.name);
- parent.layer.close(index);
- parent.layer.msg(data.message);
- parent.$('#greetingState').selectpicker('val','').trigger('change');
- parent.$('#keyGreetings').val('');
- parent.$('#settime').val('');
- parent.$('#table1').bootstrapTable('refresh');
- }
- });
- }
-
- }
- //上传文件
- $("#btndr").click(function () {
- $("#upFile").trigger("click");
- })
- $("#upFile").change(function () {
- upload();
- })
- //上传文件
- function upload() {
- if (document.getElementById("upFile").files.length > 0) {
- var formData = new FormData();
- formData.append("upFile", document.getElementById("upFile").files[0]);
- formData.append("uploadtype", 'ivr');
- $.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") {
- // $('#oldname').val(r.data.oldname);
- // $('#newname').val(r.data.newname);
- // $('#wavpath').val(r.data.wavpath);
- $('.audioCon').attr('src',r.data[0].fileurl)
- wavpath=r.data;
- layer.msg("导入成功");
- }
- }
- });
- } else {
- layer.confirm('请上传文件!', {
- btn: ['确定']
- });
- }
- }
-
- </script>
- </body>
- </html>
|