137 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			Cheetah
		
	
	
	
	
	
			
		
		
	
	
			137 lines
		
	
	
		
			4.8 KiB
		
	
	
	
		
			Cheetah
		
	
	
	
	
	
{{template "header"}}
 | 
						|
 | 
						|
{{if eq .Item.Role.ID 0}}
 | 
						|
<h3>角色数据错误, 请刷新重试</h3>
 | 
						|
return
 | 
						|
{{end}}
 | 
						|
 | 
						|
<div class="layui-body layui-bg-white">
 | 
						|
    <form class="layui-form">
 | 
						|
        <input type="hidden" name="ID" value="{{.Item.Role.ID}}" />
 | 
						|
        {{ $oneLen := len .Item.Menus }}
 | 
						|
        {{if gt $oneLen 0}}
 | 
						|
        <div class="layui-collapse" lay-accordion>
 | 
						|
            {{range .Item.Menus}}
 | 
						|
            <div class="layui-colla-item">
 | 
						|
                <div class="layui-colla-title">{{.Name}}({{.Link}})</div>
 | 
						|
                <div class="layui-colla-content">
 | 
						|
                    {{ $twoLen := len .Items }}
 | 
						|
                    {{if gt $twoLen 0}}
 | 
						|
                    <div class="layui-collapse" lay-accordion>
 | 
						|
                        {{range .Items}}
 | 
						|
                        <div class="layui-colla-item">
 | 
						|
                            <div class="layui-colla-title">{{.Name}}({{.Link}})</div>
 | 
						|
                            <div class="layui-colla-content">
 | 
						|
                                {{ $threeLen := len .Items }}
 | 
						|
                                {{if gt $threeLen 0}}
 | 
						|
                                <div class="layui-collapse" lay-accordion>
 | 
						|
                                    {{range .Items}}
 | 
						|
                                    <div class="layui-colla-item">
 | 
						|
                                        <div class="layui-colla-title">{{.Name}}({{.Link}})</div>
 | 
						|
                                        <div class="layui-colla-content">
 | 
						|
                                            {{ $fourLen := len .Items }}
 | 
						|
                                            {{if gt $fourLen 0}}
 | 
						|
                                            <div class="layui-form">
 | 
						|
                                                {{range .Items}}
 | 
						|
                                                {{if .IsSelect}}
 | 
						|
                                                <input type="checkbox" name="menus" value="{{.ID}}" lay-text="{{.Name}}"
 | 
						|
                                                    checked>
 | 
						|
                                                {{else}}
 | 
						|
                                                <input type="checkbox" name="menus" value="{{.ID}}"
 | 
						|
                                                    lay-text="{{.Name}}">
 | 
						|
                                                {{end}}
 | 
						|
                                                {{end}}
 | 
						|
                                            </div>
 | 
						|
                                            {{end}}
 | 
						|
                                        </div>
 | 
						|
                                    </div>
 | 
						|
                                    {{end}}
 | 
						|
                                </div>
 | 
						|
                                {{end}}
 | 
						|
                            </div>
 | 
						|
                        </div>
 | 
						|
                        {{end}}
 | 
						|
                    </div>
 | 
						|
                    {{end}}
 | 
						|
                </div>
 | 
						|
            </div>
 | 
						|
            {{end}}
 | 
						|
        </div>
 | 
						|
        {{end}}
 | 
						|
        <div class="layui-form-item" style="margin-top:10px;">
 | 
						|
            {{ submitBtn .AuthorizeMenus "set_menu" }}
 | 
						|
        </div>
 | 
						|
    </form>
 | 
						|
</div>
 | 
						|
 | 
						|
{{define "css"}}
 | 
						|
<style>
 | 
						|
    .layui-body {
 | 
						|
        padding: 15px;
 | 
						|
        left: 0;
 | 
						|
    }
 | 
						|
 | 
						|
    .layui-bg-white {
 | 
						|
        background-color: #ffffff;
 | 
						|
    }
 | 
						|
 | 
						|
    .layui-colla-content {
 | 
						|
        padding: 10px 15px;
 | 
						|
    }
 | 
						|
 | 
						|
    .layui-collapse {
 | 
						|
        margin-bottom: 0;
 | 
						|
    }
 | 
						|
</style>
 | 
						|
{{end}}
 | 
						|
 | 
						|
{{define "js"}}
 | 
						|
<script>
 | 
						|
    layui.use(['form', 'jquery', 'iconPicker'], function () {
 | 
						|
        let form = layui.form;
 | 
						|
        let $ = layui.jquery;
 | 
						|
        let iconPicker = layui.iconPicker;
 | 
						|
 | 
						|
        // 表单提交
 | 
						|
        form.on('submit(set_menu)', function (data) {
 | 
						|
 | 
						|
            // 获取checkbox数据,拼接成字符串!!!!!!
 | 
						|
            var menus = "";
 | 
						|
            var r = document.getElementsByName("menus");
 | 
						|
            for (var i = 0; i < r.length; i++) {
 | 
						|
                if (r[i].checked) {
 | 
						|
                    menus += "," + r[i].value;
 | 
						|
                }
 | 
						|
            }
 | 
						|
            if (menus.length > 0) {
 | 
						|
                menus = menus.substring(1);
 | 
						|
            }
 | 
						|
            data.field.roleMenu = menus;
 | 
						|
 | 
						|
            $.ajax({
 | 
						|
                url: '/system/role/set_menu',
 | 
						|
                type: 'post',
 | 
						|
                headers: { 'X-CSRF-Token': $('#csrf_token').val() },
 | 
						|
                dataType: 'json',
 | 
						|
                data: data.field,
 | 
						|
                success: function (result) {
 | 
						|
                    if (result.success) {
 | 
						|
                        layer.msg(result.msg, { icon: 1, time: 1000 }, function () {
 | 
						|
                            parent.layer.close(parent.layer.getFrameIndex(window.name)); // 关闭当前页
 | 
						|
                            parent.layui.table.reload("tablelist", {
 | 
						|
                                page: { curr: 1 },
 | 
						|
                            });
 | 
						|
                        });
 | 
						|
                    } else {
 | 
						|
                        parent.layer.msg(result.msg, { icon: 2 })
 | 
						|
                    }
 | 
						|
                }
 | 
						|
            });
 | 
						|
 | 
						|
            return false;
 | 
						|
        });
 | 
						|
    });
 | 
						|
</script>
 | 
						|
{{end}}
 | 
						|
 | 
						|
{{template "footer" .}} |