add.html 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. {extend name="common/base" /}
  2. {block name="style"}
  3. <style>
  4. .footer{
  5. display: none;
  6. }
  7. .left-note{vertical-align:top; padding-top:20px!important; text-align:center}
  8. .checkbox14 .layui-form-checkbox span{font-size:15px;font-weight:800;}
  9. .right-note .layui-checkbox-disabled span {color: #666666!important;}
  10. </style>
  11. {/block}
  12. <!-- 主体 -->
  13. {block name="body"}
  14. <form class="layui-form p-4">
  15. <h3 class="pb-3">权限角色</h3>
  16. <table class="layui-table layui-table-form">
  17. <tr>
  18. <td class="layui-td-gray">角色名称<font>*</font>
  19. </td>
  20. <td>
  21. <input type="hidden" name="id" value="{$id}" />
  22. <input class="layui-input" type="text" name="title" lay-verify="required" lay-reqText="请输入角色名称" {notempty name="$role.title"
  23. }value="{$role.title}" {/notempty} placeholder="请输入角色名称" autocomplete="off" />
  24. </td>
  25. <td class="layui-td-gray">状态<font>*</font>
  26. </td>
  27. <td>
  28. {if condition="$id eq 0"}
  29. <input type="radio" name="status" value="1" title="正常" checked>
  30. <input type="radio" name="status" value="-1" title="禁用">
  31. {else/}
  32. <input type="radio" name="status" value="1" title="正常" {eq name="$role.status" value="1" }checked{/eq}>
  33. <input type="radio" name="status" value="-1" title="禁用" {eq name="$role.status" value="-1" }checked{/eq}>
  34. {/if}
  35. </td>
  36. </tr>
  37. {if $permission == 1}
  38. <tr>
  39. <td class="layui-td-gray">权限组类型<font>*</font></td>
  40. {if condition="$id eq 0"}
  41. <td>
  42. <select name="unit_name" lay-verify="required" lay-reqText="请选择权限组单位">
  43. <option value="">请选择权限组单位</option>
  44. {volist name="department" id="v"}
  45. <option value="{$v.id}">{$v.title}</option>
  46. {/volist}
  47. </select>
  48. </td>
  49. {else/}
  50. <td>
  51. <select name="unit_name" lay-verify="required" lay-reqText="请选择权限组单位">
  52. <option value="">请选择权限组单位</option>
  53. {if $role.unit_name >= 1}
  54. {volist name="department" id="v"}
  55. <option value="{$v.id}" {eq name="$v.id" value="$role.unit_name"}selected{/eq}>{$v.title}</option>
  56. {/volist}
  57. {else/}
  58. {volist name="department" id="v"}
  59. <option value="{$v.id}">{$v.title}</option>
  60. {/volist}
  61. {/if}
  62. </select>
  63. </td>
  64. {/if}
  65. </tr>
  66. {/if}
  67. <tr>
  68. <td class="layui-td-gray-2">权限配置说明<font>*</font></td>
  69. <td colspan="3"><strong class="red">注意:如果右侧子级权限有节点被勾选了,左侧的顶级权限就必须勾选,否则无法查看右侧的子级菜单。</strong></td>
  70. </tr>
  71. <tr>
  72. <td colspan="4">
  73. <table style="width:100%" id="rule">
  74. <tr>
  75. <td style="text-align:center; background-color:#f8f8f8; width:160px;">选择可操作的顶级权限 <font style="color:red">↓</font></td>
  76. <td style="text-align:left; background-color:#f8f8f8;">选择可操作的子级权限 <font style="color:red">↓</font></td>
  77. </tr>
  78. {volist name="role_rule" id="vo"}
  79. <tr>
  80. <td class="left-note">
  81. <input type="checkbox" name="rule[]" value="{$vo.id}" title="{$vo.title}" class="aaa" {eq name="$vo.checked" value="true" }checked{/eq}>
  82. </td>
  83. {notempty name="vo.children"}
  84. <td class="right-note">
  85. <div style="padding:0 0 0 10px;">
  86. {volist name="vo.children" key="k" id="voo"}
  87. <div class="checkbox15" style="padding:10px 0;">
  88. <input type="checkbox" lay-filter="rule" name="rule[]" value="{$voo.id}" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
  89. {if $voo.title == "造价项目"}
  90. {if $voo.src == "admin/project.cost_company/datalist"}
  91. <!-- <input id="company_field" type="button" class="layui-btn layui-btn-xs" lay-filter="rule" name="field_id" value="{$field_id}" lay-skin="primary" title="属性设置"> -->
  92. <button id="company_field" type="button" class="layui-btn layui-btn-xs">属性设置</button>
  93. <input id="company_field_id" hidden type="text" name="field_id" value="{$field_id}">
  94. {/if}
  95. {if $voo.src == "admin/project.cost/datalist"}
  96. <!-- <input id="finance_field" type="button" class="layui-btn layui-btn-xs" lay-filter="rule" name="field_id" value="{$field_id}" lay-skin="primary" title="属性设置"> -->
  97. <button id="finance_field" type="button" class="layui-btn layui-btn-xs">属性设置</button>
  98. <input id="finance_field_id" hidden type="text" name="field_id" value="{$field_id}">
  99. {/if}
  100. {if $voo.src == "admin/project.costproprietor/datalist"}
  101. <!-- <input id="proprietor_field" type="button" class="layui-btn layui-btn-xs" lay-filter="rule" name="field_id" value="{$field_id}" lay-skin="primary" title="属性设置"> -->
  102. <button id="proprietor_field" type="button" class="layui-btn layui-btn-xs">属性设置</button>
  103. <input id="proprietor_field_id" hidden type="text" name="field_id" value="{$field_id}">
  104. {/if}
  105. {/if}
  106. </div>
  107. {notempty name="voo.children"}
  108. <div style="padding:0 0 3px; {if condition='$k != count($vo.children)'}margin-bottom:3px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
  109. {volist name="voo.children" id="vooo"}
  110. <div class="layui-input-inline" style="margin-right:10px;">
  111. <input type="checkbox" data-rule="{$voo.id}" name="rule[]" value="{$vooo.id}" lay-skin="primary" title="{$vooo.title}" {eq name="$vooo.checked" value="true" }checked{/eq}>
  112. </div>
  113. {notempty name="vooo.children"}
  114. <div style="padding:0 0 3px; {if condition='$k != count($vo.children)'}margin-bottom:3px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
  115. {volist name="vooo.children" id="voooo"}
  116. <div class="layui-input-inline" style="margin-right:10px;">
  117. <input type="checkbox" data-rule="{$vooo.id}" name="rule[]" value="{$voooo.id}" lay-skin="primary" title="{$voooo.title}" {eq name="$voooo.checked" value="true" }checked{/eq}>
  118. </div>
  119. {/volist}
  120. </div>
  121. {/notempty}
  122. {/volist}
  123. </div>
  124. {/notempty}
  125. {/volist}
  126. </div>
  127. </td>
  128. {/notempty}
  129. </tr>
  130. {/volist}
  131. </table>
  132. </td>
  133. </tr>
  134. <tr>
  135. <td class="layui-td-gray" style="vertical-align: top;">备注内容</td>
  136. <td colspan="3">
  137. <textarea name="desc" placeholder="请输入备注" class="layui-textarea">{notempty name="$role.desc" }{$role.desc}{/notempty}</textarea>
  138. </td>
  139. </tr>
  140. </table>
  141. <div style="padding: 10px 0">
  142. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
  143. <button type="reset" class="layui-btn layui-btn-primary">重置</button>
  144. </div>
  145. </form>
  146. {/block}
  147. <!-- /主体 -->
  148. <!-- 脚本 -->
  149. {block name="script"}
  150. <script>
  151. const moduleInit = ['tool'];
  152. function gouguInit() {
  153. var form = layui.form,tool=layui.tool, tree = layui.tree;
  154. parent.layui.field_id = 0;
  155. //监听提交
  156. form.on('submit(webform)', function (obj) {
  157. //字段的id
  158. console.log(parent.layui.field_id)
  159. console.log(1);
  160. obj.field.field_id = parent.layui.field_id
  161. $.ajax({
  162. url: "/admin/role/add",
  163. data: obj.field,
  164. type: 'post',
  165. success: function (e) {
  166. layer.msg(e.msg);
  167. if (e.code == 0) {
  168. parent.layui.tool.close(1000);
  169. }
  170. }
  171. });
  172. return false;
  173. });
  174. // $("#l1").click(parent.layui.tool.side("../field.field/add",callback));
  175. // 跳转公司
  176. $("#company_field").click(function(e){
  177. var field_id = $('[name="field_id"]').val();
  178. parent.layui.tool.side("../field.fieldcompany/add?id=" + field_id);
  179. });
  180. // 跳转财政局
  181. $("#finance_field").click(function(e){
  182. var field_id = $('[name="field_id"]').val();
  183. parent.layui.tool.side("../field.field/add?id=" + field_id);
  184. });
  185. // 跳转业主
  186. $("#proprietor_field").click(function(e){
  187. var field_id = $('[name="field_id"]').val();
  188. parent.layui.tool.side("../field.fieldproprietor/add?id=" + field_id);
  189. });
  190. //监听多选框点击事件 通过 lay-filter="menu"来监听
  191. form.on('checkbox(menu)', function (data) {
  192.   let val = data.value;
  193. if(data.elem.checked){
  194. //判断当前多选框是选中还是取消选中
  195. $("input[data-menu='"+val+"']").prop("checked", true);//true:选中 false:不选中
  196. }
  197. else{
  198. $("input[data-menu='"+val+"']").prop("checked", false);
  199. }
  200. form.render();//实时渲染选中和不选中的样式
  201. });
  202. $('[lay-filter="rule"]').click(function (){
  203. console.log(1);
  204. })
  205. //监听多选框点击事件 通过 lay-filter="rule"来监听
  206. form.on('checkbox(rule)', function (data) {
  207. let val = data.value;
  208. if(data.elem.checked){
  209. //判断当前多选框是选中还是取消选中
  210. $("input[data-rule='"+val+"']").prop("checked", true);//true:选中 false:不选中
  211. }
  212. else{
  213. $("input[data-rule='"+val+"']").prop("checked", false);
  214. }
  215. form.render();//实时渲染选中和不选中的样式
  216. });
  217. // $("#l1").click(console.log("role_rule"));
  218. }
  219. </script>
  220. {/block}
  221. <!-- /脚本 -->