TemplateClass-.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <!DOCTYPE html>
  2. <html class="x-admin-sm">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta name="renderer" content="webkit">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  7. <meta name="viewport" content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi" />
  8. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/font.css">
  9. <link rel="stylesheet" href="https://osscold.baozhida.cn/css/xadmin.css">
  10. <link rel="stylesheet" href="https://osscold.baozhida.cn/lib/layui/layui.css">
  11. <script type="text/javascript" src="https://osscold.baozhida.cn/lib/layui/layui.js" charset="utf-8"></script>
  12. <script type="text/javascript" src="https://osscold.baozhida.cn/js/xadmin.js"></script>
  13. <!-- 让IE8/9支持媒体查询,从而兼容栅格 -->
  14. <!--[if lt IE 9]>
  15. <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script>
  16. <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script>
  17. <![endif]--></head>
  18. <body>
  19. <div class="layui-fluid">
  20. <div class="layui-row">
  21. <form class="layui-form">
  22. <div class="layui-form-item">
  23. <label for="T_name" class="layui-form-label">
  24. <span class="x-red">*</span>分类名称</label>
  25. <div class="layui-input-inline">
  26. <input {{if gt .id 0 }}
  27. value="{{.T.T_name}}"
  28. {{end}} type="text" id="T_name" name="T_name" required="" lay-verify="required" autocomplete="off" class="layui-input"></div>
  29. </div>
  30. <div class="layui-form-item" style="text-align: center;margin-top: 20px">
  31. <button class="layui-btn layui-btn-normal" lay-filter="add" lay-submit="">提交</button>
  32. </div>
  33. </form>
  34. </div>
  35. </div>
  36. <script>
  37. layui.use(['form', 'layer',"layedit"],
  38. function() {
  39. $ = layui.jquery;
  40. var form = layui.form,
  41. layer = layui.layer;
  42. //监听提交
  43. form.on('submit(add)',
  44. function(data) {
  45. console.log(data);
  46. //发异步,把数据提交给php
  47. layer.alert("操作成功", {
  48. icon: 6
  49. },
  50. function() {
  51. // 获得frame索引
  52. var index = parent.layer.getFrameIndex(window.name);
  53. //关闭当前frame
  54. parent.layer.close(index);
  55. parent.location.reload();
  56. });
  57. $.ajax({
  58. type: 'POST',
  59. url: 'Class_Post',//发送请求
  60. data: {
  61. Id:"{{.id}}",
  62. T_name:data.field.T_name,
  63. },
  64. success: function(result) {
  65. console.log(result)
  66. }
  67. });
  68. return false;
  69. });
  70. });
  71. </script>
  72. <script>
  73. var _img = ""
  74. layui.use('upload', function(){
  75. var $ = layui.jquery
  76. ,upload = layui.upload;
  77. //普通图片上传
  78. var uploadInst = upload.render({
  79. elem: '#test1'
  80. ,url: '/UpFile' //改成您自己的上传接口
  81. ,before: function(obj){
  82. //预读本地文件示例,不支持ie8
  83. obj.preview(function(index, file, result){
  84. $('#demo1').attr('src', result); //图片链接(base64)
  85. });
  86. }
  87. ,done: function(res){
  88. console.log(res)
  89. //如果上传失败
  90. if(res.code != 0){
  91. return layer.msg('上传失败');
  92. }
  93. _img = res.data.src
  94. console.log(_img)
  95. //上传成功
  96. }
  97. ,error: function(){
  98. console.log("error")
  99. //演示失败状态,并实现重传
  100. var demoText = $('#demoText');
  101. demoText.html('<span style="color: #ff5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
  102. demoText.find('.demo-reload').on('click', function(){
  103. uploadInst.upload();
  104. });
  105. }
  106. });
  107. //绑定原始文件域
  108. upload.render({
  109. elem: '#test20'
  110. ,url: 'https://httpbin.org/post' //改成您自己的上传接口
  111. ,done: function(res){
  112. layer.msg('上传成功');
  113. console.log(res)
  114. }
  115. });
  116. });
  117. </script>
  118. </body>
  119. </html>