form.html 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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-block">
  7. <input name="title" maxlength="60" value='{$vo.title|default=""}' placeholder="请输入标题" class="layui-input">
  8. </div>
  9. </div>
  10. <div class="layui-form-item">
  11. <label class="layui-form-label label-required">目录</label>
  12. <div class="layui-input-inline">
  13. <select name="datum_cate" lay-filter ="datum_cate" lay-search>
  14. {foreach $datum_cate as $ck=>$cv}
  15. {if !empty($vo.datum_cate) && $vo.datum_cate == $ck}
  16. <option selected value="{$ck}">{$cv.title}</option>
  17. {else}
  18. <option value="{$ck}">{$cv.title}</option>
  19. {/if}
  20. {/foreach}
  21. </select>
  22. </div>
  23. </div>
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">资料章数</label>
  26. <div class="layui-input-block">
  27. <input name="total_sequel" type="number" value='{$vo.total_sequel|default="1"}' placeholder="请输入资料章数" class="layui-input">
  28. </div>
  29. </div>
  30. <div class="layui-form-item">
  31. <label class="layui-form-label label-required">关联视频</label>
  32. <div class="layui-input-inline">
  33. <select name="video_id" lay-filter ="video_id" lay-search>
  34. <option value="0">请选择</option>
  35. {foreach $video_list as $vk=>$vv}
  36. <option {if isset($vo.video_id) && $vo.video_id == $vv['id'] }selected{/if} data-vl_key="{$vk}" value="{$vv['id']}">{$vv['title']}</option>
  37. {/foreach}
  38. </select>
  39. </div>
  40. <div class="layui-input-inline">
  41. <select name="video_item" lay-filter ="video_item" lay-search>
  42. <option value="0">请选择</option>
  43. {foreach $video_list as $vk=>$vv}
  44. {if isset($vo.video_id) && $vo.video_id == $vv['id'] }
  45. {foreach $vv['video_arr'] as $cln}
  46. <option {if isset($vo.video_item) && $vo.video_item == $cln['id']} selected {/if} value="{$cln['id']}">{$cln['title']}</option>
  47. {/foreach}
  48. {/if}
  49. {/foreach}
  50. </select>
  51. </div>
  52. </div>
  53. <div class="layui-form-item" >
  54. <label class="layui-form-label ">关联产品</label>
  55. <div class="layui-input-inline" style="width: 300px">
  56. <select name="goods_id" lay-filter ="goods_id" lay-search="">
  57. <option value="0">请选择</option>
  58. {foreach $supplier_goods as $gk=>$gv}
  59. <option {if isset($vo.goods_id) && $vo.goods_id == $gv['id'] }selected{/if} value="{$gv['id']}">{$gv['name']}------{$gv['title']}</option>
  60. {/foreach}
  61. </select>
  62. </div>
  63. </div>
  64. <div class="layui-form-item">
  65. <label class="layui-form-label label-required">标签</label>
  66. <div class="layui-input-block">
  67. <textarea placeholder="请输入标签" maxlength="100" class="layui-textarea" name="label">{$vo.label|default=''}</textarea>
  68. <span >多个用逗号隔开(半角)</span>
  69. </div>
  70. </div>
  71. <div class="layui-form-item">
  72. <label class="layui-form-label label-required">排序</label>
  73. <div class="layui-input-block">
  74. <input name="sort" type="number" value='{$vo.sort|default="0"}' placeholder="请输入排序号" class="layui-input">
  75. </div>
  76. </div>
  77. <input type="hidden" name="type" value="{$type}">
  78. <div class="layui-form-item">
  79. <label class="layui-form-label label-required">是否VIP</label>
  80. <div class="layui-input-block">
  81. <select class="layui-select" name="is_vip">
  82. <option value="0">否</option>
  83. <option {if !empty($vo.is_vip) && $vo.is_vip == 1 }selected{/if} value="1">是</option>
  84. </select>
  85. </div>
  86. </div>
  87. {notempty name='vo.id'}<input type='hidden' value='{$vo.id}' name='id'>{/notempty}
  88. {if !$r}
  89. <div class="layui-form-item text-center">
  90. <button class="layui-btn" type='submit'>保 存</button>
  91. <button class="layui-btn layui-btn-danger" type='button' data-close>取消编辑</button>
  92. </div>
  93. {/if}
  94. </div>
  95. </form>
  96. <script src="/static/plugs/layui/layui.all.js" charset="utf-8"></script>
  97. <script>
  98. window.form.render();
  99. $('[name="cover"]').uploadOneImage();
  100. // 关联视频监听
  101. form.on('select(video_id)', function(data){
  102. var cl_html = '<option value="0">请选择</option>';
  103. if(data.value == 0) {
  104. $("select[name='video_item']").html(cl_html);
  105. }else{
  106. var vl_key = data.elem[data.elem.selectedIndex].dataset.vl_key;
  107. var video_list = {:json_encode($video_list)};
  108. $.each(video_list[vl_key]['video_arr'],function (ck,cv) {
  109. cl_html +='<option value="'+cv.id+'">'+cv.title+'</option>';
  110. })
  111. $("select[name='video_item']").html(cl_html);
  112. }
  113. window.form.render();
  114. });
  115. </script>
  116. </div>