YM
2025-04-14 508fd127fee444ab2ac375a09d63c4690d45c09b
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
{extend name="../../base/view/common/base" /}
{block name="style"}
<style>
.layui-form-checkbox[lay-skin=primary]{padding-left:20px;}
.left-note{font-weight:800; vertical-align:top; padding-top:28px!important; text-align:center}
.right-note .layui-checkbox-disabled span {color: #666666!important;}
.note-0 {display: inline-block;vertical-align: middle;}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
 
<form class="layui-form p-4">
    <h3 class="pb-3">权限组</h3>
    <table class="layui-table layui-table-form">
        <tr>
            <td class="layui-td-gray-2">权限组名称<font>*</font>
            </td>
            <td>
                <input type="hidden" name="id" value="{$id}" />
                <input class="layui-input" type="text" name="title" lay-verify="required" lay-reqText="请输入权限组名称" {notempty name="$role.title"
                }value="{$role.title}" {/notempty} placeholder="请输入权限组名称" autocomplete="off" />
            </td>
            <td class="layui-td-gray">状态<font>*</font>
            </td>
            <td>
            {if condition="$id eq 0"}
            <input type="radio" name="status" value="1" title="正常" checked>
            <input type="radio" name="status" value="-1" title="禁用">
            {else/}
            <input type="radio" name="status" value="1" title="正常" {eq name="$role.status" value="1" }checked{/eq}>
            <input type="radio" name="status" value="-1" title="禁用" {eq name="$role.status" value="-1" }checked{/eq}>
            {/if}
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-2">权限配置说明<font>*</font></td>
            <td colspan="3"><strong class="red">注意:如果右侧子级权限有节点被勾选了,左侧的顶级权限就必须勾选,否则无法查看右侧的子级菜单。</strong></td>
        </tr>
        <tr>
            <td colspan="4">    
                <table style="width:100%" id="rule">
                    <tr>
                        <td style="text-align:center; background-color:#f8f8f8; width:160px;"><font style="color:red">选择可操作的顶级权限 ↓</font></td>
                        <td style="text-align:left; background-color:#f8f8f8;"><font style="color:red">选择可操作的子级权限 ↓</font></td>
                    </tr>
                    {volist name="role_rule" id="vo"}
                    {if condition="$vo.name neq '知识网盘'"}
                    <tr>
                        <td class="left-note">
                          <input type="checkbox" name="rule[]" value="{$vo.id}" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
                        </td>
                        {gt name="vo.len" value="0"}
                            <td class="right-note">
                                <div style="padding:0 0 0 10px;">
                                {volist name="vo.children" key="k" id="voo"}
                                    {if condition="$voo.name neq '系统配置' && $voo.name neq '功能模块' && $voo.name neq '模块配置' && $voo.name neq '功能节点' && $voo.name neq '移动端配置' && $voo.name neq '定时任务' "}
                                    <div class="note-{$voo.len}" style="padding:10px 0;">
                                        <input type="checkbox" lay-filter="rule" data-pid="{$vo.id}" value="{$voo.id}" name="rule[]" lay-skin="primary" title="{$voo.title}" {eq name="$voo.checked" value="true" }checked{/eq}>
                                    </div>
                                    {gt name="voo.len" value="0"}
                                        <div style="padding:0 0 3px 22px; {if condition='$k != count($vo.children)'}margin-bottom:3px; padding-bottom:16px; border-bottom:1px solid #eee;{/if}">
                                        {volist name="voo.children" id="vooo"}
                                            <div class="note-{$vooo.len}" style="margin-right:10px;">
                                                <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}>
                                            </div>
                                            {gt name="vooo.len" value="0"}
                                                <div style="padding:6px 0 15px 22px; {if condition='$k != count($vo.children)'}margin-bottom:3px; padding-bottom:10px; margin-bottom:10px; border-bottom:1px solid #eee;{/if}">
                                                {volist name="vooo.children" id="voooo"}
                                                    <div class="note-{$voooo.len}" style="margin-right:10px;">
                                                        <input type="checkbox" data-rule="{$voo.id}" name="rule[]" value="{$voooo.id}" lay-skin="primary" title="{$voooo.title}" {eq name="$voooo.checked" value="true" }checked{/eq}>
                                                    </div>
                                                {/volist}
                                                </div>
                                            {/gt}
                                        {/volist}
                                        </div>
                                    {/gt}
                                    {/if}
                                {/volist}
                                </div>
                            </td>
                        {/gt}
                    </tr>
                    {/if}
                    {/volist}
                </table>
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-3" style="vertical-align: top;">PC工作台展示模块</td>
            <td colspan="3">
                {volist name="layout" id="vo"}
                    <div class="layui-input-inline" style="margin-right:10px;">
                        <input type="checkbox" data-rule="{$vo.id}" name="layout[]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
                    </div>
                {/volist}
            </td>
        </tr>
        <!-- <tr>
            <td class="layui-td-gray-3" style="vertical-align: top;">手机工作台展示模块</td>
            <td colspan="3">
                {volist name="mobile_menu" id="v"}
                    <dl>
                        <dt style="padding:12px 0 6px; font-weight:600">{$v.title}</dt>
                        <dd>
                        {volist name="v.list" id="vo"}
                        <div class="layui-input-inline" style="margin-right:10px;">
                            <input type="checkbox" data-rule="{$vo.id}" name="mobile_menu[]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
                        </div>
                        {/volist}
                        <dd>
                    </dl>
                {/volist}
            </td>
        </tr>
        <tr>
            <td class="layui-td-gray-3" style="vertical-align: top;">手机底部Bar菜单</td>
            <td colspan="3">
                <p style="color:red; padding-bottom:5px;">建议勾选5个,页面效果展示效果最佳</p>
                {volist name="mobile_bar" id="vo"}
                    <div class="layui-input-inline" style="margin-right:10px;">
                        <input type="checkbox" data-rule="{$vo.id}" name="mobile_bar[]" value="{$vo.id}" lay-skin="primary" title="{$vo.title}" {eq name="$vo.checked" value="true" }checked{/eq}>
                    </div>
                {/volist}
            </td>
        </tr> -->
        <tr>
            <td class="layui-td-gray" style="vertical-align: top;">备注内容</td>
            <td colspan="3">
                <textarea name="desc" placeholder="请输入备注" class="layui-textarea">{notempty name="$role.desc" }{$role.desc}{/notempty}</textarea>
            </td>
        </tr>
    </table>
    <div class="pt-4">
        <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
{/block}
<!-- /主体 -->
 
<!-- 脚本 -->
{block name="script"}
<script>
    const moduleInit = ['tool'];
    function gouguInit() {
        var form = layui.form,tool=layui.tool, tree = layui.tree;
        //监听提交
        form.on('submit(webform)', function (obj) {
            $.ajax({
                url: "/home/role/add",
                data: obj.field,
                type: 'post',
                success: function (e) {
                    layer.msg(e.msg);
                    if (e.code == 0) {
                        tool.sideClose(1000);
                    }
                }
            });
            return false;
        });
        
        //监听多选框点击事件  通过 lay-filter="rule"来监听
        form.on('checkbox(rule)', function (data) {
          let val = data.value;
            let pid =$(this).data('pid');
            if(data.elem.checked){
                //判断当前多选框是选中还是取消选中
                $("input[data-rule='"+val+"']").prop("checked", true);//true:选中 false:不选中
                $("input[value='"+pid+"']").prop("checked", true);//true:选中 false:不选中
            }
            else{
                $("input[data-rule='"+val+"']").prop("checked", false);
            }
            form.render();//实时渲染选中和不选中的样式
        });
    }
</script>
{/block}
<!-- /脚本 -->