form.html 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <div class="think-box-shadow">
  2. <form class="layui-form layui-card" action="{:request()->url()}" data-auto="true" method="post" autocomplete="off">
  3. <div class="layui-card-body">
  4. <div class="layui-form-item">
  5. <label class="layui-form-label label-required">推送类型</label>
  6. <div class="layui-input-inline">
  7. <select name="type" lay-filter ="type">
  8. {foreach [2=>'搜索标签',3=>'模块详情',4=>'智能标签'] as $ck=>$cv}
  9. {if isset($vo.type)}
  10. <option {if $vo.type == $ck } selected {/if} value="{$ck}">{$cv}</option>
  11. {else}
  12. <option {if $ck == 2 } selected {/if} value="{$ck}">{$cv}</option>
  13. {/if}
  14. {/foreach}
  15. </select>
  16. </div>
  17. </div>
  18. <div class="layui-form-item">
  19. <label class="layui-form-label ">标签</label>
  20. <div class="layui-input-block">
  21. <input name="label" value='{$vo.label|default=""}' placeholder="请输入标签 不填默认全部发送" class="layui-input">
  22. </div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label label-required">标题</label>
  26. <div class="layui-input-block">
  27. <input name="title" required value='{$vo.title|default=""}' placeholder="请输入推送标题" class="layui-input">
  28. </div>
  29. </div>
  30. <div class="label_div layui-form-item" {if !isset($vo.type) || $vo.type !== 4}style="display:none" {/if}>
  31. <label class="layui-form-label label-required">智能标签</label>
  32. <div class="layui-input-block">
  33. <div id="demo1"></div>
  34. </div>
  35. </div>
  36. <div class="module_div" {if !isset($vo.type) || $vo.type == 2}style="display:none" {/if}>
  37. <div class="layui-form-item">
  38. <label class="layui-form-label label-required">模块</label>
  39. <div class="layui-input-inline">
  40. <select name="module" lay-filter ="module">
  41. {foreach $module_arr as $ck=>$cv}
  42. <option data-sel_module="{$ck}" {if isset($vo.module) && $vo.module == $ck } selected {/if} value="{$ck}">{$cv}</option>
  43. {/foreach}
  44. </select>
  45. </div>
  46. </div>
  47. <div class="layui-form-item">
  48. <label class="layui-form-label label-required">详情</label>
  49. <div class="layui-input-inline">
  50. <select name="first_id" id="first_id" lay-filter ="first_id" lay-search="">
  51. </select>
  52. </div>
  53. <div class="layui-input-inline second_div">
  54. <select name="second_id" id="second_id" lay-filter ="second_id" lay-search="">
  55. </select>
  56. </div>
  57. </div>
  58. </div>
  59. <div class="layui-form-item">
  60. <label class="layui-form-label label-required">推送内容</label>
  61. <div class="layui-input-block">
  62. <textarea name="content" required rows="10" cols="98">{$vo.content|default=''}</textarea>
  63. </div>
  64. </div>
  65. {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
  66. <div class="layui-form-item text-center">
  67. <button class="layui-btn" type='submit'>保 存</button>
  68. <button class="layui-btn layui-btn-danger" type='button' data-close>取消编辑</button>
  69. </div>
  70. </div>
  71. </form>
  72. <!-- <script src="__ROOT__/static/xm-select.js"></script>-->
  73. <script>
  74. var user_label = {:json_encode($user_label)};
  75. console.log(user_label);
  76. var demo1 = xmSelect.render({
  77. el: '#demo1',
  78. language: 'zn',
  79. filterable: true,
  80. data: user_label
  81. })
  82. </script>
  83. <script>
  84. form.on('select(type)', function(data){
  85. if(data.value == 3) {
  86. $(".module_div").show();
  87. }else{
  88. $(".module_div").hide();
  89. }
  90. if(data.value == 4) {
  91. $(".label_div").show();
  92. $(".module_div").show();
  93. }else{
  94. $(".label_div").hide();
  95. }
  96. window.form.render();
  97. })
  98. var sel_first = {:isset($vo['first_id']) ? $vo['first_id']:0};
  99. var sel_second = {:isset($vo['second_id']) ? $vo['second_id']:0};
  100. var module_list = {:json_encode($module_list)};
  101. // 分类选择监听
  102. var arr = ['video','article','datum','supplier','recruit','mall'];
  103. first(1);
  104. form.on('select(module)', function(data){
  105. first(2)
  106. })
  107. // 详情关联监听
  108. form.on('select(first_id)', function(data){
  109. second(2);
  110. })
  111. function first(source) {
  112. sel_module = $("select[name='module']").find("option:selected").data('sel_module');
  113. if(arr.indexOf(sel_module) != -1) {
  114. $(".second_div").show();
  115. }else{
  116. $(".second_div").hide();
  117. }
  118. var cl_html = '<option value="0">请选择</option>';
  119. if(sel_module == '') {
  120. $("select[name='first_id']").html(cl_html);
  121. $("select[name='second_id']").html(cl_html);
  122. window.form.render();
  123. return true;
  124. }else{
  125. $.each(module_list,function (ck,cv) {
  126. if(cv.module == sel_module) {
  127. if(source == 1 && sel_first == cv.id) {
  128. cl_html +='<option selected value="'+cv.id+'">'+cv.title+'</option>';
  129. }else{
  130. cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
  131. }
  132. }
  133. })
  134. $("select[name='first_id']").html(cl_html);
  135. $("select[name='second_id']").html('');
  136. }
  137. second(source);
  138. window.form.render();
  139. }
  140. function second(source) {
  141. var cl_html = '<option value="0">请选择</option>';
  142. sel_module = $("select[name='module']").find("option:selected").data('sel_module');
  143. first_id = $("select[name='first_id']").find("option:selected").val();
  144. $.each(module_list,function (ck,cv) {
  145. if(sel_module == cv.module && first_id == cv.id && arr.indexOf(sel_module) != -1) {
  146. $.each(cv.children,function (sk,sv) {
  147. if(source == 1 && sel_second == sv.id) {
  148. cl_html +='<option selected value="'+sv.id+'">'+sv.title+'</option>';
  149. }else{
  150. cl_html +='<option value="'+sv.id+'">'+sv.title+'</option>';
  151. }
  152. })
  153. $("select[name='second_id']").html(cl_html);
  154. $(".second_div").show();
  155. form.render();
  156. }
  157. })
  158. }
  159. </script>
  160. </div>