edit.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. {extend name="app/admin/view/base.html"/}
  2. {block name="resources"}
  3. <style>
  4. .layui-btn-primary:hover {border-color: #C9C9C9;}
  5. .number-con {margin-right: 10px;}
  6. .ns-form {margin-top: 0;}
  7. </style>
  8. {/block}
  9. {block name="main"}
  10. <div class="layui-form ns-form">
  11. <div class="layui-form-item">
  12. <label class="layui-form-label">是否开启:</label>
  13. <div class="layui-input-block">
  14. <input type="checkbox" name="sms_is_open" value="1" {if $sms_is_open == 1}checked{/if} lay-skin="switch">
  15. </div>
  16. </div>
  17. <div class="layui-form-item">
  18. <label class="layui-form-label"><span class="required">*</span>模板ID:</label>
  19. <div class="layui-input-block">
  20. <input name="template_id" type="text" value="{if !empty($info)}{$info.template_id}{/if}" lay-verify="required" placeholder="短信模板ID" class="layui-input ns-len-long">
  21. </div>
  22. <div class="ns-word-aux">必须与短信接口的模板ID一致,否则无效!</div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">数据值:</label>
  26. <div class="layui-input-block">
  27. {foreach $message_variable_list as $message_variable_k => $message_variable_v}
  28. <button class="layui-btn layui-btn-primary number-con" onclick="clickBtn('{$message_variable_k}')">{$message_variable_v}</button>
  29. {/foreach}
  30. </div>
  31. </div>
  32. <div class="layui-form-item">
  33. <label class="layui-form-label">短信内容:</label>
  34. <div class="layui-input-block">
  35. <textarea id="text_area" name="content" class="layui-textarea ns-len-long">{if !empty($info)}{$info.content}{/if}</textarea>
  36. </div>
  37. <div class="ns-word-aux">变量只能使用上方的可用变量中的变量,否则不会被解析;如果要使用凌凯短信时,短信内容必须进行设置。</div>
  38. </div>
  39. <div class="ns-form-row">
  40. <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
  41. <button class="layui-btn layui-btn-primary" onclick="back()">返回</button>
  42. </div>
  43. <input type="hidden" name="keywords" value="{$keywords}">
  44. </div>
  45. {/block}
  46. {block name="script"}
  47. <script>
  48. layui.use('form', function() {
  49. var form = layui.form;
  50. repeat_flag = false; //防重复标识
  51. form.render();
  52. /**
  53. * 监听提交
  54. */
  55. form.on('submit(save)', function(data) {
  56. if (repeat_flag) return;
  57. repeat_flag = true;
  58. $.ajax({
  59. dataType: 'JSON',
  60. type: 'POST',
  61. url: ns.url("alisms://admin/message/edit"),
  62. data: data.field,
  63. success: function(res){
  64. repeat_flag = false;
  65. if (res.code == 0) {
  66. layer.confirm('编辑成功', {
  67. title:'操作提示',
  68. btn: ['返回列表', '继续操作'],
  69. yes: function(){
  70. location.href = ns.url("admin/message/lists")
  71. },
  72. btn2: function() {
  73. location.reload();
  74. }
  75. });
  76. }else{
  77. layer.msg(res.message);
  78. }
  79. }
  80. });
  81. });
  82. });
  83. function back(){
  84. location.href = ns.url("admin/message/lists");
  85. }
  86. function clickBtn(con) {
  87. var txtArea = $("#text_area")[0];
  88. var content = txtArea.value; //文本域内容
  89. var start = txtArea.selectionStart; //光标的初始位置,selectionStart:选区开始位置;selectionEnd:选区结束位置。
  90. txtArea.value = content.substring(0, txtArea.selectionStart) + '{' + con + '}' + content.substring(txtArea.selectionEnd, content.length);
  91. var position = start + con.length;
  92. $("#text_area").focus();
  93. txtArea.setSelectionRange(position+1, position+1); //setSelectionRange()方法用来设置<input>元素当前选中的文本的开始和结束位置
  94. }
  95. </script>
  96. {/block}