Нет описания

addGreetings.html 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>添加或修改IVR欢迎词管理</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <script src="../../Script/Common/huayi.load.js"></script>
  8. <script src="../../Script/Common/huayi.config.js"></script>
  9. <script src="../../js/laydate/laydate.js"></script>
  10. <link href="../../css/Table/table1.css" rel="stylesheet" />
  11. <link href="../../css/init.css" rel="stylesheet" />
  12. <link href="../css/addOrEditTel.css" rel="stylesheet" />
  13. </head>
  14. <body>
  15. <div class="container greetings">
  16. <ul class="row clearfix form-horizontal">
  17. <li class="form-group">
  18. <label for="greetingTitle" class="col-md-2"><b class="text_require">*</b>欢迎词标题</label>
  19. <div class="col-md-4">
  20. <input id="greetingTitle" class="form-control" type="text" autofocus="true" autocomplete="off" />
  21. </div>
  22. </li>
  23. <li class="form-group">
  24. <label for="" class="col-md-2"><b class="text_require">*</b>添加方式</label>
  25. <div class="col-md-4" id="">
  26. <label class="radio-inline">
  27. <input type="radio" name="addWays" value="1" checked="checked"> 文本
  28. </label>
  29. <label class="radio-inline">
  30. <input type="radio" name="addWays" value="2"> 语音文件
  31. </label>
  32. </div>
  33. </li>
  34. <li class="form-group textContent">
  35. <label for="greetingContent" class="col-md-2"><b class="text_require">*</b>欢迎词内容</label>
  36. <div class="col-md-9">
  37. <textarea id="greetingContent" class="form-control" rows="7"></textarea>
  38. </div>
  39. </li>
  40. <li class="form-group fielContext" style="display: none;" >
  41. <label for="" class="col-md-2"><b class="text_require">*</b>上传文件</label>
  42. <div class="col-md-9">
  43. <input id="btndr" type="button" class="btns" style="margin:0;" value="上传语音文件" />
  44. <!--<input type="file" name="upFile" id="upFile" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" style="display: none;">-->
  45. <input type="file" name="upFile" id="upFile" accept="audio/*" style="display: none;">
  46. </div>
  47. </li>
  48. <li class="form-group fielContext" style="display: none;">
  49. <label for="" class="col-md-2"><b class="text_require">*</b>录音文件</label>
  50. <div class="col-md-9">
  51. <audio style="width: 95%;"class="audioCon" src="" controls="controls" ></audio>
  52. </div>
  53. </li>
  54. <li class="form-group">
  55. <label for="greetingStart" class="col-md-2"><b class="text_require">*</b>是否启动生效</label>
  56. <div class="col-md-4" id="greetingStart">
  57. <label class="radio-inline">
  58. <input type="radio" name="inlineRadioOptions" value="1" checked="checked"> 启动
  59. </label>
  60. <label class="radio-inline">
  61. <input type="radio" name="inlineRadioOptions" value="0"> 不启动
  62. </label>
  63. </div>
  64. </li>
  65. <li class="form-group">
  66. <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>生效时间</label>
  67. <div class="col-md-4 time-box">
  68. <i class="tub fa fa-calendar"></i>
  69. <input class="form-control" type="text" id="greetingTimes">
  70. </div>
  71. </li>
  72. <li class="form-group">
  73. <label for="greetingRemark" class="col-md-2">备注</label>
  74. <div class="col-md-9">
  75. <textarea id="greetingRemark" class="form-control" rows="7"></textarea>
  76. </div>
  77. </li>
  78. </ul>
  79. <div class="form-group row clearfix">
  80. <div class="col-md-offset-2 col-md-10">
  81. <button class="btn sc_btn" id="greetingSave" type="button" onclick="addEdit()">保存</button>
  82. </div>
  83. </div>
  84. <input type="hidden" id="wavpath"/>
  85. </div>
  86. <script src="../../js/autosize/autosize.min.js"></script>
  87. <script>
  88. var greetingId = helper.request.queryString("greetingId");
  89. var wavpath;
  90. $(document).ready(function() {
  91. autosize($('textarea'));
  92. laydate.render({
  93. elem: '#greetingTimes',
  94. range: '~',
  95. type: 'datetime',
  96. //max : 31,
  97. // min: 0,
  98. theme: '#249fea',
  99. });
  100. if(greetingId){//修改
  101. getIVRWords(greetingId);
  102. }
  103. $('input[name="addWays"]').change(function(){
  104. var value=$(this).val();
  105. if(value==1){
  106. $('.textContent').show();
  107. $('.fielContext').hide();
  108. }else{
  109. $('.fielContext').show();
  110. $('.textContent').hide();
  111. }
  112. })
  113. });
  114. //获取欢迎词信息
  115. function getIVRWords(ids){
  116. $.getJSON(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/getsingle", {
  117. id: ids //主键ID
  118. }, function(data) {
  119. if(data.state == "success") {
  120. $('#greetingTitle').val(data.data.title);//标题
  121. $('#greetingContent').val(data.data.content);//内容
  122. $('#greetingStart').find('input[value="'+ data.data.isstate +'"]').attr('checked','checked');//是否启动生效(0不启动,1启动)
  123. $('#greetingTimes').val(data.data.startdate + ' ~ ' + data.data.enddate);
  124. $('#greetingRemark').val(data.data.remark);//备注
  125. if(data.data.wavfile.length>0){
  126. $('.audioCon').attr('src',data.data.wavfile[0].fileurl);
  127. wavpath=data.data.wavfile;
  128. }
  129. $('input[name="addWays"][value="'+data.data.type+'"]').prop("checked","checked");
  130. if(data.data.type==1){
  131. $('.textContent').show();
  132. $('.fielContext').hide();
  133. }else{
  134. $('.fielContext').show();
  135. $('.textContent').hide();
  136. }
  137. }
  138. });
  139. }
  140. //点击保存后修改或增加
  141. function addEdit() {
  142. if (!$.trim($('#greetingTitle').val())) {
  143. layer.confirm('请输入欢迎词标题!', {
  144. icon: 2,
  145. btn: ['确定'],
  146. });
  147. return;
  148. }
  149. if( $('input[name="addWays"]:checked').val()==1){
  150. if (!$.trim($('#greetingContent').val())) {
  151. layer.confirm('请输入欢迎词内容!', {
  152. icon: 2,
  153. btn: ['确定'],
  154. });
  155. return;
  156. }
  157. }
  158. if (!$.trim($('#greetingTimes').val())) {
  159. layer.confirm('请选择生效时间!', {
  160. icon: 2,
  161. btn: ['确定'],
  162. });
  163. return;
  164. }
  165. //id为增加 >0修改
  166. if(greetingId){
  167. $.post(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/update", {
  168. id: greetingId, //主键ID
  169. title: $('#greetingTitle').val(),//标题
  170. content: $('#greetingContent').val(),//内容
  171. isstate: $('#greetingStart').find('input[type="radio"]:checked').val(),//是否启动生效(0不启动,1启动)
  172. startdate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//生效时间
  173. enddate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//失效时间
  174. remark: $('#greetingRemark').val(),//备注
  175. type: $('input[name="addWays"]:checked').val(),//添加方式
  176. wavstr: wavpath
  177. }, function(data) {
  178. data = JSON.parse(data);
  179. if(data.state == "success") {
  180. var index = parent.layer.getFrameIndex(window.name);
  181. parent.layer.close(index);
  182. parent.layer.msg(data.message);
  183. parent.initTable1();
  184. }
  185. });
  186. }else{
  187. $.post(huayi.config.callcenter_url + "callcenterapi/api/sysivrwords/add", {
  188. id: greetingId, //主键ID
  189. title: $('#greetingTitle').val(),//标题
  190. content: $('#greetingContent').val(),//内容
  191. isstate: $('#greetingStart').find('input[type="radio"]:checked').val(),//是否启动生效(0不启动,1启动)
  192. sdate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[0],//生效时间
  193. edate: $('#greetingTimes').val() && $('#greetingTimes').val().split('~')[1],//失效时间
  194. remark: $('#greetingRemark').val(),//备注
  195. type: $('input[name="addWays"]:checked').val(),//添加方式
  196. wavstr: wavpath
  197. }, function(data) {
  198. data = JSON.parse(data);
  199. if(data.state == "success") {
  200. var index = parent.layer.getFrameIndex(window.name);
  201. parent.layer.close(index);
  202. parent.layer.msg(data.message);
  203. parent.$('#greetingState').selectpicker('val','').trigger('change');
  204. parent.$('#keyGreetings').val('');
  205. parent.$('#settime').val('');
  206. parent.$('#table1').bootstrapTable('refresh');
  207. }
  208. });
  209. }
  210. }
  211. //上传文件
  212. $("#btndr").click(function () {
  213. $("#upFile").trigger("click");
  214. })
  215. $("#upFile").change(function () {
  216. upload();
  217. })
  218. //上传文件
  219. function upload() {
  220. if (document.getElementById("upFile").files.length > 0) {
  221. var formData = new FormData();
  222. formData.append("upFile", document.getElementById("upFile").files[0]);
  223. formData.append("uploadtype", 'ivr');
  224. $.ajax({
  225. url: huayi.config.callcenter_url + "fileserverapi/Api/Upload",
  226. type: "POST",
  227. data: formData,
  228. /**
  229. *必须false才会自动加上正确的Content-Type
  230. */
  231. contentType: false,
  232. /**
  233. * 必须false才会避开jQuery对 formdata 的默认处理
  234. * XMLHttpRequest会对 formdata 进行正确的处理
  235. */
  236. processData: false,
  237. success: function (result) {
  238. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  239. $("#upFile").change(function () {
  240. upload();
  241. });
  242. var r = $.parseJSON(result);
  243. if (r.state.toLowerCase() == "success") {
  244. // $('#oldname').val(r.data.oldname);
  245. // $('#newname').val(r.data.newname);
  246. // $('#wavpath').val(r.data.wavpath);
  247. $('.audioCon').attr('src',r.data[0].fileurl)
  248. wavpath=r.data;
  249. layer.msg("导入成功");
  250. }
  251. }
  252. });
  253. } else {
  254. layer.confirm('请上传文件!', {
  255. btn: ['确定']
  256. });
  257. }
  258. }
  259. </script>
  260. </body>
  261. </html>