截流自动化的商城平台
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_oa.html 10KB

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