slide_info_add.html 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <form class="layui-form p-4">
  5. <h3 class="pb-3">幻灯片</h3>
  6. <table class="layui-table layui-table-form">
  7. <tr>
  8. <td class="layui-td-gray">标题<font>*</font>
  9. </td>
  10. <td colspan="3">
  11. <input type="hidden" name="id" value="{$id}" />
  12. <input type="text" name="title" lay-verify="required" lay-reqText="请输入标题" autocomplete="off" placeholder="请输入标题"
  13. class="layui-input" {notempty name="$slide_info.title" }value="{$slide_info.title}" {/notempty}>
  14. </td>
  15. <td class="layui-td-gray" rowspan="3">图片<font>*</font>
  16. </td>
  17. <td rowspan="3" style="vertical-align:top">
  18. <div class="layui-upload" style="text-align:center;">
  19. <button type="button" class="layui-btn layui-btn-sm layui-btn-normal" id="uploadBtn">选择要上传的图片</button>
  20. <div class="layui-upload-list" id="demo1" style="width: 100%;height:100px; overflow:hidden;">
  21. <img {notempty name="$slide_info.img" }src="{:get_file($slide_info.img)}" {/notempty}
  22. style="max-width: 120px;" />
  23. <input type="hidden" lay-verify="required" lay-reqText="请选择要上传的图片" name="img" {notempty
  24. name="$slide_info.img" }value="{$slide_info.img}" {/notempty}>
  25. </div>
  26. </div>
  27. </td>
  28. </tr>
  29. <tr>
  30. <td class="layui-td-gray">链接</td>
  31. <td colspan="3">
  32. <input type="text" name="src" autocomplete="off" placeholder="请输入链接" class="layui-input" {notempty
  33. name="$slide_info.src" }value="{$slide_info.src}" {/notempty}>
  34. </td>
  35. </tr>
  36. <tr>
  37. <td class="layui-td-gray">状态<font>*</font>
  38. </td>
  39. <td>
  40. {if condition="$id eq 0"}
  41. <input type="radio" name="status" value="1" title="正常" checked>
  42. <input type="radio" name="status" value="-1" title="禁用">
  43. {else/}
  44. <input type="radio" name="status" value="1" title="正常" {eq name="$slide_info.status" value="1" }checked{/eq}>
  45. <input type="radio" name="status" value="-1" title="禁用" {eq name="$slide_info.status" value="-1" }checked{/eq}>
  46. {/if}
  47. </td>
  48. <td class="layui-td-gray">排序</td>
  49. <td><input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input" {notempty
  50. name="$slide_info.sort" }value="{$slide_info.sort}" {/notempty}></td>
  51. </tr>
  52. <tr>
  53. <td class="layui-td-gray">备注</td>
  54. <td colspan="5">
  55. <textarea name="desc" placeholder="请输入备注"
  56. class="layui-textarea">{notempty name="$slide_info.desc" }{$slide_info.desc}{/notempty}</textarea>
  57. </td>
  58. </tr>
  59. </table>
  60. <div style="padding: 10px 0">
  61. <input type="hidden" name="slide_id" value="{$slide_id}">
  62. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  63. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  64. </div>
  65. </form>
  66. {/block}
  67. <!-- /主体 -->
  68. <!-- 脚本 -->
  69. {block name="script"}
  70. <script>
  71. const moduleInit = ['tool'];
  72. function gouguInit() {
  73. var form = layui.form, tool = layui.tool, upload = layui.upload;
  74. //头像上传
  75. var uploadInst = upload.render({
  76. elem: '#uploadBtn'
  77. , url: '/admin/api/upload'
  78. , done: function (res) {
  79. //如果上传失败
  80. if (res.code == 1) {
  81. return layer.msg('上传失败');
  82. }
  83. //上传成功
  84. $('#demo1 input').attr('value', res.data.id);
  85. $('#demo1 img').attr('src', res.data.filepath);
  86. }
  87. });
  88. //监听提交
  89. form.on('submit(webform)', function (data) {
  90. let callback = function (e) {
  91. layer.msg(e.msg);
  92. if (e.code == 0) {
  93. parent.layui.tool.close(1000);
  94. }
  95. }
  96. tool.post("/admin/slide/slide_info_add", data.field, callback);
  97. return false;
  98. });
  99. }
  100. </script>
  101. {/block}
  102. <!-- /脚本 -->