add.html 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <link rel="stylesheet" href="/static/editor.md/css/editormd.min.css" />
  2. <div class="layui-layout layui-layout-admin" style="padding-left: 40px;margin-top: 20px;">
  3. <form class="layui-form" action="" method="post">
  4. <div class="layui-form-item">
  5. <label class="layui-form-label">模板名称</label>
  6. <div class="layui-input-block " style="width: 400px">
  7. <input type="text" name="template_name" id="template_name" lay-verify="required" autocomplete="off" placeholder="比如:接口模板" class="layui-input" value="">
  8. </div>
  9. </div>
  10. <div class="layui-form-item">
  11. <label class="layui-form-label">文档内容</label>
  12. <div class="layui-input-inline" id="api-editormd" style="border: 1px solid #e4e4e4">
  13. <textarea name="detail" style="display:none;">
  14. #### 简要描述:
  15. - 用户登录接口
  16. #### 请求头:
  17. |参数名|是否必须|类型|说明|
  18. |:---- |:---|:----- |----- |
  19. |Content-Type |是 |string |请求类型: application/json |
  20. |Content-MD5 |是 |string | 请求内容签名 |
  21. #### 请求参数:
  22. |参数名|是否必须|类型|说明|示例值
  23. |:---- |:---|:----- |----- |----- |
  24. |username |是 |string |用户名 | george518
  25. |password |是 |string | 密码 | george518
  26. #### 返回参数:
  27. |参数名|类型|说明|
  28. |:----- |:-----|----- |
  29. |group_level |int |用户组id,1:超级管理员;2:普通用户 |
  30. #### 返回示例:
  31. **正确时返回:**
  32. ```
  33. {
  34. "status": 200,
  35. "message": "Success",
  36. "data": {
  37. "uid": "1",
  38. "account": "admin",
  39. "nickname": "Minho",
  40. "group_level": 0 ,
  41. "create_time": "1436864169",
  42. "last_login_time": "0",
  43. }
  44. }
  45. ```
  46. **错误时返回:**
  47. ```
  48. {
  49. "status": 300,
  50. "message": "invalid username"
  51. "data":{
  52. }
  53. }
  54. ```
  55. #### 调用示例:
  56. ```
  57. <?php
  58. echo "Hello world";
  59. ```
  60. #### 备注:
  61. - 更多返回错误代码请看首页的错误代码描述
  62. #### 接口版本:
  63. |版本号|制定人|制定日期|修订日期|
  64. |:---- |:---|:----- |----- |
  65. |2.1.0 |郝大全 |2018-01-15 | 2018-01-15 |
  66. </textarea>
  67. </div>
  68. </div>
  69. <div class="layui-form-item">
  70. <div class="layui-input-block">
  71. <button class="layui-btn" lay-submit="" lay-filter="sub">保存</button>
  72. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  73. </div>
  74. </div>
  75. </form>
  76. </div>
  77. <script>
  78. // console.log(sourceList);
  79. layui.use(['form','element','table','layer','jquery'],function(){
  80. var form = layui.form; //只有执行了这一步,部分表单元素才会自动修饰成功
  81. var $ = layui.jquery;
  82. var table = layui.table;
  83. form.on('submit(sub)', function(data){
  84. var form_data = data.field;
  85. $.post('{{urlfor "TemplateController.AjaxSave"}}', form_data, function (out) {
  86. if (out.status == 0) {
  87. layer.msg("操作成功",{icon: 1},function () {
  88. window.location.href="/template/list";
  89. })
  90. } else {
  91. layer.msg(out.message)
  92. }
  93. }, "json");
  94. return false;
  95. });
  96. //但是,如果你的HTML是动态生成的,自动渲染就会失效
  97. //因此你需要在相应的地方,执行下述方法来手动渲染,跟这类似的还有 element.init();
  98. form.render();
  99. });
  100. </script>
  101. {{template "public/editormd.html" .}}