add.html 3.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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></td>
  9. <td>
  10. <input type="hidden" name="id" value="{$id}" />
  11. <input type="text" name="name" lay-verify="required" autocomplete="off" placeholder="请输入网站名称" lay-reqText="请输入网站名称" class="layui-input" {notempty name="$links.name" }value="{$links.name}" {/notempty}>
  12. </td>
  13. <td rowspan="4" class="layui-td-gray">网站Logo</td>
  14. <td rowspan="4">
  15. <div class="layui-upload" style="text-align:center">
  16. <button type="button" class="layui-btn layui-btn-normal layui-btn-sm" id="uploadBtn">上传网站Logo</button>
  17. <div class="layui-upload-list" id="demo1" style="width:200px; height:120px; overflow:hidden">
  18. <img {notempty name="$links.logo" }src="{:get_file($links.logo)}" {/notempty} heght="120px;" style="max-width: 100%;" />
  19. <input type="hidden" name="logo" {notempty name="$links.logo" }value="{$links.logo}" {/notempty}>
  20. </div>
  21. </div>
  22. </td>
  23. </tr>
  24. <tr>
  25. <td class="layui-td-gray">网站链接<font>*</font></td>
  26. <td>
  27. <input type="text" name="src" lay-verify="required" autocomplete="off" placeholder="请输入网站链接" lay-reqText="请输入网站链接" class="layui-input" {notempty name="$links.src" }value="{$links.src}" {/notempty}>
  28. </td>
  29. </tr>
  30. <tr>
  31. <td class="layui-td-gray-2">新窗口打开</td>
  32. <td>
  33. {notempty name="$links.target" }
  34. <input type="radio" name="target" value="1" title="是" {eq name="$links.target" value="1" }checked{/eq}>
  35. <input type="radio" name="target" value="0" title="否" {eq name="$links.target" value="0" }checked{/eq}>
  36. {else/}
  37. <input type="radio" name="target" value="1" title="是" checked>
  38. <input type="radio" name="target" value="0" title="否">
  39. {/notempty}
  40. </td>
  41. </tr>
  42. <tr>
  43. <td class="layui-td-gray">排序</td>
  44. <td>
  45. {notempty name="$links.target" }
  46. <input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input" value="{$links.sort}">
  47. {else/}
  48. <input type="text" name="sort" placeholder="请输入排序,数字" autocomplete="off" class="layui-input" value="0">
  49. {/notempty}
  50. </td>
  51. </tr>
  52. </table>
  53. <div class="py-3">
  54. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  55. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  56. </div>
  57. </form>
  58. {/block}
  59. <!-- /主体 -->
  60. <!-- 脚本 -->
  61. {block name="script"}
  62. <script>
  63. const moduleInit = ['tool'];
  64. function gouguInit() {
  65. var form = layui.form,tool=layui.tool,upload = layui.upload;
  66. //pc端图片
  67. var uploadInst = upload.render({
  68. elem: '#uploadBtn',
  69. url: '/admin/api/upload',
  70. done: function (e) {
  71. //如果上传失败
  72. if (e.code == 1) {
  73. return layer.msg('上传失败');
  74. }
  75. //上传成功
  76. $('#demo1 input').attr('value', e.data.id);
  77. $('#demo1 img').attr('src', e.data.filepath);
  78. }
  79. });
  80. //监听提交
  81. form.on('submit(webform)', function (data) {
  82. let callback = function (e) {
  83. layer.msg(e.msg);
  84. if (e.code == 0) {
  85. parent.layui.tool.close(1000);
  86. }
  87. }
  88. tool.post("/admin/links/add", data.field, callback);
  89. return false;
  90. });
  91. }
  92. </script>
  93. {/block}
  94. <!-- /脚本 -->