add.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. <select name="pid" lay-verify="required">
  13. <option value="">配置分组</option>
  14. {volist name="$configGroup" id="vo"}
  15. <option value="{$vo.name}" {if !empty($info) && $info.type==$vo.name} selected {/if} >{$vo.title}</option>
  16. {/volist}
  17. </select>
  18. </div>
  19. </div>
  20. <div class="layui-form-item">
  21. <label class="layui-form-label">配置名</label>
  22. <div class="layui-input-inline">
  23. <input type="text" name="code" lay-verify="required" placeholder="{:lang('pleaseEnter')}配置名" class="layui-input">
  24. </div>
  25. <div class="layui-form-mid layui-word-aux">
  26. 英文字符。不能和当前已有的重复
  27. </div>
  28. </div>
  29. <div class="layui-form-item">
  30. <label class="layui-form-label">配置值</label>
  31. <div class="layui-input-inline">
  32. <input type="text" name="value" lay-verify="required" placeholder="{:lang('pleaseEnter')}配置值" class="layui-input">
  33. </div>
  34. </div>
  35. <div class="layui-form-item">
  36. <label class="layui-form-label">备注</label>
  37. <div class="layui-input-inline">
  38. <textarea type="text" name="remark" placeholder="{:lang('pleaseEnter')}备注" class="layui-textarea"></textarea>
  39. </div>
  40. </div>
  41. <div class="layui-form-item">
  42. <div class="layui-input-inline">
  43. <input type="hidden" name="id" >
  44. <button type="button" class="layui-btn" lay-submit="" lay-filter="submit">{:lang('submit')}</button>
  45. <a href="{:url('index')}" class="layui-btn layui-btn-primary">{:lang('back')}</a>
  46. </div>
  47. </div>
  48. </form>
  49. </div>
  50. </div>
  51. </div>
  52. {include file="common/footer"/}
  53. <script>
  54. layui.use(['form', 'layer','upload','laydate'], function () {
  55. var form = layui.form, laydate=layui.laydate,layer = layui.layer,$= layui.jquery,upload = layui.upload;
  56. var info = '';
  57. //日期范围
  58. laydate.render({
  59. elem: '#date'
  60. ,range: true
  61. });
  62. info = {:json_encode($info)};
  63. form.val("form", info);
  64. if(info){
  65. $('#addPic').attr('src',info.avatar);
  66. }
  67. form.render();
  68. form.on('submit(submit)', function (data) {
  69. loading =layer.load(1, {shade: [0.1,'#fff']});
  70. $.post("", data.field, function (res) {
  71. layer.close(loading);
  72. if (res.code > 0) {
  73. layer.msg(res.msg, {time: 1800, icon: 1}, function () {
  74. location.href = res.url;
  75. });
  76. } else {
  77. layer.msg(res.msg, {time: 1800, icon: 2});
  78. }
  79. });
  80. });
  81. //普通图片上传
  82. var uploadInt = upload.render({
  83. elem: '#addBtn'
  84. ,url: '{:url("uploads/uploads")}'
  85. ,before: function(obj){
  86. //预读本地文件示例,不支持ie8
  87. obj.preview(function(index, file, result){
  88. $('#addPic').attr('src', result); //图片链接(base64)
  89. });
  90. },
  91. done: function(res){
  92. if(res.code>0){
  93. $('#avatar').val(res.url);
  94. }else{
  95. //如果上传失败
  96. return layer.msg('上传失败');
  97. }
  98. }
  99. ,error: function(){
  100. //演示失败状态,并实现重传
  101. var notice = $('#notice');
  102. notice.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
  103. notice.find('.demo-reload').on('click', function(){
  104. uploadInt.upload();
  105. });
  106. }
  107. });
  108. });
  109. </script>