Nenhuma descrição
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

edit_pro.htm 4.5KB

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