group_edit.html 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <div class="admin-main layui-anim layui-anim-upbit">
  5. <fieldset class="layui-elem-field layui-field-title">
  6. <legend>{$title}</legend>
  7. </fieldset>
  8. <form class="layui-form layui-form-pane" lay-filter="form">
  9. <div class="layui-form-item">
  10. <label class="layui-form-label">用户组名</label>
  11. <div class="layui-input-inline">
  12. <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}用户组名" class="layui-input">
  13. </div>
  14. </div>
  15. <div class="layui-form-item">
  16. <div class="layui-input-block">
  17. <input type="hidden" name="id">
  18. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  19. <a href="{:url('group')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  20. </div>
  21. </div>
  22. </form>
  23. </div>
  24. </div>
  25. </div>
  26. {include file="common/footer"/}
  27. <script>
  28. layui.use(['form', 'layer','upload'], function () {
  29. var form = layui.form, layer = layui.layer,$= layui.jquery,upload = layui.upload;
  30. var info = {:json_encode($info)};
  31. form.val("form", info);
  32. form.render();
  33. form.on('submit(submit)', function (data) {
  34. loading =layer.load(1, {shade: [0.1,'#fff']});
  35. $.post("", data.field, function (res) {
  36. layer.close(loading);
  37. if (res.code > 0) {
  38. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  39. location.href = res.url;
  40. });
  41. } else {
  42. layer.msg(res.msg, {time: 1800, icon: 2});
  43. }
  44. });
  45. });
  46. //普通图片上传
  47. var uploadInt = upload.render({
  48. elem: '#addBtn'
  49. ,url: '{:url("uploads/uploads")}'
  50. ,before: function(obj){
  51. //预读本地文件示例,不支持ie8
  52. obj.preview(function(index, file, result){
  53. $('#addPic').attr('src', result); //图片链接(base64)
  54. });
  55. },
  56. done: function(res){
  57. if(res.code>0){
  58. $('#avatar').val(res.url);
  59. }else{
  60. //如果上传失败
  61. return layer.msg('上传失败');
  62. }
  63. }
  64. ,error: function(){
  65. //演示失败状态,并实现重传
  66. var notice = $('#notice');
  67. notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  68. notice.find('.demo-reload').on('click', function(){
  69. uploadInt.upload();
  70. });
  71. }
  72. });
  73. });
  74. </script>