save.html 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. <article class="cl pd-20">
  2. <form action="" method="post" class="form form-horizontal" id="form-save">
  3. <input type="hidden" id="roleid" name="roleid" value="{$data.roleid}">
  4. <div class="row cl">
  5. <label class="form-label col-xs-4 col-sm-2"><span class="c-red">*</span>角色名称:</label>
  6. <div class="formControls col-xs-8 col-sm-9">
  7. <input type="text" class="input-text" value="{$data.name}" placeholder="" id="name" name="name"
  8. datatype="*4-16" nullmsg="角色名称">
  9. </div>
  10. </div>
  11. <div class="row cl">
  12. <label class="form-label col-xs-4 col-sm-2">备注:</label>
  13. <div class="formControls col-xs-8 col-sm-9">
  14. <input type="text" class="input-text" value="{$data.remark}" placeholder="备注" id="remark" name="remark">
  15. </div>
  16. </div>
  17. <div class="row cl">
  18. <label class="form-label col-xs-4 col-sm-2">权限选择:</label>
  19. <div class="formControls col-xs-8 col-sm-9">
  20. {foreach $dataPermission as $value}
  21. <dl class="permission-list">
  22. <dt>
  23. <label>
  24. <input type="checkbox" value="{$value.id}" id="check_{$value.id}" name="perm_check[]" {if
  25. condition="in_array($value.id, $rolePowers)" }checked{/if}>
  26. {$value.name}</label>
  27. </dt>
  28. {notempty name='value.child'}
  29. {foreach $value.child as $val}
  30. <dd>
  31. <dl class="cl permission-list2">
  32. <dt>
  33. <label class="">
  34. <input type="checkbox" value="{$val.id}" name="perm_check[]" id="check_{$val.id}"
  35. {if condition="in_array($val.id, $rolePowers)" }checked{/if}>
  36. {$val.name}</label>
  37. </dt>
  38. {notempty name='val.child'}
  39. <dd>
  40. {foreach $val.child as $vo}
  41. <label class="">
  42. <input type="checkbox" value="{$vo.id}" name="perm_check[]" id="check_{$val.id}" {if
  43. condition="in_array($vo.id, $rolePowers)" }checked{/if}>
  44. {$vo.name}</label>
  45. {/foreach}
  46. </dd>
  47. {/notempty}
  48. </dl>
  49. </dd>
  50. {/foreach}
  51. {/notempty}
  52. </dl>
  53. {/foreach}
  54. </div>
  55. </div>
  56. <div class="row cl">
  57. <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
  58. <button type="button" class="btn btn-success radius" id="form-save-button"><i class="icon-ok"></i>
  59. 确定</button>
  60. <button type="button" class="btn btn-default radius" onClick="layer_close();"><i
  61. class="Hui-iconfont">&#xe66b;</i>取消</button>
  62. </div>
  63. </div>
  64. </form>
  65. </article>
  66. <!--请在下方写此页面业务相关的脚本-->
  67. <script type="text/javascript">
  68. $(function () {
  69. $(".permission-list dt input:checkbox").click(function () {
  70. $(this).closest("dl").find("dd input:checkbox").prop("checked", $(this).prop("checked"));
  71. });
  72. $(".permission-list2 dd input:checkbox").click(function () {
  73. var l = $(this).parent().parent().find("input:checked").length;
  74. var l2 = $(this).parents(".permission-list").find(".permission-list2 dd").find("input:checked").length;
  75. if ($(this).prop("checked")) {
  76. $(this).closest("dl").find("dt input:checkbox").prop("checked", true);
  77. $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", true);
  78. }
  79. else {
  80. if (l == 0) {
  81. $(this).closest("dl").find("dt input:checkbox").prop("checked", false);
  82. }
  83. if (l2 == 0) {
  84. $(this).parents(".permission-list").find("dt").first().find("input:checkbox").prop("checked", false);
  85. }
  86. }
  87. });
  88. $("#form-save-button").click(function () {
  89. var data = $("#form-save").serializeArray();
  90. $.ajax({
  91. type: 'POST',
  92. url: '{:url("save")}',
  93. data: data,
  94. dataType: 'json',
  95. success: function (res) {
  96. console.log(res);
  97. if (res.code == 0) {
  98. layer.msg(res.msg, {
  99. icon: 1,
  100. time: 1000
  101. }, function () {
  102. parent.location.reload(); // 父页面刷新
  103. var index = parent.layer.getFrameIndex(window.name); //获取窗口索引
  104. parent.layer.close(index);
  105. });
  106. } else {
  107. layer.msg(data.msg, {
  108. icon: 5,
  109. time: 1000
  110. });
  111. return false;
  112. }
  113. }
  114. })
  115. });
  116. })
  117. </script>
  118. <!--请在上方写此页面业务相关的脚本-->