截流自动化的商城平台
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

set_mnp.html 9.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214
  1. {layout name="layout2" /}
  2. <style>
  3. .tips{
  4. color: red;
  5. }
  6. </style>
  7. <div class="layui-form" lay-filter="layuiadmin-form-user" id="layuiadmin-form-user" style="padding: 20px 30px 0 0;">
  8. <input type="hidden" value="{$info.id}" name="id">
  9. <input type="hidden" value="{$type}" name="type">
  10. <!--通知场景-->
  11. <div class="layui-form-item">
  12. <label class="layui-form-label">通知场景:</label>
  13. <div class="layui-input-inline" style="padding-top: 8px">
  14. {$info.scene}
  15. </div>
  16. </div>
  17. <!--模板编号-->
  18. <div class="layui-form-item">
  19. <label class="layui-form-label"><span class="tips">*</span>模板编号:</label>
  20. <div class="layui-input-inline">
  21. <input type="text" name="template_sn" value="{$info.mnp_notice.template_sn | default =''}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  22. </div>
  23. </div>
  24. <!--模板名称-->
  25. <div class="layui-form-item">
  26. <label class="layui-form-label"><span class="tips">*</span>模板名称:</label>
  27. <div class="layui-input-inline">
  28. <input type="text" name="name" value="{$info.mnp_notice.name | default = ''}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  29. </div>
  30. </div>
  31. <!--模板id-->
  32. <div class="layui-form-item">
  33. <label class="layui-form-label"><span class="tips">*</span>模板ID:</label>
  34. <div class="layui-input-inline">
  35. <input type="text" name="template_id" value="{$info.mnp_notice.template_id | default =''}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  36. </div>
  37. </div>
  38. <!--场景变量-->
  39. <div class="layui-form-item">
  40. <label class="layui-form-label">场景变量:</label>
  41. <div class="layui-input-block">
  42. {foreach $info.variable as $item => $val}
  43. <button type="button" class="layui-btn layui-btn-primary variable-btn" data-value="{$item}">{$val}</button>
  44. {/foreach}
  45. </div>
  46. </div>
  47. <div class="layui-form-item">
  48. <label class="layui-form-label"></label>
  49. <div class="layui-form-mid layui-word-aux">系统在当前场景预定义好的通知变量</div>
  50. </div>
  51. <!--模板内容-->
  52. <div class="layui-form-item">
  53. <label class="layui-form-label"><span class="tips">*</span>模板内容:</label>
  54. <div class="layui-input-inline">
  55. <button class="layui-btn layui-btn-sm layui-btn-normal addTpl" type="button">新增</button>
  56. </div>
  57. </div>
  58. <!--模板-->
  59. <div class="template-body">
  60. {notempty name ="$info.mnp_notice.tpl"}
  61. {foreach $info.mnp_notice.tpl as $k => $item}
  62. <div class="layui-form-item template">
  63. <div class="layui-input-block">
  64. <label class="layui-form-label">字段名称:</label>
  65. <div class="layui-input-inline">
  66. <input type="text" name="tpl_name[]" value="{$item.tpl_name}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  67. </div>
  68. <label class="layui-form-label">关键词:</label>
  69. <div class="layui-input-inline">
  70. <input type="text" name="tpl_keyword[]" value="{$item.tpl_keyword}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  71. </div>
  72. <label class="layui-form-label">字段内容:</label>
  73. <div class="layui-input-inline">
  74. <input type="text" name="tpl_content[]" value="{$item.tpl_content}" autocomplete="off" class="layui-input" lay-verify="required" lay-vertype="tips">
  75. </div>
  76. <button class="layui-btn layui-btn-sm layui-btn-danger delTpl" type="button">删除</button>
  77. </div>
  78. </div>
  79. {/foreach}
  80. {/notempty}
  81. </div>
  82. <!--模板预览-->
  83. <div class="layui-form-item">
  84. <label class="layui-form-label"><span class="tips">*</span>模板预览:</label>
  85. <div class="layui-input-block">
  86. <div class="layui-col-sm4">
  87. <textarea placeholder="请输入内容" name="content" id="content" class="layui-textarea"></textarea>
  88. </div>
  89. </div>
  90. </div>
  91. <!--状态-->
  92. <div class="layui-form-item">
  93. <label class="layui-form-label">状态</label>
  94. <div class="layui-input-inline">
  95. <input type="radio" name="status" value="1" title="开启" {if ($info.mnp_notice.status ?? 0) == 1}checked{/if} />
  96. <input type="radio" name="status" value="0" title="关闭" {if ($info.mnp_notice.status ?? 0) == 0}checked{/if} />
  97. <div class="layui-form-mid layui-word-aux">开启或关闭当前场景通知</div>
  98. </div>
  99. </div>
  100. <div class="layui-form-item layui-hide">
  101. <input type="button" lay-submit lay-filter="addSubmit" id="addSubmit" value="确认">
  102. </div>
  103. </div>
  104. <script>
  105. layui.config({
  106. version:"{$front_version}",
  107. base: '/static/plug/'
  108. }).extend({
  109. base: '/static/plug/layui-admin/dist/layuiadmin/'
  110. }).use(['form'], function() {
  111. var $ = layui.$
  112. ,form = layui.form;
  113. //场景变量复制
  114. $(document).on('click', '.variable-btn', function () {
  115. var copyText = $(this).data('value');
  116. let aux = document.createElement("input");
  117. aux.setAttribute("value", '{'+copyText+'}');
  118. document.body.appendChild(aux);
  119. aux.select();
  120. document.execCommand("copy");
  121. document.body.removeChild(aux);
  122. layer.msg('已复制场景变量');
  123. });
  124. // 添加模板
  125. $(document).on('click','.addTpl',function() {
  126. var tpl = '<div class="layui-form-item template">' +
  127. ' <div class="layui-input-block">' +
  128. ' <label class="layui-form-label">字段名称:</label>' +
  129. ' <div class="layui-input-inline">' +
  130. ' <input type="text" name="tpl_name[]" autocomplete="off" class="layui-input" value="" lay-verify="required" lay-vertype="tips">' +
  131. ' </div>' +
  132. ' <label class="layui-form-label">关键词:</label>' +
  133. ' <div class="layui-input-inline">' +
  134. ' <input type="text" name="tpl_keyword[]" autocomplete="off" class="layui-input" value="" lay-verify="required" lay-vertype="tips">' +
  135. ' </div>' +
  136. ' <label class="layui-form-label">字段内容:</label>' +
  137. ' <div class="layui-input-inline">' +
  138. ' <input type="text" name="tpl_content[]" autocomplete="off" class="layui-input" value="" lay-verify="required" lay-vertype="tips">' +
  139. ' </div>' +
  140. ' <button class="layui-btn layui-btn-sm layui-btn-danger delTpl" type="button">删除</button>' +
  141. ' </div>' +
  142. ' </div>';
  143. $('.template-body').append(tpl);
  144. });
  145. refreshContent();
  146. //监听字段名称
  147. $(document).on("input propertychange","input[name='tpl_name[]']",function() {
  148. refreshContent();
  149. });
  150. //监听关键词
  151. $(document).on("input propertychange","input[name='tpl_keyword[]']",function() {
  152. refreshContent();
  153. });
  154. // 删除模板
  155. $(document).on('click','.delTpl',function() {
  156. var len = $("div.template-body > div.template").length;
  157. if (len == 1) {
  158. layer.msg('最少保留一个模板内容');
  159. return;
  160. } else {
  161. $(this).parents('.template').remove();
  162. refreshContent();
  163. }
  164. });
  165. //渲染模板预览
  166. function refreshContent() {
  167. var map = [];
  168. $(".template").each(function() {
  169. var index = $(this).index();
  170. var key_value = $(this).children().find("input[name='tpl_keyword[]']").val();
  171. var name_value = $(this).children().find("input[name='tpl_name[]']").val();
  172. map[index] = {name:name_value, key:key_value};
  173. });
  174. if (map.length > 0) {
  175. var content = '';
  176. for (var i=0; i < map.length; i++) {
  177. var key = '{{'+map[i].key+'.DATA}}';
  178. var name = map[i].name;
  179. if (map[i].key === undefined || map[i].key === '') {
  180. key = '';
  181. }
  182. if (map[i].name === undefined || map[i].name === '') {
  183. name = '';
  184. }
  185. content += name + ':' + key + "\n";
  186. }
  187. $('#content').text(content);
  188. }
  189. }
  190. })
  191. </script>