No Description
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

add_pro.htm 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. <link rel="stylesheet" href="__PUBLIC__/plugins/layui/css/layui.css?v={$version}" media="all">
  2. <div style="width:90%;padding:20px 5%;">
  3. <form class="layui-form" action="form.html">
  4. <!--隐藏参数-->
  5. <input type="hidden" name="typeid" value="{$typeid}"/>
  6. <input type="hidden" name="proid" value="{$proid}"/>
  7. <div class="layui-form-item">
  8. <label class="layui-form-label">名称</label>
  9. <div class="layui-input-block">
  10. <input type="text" name="name" lay-verify="title" autocomplete="off" placeholder="请输入" class="layui-input">
  11. </div>
  12. </div>
  13. <div class="layui-form-item">
  14. <label class="layui-form-label">是否热门</label>
  15. <div class="layui-input-block">
  16. <input type="radio" name="is_hot" value="1" title="是">
  17. <input type="radio" name="is_hot" value="0" title="否" checked="">
  18. </div>
  19. </div>
  20. <div class="layui-form-item">
  21. <div class="layui-input-block">
  22. <button type="submit" class="layui-btn" lay-submit="" lay-filter="demo1">立即提交</button>
  23. <!-- <button type="reset" class="layui-btn layui-btn-primary">重置</button>-->
  24. </div>
  25. </div>
  26. </form>
  27. <script src="__PUBLIC__/plugins/layui/layui.js?v={$version}" charset="utf-8"></script>
  28. <script>
  29. layui.use(['form', 'layedit', 'laydate'], function(){
  30. var form = layui.form
  31. ,layer = layui.layer
  32. ,layedit = layui.layedit
  33. ,laydate = layui.laydate
  34. ,$ = layui.$;
  35. //日期
  36. laydate.render({
  37. elem: '#date'
  38. });
  39. laydate.render({
  40. elem: '#date1'
  41. });
  42. //创建一个编辑器
  43. var editIndex = layedit.build('LAY_demo_editor');
  44. //自定义验证规则
  45. form.verify({
  46. title: function(value){
  47. if(value.length < 1){
  48. return '标题至少得1个字符啊';
  49. }
  50. }
  51. ,pass: [
  52. /^[\S]{6,12}$/
  53. ,'密码必须6到12位,且不能出现空格'
  54. ]
  55. ,content: function(value){
  56. layedit.sync(editIndex);
  57. }
  58. });
  59. //监听指定开关
  60. form.on('switch(switchTest)', function(data){
  61. layer.msg('开关checked:'+ (this.checked ? 'true' : 'false'), {
  62. offset: '6px'
  63. });
  64. layer.tips('温馨提示:请注意开关状态的文字可以随意定义,而不仅仅是ON|OFF', data.othis)
  65. });
  66. //监听提交
  67. form.on('submit(demo1)', function(data){
  68. /*layer.alert(JSON.stringify(data.field), {
  69. title: '最终的提交信息'
  70. })*/
  71. var index = parent.layer.getFrameIndex(window.name);
  72. $.post("/login.php?m=admin&c=Archives&a=add_pro_post", data.field, function (res){
  73. console.log(res);
  74. parent.layer.msg(res.msg);
  75. setTimeout(function(){
  76. parent.location.reload();
  77. parent.layer.close(index);
  78. }, 1000);
  79. });
  80. return false;
  81. });
  82. //表单赋值
  83. layui.$('#LAY-component-form-setval').on('click', function(){
  84. form.val('example', {
  85. "username": "贤心" // "name": "value"
  86. ,"password": "123456"
  87. ,"interest": 1
  88. ,"like[write]": true //复选框选中状态
  89. ,"close": true //开关状态
  90. ,"sex": "女"
  91. ,"desc": "我爱 layui"
  92. });
  93. });
  94. //表单取值
  95. layui.$('#LAY-component-form-getval').on('click', function(){
  96. var data = form.val('example');
  97. alert(JSON.stringify(data));
  98. });
  99. });
  100. </script>