鑫苑新版本前端代码

addWelcomeWords.html 6.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="UTF-8">
  5. <title>黑名单管理</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. <style>
  11. .greetings{
  12. margin-top: 20px;
  13. }
  14. .greetings label{
  15. text-align: right;
  16. }
  17. .greetings ul{
  18. margin: 0;
  19. padding: 0;
  20. }
  21. .greetings li{
  22. list-style: none;
  23. }
  24. .text_require {
  25. color: red;
  26. vertical-align: middle;
  27. font-weight: 900;
  28. }
  29. .time-box{
  30. position: relative;
  31. }
  32. i.tub {
  33. position: absolute;
  34. right: 26px;
  35. top: 8px;
  36. font-size: 18px;
  37. color: rgb(26, 179, 148);
  38. }
  39. .greetings .radio-inline input[type="radio"] {
  40. margin-top: 4px;
  41. }
  42. .greetings textarea {
  43. resize: none;
  44. }
  45. .greetings .form-horizontal .radio-inline {
  46. padding-top: 0;
  47. }
  48. #greetingSave{
  49. background: rgb(26, 179, 148);
  50. color: #fff;
  51. }
  52. </style>
  53. </head>
  54. <body class="gray-bg">
  55. <div class="container greetings">
  56. <ul class="row clearfix form-horizontal">
  57. <li class="form-group">
  58. <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>项目Id</label>
  59. <div class="col-md-10 time-box">
  60. <select id="itemid" class="form-control" >
  61. <option value="0">项目1</option>
  62. <option value="1">项目2</option>
  63. </select>
  64. </div>
  65. </li>
  66. <li class="form-group">
  67. <label for="greetingRemark" class="col-md-2"><b class="text_require">*</b>项目名称</label>
  68. <div class="col-md-10">
  69. <input type="text" class="form-control" id="item" placeholder="请输入项目名称" />
  70. </div>
  71. </li>
  72. <li class="form-group">
  73. <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>生效时限</label>
  74. <div class="col-md-10 time-box">
  75. <i class="tub fa fa-calendar"></i>
  76. <input class="form-control" type="text" id="greetingTimes">
  77. </div>
  78. </li>
  79. <li class="form-group">
  80. <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>状态</label>
  81. <div class="col-md-10 time-box">
  82. <select id="isstate" class="form-control" >
  83. <option value="0">未启动</option>
  84. <option value="1">启动中</option>
  85. </select>
  86. </div>
  87. </li>
  88. <li class="form-group">
  89. <label for="greetingTimes" class="col-md-2"><b class="text_require">*</b>语音文件</label>
  90. <div class="col-md-10 time-box">
  91. <div style="display: none;">
  92. <input type="file" id="upFile" name="Files" accept="audio/*">
  93. </div>
  94. <input type="button" class="btn" id="HY_subImport" onclick="btn_subImport()" value="导入文件" />
  95. <span class="fileName"></span>
  96. </div>
  97. </li>
  98. <li class="form-group">
  99. <label for="greetingRemark" class="col-md-2">备注</label>
  100. <div class="col-md-10">
  101. <textarea id="remark" class="form-control" rows="7" placeholder="请输入备注"></textarea>
  102. </div>
  103. </li>
  104. </ul>
  105. <div class="form-group row clearfix" style="text-align: center;">
  106. <div class="col-md-offset-2 col-md-10">
  107. <button class="btn" id="greetingSave" type="button" onclick="addedit()">保存</button>
  108. </div>
  109. </div>
  110. <input type="hidden" id="path"/>
  111. <input type="hidden" id="filename"/>
  112. <input type="hidden" id="loadpath"/>
  113. </div>
  114. <script>
  115. var ids=helper.request.queryString("id");
  116. $(document).ready(function() {
  117. laydate.render({
  118. elem: '#greetingTimes',
  119. range: '~',
  120. type: 'datetime',
  121. //max : 31,
  122. min: 0,
  123. theme: '#1ab394',
  124. });
  125. $("#upFile").change(function () {
  126. upload();
  127. });
  128. })
  129. //新增或者编辑
  130. function addedit() {
  131. if(!$("#itemid").val()) {
  132. layer.confirm('请选择项目Id', {
  133. icon: 2,
  134. btn: ['确定'] //按钮
  135. });
  136. return;
  137. }
  138. if(!$("#item").val()) {
  139. layer.confirm('请输入项目名称', {
  140. icon: 2,
  141. btn: ['确定'] //按钮
  142. });
  143. return;
  144. }
  145. if(!$("#greetingTimes").val()) {
  146. layer.confirm('请选择时间', {
  147. icon: 2,
  148. btn: ['确定'] //按钮
  149. });
  150. return;
  151. }
  152. if(!$("#path").val()) {
  153. layer.confirm('请上传语音文件', {
  154. icon: 2,
  155. btn: ['确定'] //按钮
  156. });
  157. return;
  158. }
  159. /*发送请求*/
  160. $.post(huayi.config.callcenter_url + "IVRWelcome/AddIVRWords", {
  161. id: ids,
  162. itemid: $("#itemid").val(),//项目ID
  163. item: $("#item").val(),//项目
  164. loadpath: $("#loadpath").val(),//本地路径
  165. filename: $("#filename").val(),//文件名称
  166. path: $("#path").val(),//语音路径
  167. isstate: $("#isstate").val(),//状态
  168. sdate: $('#greetingTimes').val() && $('#greetingTimes').val().split(' ~ ')[0],//生效时间
  169. edate: $('#greetingTimes').val() && $('#greetingTimes').val().split(' ~ ')[1],//失效时间
  170. remark: $("#remark").val(),//备注
  171. token: $.cookie("token")
  172. }, function(result) {
  173. result = JSON.parse(result);
  174. if(result.state.toLowerCase() == "success") {
  175. var index = parent.layer.getFrameIndex(window.name);
  176. parent.layer.close(index);
  177. parent.layer.msg("保存成功!");
  178. parent.$('#list').bootstrapTable('refresh');
  179. }
  180. })
  181. }
  182. function btn_subImport(){
  183. $("#upFile").trigger('click')
  184. }
  185. function upload(){
  186. var formData = new FormData();
  187. formData.append("upFile", document.getElementById("upFile").files[0]);
  188. $.ajax({
  189. url: huayi.config.callcenter_url + 'IVRWelcome/UploadWav',
  190. type: "POST",
  191. data: formData,
  192. /**
  193. *必须false才会自动加上正确的Content-Type
  194. */
  195. contentType: false,
  196. /**
  197. * 必须false才会避开jQuery对 formdata 的默认处理
  198. * XMLHttpRequest会对 formdata 进行正确的处理
  199. */
  200. processData: false,
  201. success: function (result) {
  202. document.getElementById("upFile").outerHTML = document.getElementById("upFile").outerHTML;
  203. $("#upFile").change(function () {
  204. upload();
  205. });
  206. var r = $.parseJSON(result);
  207. if (r.state.toLowerCase() == 'success') {
  208. layer.msg("导入成功");
  209. $('#loadpath').val(r.data.loadpath);
  210. $('#filename').val(r.data.filename);
  211. $('.fileName').text(r.data.filename);
  212. $('#path').val(r.data.wavpath);
  213. }
  214. }
  215. });
  216. }
  217. </script>
  218. </body>
  219. </html>